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