delete lazy code in viewmodels
This commit is contained in:
1 parent
066cedeb73
commit
700f54ab2b
23 files changed
+141
-214
No files matched your search
@@ -11,9 +11,9 @@ namespace HandyControlDemo.Resources
|
|||||||
public override ResourceDictionary GetSkin(SkinType skinType) =>
|
public override ResourceDictionary GetSkin(SkinType skinType) =>
|
||||||
ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
|
ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
|
||||||
|
|
||||||
public override ResourceDictionary GetTheme() => new Lazy<ResourceDictionary>(() => new ResourceDictionary
|
public override ResourceDictionary GetTheme() => new()
|
||||||
{
|
{
|
||||||
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
|
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
|
||||||
}).Value;
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
|
|
||||||
private readonly string _id = Guid.NewGuid().ToString();
|
private readonly string _id = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
private readonly Stopwatch _stopwatch = new Lazy<Stopwatch>(() => new Stopwatch()).Value;
|
private readonly Stopwatch _stopwatch = new();
|
||||||
|
|
||||||
public ChatBoxViewModel()
|
public ChatBoxViewModel()
|
||||||
{
|
{
|
||||||
@@ -52,8 +52,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
|
|
||||||
public ObservableCollection<ChatInfoModel> ChatInfos { get; set; } = new();
|
public ObservableCollection<ChatInfoModel> ChatInfos { get; set; } = new();
|
||||||
|
|
||||||
public RelayCommand<KeyEventArgs> SendStringCmd => new Lazy<RelayCommand<KeyEventArgs>>(() =>
|
public RelayCommand<KeyEventArgs> SendStringCmd => new(SendString);
|
||||||
new RelayCommand<KeyEventArgs>(SendString)).Value;
|
|
||||||
|
|
||||||
private void SendString(KeyEventArgs e)
|
private void SendString(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -73,12 +72,11 @@ namespace HandyControlDemo.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand<RoutedEventArgs> ReadMessageCmd => new Lazy<RelayCommand<RoutedEventArgs>>(() =>
|
public RelayCommand<RoutedEventArgs> ReadMessageCmd => new(ReadMessage);
|
||||||
new RelayCommand<RoutedEventArgs>(ReadMessage)).Value;
|
|
||||||
|
|
||||||
private void ReadMessage(RoutedEventArgs e)
|
private void ReadMessage(RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.OriginalSource is FrameworkElement element && element.Tag is ChatInfoModel info)
|
if (e.OriginalSource is FrameworkElement {Tag: ChatInfoModel info})
|
||||||
{
|
{
|
||||||
if (info.Type == ChatMessageType.Image)
|
if (info.Type == ChatMessageType.Image)
|
||||||
{
|
{
|
||||||
@@ -95,8 +93,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand StartRecordCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand StartRecordCmd => new(StartRecord);
|
||||||
new RelayCommand(StartRecord)).Value;
|
|
||||||
|
|
||||||
private void StartRecord()
|
private void StartRecord()
|
||||||
{
|
{
|
||||||
@@ -111,8 +108,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
_stopwatch.Start();
|
_stopwatch.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand StopRecordCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand StopRecordCmd => new(StopRecord);
|
||||||
new RelayCommand(StopRecord)).Value;
|
|
||||||
|
|
||||||
private void StopRecord()
|
private void StopRecord()
|
||||||
{
|
{
|
||||||
@@ -149,8 +145,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
Messenger.Default.Send(info, MessageToken.SendChatMessage);
|
Messenger.Default.Send(info, MessageToken.SendChatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand OpenImageCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand OpenImageCmd => new(OpenImage);
|
||||||
new RelayCommand(OpenImage)).Value;
|
|
||||||
|
|
||||||
private void OpenImage()
|
private void OpenImage()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ namespace HandyControlDemo.ViewModel
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand CloseCmd => new Lazy<RelayCommand>(() => new RelayCommand(() => CloseAction?.Invoke())).Value;
|
public RelayCommand CloseCmd => new(() => CloseAction?.Invoke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
|
||||||
namespace HandyControlDemo.ViewModel
|
namespace HandyControlDemo.ViewModel
|
||||||
@@ -18,7 +17,6 @@ namespace HandyControlDemo.ViewModel
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand CountCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand CountCmd => new(() => Count++);
|
||||||
new RelayCommand(() => Count++)).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using HandyControlDemo.Data;
|
using HandyControlDemo.Data;
|
||||||
using HandyControlDemo.Service;
|
using HandyControlDemo.Service;
|
||||||
|
|
||||||
@@ -15,16 +14,14 @@ namespace HandyControlDemo.ViewModel
|
|||||||
DataList = dataService.GetCardDataList();
|
DataList = dataService.GetCardDataList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand AddItemCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand AddItemCmd => new(() => DataList.Insert(0, _dataService.GetCardData()));
|
||||||
new RelayCommand(() => DataList.Insert(0, _dataService.GetCardData()))).Value;
|
|
||||||
|
|
||||||
public RelayCommand RemoveItemCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand RemoveItemCmd => new(() =>
|
||||||
new RelayCommand(() =>
|
{
|
||||||
|
if (DataList.Count > 0)
|
||||||
{
|
{
|
||||||
if (DataList.Count > 0)
|
DataList.RemoveAt(0);
|
||||||
{
|
}
|
||||||
DataList.RemoveAt(0);
|
});
|
||||||
}
|
|
||||||
})).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand<FrameworkElement> ShowTextCmd => new Lazy<RelayCommand<FrameworkElement>>(() =>
|
public RelayCommand<FrameworkElement> ShowTextCmd => new(ShowText);
|
||||||
new RelayCommand<FrameworkElement>(ShowText)).Value;
|
|
||||||
|
|
||||||
private void ShowText(FrameworkElement element)
|
private void ShowText(FrameworkElement element)
|
||||||
{
|
{
|
||||||
@@ -43,8 +42,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NET40
|
#if NET40
|
||||||
public RelayCommand<bool> ShowInteractiveDialogCmd => new Lazy<RelayCommand<bool>>(() =>
|
public RelayCommand<bool> ShowInteractiveDialogCmd => new(ShowInteractiveDialog);
|
||||||
new RelayCommand<bool>(ShowInteractiveDialog)).Value;
|
|
||||||
|
|
||||||
private void ShowInteractiveDialog(bool withTimer)
|
private void ShowInteractiveDialog(bool withTimer)
|
||||||
{
|
{
|
||||||
@@ -60,8 +58,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
public RelayCommand<bool> ShowInteractiveDialogCmd => new Lazy<RelayCommand<bool>>(() =>
|
public RelayCommand<bool> ShowInteractiveDialogCmd => new(async withTimer => await ShowInteractiveDialog(withTimer));
|
||||||
new RelayCommand<bool>(async withTimer => await ShowInteractiveDialog(withTimer))).Value;
|
|
||||||
|
|
||||||
private async Task ShowInteractiveDialog(bool withTimer)
|
private async Task ShowInteractiveDialog(bool withTimer)
|
||||||
{
|
{
|
||||||
@@ -78,13 +75,11 @@ namespace HandyControlDemo.ViewModel
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public RelayCommand NewWindowCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand NewWindowCmd => new(() => new DialogDemoWindow
|
||||||
new RelayCommand(() => new DialogDemoWindow
|
{
|
||||||
{
|
Owner = Application.Current.MainWindow
|
||||||
Owner = Application.Current.MainWindow
|
}.Show());
|
||||||
}.Show())).Value;
|
|
||||||
|
|
||||||
public RelayCommand<string> ShowWithTokenCmd => new Lazy<RelayCommand<string>>(() =>
|
public RelayCommand<string> ShowWithTokenCmd => new(token => Dialog.Show(new TextDialog(), token));
|
||||||
new RelayCommand<string>(token => Dialog.Show(new TextDialog(), token))).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Windows;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
@@ -23,94 +22,79 @@ namespace HandyControlDemo.ViewModel
|
|||||||
|
|
||||||
#region Window
|
#region Window
|
||||||
|
|
||||||
public RelayCommand InfoCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand InfoCmd => new(() => Growl.Info(Properties.Langs.Lang.GrowlInfo, _token));
|
||||||
new RelayCommand(() => Growl.Info(Properties.Langs.Lang.GrowlInfo, _token))).Value;
|
|
||||||
|
|
||||||
public RelayCommand SuccessCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand SuccessCmd => new(() => Growl.Success(Properties.Langs.Lang.GrowlSuccess, _token));
|
||||||
new RelayCommand(() => Growl.Success(Properties.Langs.Lang.GrowlSuccess, _token))).Value;
|
|
||||||
|
|
||||||
public RelayCommand WarningCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand WarningCmd => new(() => Growl.Warning(new GrowlInfo
|
||||||
new RelayCommand(() => Growl.Warning(new GrowlInfo
|
{
|
||||||
{
|
Message = Properties.Langs.Lang.GrowlWarning,
|
||||||
Message = Properties.Langs.Lang.GrowlWarning,
|
CancelStr = Properties.Langs.Lang.Ignore,
|
||||||
CancelStr = Properties.Langs.Lang.Ignore,
|
ActionBeforeClose = isConfirmed =>
|
||||||
ActionBeforeClose = isConfirmed =>
|
|
||||||
{
|
|
||||||
Growl.Info(isConfirmed.ToString());
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
Token = _token
|
|
||||||
}))).Value;
|
|
||||||
|
|
||||||
public RelayCommand ErrorCmd => new Lazy<RelayCommand>(() =>
|
|
||||||
new RelayCommand(() => Growl.Error(Properties.Langs.Lang.GrowlError, _token))).Value;
|
|
||||||
|
|
||||||
public RelayCommand AskCmd => new Lazy<RelayCommand>(() =>
|
|
||||||
new RelayCommand(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, isConfirmed =>
|
|
||||||
{
|
{
|
||||||
Growl.Info(isConfirmed.ToString());
|
Growl.Info(isConfirmed.ToString());
|
||||||
return true;
|
return true;
|
||||||
}, _token))).Value;
|
},
|
||||||
|
Token = _token
|
||||||
|
}));
|
||||||
|
|
||||||
public RelayCommand FatalCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand ErrorCmd => new(() => Growl.Error(Properties.Langs.Lang.GrowlError, _token));
|
||||||
new RelayCommand(() => Growl.Fatal(new GrowlInfo
|
|
||||||
{
|
|
||||||
Message = Properties.Langs.Lang.GrowlFatal,
|
|
||||||
ShowDateTime = false,
|
|
||||||
Token = _token
|
|
||||||
}))).Value;
|
|
||||||
|
|
||||||
public RelayCommand ClearCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand AskCmd => new(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, isConfirmed =>
|
||||||
new RelayCommand(() => Growl.Clear(_token))).Value;
|
{
|
||||||
|
Growl.Info(isConfirmed.ToString());
|
||||||
|
return true;
|
||||||
|
}, _token));
|
||||||
|
|
||||||
|
public RelayCommand FatalCmd => new(() => Growl.Fatal(new GrowlInfo
|
||||||
|
{
|
||||||
|
Message = Properties.Langs.Lang.GrowlFatal,
|
||||||
|
ShowDateTime = false,
|
||||||
|
Token = _token
|
||||||
|
}));
|
||||||
|
|
||||||
|
public RelayCommand ClearCmd => new(() => Growl.Clear(_token));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Desktop
|
#region Desktop
|
||||||
|
|
||||||
public RelayCommand InfoGlobalCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand InfoGlobalCmd => new(() => Growl.InfoGlobal(Properties.Langs.Lang.GrowlInfo));
|
||||||
new RelayCommand(() => Growl.InfoGlobal(Properties.Langs.Lang.GrowlInfo))).Value;
|
|
||||||
|
|
||||||
public RelayCommand SuccessGlobalCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand SuccessGlobalCmd => new(() => Growl.SuccessGlobal(Properties.Langs.Lang.GrowlSuccess));
|
||||||
new RelayCommand(() => Growl.SuccessGlobal(Properties.Langs.Lang.GrowlSuccess))).Value;
|
|
||||||
|
|
||||||
public RelayCommand WarningGlobalCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand WarningGlobalCmd => new(() => Growl.WarningGlobal(new GrowlInfo
|
||||||
new RelayCommand(() => Growl.WarningGlobal(new GrowlInfo
|
{
|
||||||
{
|
Message = Properties.Langs.Lang.GrowlWarning,
|
||||||
Message = Properties.Langs.Lang.GrowlWarning,
|
CancelStr = Properties.Langs.Lang.Ignore,
|
||||||
CancelStr = Properties.Langs.Lang.Ignore,
|
ActionBeforeClose = isConfirmed =>
|
||||||
ActionBeforeClose = isConfirmed =>
|
|
||||||
{
|
|
||||||
Growl.InfoGlobal(isConfirmed.ToString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}))).Value;
|
|
||||||
|
|
||||||
public RelayCommand ErrorGlobalCmd => new Lazy<RelayCommand>(() =>
|
|
||||||
new RelayCommand(() => Growl.ErrorGlobal(Properties.Langs.Lang.GrowlError))).Value;
|
|
||||||
|
|
||||||
public RelayCommand AskGlobalCmd => new Lazy<RelayCommand>(() =>
|
|
||||||
new RelayCommand(() => Growl.AskGlobal(Properties.Langs.Lang.GrowlAsk, isConfirmed =>
|
|
||||||
{
|
{
|
||||||
Growl.InfoGlobal(isConfirmed.ToString());
|
Growl.InfoGlobal(isConfirmed.ToString());
|
||||||
return true;
|
return true;
|
||||||
}))).Value;
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
public RelayCommand FatalGlobalCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand ErrorGlobalCmd => new(() => Growl.ErrorGlobal(Properties.Langs.Lang.GrowlError));
|
||||||
new RelayCommand(() => Growl.FatalGlobal(new GrowlInfo
|
|
||||||
{
|
|
||||||
Message = Properties.Langs.Lang.GrowlFatal,
|
|
||||||
ShowDateTime = false
|
|
||||||
}))).Value;
|
|
||||||
|
|
||||||
public RelayCommand ClearGlobalCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand AskGlobalCmd => new(() => Growl.AskGlobal(Properties.Langs.Lang.GrowlAsk, isConfirmed =>
|
||||||
new RelayCommand(Growl.ClearGlobal)).Value;
|
{
|
||||||
|
Growl.InfoGlobal(isConfirmed.ToString());
|
||||||
|
return true;
|
||||||
|
}));
|
||||||
|
|
||||||
|
public RelayCommand FatalGlobalCmd => new(() => Growl.FatalGlobal(new GrowlInfo
|
||||||
|
{
|
||||||
|
Message = Properties.Langs.Lang.GrowlFatal,
|
||||||
|
ShowDateTime = false
|
||||||
|
}));
|
||||||
|
|
||||||
|
public RelayCommand ClearGlobalCmd => new(Growl.ClearGlobal);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public RelayCommand NewWindowCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand NewWindowCmd => new(() => new GrowlDemoWindow
|
||||||
new RelayCommand(() => new GrowlDemoWindow
|
{
|
||||||
{
|
Owner = Application.Current.MainWindow
|
||||||
Owner = Application.Current.MainWindow
|
}.Show());
|
||||||
}.Show())).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class ImageBrowserDemoViewModel
|
public class ImageBrowserDemoViewModel
|
||||||
{
|
{
|
||||||
public RelayCommand OpenImgCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand OpenImgCmd => new(() =>
|
||||||
new RelayCommand(() =>
|
new ImageBrowser(new Uri("pack://application:,,,/Resources/Img/1.jpg")).Show());
|
||||||
new ImageBrowser(new Uri("pack://application:,,,/Resources/Img/1.jpg")).Show())).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
@@ -9,8 +8,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class NotificationDemoViewModel : ViewModelBase
|
public class NotificationDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public RelayCommand OpenCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand OpenCmd => new(() => Notification.Show(new AppNotification(), ShowAnimation, StaysOpen));
|
||||||
new RelayCommand(() => Notification.Show(new AppNotification(), ShowAnimation, StaysOpen))).Value;
|
|
||||||
|
|
||||||
private ShowAnimation _showAnimation;
|
private ShowAnimation _showAnimation;
|
||||||
|
|
||||||
|
|||||||
@@ -93,11 +93,9 @@ namespace HandyControlDemo.ViewModel
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand<object> MouseCmd => new Lazy<RelayCommand<object>>(() =>
|
public RelayCommand<object> MouseCmd => new(str => Growl.Info(str.ToString()));
|
||||||
new RelayCommand<object>(str => Growl.Info(str.ToString()))).Value;
|
|
||||||
|
|
||||||
public RelayCommand SendNotificationCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand SendNotificationCmd => new(SendNotification);
|
||||||
new RelayCommand(SendNotification)).Value;
|
|
||||||
|
|
||||||
private void SendNotification()
|
private void SendNotification()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
@@ -42,9 +41,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 页码改变命令
|
/// 页码改变命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand<FunctionEventArgs<int>> PageUpdatedCmd =>
|
public RelayCommand<FunctionEventArgs<int>> PageUpdatedCmd => new(PageUpdated);
|
||||||
new Lazy<RelayCommand<FunctionEventArgs<int>>>(() =>
|
|
||||||
new RelayCommand<FunctionEventArgs<int>>(PageUpdated)).Value;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 页码改变
|
/// 页码改变
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
|
|
||||||
@@ -7,8 +6,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class SearchBarDemoViewModel : ViewModelBase
|
public class SearchBarDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public RelayCommand<string> SearchCmd => new Lazy<RelayCommand<string>>(() =>
|
public RelayCommand<string> SearchCmd => new(Search);
|
||||||
new RelayCommand<string>(Search)).Value;
|
|
||||||
|
|
||||||
private void Search(string key)
|
private void Search(string key)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
@@ -8,13 +7,11 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class SideMenuDemoViewModel : ViewModelBase
|
public class SideMenuDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public RelayCommand<FunctionEventArgs<object>> SwitchItemCmd => new Lazy<RelayCommand<FunctionEventArgs<object>>>(() =>
|
public RelayCommand<FunctionEventArgs<object>> SwitchItemCmd => new(SwitchItem);
|
||||||
new RelayCommand<FunctionEventArgs<object>>(SwitchItem)).Value;
|
|
||||||
|
|
||||||
private void SwitchItem(FunctionEventArgs<object> info) => Growl.Info((info.Info as SideMenuItem)?.Header.ToString());
|
private void SwitchItem(FunctionEventArgs<object> info) => Growl.Info((info.Info as SideMenuItem)?.Header.ToString());
|
||||||
|
|
||||||
public RelayCommand<string> SelectCmd => new Lazy<RelayCommand<string>>(() =>
|
public RelayCommand<string> SelectCmd => new(Select);
|
||||||
new RelayCommand<string>(Select)).Value;
|
|
||||||
|
|
||||||
private void Select(string header) => Growl.Success(header);
|
private void Select(string header) => Growl.Success(header);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
|
|
||||||
@@ -7,7 +6,6 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class SplitButtonDemoViewModel : ViewModelBase
|
public class SplitButtonDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public RelayCommand<string> SelectCmd => new Lazy<RelayCommand<string>>(() =>
|
public RelayCommand<string> SelectCmd => new(str => Growl.Info(str));
|
||||||
new RelayCommand<string>(str => Growl.Info(str))).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using HandyControlDemo.UserControl;
|
using HandyControlDemo.UserControl;
|
||||||
|
|
||||||
@@ -7,7 +6,6 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class SpriteDemoViewModel
|
public class SpriteDemoViewModel
|
||||||
{
|
{
|
||||||
public RelayCommand OpenCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand OpenCmd => new(() => Sprite.Show(new AppSprite()));
|
||||||
new RelayCommand(() => Sprite.Show(new AppSprite()))).Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
@@ -27,12 +26,12 @@ namespace HandyControlDemo.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下一步
|
/// 下一步
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand<Panel> NextCmd => new Lazy<RelayCommand<Panel>>(() => new RelayCommand<Panel>(Next)).Value;
|
public RelayCommand<Panel> NextCmd => new(Next);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上一步
|
/// 上一步
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand<Panel> PrevCmd => new Lazy<RelayCommand<Panel>>(() => new RelayCommand<Panel>(Prev)).Value;
|
public RelayCommand<Panel> PrevCmd => new(Prev);
|
||||||
|
|
||||||
private void Next(Panel panel)
|
private void Next(Panel panel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Windows;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
@@ -12,16 +11,14 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public TabControlDemoViewModel(DataService dataService) => DataList = dataService.GetTabControlDemoDataList();
|
public TabControlDemoViewModel(DataService dataService) => DataList = dataService.GetTabControlDemoDataList();
|
||||||
|
|
||||||
public RelayCommand<CancelRoutedEventArgs> ClosingCmd => new Lazy<RelayCommand<CancelRoutedEventArgs>>(() =>
|
public RelayCommand<CancelRoutedEventArgs> ClosingCmd => new(Closing);
|
||||||
new RelayCommand<CancelRoutedEventArgs>(Closing)).Value;
|
|
||||||
|
|
||||||
private void Closing(CancelRoutedEventArgs args)
|
private void Closing(CancelRoutedEventArgs args)
|
||||||
{
|
{
|
||||||
Growl.Info($"{(args.OriginalSource as TabItem)?.Header} Closing");
|
Growl.Info($"{(args.OriginalSource as TabItem)?.Header} Closing");
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand<RoutedEventArgs> ClosedCmd => new Lazy<RelayCommand<RoutedEventArgs>>(() =>
|
public RelayCommand<RoutedEventArgs> ClosedCmd => new(Closed);
|
||||||
new RelayCommand<RoutedEventArgs>(Closed)).Value;
|
|
||||||
|
|
||||||
private void Closed(RoutedEventArgs args)
|
private void Closed(RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using GalaSoft.MvvmLight;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
@@ -30,21 +29,20 @@ namespace HandyControlDemo.ViewModel
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand AddItemCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand AddItemCmd => new(() =>
|
||||||
new RelayCommand(() =>
|
{
|
||||||
|
if (string.IsNullOrEmpty(TagName))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(TagName))
|
Growl.Warning(Lang.PlsEnterContent);
|
||||||
{
|
return;
|
||||||
Growl.Warning(Lang.PlsEnterContent);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataList.Insert(0, new DemoDataModel
|
DataList.Insert(0, new DemoDataModel
|
||||||
{
|
{
|
||||||
IsSelected = DataList.Count % 2 == 0,
|
IsSelected = DataList.Count % 2 == 0,
|
||||||
Name = TagName
|
Name = TagName
|
||||||
});
|
});
|
||||||
TagName = string.Empty;
|
TagName = string.Empty;
|
||||||
})).Value;
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Windows;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using HandyControlDemo.Tools;
|
using HandyControlDemo.Tools;
|
||||||
|
|
||||||
@@ -7,7 +6,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
{
|
{
|
||||||
public class WindowDemoViewModel
|
public class WindowDemoViewModel
|
||||||
{
|
{
|
||||||
public RelayCommand<string> OpenWindowCmd => new Lazy<RelayCommand<string>>(() => new RelayCommand<string>(OpenWindow)).Value;
|
public RelayCommand<string> OpenWindowCmd => new(OpenWindow);
|
||||||
|
|
||||||
private void OpenWindow(string windowTag)
|
private void OpenWindow(string windowTag)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,24 +89,18 @@ namespace HandyControlDemo.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 切换例子命令
|
/// 切换例子命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand<SelectionChangedEventArgs> SwitchDemoCmd =>
|
public RelayCommand<SelectionChangedEventArgs> SwitchDemoCmd => new(SwitchDemo);
|
||||||
new Lazy<RelayCommand<SelectionChangedEventArgs>>(() =>
|
|
||||||
new RelayCommand<SelectionChangedEventArgs>(SwitchDemo)).Value;
|
|
||||||
|
|
||||||
public RelayCommand OpenPracticalDemoCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand OpenPracticalDemoCmd => new(OpenPracticalDemo);
|
||||||
new RelayCommand(OpenPracticalDemo)).Value;
|
|
||||||
|
|
||||||
public RelayCommand GlobalShortcutInfoCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand GlobalShortcutInfoCmd => new(() => Growl.Info("Global Shortcut Info"));
|
||||||
new RelayCommand(() => Growl.Info("Global Shortcut Info"))).Value;
|
|
||||||
|
|
||||||
public RelayCommand GlobalShortcutWarningCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand GlobalShortcutWarningCmd => new(() => Growl.Warning("Global Shortcut Warning"));
|
||||||
new RelayCommand(() => Growl.Warning("Global Shortcut Warning"))).Value;
|
|
||||||
|
|
||||||
public RelayCommand OpenDocCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand OpenDocCmd => new(() =>
|
||||||
new RelayCommand(() =>
|
{
|
||||||
{
|
ControlCommands.OpenLink.Execute(_dataService.GetDemoUrl(DemoInfoCurrent, DemoItemCurrent));
|
||||||
ControlCommands.OpenLink.Execute(_dataService.GetDemoUrl(DemoInfoCurrent, DemoItemCurrent));
|
});
|
||||||
})).Value;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using GalaSoft.MvvmLight.Messaging;
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
using HandyControlDemo.Data;
|
using HandyControlDemo.Data;
|
||||||
@@ -14,8 +13,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
VersionInfo = VersionHelper.GetVersion();
|
VersionInfo = VersionHelper.GetVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand<string> OpenViewCmd => new Lazy<RelayCommand<string>>(() =>
|
public RelayCommand<string> OpenViewCmd => new(OpenView);
|
||||||
new RelayCommand<string>(OpenView)).Value;
|
|
||||||
|
|
||||||
private void OpenView(string viewName)
|
private void OpenView(string viewName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -214,7 +214,13 @@ namespace HandyControl.Themes
|
|||||||
|
|
||||||
private void UpdateSkin() => MergedDictionaries[0] = GetSkin(Skin);
|
private void UpdateSkin() => MergedDictionaries[0] = GetSkin(Skin);
|
||||||
|
|
||||||
public virtual ResourceDictionary GetTheme() => ResourceHelper.GetTheme();
|
private ResourceDictionary _theme;
|
||||||
|
|
||||||
|
public virtual ResourceDictionary GetTheme()
|
||||||
|
{
|
||||||
|
_theme ??= ResourceHelper.GetTheme();
|
||||||
|
return _theme;
|
||||||
|
}
|
||||||
|
|
||||||
private void InitResource()
|
private void InitResource()
|
||||||
{
|
{
|
||||||
@@ -231,6 +237,6 @@ namespace HandyControl.Themes
|
|||||||
|
|
||||||
public class StandaloneTheme : Theme
|
public class StandaloneTheme : Theme
|
||||||
{
|
{
|
||||||
public override ResourceDictionary GetTheme() => ResourceHelper.GetTheme(true);
|
public override ResourceDictionary GetTheme() => ResourceHelper.GetTheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,28 +79,12 @@ namespace HandyControl.Tools
|
|||||||
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
|
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
|
||||||
};
|
};
|
||||||
|
|
||||||
private static ResourceDictionary HcTheme;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// get HandyControl theme
|
/// get HandyControl theme
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
public static ResourceDictionary GetTheme() => new()
|
||||||
public static ResourceDictionary GetTheme(bool standalone = false)
|
|
||||||
{
|
{
|
||||||
if (!standalone)
|
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
||||||
{
|
};
|
||||||
HcTheme ??= new ResourceDictionary
|
|
||||||
{
|
|
||||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
|
||||||
};
|
|
||||||
|
|
||||||
return HcTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResourceDictionary
|
|
||||||
{
|
|
||||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user