update to v1.2.0
This commit is contained in:
1 parent
c402f428fb
commit
4afd1097de
90 files changed
+2992
-1652
No files matched your search
@@ -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<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Info(ResourceHelper.GetString("GrowlInfo")))).Value;
|
||||
|
||||
public RelayCommand SuccessCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Success(ResourceHelper.GetString("GrowlSuccess")))).Value;
|
||||
|
||||
public RelayCommand WarningCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Warning(ResourceHelper.GetString("GrowlWarning")))).Value;
|
||||
|
||||
public RelayCommand ErrorCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Error(ResourceHelper.GetString("GrowlError")))).Value;
|
||||
|
||||
public RelayCommand AskCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Ask("GrowlAsk", (closeAction, b) =>
|
||||
{
|
||||
Growl.Info(b.ToString());
|
||||
closeAction?.Invoke();
|
||||
}))).Value;
|
||||
|
||||
public RelayCommand FatalCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Fatal(ResourceHelper.GetString("GrowlFatal")))).Value;
|
||||
|
||||
public RelayCommand ClearCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(Growl.Clear)).Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using HandyControl.Controls;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class ImageBrowserDemoViewModel
|
||||
{
|
||||
public RelayCommand OpenImgCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() =>
|
||||
new ImageBrowser(new Uri("pack://application:,,,/Resources/Img/1.jpg")).Show())).Value;
|
||||
}
|
||||
}
|
||||
@@ -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 字段
|
||||
|
||||
/// <summary>
|
||||
/// 内容标题
|
||||
/// </summary>
|
||||
private object _contentTitle;
|
||||
|
||||
/// <summary>
|
||||
/// 左侧主内容
|
||||
/// </summary>
|
||||
private object _leftMainContent;
|
||||
|
||||
/// <summary>
|
||||
/// 主内容
|
||||
/// </summary>
|
||||
private object _mainContent;
|
||||
|
||||
/// <summary>
|
||||
/// 子内容
|
||||
/// </summary>
|
||||
private object _subContent;
|
||||
|
||||
#endregion
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
LeftMainContent = ControlLocator.Instance.LeftMainContent;
|
||||
MainContent = ControlLocator.Instance.MainContent;
|
||||
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadGrowlDemoCtl, obj => SubContent = ControlLocator.Instance.GrowlDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadLoadingDemoCtl, obj => SubContent = ControlLocator.Instance.LoadingDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadImageBrowserDemoCtl, obj => SubContent = ControlLocator.Instance.ImageBrowserDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadColorPickerDemoCtl, obj => SubContent = ControlLocator.Instance.ColorPickerDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadCarouselDemoCtl, obj => SubContent = ControlLocator.Instance.CarouselDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadCompareSliderDemoCtl, obj => SubContent = ControlLocator.Instance.CompareSliderDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadTimeBarDemoCtl, obj => SubContent = ControlLocator.Instance.TimeBarDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadPaginationDemoCtl, obj => SubContent = ControlLocator.Instance.PaginationDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadExpanderDemoCtl, obj => SubContent = ControlLocator.Instance.ExpanderDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadProgressBarDemoCtl, obj => SubContent = ControlLocator.Instance.ProgressBarDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadAnimationPathDemoCtl, obj => SubContent = ControlLocator.Instance.AnimationPathDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadButtonDemoCtl, obj => SubContent = ControlLocator.Instance.ButtonDemoCtl);
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadToggleButtonDemoCtl, obj => SubContent = ControlLocator.Instance.ToggleButtonDemoCtl);
|
||||
}
|
||||
|
||||
#region 属性
|
||||
|
||||
/// <summary>
|
||||
/// 左侧主内容
|
||||
/// </summary>
|
||||
public object LeftMainContent
|
||||
{
|
||||
get => _leftMainContent;
|
||||
set => Set(ref _leftMainContent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主内容
|
||||
/// </summary>
|
||||
public object MainContent
|
||||
{
|
||||
get => _mainContent;
|
||||
set => Set(ref _mainContent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 子内容
|
||||
/// </summary>
|
||||
public object SubContent
|
||||
{
|
||||
get => _subContent;
|
||||
set => Set(ref _subContent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内容标题
|
||||
/// </summary>
|
||||
public object ContentTitle
|
||||
{
|
||||
get => _contentTitle;
|
||||
set => Set(ref _contentTitle, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 命令
|
||||
|
||||
/// <summary>
|
||||
/// 切换例子命令
|
||||
/// </summary>
|
||||
public RelayCommand<RoutedPropertyChangedEventArgs<object>> SwitchDemoCmd =>
|
||||
new Lazy<RelayCommand<RoutedPropertyChangedEventArgs<object>>>(() =>
|
||||
new RelayCommand<RoutedPropertyChangedEventArgs<object>>(SwitchDemo)).Value;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 方法
|
||||
|
||||
/// <summary>
|
||||
/// 切换例子
|
||||
/// </summary>
|
||||
private void SwitchDemo(RoutedPropertyChangedEventArgs<object> e)
|
||||
{
|
||||
if (e.NewValue is TreeViewItem item)
|
||||
{
|
||||
if (item.Tag is string tag)
|
||||
{
|
||||
ContentTitle = item.Header;
|
||||
Messenger.Default.Send<object>(null, tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentTitle = null;
|
||||
SubContent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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<MainViewModel>();
|
||||
SimpleIoc.Default.Register<GrowlDemoViewModel>();
|
||||
SimpleIoc.Default.Register<ImageBrowserDemoViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
Application.Current.TryFindResource("Locator") as ViewModelLocator).Value;
|
||||
|
||||
#region Vm
|
||||
|
||||
public MainViewModel Main => ServiceLocator.Current.GetInstance<MainViewModel>();
|
||||
|
||||
public GrowlDemoViewModel GrowlDemo => ServiceLocator.Current.GetInstance<GrowlDemoViewModel>();
|
||||
|
||||
public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance<ImageBrowserDemoViewModel>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user