diff --git a/.gitignore b/.gitignore index bf2e5be0a..889428054 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.vs +/packages /HandyControl/bin/Debug /HandyControl/obj/Debug /HandyControl/bin/Release diff --git a/ChangeLog.txt b/ChangeLog.txt index 68e6fdd2c..f69316d0e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,17 @@ +2018.09.04 Version 1.2.0 +* new controls + - add Growl + - add AnimationPath + - add TransitioningContentControl + +* new style + - add ProgressBar + - add TreeView + +* other +- update HandyControlDemo UI +- the ScrollViewer will auto hidden + 2018.08.31 Version 1.1.2 * new controls - add CompareSlider diff --git a/HandyControl/Controls/AnimationPath.cs b/HandyControl/Controls/AnimationPath.cs new file mode 100644 index 000000000..ce23dbbc0 --- /dev/null +++ b/HandyControl/Controls/AnimationPath.cs @@ -0,0 +1,188 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; + +namespace HandyControl.Controls +{ + public class AnimationPath : Shape + { + private bool _isLoaded; + + /// + /// 故事版 + /// + private Storyboard _storyboard; + + /// + /// 路径 + /// + public static readonly DependencyProperty DataProperty = DependencyProperty.Register(nameof(Data), + typeof(Geometry), typeof(AnimationPath), new FrameworkPropertyMetadata(null, + OnPropertiesChanged)); + + private static void OnPropertiesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is AnimationPath path) + { + path.UpdatePath(); + } + } + + /// + /// 路径 + /// + public Geometry Data + { + get => (Geometry)GetValue(DataProperty); + set => SetValue(DataProperty, value); + } + + protected override Geometry DefiningGeometry => Data ?? Geometry.Empty; + + /// + /// 路径长度 + /// + public static readonly DependencyProperty PathLengthProperty = DependencyProperty.Register( + "PathLength", typeof(double), typeof(AnimationPath), new FrameworkPropertyMetadata(default(double), + OnPropertiesChanged)); + + /// + /// 路径长度 + /// + public double PathLength + { + get => (double)GetValue(PathLengthProperty); + set => SetValue(PathLengthProperty, value); + } + + /// + /// 动画间隔时间 + /// + public static readonly DependencyProperty DurationProperty = DependencyProperty.Register( + "Duration", typeof(Duration), typeof(AnimationPath), new FrameworkPropertyMetadata(new Duration(TimeSpan.FromSeconds(2)), + OnPropertiesChanged)); + + /// + /// 动画间隔时间 + /// + public Duration Duration + { + get => (Duration)GetValue(DurationProperty); + set => SetValue(DurationProperty, value); + } + + public static readonly DependencyProperty IsPlayingProperty = DependencyProperty.Register( + "IsPlaying", typeof(bool), typeof(AnimationPath), new FrameworkPropertyMetadata(true, (o, args) => + { + var ctl = (AnimationPath)o; + var v = (bool)args.NewValue; + if (v) + { + ctl.UpdatePath(); + } + else + { + ctl._storyboard?.Pause(); + } + })); + + /// + /// 是否正在播放动画 + /// + public bool IsPlaying + { + get => (bool)GetValue(IsPlayingProperty); + set => SetValue(IsPlayingProperty, value); + } + + public static readonly DependencyProperty RepeatBehaviorProperty = DependencyProperty.Register( + "RepeatBehavior", typeof(RepeatBehavior), typeof(AnimationPath), new PropertyMetadata(RepeatBehavior.Forever)); + + /// + /// 动画重复行为 + /// + public RepeatBehavior RepeatBehavior + { + get => (RepeatBehavior)GetValue(RepeatBehaviorProperty); + set => SetValue(RepeatBehaviorProperty, value); + } + + static AnimationPath() + { + StretchProperty.AddOwner(typeof(AnimationPath), new FrameworkPropertyMetadata(Stretch.Uniform, + OnPropertiesChanged)); + + StrokeThicknessProperty.AddOwner(typeof(AnimationPath), new FrameworkPropertyMetadata(1.0, + OnPropertiesChanged)); + } + + public AnimationPath() + { + Loaded += (s, e) => + { + if (_isLoaded) return; + UpdatePath(); + _isLoaded = true; + }; + } + + /// + /// 动画完成事件 + /// + public static readonly RoutedEvent CompletedEvent = + EventManager.RegisterRoutedEvent("Completed", RoutingStrategy.Bubble, + typeof(EventHandler), typeof(AnimationPath)); + + /// + /// 动画完成事件 + /// + public event EventHandler Completed + { + add => AddHandler(CompletedEvent, value); + remove => RemoveHandler(CompletedEvent, value); + } + + private void UpdatePath() + { + if (!Duration.HasTimeSpan || !IsPlaying) return; + StrokeDashOffset = PathLength; + StrokeDashArray = new DoubleCollection(new List + { + PathLength, + PathLength + }); + + //定义动画 + _storyboard = new Storyboard + { + RepeatBehavior = RepeatBehavior + }; + _storyboard.Completed += (s, e) => RaiseEvent(new RoutedEventArgs(CompletedEvent)); + + var frames = new DoubleAnimationUsingKeyFrames(); + //开始位置 + var frame0 = new LinearDoubleKeyFrame + { + Value = PathLength, + KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero) + }; + //结束位置 + var frame1 = new LinearDoubleKeyFrame + { + Value = -PathLength, + KeyTime = KeyTime.FromTimeSpan(Duration.TimeSpan) + }; + frames.KeyFrames.Add(frame0); + frames.KeyFrames.Add(frame1); + + Storyboard.SetTarget(frames, this); + Storyboard.SetTargetProperty(frames, new PropertyPath(StrokeDashOffsetProperty)); + _storyboard.Children.Add(frames); + + _storyboard.Begin(); + } + } +} \ No newline at end of file diff --git a/HandyControl/Controls/Attach/BackgroundSwitchElement.cs b/HandyControl/Controls/Attach/BackgroundSwitchElement.cs new file mode 100644 index 000000000..1711f7d88 --- /dev/null +++ b/HandyControl/Controls/Attach/BackgroundSwitchElement.cs @@ -0,0 +1,35 @@ +using System.Windows; +using System.Windows.Media; + +// ReSharper disable once CheckNamespace +namespace HandyControl.Controls +{ + public class BackgroundSwitchElement : DependencyObject + { + public static readonly DependencyProperty MouseHoverBackgroundProperty = DependencyProperty.RegisterAttached( + "MouseHoverBackground", typeof(Brush), typeof(BackgroundSwitchElement), new PropertyMetadata(Brushes.Transparent)); + + public static void SetMouseHoverBackground(DependencyObject element, Brush value) + { + element.SetValue(MouseHoverBackgroundProperty, value); + } + + public static Brush GetMouseHoverBackground(DependencyObject element) + { + return (Brush)element.GetValue(MouseHoverBackgroundProperty); + } + + public static readonly DependencyProperty MouseDownBackgroundProperty = DependencyProperty.RegisterAttached( + "MouseDownBackground", typeof(Brush), typeof(BackgroundSwitchElement), new PropertyMetadata(Brushes.Transparent)); + + public static void SetMouseDownBackground(DependencyObject element, Brush value) + { + element.SetValue(MouseDownBackgroundProperty, value); + } + + public static Brush GetMouseDownBackground(DependencyObject element) + { + return (Brush)element.GetValue(MouseDownBackgroundProperty); + } + } +} \ No newline at end of file diff --git a/HandyControl/Controls/Attach/BorderElement.cs b/HandyControl/Controls/Attach/BorderElement.cs new file mode 100644 index 000000000..77b24384e --- /dev/null +++ b/HandyControl/Controls/Attach/BorderElement.cs @@ -0,0 +1,21 @@ +using System.Windows; + +// ReSharper disable once CheckNamespace +namespace HandyControl.Controls +{ + public class BorderElement : DependencyObject + { + public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached( + "CornerRadius", typeof(CornerRadius), typeof(BorderElement), new PropertyMetadata(default(CornerRadius))); + + public static void SetCornerRadius(DependencyObject element, CornerRadius value) + { + element.SetValue(CornerRadiusProperty, value); + } + + public static CornerRadius GetCornerRadius(DependencyObject element) + { + return (CornerRadius) element.GetValue(CornerRadiusProperty); + } + } +} \ No newline at end of file diff --git a/HandyControl/Controls/ColorPicker.xaml b/HandyControl/Controls/ColorPicker.xaml index 22a683d51..2e0005c6e 100644 --- a/HandyControl/Controls/ColorPicker.xaml +++ b/HandyControl/Controls/ColorPicker.xaml @@ -75,24 +75,6 @@ - + + + + + + \ No newline at end of file diff --git a/HandyControl/Controls/Growl.xaml.cs b/HandyControl/Controls/Growl.xaml.cs new file mode 100644 index 000000000..11b72942b --- /dev/null +++ b/HandyControl/Controls/Growl.xaml.cs @@ -0,0 +1,239 @@ +using System; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Threading; +using HandyControl.Interactivity; +using HandyControl.Tools; +using HandyControl.Tools.Extension; + +namespace HandyControl.Controls +{ + /// + /// Growl.xaml 的交互逻辑 + /// + public partial class Growl + { + /// + /// 最大计数 + /// + private const int MaxTickCount = 6; + + public static readonly DependencyProperty MessageProperty = DependencyProperty.Register( + "Message", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); + + public static readonly DependencyProperty TimeProperty = DependencyProperty.Register( + "Time", typeof(DateTime), typeof(Growl), new PropertyMetadata(default(DateTime))); + + public static readonly DependencyProperty IconProperty = DependencyProperty.Register( + "Icon", typeof(Geometry), typeof(Growl), new PropertyMetadata(default(Geometry))); + + public static readonly DependencyProperty IconBrushProperty = DependencyProperty.Register( + "IconBrush", typeof(Brush), typeof(Growl), new PropertyMetadata(default(Brush))); + + /// + /// 消息容器 + /// + private static Panel GrowlPanel; + + /// + /// 计数 + /// + private int _tickCount; + + /// + /// 关闭计时器 + /// + private DispatcherTimer _timerClose; + + public Growl() => InitializeComponent(); + + private Action CloseAction { get; set; } + + public string Message + { + get => (string)GetValue(MessageProperty); + set => SetValue(MessageProperty, value); + } + + public DateTime Time + { + get => (DateTime)GetValue(TimeProperty); + set => SetValue(TimeProperty, value); + } + + public Geometry Icon + { + get => (Geometry)GetValue(IconProperty); + set => SetValue(IconProperty, value); + } + + public Brush IconBrush + { + get => (Brush)GetValue(IconBrushProperty); + set => SetValue(IconBrushProperty, value); + } + + /// + /// 开始计时器 + /// + private void StartTimer() + { + _timerClose = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + _timerClose.Tick += delegate + { + if (IsMouseOver) + { + _tickCount = 0; + return; + } + + _tickCount++; + if (_tickCount >= MaxTickCount) Close(); + }; + _timerClose.Start(); + } + + /// + /// 消息容器 + /// + /// + public static void SetGrowlPanel(Panel panel) + { + GrowlPanel = panel; + var menuItem = new MenuItem + { + Header = "清空消息" + }; + menuItem.Click += (s, e) => + { + foreach (var item in GrowlPanel.Children.OfType()) + { + //if (item.CloseAction != null) + //{ + // item.Close(); + //} + item.Close(); + } + }; + GrowlPanel.ContextMenu = new ContextMenu + { + Items = + { + menuItem + } + }; + var behavior = new FluidMoveBehavior + { + AppliesTo = FluidMoveScope.Children, + Duration = new Duration(TimeSpan.FromMilliseconds(400)), + EaseY = new PowerEase() + }; + var collection = Interaction.GetBehaviors(GrowlPanel); + collection.Add(behavior); + } + + /// + /// 显示信息 + /// + private static void Show(string message, string iconKey, string iconBrushKey, Action closeAction = null, + bool staysOpen = false, bool showCloseButton = true) + { + var ctl = new Growl + { + Message = message, + Time = DateTime.Now, + Icon = ResourceHelper.GetResource(iconKey), + IconBrush = ResourceHelper.GetResource(iconBrushKey) + }; + if (!showCloseButton) ctl.Triggers.Clear(); + + if (closeAction != null) + { + staysOpen = true; + ctl.Triggers.Clear(); + ctl.PanelMore.IsEnabled = true; + ctl.PanelMore.Show(); + ctl.CloseAction = closeAction; + } + + var transform = new TranslateTransform + { + X = ctl.MaxWidth + }; + ctl.GridMain.RenderTransform = transform; + GrowlPanel.Children.Insert(0, ctl); + transform.BeginAnimation(TranslateTransform.XProperty, AnimationHelper.CreateAnimation(0)); + if (!staysOpen) ctl.StartTimer(); + } + + /// + /// 成功 + /// + public static void Success(string message) => Show(message, "SuccessGeometry", "SuccessBrush"); + + /// + /// 消息 + /// + public static void Info(string message) => Show(message, "InfoGeometry", "InfoBrush"); + + /// + /// 错误 + /// + public static void Error(string message) => Show(message, "ErrorGeometry", "DangerBrush", null, true); + + /// + /// 警告 + /// + public static void Warning(string message) => Show(message, "WarningGeometry", "WarningBrush"); + + /// + /// 严重 + /// + /// + /// + public static void Fatal(string message, bool showContextMenu = true) + { + if (!showContextMenu) + { + GrowlPanel.ContextMenu.Collapse(); + } + Show(message, "FatalGeometry", "PrimaryTextBrush", null, true, false); + } + + public static void Ask(string message, Action closeAction) => Show(message, "AskGeometry", "AccentBrush", closeAction); + + private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close(); + + /// + /// 关闭 + /// + private void Close() + { + _timerClose?.Stop(); + var transform = new TranslateTransform(); + GridMain.RenderTransform = transform; + var animation = AnimationHelper.CreateAnimation(MaxWidth); + animation.Completed += delegate { GrowlPanel.Children.Remove(this); }; + transform.BeginAnimation(TranslateTransform.XProperty, animation); + } + + /// + /// 清除 + /// + public static void Clear() + { + GrowlPanel.Children.Clear(); + GrowlPanel.Show(); + } + + private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => CloseAction?.Invoke(Close, false); + + private void ButtonOk_OnClick(object sender, RoutedEventArgs e) => CloseAction?.Invoke(Close, true); + } +} \ No newline at end of file diff --git a/HandyControl/Controls/ScrollViewer.cs b/HandyControl/Controls/ScrollViewer.cs index 142dc9c25..129b6e728 100644 --- a/HandyControl/Controls/ScrollViewer.cs +++ b/HandyControl/Controls/ScrollViewer.cs @@ -49,22 +49,32 @@ protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParam /// /// 是否支持惯性 /// - public static readonly DependencyProperty IsEnableInertiaProperty = DependencyProperty.Register( + public static readonly DependencyProperty IsEnableInertiaProperty = DependencyProperty.RegisterAttached( "IsEnableInertia", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(default(bool))); + public static void SetIsEnableInertia(DependencyObject element, bool value) + { + element.SetValue(IsEnableInertiaProperty, value); + } + + public static bool GetIsEnableInertia(DependencyObject element) + { + return (bool) element.GetValue(IsEnableInertiaProperty); + } + /// /// 是否支持惯性 /// public bool IsEnableInertia { - get => (bool) GetValue(IsEnableInertiaProperty); + get => (bool)GetValue(IsEnableInertiaProperty); set => SetValue(IsEnableInertiaProperty, value); } /// /// 控件是否可以穿透点击 /// - public static readonly DependencyProperty IsPenetratingProperty = DependencyProperty.Register( + public static readonly DependencyProperty IsPenetratingProperty = DependencyProperty.RegisterAttached( "IsPenetrating", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(default(bool))); /// @@ -72,10 +82,20 @@ public bool IsEnableInertia /// public bool IsPenetrating { - get => (bool) GetValue(IsPenetratingProperty); + get => (bool)GetValue(IsPenetratingProperty); set => SetValue(IsPenetratingProperty, value); } + public static void SetIsPenetrating(DependencyObject element, bool value) + { + element.SetValue(IsPenetratingProperty, value); + } + + public static bool GetIsPenetrating(DependencyObject element) + { + return (bool) element.GetValue(IsPenetratingProperty); + } + /// /// 当前垂直滚动偏移 /// @@ -95,6 +115,7 @@ private static void CurrentVerticalOffsetChangedCallback(DependencyObject d, Dep /// private double CurrentVerticalOffset { + // ReSharper disable once UnusedMember.Local get => (double) GetValue(CurrentVerticalOffsetProperty); set => SetValue(CurrentVerticalOffsetProperty, value); } diff --git a/HandyControl/Controls/TransitioningContentControl.cs b/HandyControl/Controls/TransitioningContentControl.cs new file mode 100644 index 000000000..6a0e84f88 --- /dev/null +++ b/HandyControl/Controls/TransitioningContentControl.cs @@ -0,0 +1,259 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media.Animation; +using HandyControl.Tools; + +namespace HandyControl.Controls +{ + [TemplateVisualState(GroupName = PresentationGroup, Name = NormalState)] + [TemplateVisualState(GroupName = PresentationGroup, Name = DefaultTransitionState)] + [TemplatePart(Name = PreviousContentPresentationSitePartName, Type = typeof(ContentControl))] + [TemplatePart(Name = CurrentContentPresentationSitePartName, Type = typeof(ContentControl))] + public class TransitioningContentControl : ContentControl + { + private Storyboard _currentTransition; + + public TransitioningContentControl() + { + DefaultStyleKey = typeof(TransitioningContentControl); + } + + private Storyboard CurrentTransition + { + set + { + if (_currentTransition != null) + _currentTransition.Completed -= OnTransitionCompleted; + + _currentTransition = value; + + if (_currentTransition != null) + _currentTransition.Completed += OnTransitionCompleted; + } + } + + #region Events + + public event RoutedEventHandler TransitionCompleted; + + #endregion Events + + public override void OnApplyTemplate() + { + if (IsTransitioning) + AbortTransition(); + + base.OnApplyTemplate(); + + PreviousContentPresentationSite = + GetTemplateChild(PreviousContentPresentationSitePartName) as ContentPresenter; + CurrentContentPresentationSite = + GetTemplateChild(CurrentContentPresentationSitePartName) as ContentPresenter; + + if (CurrentContentPresentationSite != null) + CurrentContentPresentationSite.Content = Content; + + var transition = GetStoryboard(Transition); + CurrentTransition = transition; + if (transition == null) + { + Transition = DefaultTransitionState; + + throw new ArgumentException("TransitioningContentControl_TransitionNotFound"); + } + + VisualStateManager.GoToState(this, NormalState, false); + VisualStateManager.GoToState(this, Transition, true); + } + + protected override void OnContentChanged(object oldContent, object newContent) + { + base.OnContentChanged(oldContent, newContent); + + StartTransition(oldContent, newContent); + } + + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "newContent", Justification = "Should be used in the future.")] + private void StartTransition(object oldContent, object newContent) + { + if (CurrentContentPresentationSite != null && PreviousContentPresentationSite != null) + { + CurrentContentPresentationSite.Content = newContent; + + PreviousContentPresentationSite.Content = oldContent; + + if (!IsTransitioning || RestartTransitionOnContentChange) + { + IsTransitioning = true; + VisualStateManager.GoToState(this, NormalState, false); + VisualStateManager.GoToState(this, Transition, true); + } + } + } + + private void OnTransitionCompleted(object sender, EventArgs e) + { + AbortTransition(); + + var handler = TransitionCompleted; + handler?.Invoke(this, new RoutedEventArgs()); + } + + public void AbortTransition() + { + VisualStateManager.GoToState(this, NormalState, false); + IsTransitioning = false; + if (PreviousContentPresentationSite != null) + PreviousContentPresentationSite.Content = null; + } + + private Storyboard GetStoryboard(string newTransition) + { + var presentationGroup = VisualStates.TryGetVisualStateGroup(this, PresentationGroup); + Storyboard newStoryboard = null; + if (presentationGroup != null) + newStoryboard = presentationGroup.States + .OfType() + .Where(state => state.Name == newTransition) + .Select(state => state.Storyboard) + .FirstOrDefault(); + return newStoryboard; + } + + #region Visual state names + + private const string PresentationGroup = "PresentationStates"; + + private const string NormalState = "Normal"; + + public const string DefaultTransitionState = "DefaultTransition"; + + #endregion Visual state names + + #region Template part names + + internal const string PreviousContentPresentationSitePartName = "PreviousContentPresentationSite"; + + internal const string CurrentContentPresentationSitePartName = "CurrentContentPresentationSite"; + + #endregion Template part names + + #region TemplateParts + + private ContentPresenter CurrentContentPresentationSite { get; set; } + + private ContentPresenter PreviousContentPresentationSite { get; set; } + + #endregion TemplateParts + + #region public bool IsTransitioning + + private bool _allowIsTransitioningWrite; + + public bool IsTransitioning + { + get => (bool)GetValue(IsTransitioningProperty); + private set + { + _allowIsTransitioningWrite = true; + SetValue(IsTransitioningProperty, value); + _allowIsTransitioningWrite = false; + } + } + + public static readonly DependencyProperty IsTransitioningProperty = + DependencyProperty.Register( + "IsTransitioning", + typeof(bool), + typeof(TransitioningContentControl), + new PropertyMetadata(OnIsTransitioningPropertyChanged)); + + private static void OnIsTransitioningPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var source = (TransitioningContentControl)d; + + if (!source._allowIsTransitioningWrite) + { + source.IsTransitioning = (bool)e.OldValue; + throw new InvalidOperationException("TransitiotioningContentControl_IsTransitioningReadOnly"); + } + } + + #endregion public bool IsTransitioning + + #region public string Transition + + public string Transition + { + get => GetValue(TransitionProperty) as string; + set => SetValue(TransitionProperty, value); + } + + public static readonly DependencyProperty TransitionProperty = + DependencyProperty.Register( + "Transition", + typeof(string), + typeof(TransitioningContentControl), + new PropertyMetadata(DefaultTransitionState, OnTransitionPropertyChanged)); + + private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var source = (TransitioningContentControl)d; + var oldTransition = e.OldValue as string; + var newTransition = e.NewValue as string; + + if (source.IsTransitioning) + source.AbortTransition(); + + var newStoryboard = source.GetStoryboard(newTransition); + + if (newStoryboard == null) + if (VisualStates.TryGetVisualStateGroup(source, PresentationGroup) == null) + { + source.CurrentTransition = null; + } + else + { + source.SetValue(TransitionProperty, oldTransition); + + throw new ArgumentException( + "TransitioningContentControl_TransitionNotFound"); + } + else + source.CurrentTransition = newStoryboard; + } + + #endregion public string Transition + + #region public bool RestartTransitionOnContentChange + + public bool RestartTransitionOnContentChange + { + get => (bool)GetValue(RestartTransitionOnContentChangeProperty); + set => SetValue(RestartTransitionOnContentChangeProperty, value); + } + + public static readonly DependencyProperty RestartTransitionOnContentChangeProperty = + DependencyProperty.Register( + "RestartTransitionOnContentChange", + typeof(bool), + typeof(TransitioningContentControl), + new PropertyMetadata(false, OnRestartTransitionOnContentChangePropertyChanged)); + + private static void OnRestartTransitionOnContentChangePropertyChanged(DependencyObject d, + DependencyPropertyChangedEventArgs e) + { + ((TransitioningContentControl)d).OnRestartTransitionOnContentChangeChanged((bool)e.OldValue, + (bool)e.NewValue); + } + + protected virtual void OnRestartTransitionOnContentChangeChanged(bool oldValue, bool newValue) + { + } + + #endregion public bool RestartTransitionOnContentChange + } +} \ No newline at end of file diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 06606ba77..2f09af67f 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -33,6 +33,9 @@ bin\Release\HandyControl.xml + + + @@ -43,6 +46,9 @@ + + Growl.xaml + @@ -61,6 +67,7 @@ TimeBar.xaml + ImageBrowser.xaml @@ -122,6 +129,8 @@ + + @@ -135,6 +144,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -227,6 +240,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -271,6 +288,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -287,6 +308,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/HandyControl/Properties/AssemblyInfo.cs b/HandyControl/Properties/AssemblyInfo.cs index cd7f8ae85..86af382fa 100644 --- a/HandyControl/Properties/AssemblyInfo.cs +++ b/HandyControl/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("HandyControl")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Contains some commonly used simple WPF controls")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HandyControl")] @@ -10,5 +10,5 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.1.2.0")] -[assembly: AssemblyFileVersion("1.1.2.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/HandyControl/Themes/Basic/Brushes.xaml b/HandyControl/Themes/Basic/Brushes.xaml index 21ca0b886..036758709 100644 --- a/HandyControl/Themes/Basic/Brushes.xaml +++ b/HandyControl/Themes/Basic/Brushes.xaml @@ -32,4 +32,5 @@ + \ No newline at end of file diff --git a/HandyControl/Themes/Basic/Colors.xaml b/HandyControl/Themes/Basic/Colors.xaml index 9e595f9cd..2b9727f75 100644 --- a/HandyControl/Themes/Basic/Colors.xaml +++ b/HandyControl/Themes/Basic/Colors.xaml @@ -32,4 +32,5 @@ #ff5722 #d43f3a + #20000000 \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ButtonBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ButtonBaseStyle.xaml index 741d136af..3f9000fec 100644 --- a/HandyControl/Themes/Styles/Base/ButtonBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ButtonBaseStyle.xaml @@ -7,84 +7,68 @@ \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml new file mode 100644 index 000000000..3d0de4c2f --- /dev/null +++ b/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml @@ -0,0 +1,51 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ScrollViewerBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ScrollViewerBaseStyle.xaml index c463eeab0..c1378e385 100644 --- a/HandyControl/Themes/Styles/Base/ScrollViewerBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ScrollViewerBaseStyle.xaml @@ -115,7 +115,25 @@ - + + + + + + + + + + + + + + + + + + + @@ -125,17 +143,24 @@ - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml index 1930b0cd2..3db1189ac 100644 --- a/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml @@ -1,49 +1,43 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="clr-namespace:HandyControl.Controls"> \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml index ad96b31f4..49c88fd97 100644 --- a/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:HandyControl.Controls"> + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Button.xaml b/HandyControl/Themes/Styles/Button.xaml index 4e19ae31f..083379302 100644 --- a/HandyControl/Themes/Styles/Button.xaml +++ b/HandyControl/Themes/Styles/Button.xaml @@ -9,64 +9,29 @@ - - \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Expander.xaml b/HandyControl/Themes/Styles/Expander.xaml index 2c6f3625f..ec08bcb60 100644 --- a/HandyControl/Themes/Styles/Expander.xaml +++ b/HandyControl/Themes/Styles/Expander.xaml @@ -33,7 +33,7 @@ - + @@ -48,35 +48,6 @@ - diff --git a/HandyControl/Themes/Styles/ProgressBar.xaml b/HandyControl/Themes/Styles/ProgressBar.xaml new file mode 100644 index 000000000..afd6ba292 --- /dev/null +++ b/HandyControl/Themes/Styles/ProgressBar.xaml @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Slider.xaml b/HandyControl/Themes/Styles/Slider.xaml index 1eeb16477..d8c7e8724 100644 --- a/HandyControl/Themes/Styles/Slider.xaml +++ b/HandyControl/Themes/Styles/Slider.xaml @@ -305,6 +305,9 @@ + + + diff --git a/HandyControl/Themes/Styles/Style.xaml b/HandyControl/Themes/Styles/Style.xaml index 03c10e5f9..268716613 100644 --- a/HandyControl/Themes/Styles/Style.xaml +++ b/HandyControl/Themes/Styles/Style.xaml @@ -10,11 +10,11 @@ - + - + diff --git a/HandyControl/Themes/Styles/ToggleButton.xaml b/HandyControl/Themes/Styles/ToggleButton.xaml index db9849cfd..a127aa461 100644 --- a/HandyControl/Themes/Styles/ToggleButton.xaml +++ b/HandyControl/Themes/Styles/ToggleButton.xaml @@ -10,75 +10,59 @@ - - + + + + - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Window.xaml b/HandyControl/Themes/Styles/Window.xaml index c69448807..0e1f63c37 100644 --- a/HandyControl/Themes/Styles/Window.xaml +++ b/HandyControl/Themes/Styles/Window.xaml @@ -125,4 +125,106 @@ + + \ No newline at end of file diff --git a/HandyControl/Tools/ResourceHelper.cs b/HandyControl/Tools/ResourceHelper.cs new file mode 100644 index 000000000..2e4ae160c --- /dev/null +++ b/HandyControl/Tools/ResourceHelper.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; +using System.Windows; + +namespace HandyControl.Tools +{ + /// + /// 资源帮助类 + /// + public class ResourceHelper + { + /// + /// 获取字符串 + /// + /// + /// + public static string GetString(string key) => Application.Current.TryFindResource(key) as string; + + /// + /// 获取字符串 + /// + /// + /// + /// + public static string GetString(string separator = ";", params string[] keyArr) => + string.Join(separator, keyArr.Select(key => Application.Current.TryFindResource(key) as string).ToList()); + + /// + /// 获取字符串 + /// + /// + /// + public static List GetStringList(params string[] keyArr) => keyArr.Select(key => Application.Current.TryFindResource(key) as string).ToList(); + + /// + /// 获取资源 + /// + /// + /// + public static T GetResource(string key) where T : class => Application.Current.TryFindResource(key) as T; + } +} \ No newline at end of file diff --git a/HandyControl/Tools/VisualStates.cs b/HandyControl/Tools/VisualStates.cs new file mode 100644 index 000000000..da2faf172 --- /dev/null +++ b/HandyControl/Tools/VisualStates.cs @@ -0,0 +1,30 @@ +using System.Linq; +using System.Windows; +using System.Windows.Media; + +namespace HandyControl.Tools +{ + public class VisualStates + { + public static VisualStateGroup TryGetVisualStateGroup(DependencyObject dependencyObject, string groupName) + { + var root = GetImplementationRoot(dependencyObject); + if (root == null) + { + return null; + } + + return VisualStateManager + .GetVisualStateGroups(root)? + .OfType() + .FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0); + } + + public static FrameworkElement GetImplementationRoot(DependencyObject dependencyObject) + { + return 1 == VisualTreeHelper.GetChildrenCount(dependencyObject) + ? VisualTreeHelper.GetChild(dependencyObject, 0) as FrameworkElement + : null; + } + } +} \ No newline at end of file diff --git a/HandyControlDemo/App.xaml b/HandyControlDemo/App.xaml index 59e91ab32..12f6ccc6d 100644 --- a/HandyControlDemo/App.xaml +++ b/HandyControlDemo/App.xaml @@ -1,12 +1,21 @@  + + + + + diff --git a/HandyControlDemo/Data/MessageToken.cs b/HandyControlDemo/Data/MessageToken.cs new file mode 100644 index 000000000..feccd5f97 --- /dev/null +++ b/HandyControlDemo/Data/MessageToken.cs @@ -0,0 +1,34 @@ +namespace HandyControlDemo.Data +{ + /// + /// 包含整个程序使用的所有标识 + /// + internal class MessageToken + { + public static readonly string LoadGrowlDemoCtl = nameof(LoadGrowlDemoCtl); + + public static readonly string LoadLoadingDemoCtl = nameof(LoadLoadingDemoCtl); + + public static readonly string LoadImageBrowserDemoCtl = nameof(LoadImageBrowserDemoCtl); + + public static readonly string LoadColorPickerDemoCtl = nameof(LoadColorPickerDemoCtl); + + public static readonly string LoadCarouselDemoCtl = nameof(LoadCarouselDemoCtl); + + public static readonly string LoadCompareSliderDemoCtl = nameof(LoadCompareSliderDemoCtl); + + public static readonly string LoadTimeBarDemoCtl = nameof(LoadTimeBarDemoCtl); + + public static readonly string LoadExpanderDemoCtl = nameof(LoadExpanderDemoCtl); + + public static readonly string LoadPaginationDemoCtl = nameof(LoadPaginationDemoCtl); + + public static readonly string LoadProgressBarDemoCtl = nameof(LoadProgressBarDemoCtl); + + public static readonly string LoadAnimationPathDemoCtl = nameof(LoadAnimationPathDemoCtl); + + public static readonly string LoadButtonDemoCtl = nameof(LoadButtonDemoCtl); + + public static readonly string LoadToggleButtonDemoCtl = nameof(LoadToggleButtonDemoCtl); + } +} \ No newline at end of file diff --git a/HandyControlDemo/Data/Model/CellGateInfo.cs b/HandyControlDemo/Data/Model/CellGateInfo.cs deleted file mode 100644 index 9c9c89390..000000000 --- a/HandyControlDemo/Data/Model/CellGateInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; - -namespace HandyControlDemo.Data.Model -{ - public class CellGateInfo - { - public int Id { get; set; } - - public string Name { get; set; } - - public int Parent { get; set; } - - public List InfoList { get; set; } - } -} \ No newline at end of file diff --git a/HandyControlDemo/Data/Model/CellGateRecord.cs b/HandyControlDemo/Data/Model/CellGateRecord.cs deleted file mode 100644 index 88a76de61..000000000 --- a/HandyControlDemo/Data/Model/CellGateRecord.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace HandyControlDemo.Data.Model -{ - public class CellGateRecord - { - public string CellGateId { get; set; } - - public string PersonId { get; set; } - - public DateTime CreateTime { get; set; } - - public string Direction { get; set; } - - public string DeviceId { get; set; } - } -} \ No newline at end of file diff --git a/HandyControlDemo/HandyControlDemo.csproj b/HandyControlDemo/HandyControlDemo.csproj index 4195c6c72..aa937f6f5 100644 --- a/HandyControlDemo/HandyControlDemo.csproj +++ b/HandyControlDemo/HandyControlDemo.csproj @@ -34,8 +34,23 @@ 4 + + ..\packages\CommonServiceLocator.2.0.2\lib\net45\CommonServiceLocator.dll + + + ..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.dll + + + ..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\packages\MvvmLightLibs.5.4.1\lib\net45\System.Windows.Interactivity.dll + 4.0 @@ -47,6 +62,61 @@ MSBuild:Compile Designer + + + True + True + ControlLocator.tt + + + AnimationPathDemoCtl.xaml + + + CarouselDemoCtl.xaml + + + ColorPickerDemoCtl.xaml + + + CompareSliderDemoCtl.xaml + + + GrowlDemoCtl.xaml + + + ImageBrowserDemoCtl.xaml + + + LoadingDemoCtl.xaml + + + ButtonDemoCtl.xaml + + + ExpanderDemoCtl.xaml + + + LeftMainContent.xaml + + + MainContent.xaml + + + PaginationDemoCtl.xaml + + + TimeBarDemoCtl.xaml + + + ProgressBarDemoCtl.xaml + + + ToggleButtonDemoCtl.xaml + + + + + MSBuild:Compile Designer @@ -55,12 +125,86 @@ App.xaml Code - - MainWindow.xaml Code + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + @@ -74,18 +218,33 @@ - - - - - + + + + + + + + + + + + + + + + + + - + + TextTemplatingFileGenerator + ControlLocator.cs + - - + \ No newline at end of file diff --git a/HandyControlDemo/MainWindow.xaml b/HandyControlDemo/MainWindow.xaml index e4cb0d251..cf3290592 100644 --- a/HandyControlDemo/MainWindow.xaml +++ b/HandyControlDemo/MainWindow.xaml @@ -14,13 +14,14 @@ WindowState="Maximized" Title="MainWindow" Name="MyWindow" + DataContext="{Binding Main,Source={StaticResource Locator}}" d:DesignHeight="800" d:DesignWidth="1400"> - + @@ -38,917 +39,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (ImageBrowser) - - - - - - - - - - - - - - (ColorPicker) - - - - - - - - - - - - - - - - - - - - - - (Carousel) - - - - - - - - - - - - - - - - - - - - - - - (CompareSlider) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (TimeBar) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/MainWindow.xaml.cs b/HandyControlDemo/MainWindow.xaml.cs index de19b363b..763b8abb0 100644 --- a/HandyControlDemo/MainWindow.xaml.cs +++ b/HandyControlDemo/MainWindow.xaml.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControl.Tools.Extension; -using HandyControlDemo.Data.Model; +using HandyControl.Controls; namespace HandyControlDemo { @@ -17,311 +7,11 @@ namespace HandyControlDemo /// public partial class MainWindow { - public static readonly DependencyProperty FruitListProperty = DependencyProperty.Register( - "FruitList", typeof(ObservableCollection), typeof(MainWindow), new PropertyMetadata(default(ObservableCollection))); - - public ObservableCollection FruitList - { - get => (ObservableCollection)GetValue(FruitListProperty); - set => SetValue(FruitListProperty, value); - } - public MainWindow() { InitializeComponent(); - foreach (var border in StackPanelMain.Children.OfType()) - { - border.Show(); - } - - var listZ = new List(); - - for (int i = 1; i <= 40; i++) - { - var itemC = new CellGateInfo(); - var listC = new List(); - itemC.Name = $"{i}幢"; - for (int j = 1; j <= 2; j++) - { - var itemF = new CellGateInfo(); - var listF = new List(); - itemF.Name = $"{itemC.Name}{j}单元"; - for (int k = 1; k <= 10; k++) - { - for (int l = 1; l <= 4; l++) - { - var itemR = new CellGateInfo - { - Name = $"{itemF.Name}{k}0{l}室" - }; - listF.Add(itemR); - } - } - itemF.InfoList = listF; - listC.Add(itemF); - } - itemC.InfoList = listC; - listZ.Add(itemC); - } - - //TreeViewMain.ItemsSource = listZ; - //ListBoxMain.ItemsSource = listZ; - //ButtonContextMenu.ItemsSource = listZ; - - var showRecords = new List - { - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-1), - CellGateId = "1幢1单元A单元门", - PersonId = "宋立才", - DeviceId = "刷卡", - Direction = "进" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-2), - CellGateId = "1幢1单元A单元门", - PersonId = "宋立才", - DeviceId = "刷卡", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-2), - CellGateId = "20幢2单元A单元门", - PersonId = "周弘益", - DeviceId = "人脸", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-3), - CellGateId = "20幢2单元A单元门", - PersonId = "周弘益", - DeviceId = "人脸", - Direction = "进" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-2), - CellGateId = "20幢2单元A单元门", - PersonId = "彭念文", - DeviceId = "RFID", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-3), - CellGateId = "20幢2单元A单元门", - PersonId = "彭念文", - DeviceId = "RFID", - Direction = "进" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "王跃", - DeviceId = "指纹", - Direction = "出" - }, - new CellGateRecord - { - CreateTime = DateTime.Now.AddDays(-4), - CellGateId = "20幢2单元A单元门", - PersonId = "赵兴隆", - DeviceId = "指纹", - Direction = "出" - } - }; - //DataGridMain.ItemsSource = showRecords; - - FruitList = new ObservableCollection - { - new Fruit - { - Name = "苹果", - Id = 0 - }, - new Fruit - { - Name = "香蕉", - Id = 1 - } - }; - - } - - public class Fruit - { - public string Name { get; set; } - - public int Id { get; set; } - } - - //private void ThemesComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) - //{ - // if (sender is ComboBox comboBox && comboBox.SelectedItem is ComboBoxItem comboBoxItem && - // comboBoxItem.Tag is string tag) - // { - // var str = File.ReadAllText($"./Files/Themes/{tag}.json"); - // var jObject = JObject.Parse(str); - // foreach (var item in jObject.Properties()) - // { - // Resources.Remove(item.Name); - // Resources.Add(item.Name, item.Value.ToObject()); - // } - // } - //} - - //private void ButtonStepPrec_OnClick(object sender, RoutedEventArgs e) - //{ - // StepsExample.Prev(); - //} - - - //private void ButtonStepNext_OnClick(object sender, RoutedEventArgs e) - //{ - // StepsExample.Next(); - //} - - private void ButtonImageBrowser_OnClick(object sender, RoutedEventArgs e) => - new ImageBrowser(new Uri("pack://application:,,,/Resources/1.jpg")).Show(); - - private void ColorPicker_OnColorSelected(object sender, FunctionEventArgs e) - { - BlockColor.Text = $"{e.Info}-----{e.Info.ToInt32()}"; - PopupColor.IsOpen = false; - } - - private void ColorPicker_OnCanceled(object sender, EventArgs e) - { - PopupColor.IsOpen = false; - } - - private void ButtonColor_OnClick(object sender, RoutedEventArgs e) - { - PopupColor.IsOpen = true; - } - - private void ButtonColorPreset_OnClick(object sender, RoutedEventArgs e) - { - ColorPicker.SelectedBrush = Brushes.Blue; - PopupColor.IsOpen = true; + Growl.SetGrowlPanel(PanelMessage); } } } \ No newline at end of file diff --git a/HandyControlDemo/Properties/AssemblyInfo.cs b/HandyControlDemo/Properties/AssemblyInfo.cs index 45521dfcd..5b9572c96 100644 --- a/HandyControlDemo/Properties/AssemblyInfo.cs +++ b/HandyControlDemo/Properties/AssemblyInfo.cs @@ -2,52 +2,15 @@ using System.Runtime.InteropServices; using System.Windows; -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 [assembly: AssemblyTitle("HandyControlDemo")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("HandyControlDemo")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HandyControlDemo")] -[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCopyright("Copyright © 纳边 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 [assembly: ComVisible(false)] - -//若要开始生成可本地化的应用程序,请设置 -//.csproj 文件中的 CultureYouAreCodingWith -//例如,如果您在源文件中使用的是美国英语, -//使用的是美国英语,请将 设置为 en-US。 然后取消 -//对以下 NeutralResourceLanguage 特性的注释。 更新 -//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //主题特定资源词典所处位置 - //(未在页面中找到资源时使用, - //或应用程序资源字典中找到时使用) - ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 - //(未在页面中找到资源时使用, - //、应用程序或任何主题专用资源字典中找到时使用) -)] - - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/HandyControlDemo/Resources/1.jpg b/HandyControlDemo/Resources/Img/1.jpg similarity index 100% rename from HandyControlDemo/Resources/1.jpg rename to HandyControlDemo/Resources/Img/1.jpg diff --git a/HandyControlDemo/Resources/2.jpg b/HandyControlDemo/Resources/Img/2.jpg similarity index 100% rename from HandyControlDemo/Resources/2.jpg rename to HandyControlDemo/Resources/Img/2.jpg diff --git a/HandyControlDemo/Resources/3.jpg b/HandyControlDemo/Resources/Img/3.jpg similarity index 100% rename from HandyControlDemo/Resources/3.jpg rename to HandyControlDemo/Resources/Img/3.jpg diff --git a/HandyControlDemo/Resources/4.jpg b/HandyControlDemo/Resources/Img/4.jpg similarity index 100% rename from HandyControlDemo/Resources/4.jpg rename to HandyControlDemo/Resources/Img/4.jpg diff --git a/HandyControlDemo/Resources/5.jpg b/HandyControlDemo/Resources/Img/5.jpg similarity index 100% rename from HandyControlDemo/Resources/5.jpg rename to HandyControlDemo/Resources/Img/5.jpg diff --git a/HandyControlDemo/Resources/b1.jpg b/HandyControlDemo/Resources/Img/b1.jpg similarity index 100% rename from HandyControlDemo/Resources/b1.jpg rename to HandyControlDemo/Resources/Img/b1.jpg diff --git a/HandyControlDemo/Resources/b2.jpg b/HandyControlDemo/Resources/Img/b2.jpg similarity index 100% rename from HandyControlDemo/Resources/b2.jpg rename to HandyControlDemo/Resources/Img/b2.jpg diff --git a/HandyControlDemo/Resources/icon-white.png b/HandyControlDemo/Resources/Img/icon-white.png similarity index 100% rename from HandyControlDemo/Resources/icon-white.png rename to HandyControlDemo/Resources/Img/icon-white.png diff --git a/HandyControlDemo/Resources/Lang/zh-cn.xaml b/HandyControlDemo/Resources/Lang/zh-cn.xaml new file mode 100644 index 000000000..83f9964b2 --- /dev/null +++ b/HandyControlDemo/Resources/Lang/zh-cn.xaml @@ -0,0 +1,28 @@ + + + 控件 + 样式模板 + 信息通知 + 今天的天气不错~~~ + 文件保存成功! + 磁盘空间快要满了! + 连接服务器失败,请检查网络! + 程序已崩溃~~~ + 检测到有新版本,是否更新? + 加载条 + 图片浏览器 + 颜色拾取器 + 轮播 + 对比滑块 + 时间条 + 展开框 + 页码条 + 点击打开图片浏览器 + 进度条 + 动画路径 + 按钮 + 切换按钮 + + \ No newline at end of file diff --git a/HandyControlDemo/Resources/Themes/Basic/Brushes.xaml b/HandyControlDemo/Resources/Themes/Basic/Brushes.xaml new file mode 100644 index 000000000..bdbcf4edb --- /dev/null +++ b/HandyControlDemo/Resources/Themes/Basic/Brushes.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/Resources/Themes/Basic/Colors.xaml b/HandyControlDemo/Resources/Themes/Basic/Colors.xaml new file mode 100644 index 000000000..9b749667f --- /dev/null +++ b/HandyControlDemo/Resources/Themes/Basic/Colors.xaml @@ -0,0 +1,6 @@ + + + #262e2f + + \ No newline at end of file diff --git a/HandyControlDemo/Resources/Themes/Style.xaml b/HandyControlDemo/Resources/Themes/Style.xaml new file mode 100644 index 000000000..ea95bea77 --- /dev/null +++ b/HandyControlDemo/Resources/Themes/Style.xaml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/UserControl/ControlLocator.cs b/HandyControlDemo/UserControl/ControlLocator.cs new file mode 100644 index 000000000..20268ccb1 --- /dev/null +++ b/HandyControlDemo/UserControl/ControlLocator.cs @@ -0,0 +1,75 @@ +using System; +using CommonServiceLocator; +using GalaSoft.MvvmLight.Ioc; + +namespace HandyControlDemo.UserControl +{ + /// + /// 控件定位器 + /// + public class ControlLocator + { + private ControlLocator() + { + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + } + + public static ControlLocator Instance => new Lazy(() => new ControlLocator()).Value; + + #region Main + + public MainContent MainContent => ServiceLocator.Current.GetInstance(); + + public LeftMainContent LeftMainContent => ServiceLocator.Current.GetInstance(); + + #endregion + + #region Controls + + public GrowlDemoCtl GrowlDemoCtl => new GrowlDemoCtl(); + + public LoadingDemoCtl LoadingDemoCtl => new LoadingDemoCtl(); + + public ImageBrowserDemoCtl ImageBrowserDemoCtl => new ImageBrowserDemoCtl(); + + public ColorPickerDemoCtl ColorPickerDemoCtl => new ColorPickerDemoCtl(); + + public CarouselDemoCtl CarouselDemoCtl => new CarouselDemoCtl(); + + public CompareSliderDemoCtl CompareSliderDemoCtl => new CompareSliderDemoCtl(); + + public TimeBarDemoCtl TimeBarDemoCtl => new TimeBarDemoCtl(); + + public PaginationDemoCtl PaginationDemoCtl => new PaginationDemoCtl(); + + public AnimationPathDemoCtl AnimationPathDemoCtl => new AnimationPathDemoCtl(); + + #endregion + + #region Styles + + public ButtonDemoCtl ButtonDemoCtl => new ButtonDemoCtl(); + + public ToggleButtonDemoCtl ToggleButtonDemoCtl => new ToggleButtonDemoCtl(); + + public ExpanderDemoCtl ExpanderDemoCtl => new ExpanderDemoCtl(); + + public ProgressBarDemoCtl ProgressBarDemoCtl => new ProgressBarDemoCtl(); + + #endregion + } +} \ No newline at end of file diff --git a/HandyControlDemo/UserControl/ControlLocator.tt b/HandyControlDemo/UserControl/ControlLocator.tt new file mode 100644 index 000000000..d0afc8785 --- /dev/null +++ b/HandyControlDemo/UserControl/ControlLocator.tt @@ -0,0 +1,80 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ import namespace="System.Collections.Generic"#> +<#@ output extension=".cs" #> +<# +var singleList = new List +{ + "MainContent", + "LeftMainContent" +}; +var controlList = new List +{ + "GrowlDemoCtl", + "LoadingDemoCtl", + "ImageBrowserDemoCtl", + "ColorPickerDemoCtl", + "CarouselDemoCtl", + "CompareSliderDemoCtl", + "TimeBarDemoCtl", + "PaginationDemoCtl", + "AnimationPathDemoCtl" +}; +var styleList = new List +{ + "ButtonDemoCtl", + "ToggleButtonDemoCtl", + "ExpanderDemoCtl", + "ProgressBarDemoCtl" +}; +#> +using System; +using CommonServiceLocator; +using GalaSoft.MvvmLight.Ioc; + +namespace HandyControlDemo.UserControl +{ + /// + /// 控件定位器 + /// + public class ControlLocator + { + private ControlLocator() + { + <#foreach(var item in singleList){#> + SimpleIoc.Default.Register<<#=item#>>(); + <#}#> +<#foreach(var item in controlList){#> + SimpleIoc.Default.Register<<#=item#>>(); + <#}#> +<#foreach(var item in styleList){#> + SimpleIoc.Default.Register<<#=item#>>(); + <#}#> +} + + public static ControlLocator Instance => new Lazy(() => new ControlLocator()).Value; + + #region Main + + <#foreach(var item in singleList){#> +public <#=item#> <#=item#> => ServiceLocator.Current.GetInstance<<#=item#>>(); + + <#}#> +#endregion + + #region Controls + + <#foreach(var item in controlList){#> +public <#=item#> <#=item#> => new <#=item#>(); + + <#}#> +#endregion + + #region Styles + + <#foreach(var item in styleList){#> +public <#=item#> <#=item#> => new <#=item#>(); + + <#}#> +#endregion + } +} \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Controls/AnimationPathDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/AnimationPathDemoCtl.xaml new file mode 100644 index 000000000..d04888ae3 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/AnimationPathDemoCtl.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/HandyControlDemo/UserControl/Controls/AnimationPathDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/AnimationPathDemoCtl.xaml.cs new file mode 100644 index 000000000..04a991944 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/AnimationPathDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// AnimationPathDemoCtl.xaml 的交互逻辑 + /// + public partial class AnimationPathDemoCtl + { + public AnimationPathDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/CarouselDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/CarouselDemoCtl.xaml new file mode 100644 index 000000000..eaf333451 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/CarouselDemoCtl.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Controls/CarouselDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/CarouselDemoCtl.xaml.cs new file mode 100644 index 000000000..8fccc343b --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/CarouselDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// CarouselDemoCtl.xaml 的交互逻辑 + /// + public partial class CarouselDemoCtl + { + public CarouselDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/ColorPickerDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/ColorPickerDemoCtl.xaml new file mode 100644 index 000000000..5e41bcea9 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/ColorPickerDemoCtl.xaml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/HandyControlDemo/UserControl/Controls/ColorPickerDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/ColorPickerDemoCtl.xaml.cs new file mode 100644 index 000000000..e2b28ee2e --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/ColorPickerDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// ColorPickerDemoCtl.xaml 的交互逻辑 + /// + public partial class ColorPickerDemoCtl + { + public ColorPickerDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/CompareSliderDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/CompareSliderDemoCtl.xaml new file mode 100644 index 000000000..97e125fee --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/CompareSliderDemoCtl.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Controls/CompareSliderDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/CompareSliderDemoCtl.xaml.cs new file mode 100644 index 000000000..fd80f4d8d --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/CompareSliderDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// CompareSliderDemoCtl.xaml 的交互逻辑 + /// + public partial class CompareSliderDemoCtl + { + public CompareSliderDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/GrowlDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/GrowlDemoCtl.xaml new file mode 100644 index 000000000..21975f89a --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/GrowlDemoCtl.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Controls/GrowlDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/GrowlDemoCtl.xaml.cs new file mode 100644 index 000000000..6afc4816f --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/GrowlDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// GrowlDemoGrid.xaml 的交互逻辑 + /// + public partial class GrowlDemoCtl + { + public GrowlDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/ImageBrowserDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/ImageBrowserDemoCtl.xaml new file mode 100644 index 000000000..78b9247a8 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/ImageBrowserDemoCtl.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/HandyControlDemo/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs new file mode 100644 index 000000000..5c030a49c --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// ImageBrowserDemoCtl.xaml 的交互逻辑 + /// + public partial class ImageBrowserDemoCtl + { + public ImageBrowserDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/LoadingDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/LoadingDemoCtl.xaml new file mode 100644 index 000000000..378315d53 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/LoadingDemoCtl.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Controls/LoadingDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/LoadingDemoCtl.xaml.cs new file mode 100644 index 000000000..5d05c65a5 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/LoadingDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// LoadingDemoCtl.xaml 的交互逻辑 + /// + public partial class LoadingDemoCtl + { + public LoadingDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/PaginationDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/PaginationDemoCtl.xaml new file mode 100644 index 000000000..64e04f3c1 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/PaginationDemoCtl.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/HandyControlDemo/UserControl/Controls/PaginationDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/PaginationDemoCtl.xaml.cs new file mode 100644 index 000000000..10466553e --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/PaginationDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// PaginationDemoCtl.xaml 的交互逻辑 + /// + public partial class PaginationDemoCtl + { + public PaginationDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/TimeBarDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/TimeBarDemoCtl.xaml new file mode 100644 index 000000000..9b6ab74fa --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/TimeBarDemoCtl.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/HandyControlDemo/UserControl/Controls/TimeBarDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/TimeBarDemoCtl.xaml.cs new file mode 100644 index 000000000..497ccc44c --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/TimeBarDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// TimeBarDemoCtl.xaml 的交互逻辑 + /// + public partial class TimeBarDemoCtl + { + public TimeBarDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml new file mode 100644 index 000000000..fca35ebc5 --- /dev/null +++ b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml.cs b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml.cs new file mode 100644 index 000000000..e028dc422 --- /dev/null +++ b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// 左侧主内容 + /// + public partial class LeftMainContent + { + public LeftMainContent() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Main/MainContent.xaml b/HandyControlDemo/UserControl/Main/MainContent.xaml new file mode 100644 index 000000000..e25e1273f --- /dev/null +++ b/HandyControlDemo/UserControl/Main/MainContent.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Main/MainContent.xaml.cs b/HandyControlDemo/UserControl/Main/MainContent.xaml.cs new file mode 100644 index 000000000..16fdb298d --- /dev/null +++ b/HandyControlDemo/UserControl/Main/MainContent.xaml.cs @@ -0,0 +1,43 @@ +using System.Windows; +using HandyControl.Tools.Extension; + +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// 主内容 + /// + public partial class MainContent + { + private bool _isFull; + + public MainContent() + { + InitializeComponent(); + } + + public void FullSwitch(bool isFull) + { + if (_isFull == isFull) return; + _isFull = isFull; + if (_isFull) + { + BorderEffect.Collapse(); + BorderTitle.Collapse(); + GridMain.HorizontalAlignment = HorizontalAlignment.Stretch; + GridMain.VerticalAlignment = VerticalAlignment.Stretch; + GridMain.Margin = new Thickness(); + PresenterMain.Margin = new Thickness(); + } + else + { + BorderEffect.Show(); + BorderTitle.Show(); + GridMain.HorizontalAlignment = HorizontalAlignment.Center; + GridMain.VerticalAlignment = VerticalAlignment.Top; + GridMain.Margin = new Thickness(16, 0, 16, 16); + PresenterMain.Margin = new Thickness(0, 0, 0, 10); + } + } + } +} \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Styles/ButtonDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/ButtonDemoCtl.xaml new file mode 100644 index 000000000..142798ec2 --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ButtonDemoCtl.xaml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Styles/ButtonDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Styles/ButtonDemoCtl.xaml.cs new file mode 100644 index 000000000..8fef6cc90 --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ButtonDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// ButtonDemoCtl.xaml 的交互逻辑 + /// + public partial class ButtonDemoCtl + { + public ButtonDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Styles/ExpanderDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/ExpanderDemoCtl.xaml new file mode 100644 index 000000000..bdef7ab3d --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ExpanderDemoCtl.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Styles/ExpanderDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Styles/ExpanderDemoCtl.xaml.cs new file mode 100644 index 000000000..72e4d42ad --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ExpanderDemoCtl.xaml.cs @@ -0,0 +1,15 @@ +// ReSharper disable once CheckNamespace + +namespace HandyControlDemo.UserControl +{ + /// + /// ExpanderDemoCtl.xaml 的交互逻辑 + /// + public partial class ExpanderDemoCtl + { + public ExpanderDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Styles/ProgressBarDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/ProgressBarDemoCtl.xaml new file mode 100644 index 000000000..b91b2591a --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ProgressBarDemoCtl.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Styles/ProgressBarDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Styles/ProgressBarDemoCtl.xaml.cs new file mode 100644 index 000000000..35b5da795 --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ProgressBarDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// ProgressBarDemoCtl.xaml 的交互逻辑 + /// + public partial class ProgressBarDemoCtl + { + public ProgressBarDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/UserControl/Styles/ToggleButtonDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/ToggleButtonDemoCtl.xaml new file mode 100644 index 000000000..6e0978ea0 --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ToggleButtonDemoCtl.xaml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Styles/ToggleButtonDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Styles/ToggleButtonDemoCtl.xaml.cs new file mode 100644 index 000000000..0a1e5e549 --- /dev/null +++ b/HandyControlDemo/UserControl/Styles/ToggleButtonDemoCtl.xaml.cs @@ -0,0 +1,14 @@ +// ReSharper disable once CheckNamespace +namespace HandyControlDemo.UserControl +{ + /// + /// ToggleButtonDemoCtl.xaml 的交互逻辑 + /// + public partial class ToggleButtonDemoCtl + { + public ToggleButtonDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/HandyControlDemo/ViewModel/GrowlDemoViewModel.cs b/HandyControlDemo/ViewModel/GrowlDemoViewModel.cs new file mode 100644 index 000000000..8cb26d9a8 --- /dev/null +++ b/HandyControlDemo/ViewModel/GrowlDemoViewModel.cs @@ -0,0 +1,35 @@ +using System; +using GalaSoft.MvvmLight.Command; +using HandyControl.Controls; +using HandyControl.Tools; + +namespace HandyControlDemo.ViewModel +{ + public class GrowlDemoViewModel + { + public RelayCommand InfoCmd => new Lazy(() => + new RelayCommand(() => Growl.Info(ResourceHelper.GetString("GrowlInfo")))).Value; + + public RelayCommand SuccessCmd => new Lazy(() => + new RelayCommand(() => Growl.Success(ResourceHelper.GetString("GrowlSuccess")))).Value; + + public RelayCommand WarningCmd => new Lazy(() => + new RelayCommand(() => Growl.Warning(ResourceHelper.GetString("GrowlWarning")))).Value; + + public RelayCommand ErrorCmd => new Lazy(() => + new RelayCommand(() => Growl.Error(ResourceHelper.GetString("GrowlError")))).Value; + + public RelayCommand AskCmd => new Lazy(() => + new RelayCommand(() => Growl.Ask("GrowlAsk", (closeAction, b) => + { + Growl.Info(b.ToString()); + closeAction?.Invoke(); + }))).Value; + + public RelayCommand FatalCmd => new Lazy(() => + new RelayCommand(() => Growl.Fatal(ResourceHelper.GetString("GrowlFatal")))).Value; + + public RelayCommand ClearCmd => new Lazy(() => + new RelayCommand(Growl.Clear)).Value; + } +} \ No newline at end of file diff --git a/HandyControlDemo/ViewModel/ImageBrowserDemoViewModel.cs b/HandyControlDemo/ViewModel/ImageBrowserDemoViewModel.cs new file mode 100644 index 000000000..2fa5120ae --- /dev/null +++ b/HandyControlDemo/ViewModel/ImageBrowserDemoViewModel.cs @@ -0,0 +1,13 @@ +using System; +using GalaSoft.MvvmLight.Command; +using HandyControl.Controls; + +namespace HandyControlDemo.ViewModel +{ + public class ImageBrowserDemoViewModel + { + public RelayCommand OpenImgCmd => new Lazy(() => + new RelayCommand(() => + new ImageBrowser(new Uri("pack://application:,,,/Resources/Img/1.jpg")).Show())).Value; + } +} \ No newline at end of file diff --git a/HandyControlDemo/ViewModel/MainViewModel.cs b/HandyControlDemo/ViewModel/MainViewModel.cs new file mode 100644 index 000000000..12e94878a --- /dev/null +++ b/HandyControlDemo/ViewModel/MainViewModel.cs @@ -0,0 +1,133 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Messaging; +using HandyControlDemo.Data; +using HandyControlDemo.UserControl; + +namespace HandyControlDemo.ViewModel +{ + public class MainViewModel : ViewModelBase + { + #region 字段 + + /// + /// 内容标题 + /// + private object _contentTitle; + + /// + /// 左侧主内容 + /// + private object _leftMainContent; + + /// + /// 主内容 + /// + private object _mainContent; + + /// + /// 子内容 + /// + private object _subContent; + + #endregion + + public MainViewModel() + { + LeftMainContent = ControlLocator.Instance.LeftMainContent; + MainContent = ControlLocator.Instance.MainContent; + + Messenger.Default.Register(this, MessageToken.LoadGrowlDemoCtl, obj => SubContent = ControlLocator.Instance.GrowlDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadLoadingDemoCtl, obj => SubContent = ControlLocator.Instance.LoadingDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadImageBrowserDemoCtl, obj => SubContent = ControlLocator.Instance.ImageBrowserDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadColorPickerDemoCtl, obj => SubContent = ControlLocator.Instance.ColorPickerDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadCarouselDemoCtl, obj => SubContent = ControlLocator.Instance.CarouselDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadCompareSliderDemoCtl, obj => SubContent = ControlLocator.Instance.CompareSliderDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadTimeBarDemoCtl, obj => SubContent = ControlLocator.Instance.TimeBarDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadPaginationDemoCtl, obj => SubContent = ControlLocator.Instance.PaginationDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadExpanderDemoCtl, obj => SubContent = ControlLocator.Instance.ExpanderDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadProgressBarDemoCtl, obj => SubContent = ControlLocator.Instance.ProgressBarDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadAnimationPathDemoCtl, obj => SubContent = ControlLocator.Instance.AnimationPathDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadButtonDemoCtl, obj => SubContent = ControlLocator.Instance.ButtonDemoCtl); + Messenger.Default.Register(this, MessageToken.LoadToggleButtonDemoCtl, obj => SubContent = ControlLocator.Instance.ToggleButtonDemoCtl); + } + + #region 属性 + + /// + /// 左侧主内容 + /// + public object LeftMainContent + { + get => _leftMainContent; + set => Set(ref _leftMainContent, value); + } + + /// + /// 主内容 + /// + public object MainContent + { + get => _mainContent; + set => Set(ref _mainContent, value); + } + + /// + /// 子内容 + /// + public object SubContent + { + get => _subContent; + set => Set(ref _subContent, value); + } + + /// + /// 内容标题 + /// + public object ContentTitle + { + get => _contentTitle; + set => Set(ref _contentTitle, value); + } + + #endregion + + #region 命令 + + /// + /// 切换例子命令 + /// + public RelayCommand> SwitchDemoCmd => + new Lazy>>(() => + new RelayCommand>(SwitchDemo)).Value; + + #endregion + + #region 方法 + + /// + /// 切换例子 + /// + private void SwitchDemo(RoutedPropertyChangedEventArgs e) + { + if (e.NewValue is TreeViewItem item) + { + if (item.Tag is string tag) + { + ContentTitle = item.Header; + Messenger.Default.Send(null, tag); + } + else + { + ContentTitle = null; + SubContent = null; + } + } + } + + #endregion + } +} \ No newline at end of file diff --git a/HandyControlDemo/ViewModel/ViewModelLocator.cs b/HandyControlDemo/ViewModel/ViewModelLocator.cs new file mode 100644 index 000000000..b20e9a1cf --- /dev/null +++ b/HandyControlDemo/ViewModel/ViewModelLocator.cs @@ -0,0 +1,32 @@ +using System; +using System.Windows; +using CommonServiceLocator; +using GalaSoft.MvvmLight.Ioc; + +namespace HandyControlDemo.ViewModel +{ + public class ViewModelLocator + { + public ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + } + + public static ViewModelLocator Instance => new Lazy(() => + Application.Current.TryFindResource("Locator") as ViewModelLocator).Value; + + #region Vm + + public MainViewModel Main => ServiceLocator.Current.GetInstance(); + + public GrowlDemoViewModel GrowlDemo => ServiceLocator.Current.GetInstance(); + + public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance(); + + #endregion + } +} \ No newline at end of file diff --git a/HandyControlDemo/packages.config b/HandyControlDemo/packages.config new file mode 100644 index 000000000..59fa3173e --- /dev/null +++ b/HandyControlDemo/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 47eb67e55..fc6062c32 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,23 @@ ![图片浏览器ImageBrowser](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ImageBrowser.gif) ### 8、对比滑块CompareSlider + ![对比滑块CompareSlider](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/CompareSlider-h.gif) ![对比滑块CompareSlider](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/CompareSlider-v.gif) +### 9、信息通知Growl + +![信息通知Growl](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Growl.gif) + +### 10、动画路径AnimationPath + +![动画路径AnimationPath](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/AnimationPath.gif) + +### 11、进度条ProgressBar + +![进度条ProgressBar](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ProgressBar.gif) + # 使用方法 第一步:添加HandyControl的引用; @@ -56,23 +69,26 @@ ``` 第三步:enjoy coding -# 其他主要功能 -1、如何让**Scrollviewer**具有惯性?只要: +# FAQ +* 如何让**Scrollviewer**具有惯性?只要: ```XML ``` -2、如何让**Scrollviewer**具有穿透效果?只要: +* 如何让**Scrollviewer**具有穿透效果?只要: ```XML ``` -# 下一版本计划 +* 为什么我连编译都无法通过: +编译之前,请确保IDE为vs2017且c#最低版本为7.0,HandyControl目前仅支持4.5以上的.net环境,低版本支持估计很快就有了。 + +# v1.3.0版本计划 -1、添加信息通知控件; -2、添加进度条样式; -3、添加路径动画控件; \ No newline at end of file +1、添加可拖动的tabcontrol; +2、添加时间、日历控件; +3、添加步骤条控件; \ No newline at end of file diff --git a/Resources/AnimationPath.gif b/Resources/AnimationPath.gif new file mode 100644 index 000000000..d58704cfa Binary files /dev/null and b/Resources/AnimationPath.gif differ diff --git a/Resources/Growl.gif b/Resources/Growl.gif new file mode 100644 index 000000000..22faeb208 Binary files /dev/null and b/Resources/Growl.gif differ diff --git a/Resources/ProgressBar.gif b/Resources/ProgressBar.gif new file mode 100644 index 000000000..7ba120226 Binary files /dev/null and b/Resources/ProgressBar.gif differ