From 16ef430a39e41ba321bc89a05a2a4117356bfeaf Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 10 Apr 2019 00:53:59 +0800 Subject: [PATCH] Adjust project structure --- .../ViewModel/Basic/ChatBoxViewModel.cs | 172 -- .../Basic/InteractiveDialogViewModel.cs | 30 - .../ViewModel/Controls/BadgeDemoViewModel.cs | 20 - .../ViewModel/Controls/DialogDemoViewModel.cs | 41 - .../ViewModel/Controls/GrowlDemoViewModel.cs | 66 - .../Controls/ImageBrowserDemoViewModel.cs | 13 - .../Controls/NotifyIconDemoViewModel.cs | 54 - .../Controls/PaginationDemoViewModel.cs | 53 - .../Controls/SearchBarDemoViewModel.cs | 18 - .../Controls/StepBarDemoViewModel.cs | 41 - .../ViewModel/Controls/WindowDemoViewModel.cs | 21 - .../ViewModel/DemoViewModelBase!1.cs | 22 - .../ViewModel/Main/ContributorsViewModel.cs | 17 - .../ViewModel/Main/MainViewModel.cs | 113 - .../ViewModel/ViewModelLocator.cs | 76 - .../Controls/Other/Growl.cs | 601 ---- .../Controls/Window/MessageBox.cs | 436 --- .../HandyControl_Core_30/HandyControl.xml | 2648 ----------------- .../HandyControlDemo_Net_40.csproj | 19 +- .../ViewModel/Basic/ChatBoxViewModel.cs | 172 -- .../Basic/InteractiveDialogViewModel.cs | 30 - .../ViewModel/Controls/BadgeDemoViewModel.cs | 20 - .../ViewModel/Controls/DialogDemoViewModel.cs | 40 - .../ViewModel/Controls/GrowlDemoViewModel.cs | 66 - .../Controls/ImageBrowserDemoViewModel.cs | 13 - .../Controls/NotifyIconDemoViewModel.cs | 54 - .../Controls/PaginationDemoViewModel.cs | 53 - .../Controls/SearchBarDemoViewModel.cs | 18 - .../Controls/StepBarDemoViewModel.cs | 41 - .../ViewModel/Controls/WindowDemoViewModel.cs | 21 - .../ViewModel/DemoViewModelBase!1.cs | 22 - .../ViewModel/Main/ContributorsViewModel.cs | 14 - .../ViewModel/Main/MainViewModel.cs | 113 - .../ViewModel/ViewModelLocator.cs | 76 - .../Controls/Other/Growl.cs | 601 ---- .../Controls/Window/MessageBox.cs | 390 --- .../HandyControl_Net_40.csproj | 4 - .../HandyControlDemo_Net_GE45.csproj | 15 - .../ViewModel/Basic/ChatBoxViewModel.cs | 172 -- .../Basic/InteractiveDialogViewModel.cs | 30 - .../ViewModel/Controls/BadgeDemoViewModel.cs | 20 - .../ViewModel/Controls/DialogDemoViewModel.cs | 41 - .../ViewModel/Controls/GrowlDemoViewModel.cs | 66 - .../Controls/ImageBrowserDemoViewModel.cs | 13 - .../Controls/NotifyIconDemoViewModel.cs | 54 - .../Controls/PaginationDemoViewModel.cs | 53 - .../Controls/SearchBarDemoViewModel.cs | 18 - .../Controls/StepBarDemoViewModel.cs | 41 - .../ViewModel/Controls/WindowDemoViewModel.cs | 21 - .../ViewModel/DemoViewModelBase!1.cs | 22 - .../ViewModel/Main/ContributorsViewModel.cs | 17 - .../ViewModel/Main/MainViewModel.cs | 113 - .../ViewModel/ViewModelLocator.cs | 76 - .../Controls/Other/Growl.cs | 601 ---- .../Controls/Window/MessageBox.cs | 436 --- .../HandyControl_Net_GE45.csproj | 4 - .../HandyControlDemo_Shared.projitems | 15 + .../UserControl/Main/NoUserContent.xaml | 98 - .../UserControl/Main/NoUserContent.xaml.cs | 84 - .../ViewModel/Basic/ChatBoxViewModel.cs | 8 + .../Basic/InteractiveDialogViewModel.cs | 16 +- .../ViewModel/Controls/BadgeDemoViewModel.cs | 8 + .../ViewModel/Controls/DialogDemoViewModel.cs | 22 +- .../ViewModel/Controls/GrowlDemoViewModel.cs | 4 + .../Controls/ImageBrowserDemoViewModel.cs | 4 + .../Controls/NotifyIconDemoViewModel.cs | 20 + .../Controls/PaginationDemoViewModel.cs | 8 + .../Controls/SearchBarDemoViewModel.cs | 4 + .../Controls/StepBarDemoViewModel.cs | 4 + .../ViewModel/Controls/WindowDemoViewModel.cs | 4 + .../ViewModel/DemoViewModelBase!1.cs | 4 + .../ViewModel/Main/ContributorsViewModel.cs | 7 + .../ViewModel/Main/MainViewModel.cs | 24 +- .../Controls/Other/Growl.cs | 32 + .../Controls/Window/MessageBox.cs | 92 + .../HandyControl_Shared.projitems | 2 + .../Themes/Styles/Base/ComboBoxBaseStyle.xaml | 1040 ------- .../Themes/Styles/DataGrid.xaml | 279 -- .../Themes/Styles/Growl.xaml | 60 - .../Themes/Styles/ListView.xaml | 178 -- .../Themes/Styles/MessageBox.xaml | 122 - .../Themes/Styles/Window.xaml | 223 -- 82 files changed, 271 insertions(+), 10113 deletions(-) delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/ChatBoxViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/InteractiveDialogViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/BadgeDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/DialogDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/GrowlDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/ImageBrowserDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/NotifyIconDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/PaginationDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/SearchBarDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/StepBarDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/WindowDemoViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/DemoViewModelBase!1.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/ContributorsViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/MainViewModel.cs delete mode 100644 src/Core_30/HandyControlDemo_Core_30/ViewModel/ViewModelLocator.cs delete mode 100644 src/Core_30/HandyControl_Core_30/Controls/Other/Growl.cs delete mode 100644 src/Core_30/HandyControl_Core_30/Controls/Window/MessageBox.cs delete mode 100644 src/Core_30/HandyControl_Core_30/HandyControl.xml delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/ChatBoxViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/InteractiveDialogViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/BadgeDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/DialogDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/GrowlDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/ImageBrowserDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/NotifyIconDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/PaginationDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/SearchBarDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/StepBarDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/WindowDemoViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/DemoViewModelBase!1.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/ContributorsViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/MainViewModel.cs delete mode 100644 src/Net_40/HandyControlDemo_Net_40/ViewModel/ViewModelLocator.cs delete mode 100644 src/Net_40/HandyControl_Net_40/Controls/Other/Growl.cs delete mode 100644 src/Net_40/HandyControl_Net_40/Controls/Window/MessageBox.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/ChatBoxViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/InteractiveDialogViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/BadgeDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/DialogDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/GrowlDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/ImageBrowserDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/NotifyIconDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/PaginationDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/SearchBarDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/StepBarDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/WindowDemoViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/DemoViewModelBase!1.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/ContributorsViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/MainViewModel.cs delete mode 100644 src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/ViewModelLocator.cs delete mode 100644 src/Net_GE45/HandyControl_Net_GE45/Controls/Other/Growl.cs delete mode 100644 src/Net_GE45/HandyControl_Net_GE45/Controls/Window/MessageBox.cs delete mode 100644 src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml delete mode 100644 src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs delete mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/Base/ComboBoxBaseStyle.xaml delete mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/DataGrid.xaml delete mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/Growl.xaml delete mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/ListView.xaml delete mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/MessageBox.xaml delete mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/Window.xaml diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/ChatBoxViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/ChatBoxViewModel.cs deleted file mode 100644 index aa959105..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/ChatBoxViewModel.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Media; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media.Imaging; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using GalaSoft.MvvmLight.Messaging; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControl.Tools; -using HandyControlDemo.Data; -using HandyControlDemo.Tools; -using Microsoft.Win32; - -namespace HandyControlDemo.ViewModel -{ - public class ChatBoxViewModel : ViewModelBase - { - private static readonly string AudioCachePath = $"{AppDomain.CurrentDomain.BaseDirectory}Cache"; - - private readonly string _id = Guid.NewGuid().ToString(); - - private readonly Stopwatch _stopwatch = new Lazy(() => new Stopwatch()).Value; - - public ChatBoxViewModel() - { - Messenger.Default.Register(this, MessageToken.SendChatMessage, ReceiveMessage); - } - - private void ReceiveMessage(ChatInfoModel info) - { - if (_id.Equals(info.SenderId)) return; - info.Role = ChatRoleType.Receiver; - ChatInfos.Add(info); - } - - private string _chatString; - - public string ChatString - { - get => _chatString; - set => Set(ref _chatString, value); - } - - public ObservableCollection ChatInfos { get; set; } = new ObservableCollection(); - - public RelayCommand SendStringCmd => new Lazy>(() => - new RelayCommand(SendString)).Value; - - private void SendString(KeyEventArgs e) - { - if (e.Key == Key.Enter) - { - if (string.IsNullOrEmpty(ChatString)) return; - var info = new ChatInfoModel - { - Message = ChatString, - SenderId = _id, - Type = ChatMessageType.String, - Role = ChatRoleType.Sender - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - ChatString = string.Empty; - } - } - - public RelayCommand ReadMessageCmd => new Lazy>(() => - new RelayCommand(ReadMessage)).Value; - - private void ReadMessage(RoutedEventArgs e) - { - if (e.OriginalSource is FrameworkElement element && element.Tag is ChatInfoModel info) - { - if (info.Type == ChatMessageType.Image) - { - new ImageBrowser(new Uri(info.Enclosure.ToString())) - { - Owner = VisualHelper.GetActiveWindow() - }.Show(); - } - else if (info.Type == ChatMessageType.Audio) - { - var player = new SoundPlayer(info.Enclosure.ToString()); - player.PlaySync(); - } - } - } - - public RelayCommand StartRecordCmd => new Lazy(() => - new RelayCommand(StartRecord)).Value; - - private void StartRecord() - { - ExternDllHelper.MciSendString("set wave bitpersample 8", "", 0, 0); - ExternDllHelper.MciSendString("set wave samplespersec 20000", "", 0, 0); - ExternDllHelper.MciSendString("set wave channels 2", "", 0, 0); - ExternDllHelper.MciSendString("set wave format tag pcm", "", 0, 0); - ExternDllHelper.MciSendString("open new type WAVEAudio alias movie", "", 0, 0); - ExternDllHelper.MciSendString("record movie", "", 0, 0); - - _stopwatch.Reset(); - _stopwatch.Start(); - } - - public RelayCommand StopRecordCmd => new Lazy(() => - new RelayCommand(StopRecord)).Value; - - private void StopRecord() - { - if (!Directory.Exists(AudioCachePath)) - { - try - { - Directory.CreateDirectory(AudioCachePath); - } - catch (Exception e) - { - Growl.Error(e.Message); - return; - } - } - - var cachePath = $"{AudioCachePath}\\{Guid.NewGuid().ToString()}"; - ExternDllHelper.MciSendString("stop movie", "", 0, 0); - ExternDllHelper.MciSendString($"save movie {cachePath}", "", 0, 0); - ExternDllHelper.MciSendString("close movie", "", 0, 0); - - _stopwatch.Stop(); - - var info = new ChatInfoModel - { - Message = $"{_stopwatch.Elapsed.Seconds.ToString()} {Properties.Langs.Lang.Second}", - SenderId = _id, - Type = ChatMessageType.Audio, - Role = ChatRoleType.Sender, - Enclosure = cachePath - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - } - - public RelayCommand OpenImageCmd => new Lazy(() => - new RelayCommand(OpenImage)).Value; - - private void OpenImage() - { - var dialog = new OpenFileDialog(); - if (dialog.ShowDialog() == true) - { - var fileName = dialog.FileName; - if (File.Exists(fileName)) - { - var info = new ChatInfoModel - { - Message = BitmapFrame.Create(new Uri(fileName)), - SenderId = _id, - Type = ChatMessageType.Image, - Role = ChatRoleType.Sender, - Enclosure = fileName - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - } - } - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/InteractiveDialogViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/InteractiveDialogViewModel.cs deleted file mode 100644 index 6566c970..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Basic/InteractiveDialogViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Tools.Extension; - -namespace HandyControlDemo.ViewModel.Basic -{ - public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable - { - public Action CloseAction { get; set; } - - private string _result; - - public string Result - { - get => _result; - set => Set(ref _result, value); - } - - private string _message; - - public string Message - { - get => _message; - set => Set(ref _message, value); - } - - public RelayCommand CloseCmd => new Lazy(() => new RelayCommand(() => CloseAction?.Invoke())).Value; - } -} diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/BadgeDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/BadgeDemoViewModel.cs deleted file mode 100644 index d12b1d55..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/BadgeDemoViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; - -namespace HandyControlDemo.ViewModel.Controls -{ - public class BadgeDemoViewModel : ViewModelBase - { - private int _count = 1; - - public int Count - { - get => _count; - set => Set(ref _count, value); - } - - public RelayCommand CountCmd => new Lazy(() => - new RelayCommand(() => Count++)).Value; - } -} diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/DialogDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/DialogDemoViewModel.cs deleted file mode 100644 index 02048357..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/DialogDemoViewModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Threading.Tasks; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControl.Tools.Extension; -using HandyControlDemo.UserControl; -using HandyControlDemo.UserControl.Basic; -using HandyControlDemo.ViewModel.Basic; - -namespace HandyControlDemo.ViewModel -{ - public class DialogDemoViewModel : ViewModelBase - { - private string _dialogResult; - - public string DialogResult - { - get => _dialogResult; - set => Set(ref _dialogResult, value); - } - - public RelayCommand ShowTextCmd => new Lazy(() => - new RelayCommand(ShowText)).Value; - - private void ShowText() - { - Dialog.Show(new TextDialog()); - } - - public RelayCommand ShowInteractiveDialogCmd => new Lazy(() => - new RelayCommand(async () => await ShowInteractiveDialog())).Value; - - private async Task ShowInteractiveDialog() - { - DialogResult = await Dialog.Show() - .Initialize(vm => vm.Message = DialogResult) - .GetResultAsync(); - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/GrowlDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/GrowlDemoViewModel.cs deleted file mode 100644 index 567367a5..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/GrowlDemoViewModel.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControlDemo.Window; - -namespace HandyControlDemo.ViewModel -{ - public class GrowlDemoViewModel - { - private readonly string _token; - - public GrowlDemoViewModel() - { - - } - - public GrowlDemoViewModel(string token) - { - _token = token; - } - - public RelayCommand InfoCmd => new Lazy(() => - new RelayCommand(() => Growl.Info(Properties.Langs.Lang.GrowlInfo, _token))).Value; - - public RelayCommand SuccessCmd => new Lazy(() => - new RelayCommand(() => Growl.Success(Properties.Langs.Lang.GrowlSuccess, _token))).Value; - - public RelayCommand WarningCmd => new Lazy(() => - 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(() => - new RelayCommand(() => Growl.Error(Properties.Langs.Lang.GrowlError, _token))).Value; - - public RelayCommand AskCmd => new Lazy(() => - new RelayCommand(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, isConfirmed => - { - Growl.Info(isConfirmed.ToString()); - return true; - }, _token))).Value; - - public RelayCommand FatalCmd => new Lazy(() => - new RelayCommand(() => Growl.Fatal(new GrowlInfo - { - Message = Properties.Langs.Lang.GrowlFatal, - ShowDateTime = false, - Token = _token - }))).Value; - - public RelayCommand ClearCmd => new Lazy(() => - new RelayCommand(() => Growl.Clear(_token))).Value; - - public RelayCommand NewWindowCmd => new Lazy(() => - new RelayCommand(() => new GrowlDemoWindow().Show())).Value; - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/ImageBrowserDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/ImageBrowserDemoViewModel.cs deleted file mode 100644 index 2324a4e7..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/ImageBrowserDemoViewModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using GalaSoft.MvvmLight.CommandWpf; -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/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/NotifyIconDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/NotifyIconDemoViewModel.cs deleted file mode 100644 index 77456549..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/NotifyIconDemoViewModel.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControlDemo.Data; - -namespace HandyControlDemo.ViewModel -{ - public class NotifyIconDemoViewModel : ViewModelBase - { - private bool _contextMenuIsShow; - - public bool ContextMenuIsShow - { - get => _contextMenuIsShow; - set - { - Set(ref _contextMenuIsShow, value); - GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; - } - } - - private bool _contextMenuIsBlink; - - public bool ContextMenuIsBlink - { - get => _contextMenuIsBlink; - set => Set(ref _contextMenuIsBlink, value); - } - - private bool _contextContentIsShow; - - public bool ContextContentIsShow - { - get => _contextContentIsShow; - set - { - Set(ref _contextContentIsShow, value); - GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; - } - } - - private bool _contextContentIsBlink; - - public bool ContextContentIsBlink - { - get => _contextContentIsBlink; - set => Set(ref _contextContentIsBlink, value); - } - - public RelayCommand MouseCmd => new Lazy>(() => - new RelayCommand(str=> Growl.Info(str.ToString()))).Value; - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/PaginationDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/PaginationDemoViewModel.cs deleted file mode 100644 index 26420e20..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/PaginationDemoViewModel.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Data; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class PaginationDemoViewModel : DemoViewModelBase - { - /// - /// 所有数据 - /// - private readonly List _totalDataList; - - /// - /// 页码 - /// - private int _pageIndex = 1; - - /// - /// 页码 - /// - public int PageIndex - { - get => _pageIndex; - set => Set(ref _pageIndex, value); - } - - public PaginationDemoViewModel(DataService dataService) - { - _totalDataList = dataService.GetDemoDataList(100); - DataList = _totalDataList.Take(10).ToList(); - } - - /// - /// 页码改变命令 - /// - public RelayCommand> PageUpdatedCmd => - new Lazy>>(() => - new RelayCommand>(PageUpdated)).Value; - - /// - /// 页码改变 - /// - private void PageUpdated(FunctionEventArgs info) - { - DataList = _totalDataList.Skip((info.Info - 1) * 10).Take(10).ToList(); - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/SearchBarDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/SearchBarDemoViewModel.cs deleted file mode 100644 index d854c035..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/SearchBarDemoViewModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; - -namespace HandyControlDemo.ViewModel -{ - public class SearchBarDemoViewModel : ViewModelBase - { - public RelayCommand SearchCmd => new Lazy>(() => - new RelayCommand(Search)).Value; - - private void Search(string key) - { - Growl.Info(key); - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/StepBarDemoViewModel.cs deleted file mode 100644 index d2bba196..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/StepBarDemoViewModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Linq; -using System.Windows.Controls; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class StepBarDemoViewModel : DemoViewModelBase - { - public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList(); - - /// - /// 下一步 - /// - public RelayCommand NextCmd => new Lazy>(() => new RelayCommand(Next)).Value; - - /// - /// 上一步 - /// - public RelayCommand PrevCmd => new Lazy>(() => new RelayCommand(Prev)).Value; - - private void Next(Panel panel) - { - foreach (var stepBar in panel.Children.OfType()) - { - stepBar.Next(); - } - } - - private void Prev(Panel panel) - { - foreach (var stepBar in panel.Children.OfType()) - { - stepBar.Prev(); - } - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/WindowDemoViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/WindowDemoViewModel.cs deleted file mode 100644 index 9e694c94..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Controls/WindowDemoViewModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Windows; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControlDemo.Tools; - -namespace HandyControlDemo.ViewModel -{ - public class WindowDemoViewModel - { - public RelayCommand OpenWindowCmd => new Lazy>(() => new RelayCommand(OpenWindow)).Value; - - private void OpenWindow(string windowTag) - { - if (AssemblyHelper.CreateInternalInstance($"Window.{windowTag}") is System.Windows.Window window) - { - window.Owner = Application.Current.MainWindow; - window.ShowDialog(); - } - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/DemoViewModelBase!1.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/DemoViewModelBase!1.cs deleted file mode 100644 index 7714d2db..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/DemoViewModelBase!1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using GalaSoft.MvvmLight; - -namespace HandyControlDemo.ViewModel -{ - public class DemoViewModelBase : ViewModelBase - { - /// - /// 数据列表 - /// - private IList _dataList; - - /// - /// 数据列表 - /// - public IList DataList - { - get => _dataList; - set => Set(ref _dataList, value); - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/ContributorsViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/ContributorsViewModel.cs deleted file mode 100644 index 5045e447..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/ContributorsViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Threading.Tasks; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class ContributorsViewModel : DemoViewModelBase - { - public ContributorsViewModel(DataService dataService) - { - Task.Run(() => - { - DataList = dataService.GetContributorDataList(); - }); - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/MainViewModel.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/MainViewModel.cs deleted file mode 100644 index b580666f..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/Main/MainViewModel.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Windows.Controls; -using GalaSoft.MvvmLight.CommandWpf; -using GalaSoft.MvvmLight.Messaging; -using HandyControlDemo.Data; -using HandyControlDemo.Service; -using HandyControlDemo.Tools; - -namespace HandyControlDemo.ViewModel -{ - public class MainViewModel : DemoViewModelBase - { - #region 字段 - - /// - /// 内容标题 - /// - private object _contentTitle; - - /// - /// 子内容 - /// - private object _subContent; - - /// - /// 当前选中的列表项 - /// - private ListBoxItem _listBoxItemCurrent; - - #endregion - - public MainViewModel(DataService dataService) - { - Messenger.Default.Register(this, MessageToken.LoadShowContent, obj => - { - if (SubContent is IDisposable disposable) - { - disposable.Dispose(); - } - SubContent = obj; - }); - Messenger.Default.Register(this, MessageToken.ClearLeftSelected, obj => - { - if (_listBoxItemCurrent == null) return; - _listBoxItemCurrent.IsSelected = false; - _listBoxItemCurrent = null; - }); - DataList = dataService.GetDemoDataList(); - } - - #region 属性 - - /// - /// 子内容 - /// - 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(SelectionChangedEventArgs e) - { - if (e.AddedItems.Count == 0) return; - if (e.AddedItems[0] is ListBoxItem item) - { - if (item.Tag is string tag) - { - if (Equals(_listBoxItemCurrent, item)) return; - _listBoxItemCurrent = item; - ContentTitle = item.Content; - Messenger.Default.Send(false, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{tag}"), MessageToken.LoadShowContent); - } - else - { - _listBoxItemCurrent = null; - ContentTitle = null; - SubContent = null; - } - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControlDemo_Core_30/ViewModel/ViewModelLocator.cs b/src/Core_30/HandyControlDemo_Core_30/ViewModel/ViewModelLocator.cs deleted file mode 100644 index e7f59c12..00000000 --- a/src/Core_30/HandyControlDemo_Core_30/ViewModel/ViewModelLocator.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Windows; -using CommonServiceLocator; -using GalaSoft.MvvmLight.Ioc; -using HandyControlDemo.Data; -using HandyControlDemo.Service; -using HandyControlDemo.ViewModel.Basic; -using HandyControlDemo.ViewModel.Controls; - -namespace HandyControlDemo.ViewModel -{ - public class ViewModelLocator - { - public ViewModelLocator() - { - ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - - SimpleIoc.Default.Register(); - - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(() => new GrowlDemoViewModel(), "GrowlDemo"); - SimpleIoc.Default.Register(() => new GrowlDemoViewModel(MessageToken.GrowlDemoPanel), "GrowlDemoWithToken"); - 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 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("GrowlDemo"); - - public GrowlDemoViewModel GrowlDemoWithToken => ServiceLocator.Current.GetInstance("GrowlDemoWithToken"); - - public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance(); - - public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance(); - - public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance(); - - public ContributorsViewModel ContributorsView => ServiceLocator.Current.GetInstance(); - - public StepBarDemoViewModel StepBarDemo => ServiceLocator.Current.GetInstance(); - - public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance(); - - public ChatBoxViewModel ChatBox => new ChatBoxViewModel(); - - public CoverViewModel CoverView => ServiceLocator.Current.GetInstance(); - - public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance(); - - public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance(); - - public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance(); - - public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance(); - - public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance(); - #endregion - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControl_Core_30/Controls/Other/Growl.cs b/src/Core_30/HandyControl_Core_30/Controls/Other/Growl.cs deleted file mode 100644 index 31b3c932..00000000 --- a/src/Core_30/HandyControl_Core_30/Controls/Other/Growl.cs +++ /dev/null @@ -1,601 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Threading; -using HandyControl.Data; -using HandyControl.Interactivity; -using HandyControl.Tools; -using HandyControl.Tools.Extension; - -namespace HandyControl.Controls -{ - /// - /// 消息提醒 - /// - [TemplatePart(Name = ElementPanelMore, Type = typeof(Panel))] - [TemplatePart(Name = ElementGridMain, Type = typeof(Grid))] - [TemplatePart(Name = ElementButtonClose, Type = typeof(Button))] - public class Growl : Control - { - #region Constants - - private const string ElementPanelMore = "PART_PanelMore"; - private const string ElementGridMain = "PART_GridMain"; - private const string ElementButtonClose = "PART_ButtonClose"; - - #endregion Constants - - #region Data - - private Panel _panelMore; - - private Grid _gridMain; - - private Button _buttonClose; - - private bool _showCloseButton; - - private bool _staysOpen; - - private int _waitTime = 6; - - /// - /// 计数 - /// - private int _tickCount; - - /// - /// 关闭计时器 - /// - private DispatcherTimer _timerClose; - - private static readonly Dictionary PanelDic = new Dictionary(); - - #endregion Data - - public Growl() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick)); - CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancel_OnClick)); - CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick)); - } - - public static void Register(string token, Panel panel) - { - if (string.IsNullOrEmpty(token) || panel == null) return; - PanelDic[token] = panel; - InitGrowlPanel(panel); - } - - public static void Unregister(string token, Panel panel) - { - if (string.IsNullOrEmpty(token) || panel == null) return; - - if (PanelDic.ContainsKey(token)) - { - if (ReferenceEquals(PanelDic[token], panel)) - { - PanelDic.Remove(token); - panel.ContextMenu = null; - panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue); - } - } - } - - public static void Unregister(Panel panel) - { - if (panel == null) return; - var first = PanelDic.FirstOrDefault(item => ReferenceEquals(panel, item.Value)); - if (!string.IsNullOrEmpty(first.Key)) - { - PanelDic.Remove(first.Key); - panel.ContextMenu = null; - panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue); - } - } - - protected override void OnMouseEnter(MouseEventArgs e) - { - base.OnMouseEnter(e); - - _buttonClose.Show(_showCloseButton); - } - - protected override void OnMouseLeave(MouseEventArgs e) - { - base.OnMouseLeave(e); - - _buttonClose.Collapse(); - } - - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - _panelMore = GetTemplateChild(ElementPanelMore) as Panel; - _gridMain = GetTemplateChild(ElementGridMain) as Grid; - _buttonClose = GetTemplateChild(ElementButtonClose) as Button; - - CheckNull(); - Update(); - } - - private void CheckNull() - { - if (_panelMore == null || _gridMain == null || _buttonClose == null) throw new Exception(); - } - - private Func ActionBeforeClose { get; set; } - - /// - /// 消息容器 - /// - public static Panel GrowlPanel { get; set; } - - internal static readonly DependencyProperty CancelStrProperty = DependencyProperty.Register( - "CancelStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); - - internal static readonly DependencyProperty ConfirmStrProperty = DependencyProperty.Register( - "ConfirmStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); - - public static readonly DependencyProperty ShowDateTimeProperty = DependencyProperty.Register( - "ShowDateTime", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.TrueBox)); - - 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))); - - public static readonly DependencyProperty TypeProperty = DependencyProperty.Register( - "Type", typeof(InfoType), typeof(Growl), new PropertyMetadata(default(InfoType))); - - public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached( - "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) => - { - if ((bool)args.NewValue && o is Panel panel) - { - SetGrowlPanel(panel); - } - })); - - public static readonly DependencyProperty TokenProperty = DependencyProperty.RegisterAttached( - "Token", typeof(string), typeof(Growl), new PropertyMetadata(default(string), OnTokenChanged)); - - private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is Panel panel) - { - if (e.NewValue == null) - { - Unregister(panel); - } - else - { - Register(e.NewValue.ToString(), panel); - } - } - } - - public static void SetToken(DependencyObject element, string value) - => element.SetValue(TokenProperty, value); - - public static string GetToken(DependencyObject element) - => (string) element.GetValue(TokenProperty); - - public static void SetGrowlParent(DependencyObject element, bool value) => element.SetValue(GrowlParentProperty, value); - - public static bool GetGrowlParent(DependencyObject element) => (bool)element.GetValue(GrowlParentProperty); - - public InfoType Type - { - get => (InfoType)GetValue(TypeProperty); - set => SetValue(TypeProperty, value); - } - - internal string CancelStr - { - get => (string)GetValue(CancelStrProperty); - set => SetValue(CancelStrProperty, value); - } - - internal string ConfirmStr - { - get => (string)GetValue(ConfirmStrProperty); - set => SetValue(ConfirmStrProperty, value); - } - - public bool ShowDateTime - { - get => (bool)GetValue(ShowDateTimeProperty); - set => SetValue(ShowDateTimeProperty, value); - } - - 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 >= _waitTime) Close(); - }; - _timerClose.Start(); - } - - /// - /// 消息容器 - /// - /// - private static void SetGrowlPanel(Panel panel) - { - GrowlPanel = panel; - InitGrowlPanel(panel); - } - - private static void InitGrowlPanel(Panel panel) - { - var menuItem = new MenuItem - { - Header = Properties.Langs.Lang.Clear - }; - menuItem.Click += (s, e) => - { - foreach (var item in panel.Children.OfType()) - { - item.Close(); - } - }; - panel.ContextMenu = new ContextMenu - { - Items = - { - menuItem - } - }; - - PanelElement.SetFluidMoveBehavior(panel, ResourceHelper.GetResource(ResourceToken.BehaviorXY400)); - } - - private void Update() - { - if (ActionBeforeClose != null) - { - _staysOpen = true; - _showCloseButton = false; - _panelMore.IsEnabled = true; - _panelMore.Show(); - } - - var transform = new TranslateTransform - { - X = MaxWidth - }; - _gridMain.RenderTransform = transform; - transform.BeginAnimation(TranslateTransform.XProperty, AnimationHelper.CreateAnimation(0)); - if (!_staysOpen) StartTimer(); - } - - /// - /// 显示信息 - /// - /// - private static void Show(GrowlInfo growlInfo) - { - Application.Current.Dispatcher.Invoke(() => - { - var ctl = new Growl - { - Message = growlInfo.Message, - Time = DateTime.Now, - Icon = ResourceHelper.GetResource(growlInfo.IconKey), - IconBrush = ResourceHelper.GetResource(growlInfo.IconBrushKey), - _showCloseButton = growlInfo.ShowCloseButton, - ActionBeforeClose = growlInfo.ActionBeforeClose, - _staysOpen = growlInfo.StaysOpen, - ShowDateTime = growlInfo.ShowDateTime, - ConfirmStr = growlInfo.ConfirmStr, - CancelStr = growlInfo.CancelStr, - Type = growlInfo.Type, - _waitTime = Math.Max(growlInfo.WaitTime, 2) - }; - if (!string.IsNullOrEmpty(growlInfo.Token)) - { - if (PanelDic.TryGetValue(growlInfo.Token, out var panel)) - { - panel?.Children.Insert(0, ctl); - } - } - else - { - GrowlPanel.Children.Insert(0, ctl); - } - }); - } - - /// - /// 成功 - /// - /// - /// - public static void Success(string message, string token = "") => Success(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 成功 - /// - /// - public static void Success(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.SuccessGeometry; - growlInfo.IconBrushKey = ResourceToken.SuccessBrush; - growlInfo.Type = InfoType.Success; - } - Show(growlInfo); - } - - /// - /// 消息 - /// - /// - /// - public static void Info(string message, string token = "") => Info(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 消息 - /// - /// - public static void Info(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.InfoGeometry; - growlInfo.IconBrushKey = ResourceToken.InfoBrush; - growlInfo.Type = InfoType.Info; - } - Show(growlInfo); - } - - /// - /// 警告 - /// - /// - /// - public static void Warning(string message, string token = "") => Warning(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 警告 - /// - /// - public static void Warning(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.WarningGeometry; - growlInfo.IconBrushKey = ResourceToken.WarningBrush; - growlInfo.Type = InfoType.Warning; - } - Show(growlInfo); - } - - /// - /// 错误 - /// - /// - /// - public static void Error(string message, string token = "") => Error(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 错误 - /// - /// - public static void Error(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.ErrorGeometry; - growlInfo.IconBrushKey = ResourceToken.DangerBrush; - growlInfo.StaysOpen = true; - growlInfo.Type = InfoType.Error; - } - Show(growlInfo); - } - - /// - /// 严重 - /// - /// - /// - public static void Fatal(string message, string token = "") => Fatal(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 严重 - /// - /// - public static void Fatal(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.FatalGeometry; - growlInfo.IconBrushKey = ResourceToken.PrimaryTextBrush; - growlInfo.StaysOpen = true; - growlInfo.ShowCloseButton = false; - growlInfo.Type = InfoType.Fatal; - if (GrowlPanel.ContextMenu != null) GrowlPanel.ContextMenu.Opacity = 0; - } - Show(growlInfo); - } - - /// - /// 询问 - /// - /// - /// - /// - public static void Ask(string message, Func actionBeforeClose, string token = "") => Ask(new GrowlInfo - { - Message = message, - ActionBeforeClose = actionBeforeClose, - Token = token - }); - - /// - /// 询问 - /// - /// - public static void Ask(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.AskGeometry; - growlInfo.IconBrushKey = ResourceToken.AccentBrush; - growlInfo.StaysOpen = true; - growlInfo.ShowCloseButton = false; - growlInfo.Type = InfoType.Ask; - } - Show(growlInfo); - } - - 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 += (s, e) => - { - if (Parent is Panel panel) - { - panel.Children.Remove(this); - } - }; - transform.BeginAnimation(TranslateTransform.XProperty, animation); - } - - /// - /// 清除 - /// - /// - public static void Clear(string token = "") - { - if (!string.IsNullOrEmpty(token)) - { - if (PanelDic.TryGetValue(token, out var panel)) - { - Clear(panel); - } - } - else - { - Clear(GrowlPanel); - } - } - - /// - /// 清除 - /// - /// - private static void Clear(Panel panel) - { - panel.Children.Clear(); - if (panel.ContextMenu != null) - { - panel.ContextMenu.IsOpen = false; - panel.ContextMenu.Opacity = 1; - } - } - - private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) - { - if (ActionBeforeClose?.Invoke(false) == true) - { - Close(); - } - } - - private void ButtonOk_OnClick(object sender, RoutedEventArgs e) - { - if (ActionBeforeClose?.Invoke(true) == true) - { - Close(); - } - } - } -} \ No newline at end of file diff --git a/src/Core_30/HandyControl_Core_30/Controls/Window/MessageBox.cs b/src/Core_30/HandyControl_Core_30/Controls/Window/MessageBox.cs deleted file mode 100644 index 67342fd7..00000000 --- a/src/Core_30/HandyControl_Core_30/Controls/Window/MessageBox.cs +++ /dev/null @@ -1,436 +0,0 @@ -using System; -using System.ComponentModel; -using System.Text; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media; -using HandyControl.Data; -using HandyControl.Interactivity; -using HandyControl.Tools; - -namespace HandyControl.Controls -{ - /// - /// 消息框 - /// - public sealed class MessageBox : Window - { - private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel; - - private bool _showOk; - - private bool _showCancel; - - private bool _showYes; - - private bool _showNo; - - public static readonly DependencyProperty MessageProperty = DependencyProperty.Register( - "Message", typeof(string), typeof(MessageBox), new PropertyMetadata(default(string))); - - public string Message - { - get => (string) GetValue(MessageProperty); - set => SetValue(MessageProperty, value); - } - - public static readonly DependencyProperty ImageProperty = DependencyProperty.Register( - "Image", typeof(Geometry), typeof(MessageBox), new PropertyMetadata(default(Geometry))); - - public Geometry Image - { - get => (Geometry) GetValue(ImageProperty); - set => SetValue(ImageProperty, value); - } - - public static readonly DependencyProperty ImageBrushProperty = DependencyProperty.Register( - "ImageBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(default(Brush))); - - public Brush ImageBrush - { - get => (Brush) GetValue(ImageBrushProperty); - set => SetValue(ImageBrushProperty, value); - } - - public static readonly DependencyProperty ShowImageProperty = DependencyProperty.Register( - "ShowImage", typeof(bool), typeof(MessageBox), new PropertyMetadata(ValueBoxes.FalseBox)); - - public bool ShowImage - { - get => (bool) GetValue(ShowImageProperty); - set => SetValue(ShowImageProperty, value); - } - - private MessageBox() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, (s, e) => - { - _messageBoxResult = MessageBoxResult.OK; - Close(); - }, (s, e) => e.CanExecute = _showOk)); - CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, (s, e) => - { - _messageBoxResult = MessageBoxResult.Cancel; - Close(); - }, (s, e) => e.CanExecute = _showCancel)); - CommandBindings.Add(new CommandBinding(ControlCommands.Yes, (s, e) => - { - _messageBoxResult = MessageBoxResult.Yes; - Close(); - }, (s, e) => e.CanExecute = _showYes)); - CommandBindings.Add(new CommandBinding(ControlCommands.No, (s, e) => - { - _messageBoxResult = MessageBoxResult.No; - Close(); - }, (s, e) => e.CanExecute = _showNo)); - } - - protected override void OnPreviewKeyDown(KeyEventArgs e) - { - base.OnPreviewKeyDown(e); - - if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.C) - { - var builder = new StringBuilder(); - var line = new string('-', 27); - builder.Append(line); - builder.Append(Environment.NewLine); - builder.Append(Title); - builder.Append(Environment.NewLine); - builder.Append(line); - builder.Append(Environment.NewLine); - builder.Append(Message); - builder.Append(Environment.NewLine); - builder.Append(line); - builder.Append(Environment.NewLine); - if (_showOk) - { - builder.Append(Properties.Langs.Lang.Confirm); - builder.Append(" "); - } - if (_showYes) - { - builder.Append(Properties.Langs.Lang.Yes); - builder.Append(" "); - } - if (_showNo) - { - builder.Append(Properties.Langs.Lang.No); - builder.Append(" "); - } - if (_showCancel) - { - builder.Append(Properties.Langs.Lang.Cancel); - builder.Append(" "); - } - builder.Append(Environment.NewLine); - builder.Append(line); - builder.Append(Environment.NewLine); - Clipboard.SetText(builder.ToString()); - } - } - - /// - /// 成功 - /// - /// - /// - public static MessageBoxResult Success(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(ResourceToken.SuccessGeometry); - messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.SuccessBrush); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 消息 - /// - /// - /// - public static MessageBoxResult Info(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Information); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 警告 - /// - /// - /// - public static MessageBoxResult Warning(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Warning); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 错误 - /// - /// - /// - public static MessageBoxResult Error(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Error); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 严重 - /// - /// - /// - public static MessageBoxResult Fatal(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(ResourceToken.FatalGeometry); - messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.PrimaryTextBrush); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 询问 - /// - /// - /// - public static MessageBoxResult Ask(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); - SetButtonStatus(messageBox, MessageBoxButton.OKCancel); - SetImage(messageBox, MessageBoxImage.Question); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 自定义信息展示 - /// - /// - /// - public static MessageBoxResult Show(MessageBoxInfo info) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, info.MessageBoxText, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult); - SetButtonStatus(messageBox, info.Button); - - if (!string.IsNullOrEmpty(info.IconKey)) - { - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(info.IconKey); - messageBox.ImageBrush = ResourceHelper.GetResource(info.IconBrushKey); - } - - messageBox.Style = info.Style; - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 信息展示 - /// - /// - /// - /// - /// - /// - /// - public static MessageBoxResult Show(string messageBoxText, string caption = null, - MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, - MessageBoxResult defaultResult = MessageBoxResult.None) => - Show(null, messageBoxText, caption, button, icon, defaultResult); - - /// - /// 信息展示 - /// - /// - /// - /// - /// - /// - /// - /// - public static MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption = null, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult); - SetButtonStatus(messageBox, button); - SetImage(messageBox, icon); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - private static MessageBox CreateMessageBox( - System.Windows.Window owner, - string messageBoxText, - string caption, - MessageBoxButton button, - MessageBoxImage icon, - MessageBoxResult defaultResult) - { - if (!IsValidMessageBoxButton(button)) - { - throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(MessageBoxButton)); - } - if (!IsValidMessageBoxImage(icon)) - { - throw new InvalidEnumArgumentException(nameof(icon), (int)icon, typeof(MessageBoxImage)); - } - if (!IsValidMessageBoxResult(defaultResult)) - { - throw new InvalidEnumArgumentException(nameof(defaultResult), (int)defaultResult, typeof(MessageBoxResult)); - } - - var ownerWindow = owner ?? VisualHelper.GetActiveWindow(); - var ownerIsNull = ownerWindow is null; - - return new MessageBox - { - Message = messageBoxText, - Owner = ownerWindow, - WindowStartupLocation = WindowStartupLocation.CenterScreen, - ShowTitle = true, - Title = caption ?? string.Empty, - Topmost = ownerIsNull, - _messageBoxResult = defaultResult - }; - } - - private static void SetButtonStatus(MessageBox messageBox, MessageBoxButton messageBoxButton) - { - switch (messageBoxButton) - { - case MessageBoxButton.OK: - messageBox._showOk = true; - break; - case MessageBoxButton.OKCancel: - messageBox._showOk = true; - messageBox._showCancel = true; - break; - case MessageBoxButton.YesNo: - messageBox._showYes = true; - messageBox._showNo = true; - break; - case MessageBoxButton.YesNoCancel: - messageBox._showYes = true; - messageBox._showNo = true; - messageBox._showCancel = true; - break; - } - } - - private static void SetImage(MessageBox messageBox, MessageBoxImage messageBoxImage) - { - var iconKey = string.Empty; - var iconBrushKey = string.Empty; - - switch (messageBoxImage) - { - case MessageBoxImage.Error: - iconKey = ResourceToken.ErrorGeometry; - iconBrushKey = ResourceToken.DangerBrush; - break; - case MessageBoxImage.Question: - iconKey = ResourceToken.AskGeometry; - iconBrushKey = ResourceToken.AccentBrush; - break; - case MessageBoxImage.Warning: - iconKey = ResourceToken.WarningGeometry; - iconBrushKey = ResourceToken.WarningBrush; - break; - case MessageBoxImage.Information: - iconKey = ResourceToken.InfoGeometry; - iconBrushKey = ResourceToken.InfoBrush; - break; - } - - if (string.IsNullOrEmpty(iconKey)) return; - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(iconKey); - messageBox.ImageBrush = ResourceHelper.GetResource(iconBrushKey); - } - - private static bool IsValidMessageBoxButton(MessageBoxButton value) - { - return value == MessageBoxButton.OK - || value == MessageBoxButton.OKCancel - || value == MessageBoxButton.YesNo - || value == MessageBoxButton.YesNoCancel; - } - - private static bool IsValidMessageBoxImage(MessageBoxImage value) - { - return value == MessageBoxImage.Asterisk - || value == MessageBoxImage.Error - || value == MessageBoxImage.Exclamation - || value == MessageBoxImage.Hand - || value == MessageBoxImage.Information - || value == MessageBoxImage.None - || value == MessageBoxImage.Question - || value == MessageBoxImage.Stop - || value == MessageBoxImage.Warning; - } - - private static bool IsValidMessageBoxResult(MessageBoxResult value) - { - return value == MessageBoxResult.Cancel - || value == MessageBoxResult.No - || value == MessageBoxResult.None - || value == MessageBoxResult.OK - || value == MessageBoxResult.Yes; - } - } -} diff --git a/src/Core_30/HandyControl_Core_30/HandyControl.xml b/src/Core_30/HandyControl_Core_30/HandyControl.xml deleted file mode 100644 index 18a30d36..00000000 --- a/src/Core_30/HandyControl_Core_30/HandyControl.xml +++ /dev/null @@ -1,2648 +0,0 @@ - - - - HandyControl - - - - - 消息提醒 - - - - - 计数 - - - - - 关闭计时器 - - - - - 消息容器 - - - - - 开始计时器 - - - - - 消息容器 - - - - - - 显示信息 - - - - - - 成功 - - - - - - - 成功 - - - - - - 消息 - - - - - - - 消息 - - - - - - 警告 - - - - - - - 警告 - - - - - - 错误 - - - - - - - 错误 - - - - - - 严重 - - - - - - - 严重 - - - - - - 询问 - - - - - - - - 询问 - - - - - - 关闭 - - - - - 清除 - - - - - - 清除 - - - - - - 消息框 - - - - - 成功 - - - - - - - 消息 - - - - - - - 警告 - - - - - - - 错误 - - - - - - - 严重 - - - - - - - 询问 - - - - - - - 自定义信息展示 - - - - - - - 信息展示 - - - - - - - - - - - 信息展示 - - - - - - - - - - - - 占位符 - - - - - 是否必填 - - - - - 标记 - - - - - 内容高度 - - - - - 密码长度 - - - - - 是否监测 - - - - - 选中时展示的元素 - - - - - 是否隐藏元素 - - - - - 标题对齐方式 - - - - - 标题宽度 - - - - - 规则ItemsControl - - - 该类的每一项都具有相同的大小和外边距 - - - - - ItemsControl的轻量级版本 - - - - - 带上下文菜单的按钮 - - - - - 带上下文菜单的切换按钮 - - - - - 封面流 - - - - - 最大显示数量的一半 - - - - - 页码 - - - - - 是否循环 - - - - - 存储所有的资源标识符 - - - - - 当前在显示范围内的项 - - - - - 相机 - - - - - 3d画布 - - - - - 项容器 - - - - - 显示范围内第一个项的编号 - - - - - 显示范围内最后一个项的编号 - - - - - 跳转编号 - - - - - 页码 - - - - - 是否循环 - - - - - 批量添加资源 - - - - - - 添加一项资源 - - - - - - 添加一项资源 - - - - - - 跳转 - - - - - 删除指定位置的项 - - - - - - 移动项到指定的位置 - - - - - - - 更新项的位置 - - - - - - - 更新显示范围 - - - - - 创建网格形状 - - - - - - - - - - 创建内容形状 - - - - - - 移动 - - - - - 命中测试 - - - - - - - 更新内容视图 - - - - - 更新内容视图位置 - - - - - 生成序号 - - - - - 缩放比间隔 - - - - - 图片保存对话框 - - - - - 右下角小图片是否加载过 - - - - - 图片是否可以在x轴方向移动 - - - - - 图片是否可以在y轴方向移动 - - - - - 图片实际位置 - - - - - 图片实际旋转角度 - - - - - 图片实际旋缩放比 - - - - - 在图片上鼠标移动时的即时位置 - - - - - 鼠标是否在图片上按下左键 - - - - - 在图片上按下时图片的位置 - - - - - 在图片上按下时鼠标的位置 - - - - - 在小图片上鼠标移动时的即时位置 - - - - - 鼠标是否在小图片上按下左键 - - - - - 在小图片上按下时图片的位置 - - - - - 在小图片上按下时鼠标的位置 - - - - - 图片长宽比 - - - - - 是否已经初始化 - - - - - 图片是否倾斜 - - - - - 缩放高度间隔 - - - - - 缩放宽度间隔 - - - - - 底部BorderBottom(包含一些图片操作)是否显示中 - - - - - 带一个图片Uri的构造函数 - - - - - - 带一个图片路径的构造函数 - - - - - - 是否显示全屏按钮 - - - - - 关闭按钮是否显示中 - - - - - 是否显示全屏按钮 - - - - - 图片原始宽度 - - - - - 图片原始高度 - - - - - 关闭按钮是否显示中 - - - - - 底部BorderBottom(包含一些图片操作)是否显示中 - - - - - 初始化 - - - - - 右下角小图片显示切换 - - - - - 初始化右下角小图片 - - - - - 更新右下角小图片 - - - - - 缩放图片 - - - - - - 旋转图片 - - - - - - 移动图片 - - - - - 移动小图片 - - - - - - - - 数据是否错误 - - - - - 错误提示 - - - - - 文本类型 - - - - - 是否显示清除按钮 - - - - - - - - 时间日期选择器 - - - - - Sets the local Text property without breaking bindings - - - - - - 表示可以成为一个数据输入控件 - - - - - 验证数据 - - - - - - 数据验证委托 - - - - - 数据是否错误 - - - - - 错误提示 - - - - - 文本类型 - - - - - 是否显示清除按钮 - - - - - - 数值选择控件 - - - - - 值改变事件 - - - - - 值改变事件 - - - - - 当前值 - - - - - 当前值 - - - - - 最大值 - - - - - 最大值 - - - - - 最小值 - - - - - 最小值 - - - - - 指示每单击一下按钮时增加或减少的数量 - - - - - 指示每单击一下按钮时增加或减少的数量 - - - - - 指示要显示的小数位数 - - - - - 指示要显示的小数位数 - - - - - 是否显示上下调值按钮 - - - - - 是否显示上下调值按钮 - - - - - 数据是否错误 - - - - - 错误提示 - - - - - 文本类型 - - - - - 是否显示清除按钮 - - - - - - - - 掩码字符 - - - - - 数据是否错误 - - - - - 错误提示 - - - - - 文本类型 - - - - - 是否显示清除按钮 - - - - - 是否实时搜索 - - - - - 是否实时搜索 - - - - - - - - 数据是否错误 - - - - - 错误提示 - - - - - 文本类型 - - - - - 是否显示清除按钮 - - - - - 时间选择器 - - - - - Sets the local Text property without breaking bindings - - - - - - 故事版 - - - - - 路径长度 - - - - - 路径 - - - - - 路径 - - - - - 路径长度 - - - - - 路径长度 - - - - - 动画间隔时间 - - - - - 动画间隔时间 - - - - - 是否正在播放动画 - - - - - 动画重复行为 - - - - - 动画完成事件 - - - - - 动画完成事件 - - - - - 更新路径 - - - - - 标记 - - - - - 轮播控件 - - - - - 是否自动跳转 - - - - - 跳转时间间隔 - - - - - 页码 - - - - - 计时器开关 - - - - - 更新页按钮 - - - - - 更新项的位置 - - - - - 创建页按钮 - - - - - - 颜色拾取器 - - - - - 当前显示的颜色类型 - - - - - 是否已经加载控件 - - - - - 是否需要更新小球位置 - - - - - 是否在拖动小球 - - - - - 是否需要更新信息 - - - - - 颜色选取面板宽度 - - - - - 颜色选取面板高度 - - - - - 预设的颜色(一共18个,两行) - - - - - 颜色范围集合 - - - - - 颜色分隔集合 - - - - - 颜色改变事件 - - - - - 颜色改变事件 - - - - - 取消事件 - - - - - 取消事件 - - - - - 当前选中的颜色 - - - - - 当前显示的颜色类型 - - - - - 初始化 - - - - - 创建颜色按钮 - - - - - - 内部更新 - - - - - 拖动时更新颜色 - - - - - 页码 - - - - - 页面更新事件 - - - - - 页面更新事件 - - - - - 最大页数 - - - - - 最大页数 - - - - - 每页的数据量 - - - - - 每页的数据量 - - - - - 当前页 - - - - - 当前页 - - - - - 表示当前选中的按钮距离左右两个方向按钮的最大间隔(4表示间隔4个按钮,如果超过则用省略号表示) - - - - - 表示当前选中的按钮距离左右两个方向按钮的最大间隔(4表示间隔4个按钮,如果超过则用省略号表示) - - - - - 更新 - - - - - 滚动方向 - - - - - 滚动方向 - - - - - 是否响应鼠标滚轮操作 - - - - - 是否响应鼠标滚轮操作 - - - - - 是否支持惯性 - - - - - 是否支持惯性 - - - - - 控件是否可以穿透点击 - - - - - 控件是否可以穿透点击 - - - - - 当前垂直滚动偏移 - - - - - 当前垂直滚动偏移 - - - - - 当前水平滚动偏移 - - - - - 当前水平滚动偏移 - - - - - 用以代替Grid - - - 当不需要Grid的行、列分隔等功能时建议用此轻量级类代替 - - - - - 波浪进度条 - - - - - 预览内容 - - - - - 预览内容 - - - - - 值改变事件 - - - - - 值改变事件 - - - - - 步骤改变事件 - - - - - 步骤改变事件 - - - - - 步骤条单元项 - - - - - 步骤编号 - - - - - 步骤编号 - - - - - 步骤状态 - - - - - 步骤状态 - - - - - 是否为内部操作 - - - - - 是否启用动画 - - - - - 是否启用动画 - - - - - 是否可以拖动 - - - - - 是否可以拖动 - - - - - 是否显示关闭按钮 - - - - - 是否显示关闭按钮 - - - - - 是否将标签填充 - - - - - 是否将标签填充 - - - - - 标签宽度 - - - - - 标签宽度 - - - - - 标签高度 - - - - - 标签高度 - - - - - 可见的标签数量 - - - - - 动画速度 - - - - - 选项卡是否处于拖动状态 - - - - - 选项卡是否等待被拖动 - - - - - 拖动中的选项卡坐标 - - - - - 鼠标按下时选项卡位置 - - - - - 鼠标按下时选项卡横向偏移 - - - - - 鼠标按下时的坐标 - - - - - 右侧可移动的最大值 - - - - - 左侧可移动的最大值 - - - - - 选项卡宽度 - - - - - 选项卡拖动等待距离(在鼠标移动了超过20个像素无关单位后,选项卡才开始被拖动) - - - - - 选项卡是否处于拖动状态 - - - - - 选项卡是否已经被拖动 - - - - - 目标横向位移 - - - - - 当前编号 - - - - - 标签容器 - - - - - 当前编号 - - - - - 更新选项卡横向偏移 - - - - - - 关闭 - - - - - 创建动画 - - - - - 计算选项卡当前合适的位置编号 - - - - - - - 是否可以更新 - - - - - 选项卡字典 - - - - - 流式行为持续时间 - - - - - 流式行为持续时间 - - - - - 是否将标签填充 - - - - - 是否将标签填充 - - - - - 标签宽度 - - - - - 标签宽度 - - - - - 标签高度 - - - - - 标签高度 - - - - - 是否可以强制更新 - - - - - 是否已经加载 - - - - - 更新 - - - - - - 获取显示时间 - - - - - - 作为刻度使用的文字块 - - - - - 时间 - - - - - 时间 - - - - - 时间格式 - - - - - 横向移动 - - - - - - 时间条 - - - - - 是否显示刻度字符串 - - - - - 刻度字符串 - - - - - 选中时间 - - - - - 时间改变事件 - - - - - 刻度集合 - - - - - 初始化时时间 - - - - - 时间段集合 - - - - - 顶部border是否被按下 - - - - - 控件是否处于拖动中 - - - - - 刻度单项宽度 - - - - - 鼠标按下拖动时选中的时间 - - - - - 显示的刻度数目 - - - - - 刻度区间编号 - - - - - 刻度单次偏移 - - - - - 刻度总偏移 - - - - - 是否显示刻度字符串 - - - - - 刻度字符串 - - - - - 选中时间 - - - - - 刻度区间编号 - - - - - 时间改变事件 - - - - - 设置刻度时间格式 - - - - - - 设置显示的时间 - - - - - - 更新 - - - - - 时间转换 - - - - - - - 鼠标滚轮滚动时改变刻度区间 - - - - - - 穿梭框 - - - - - 图片浏览器 - - - - - 带一个图片Uri的构造函数 - - - - - - 带一个图片路径的构造函数 - - - - - - 弹出窗口 - - - - - 颜色范围 - - - - - 颜色1 - - - - - 颜色1 - - - - - 颜色2 - - - - - 颜色2 - - - - - 颜色差值 - - - - - 更新 - - - - - 获取指定比例处的颜色 - - 范围(0-1) - - - - - IP类型枚举 - - - - - A类IP地址 - - - - - B类IP地址 - - - - - C类IP地址 - - - - - D类IP地址 - - - - - E类IP地址 - - - - - 表示一个操作的返回结果类型 - - - - - 成功 - - - - - 失败 - - - - - 无数据 - - - - - 步骤状态 - - - - - 完成 - - - - - 进行中 - - - - - 等待中 - - - - - 文本类型枚举 - - - - - 标题对齐方式 - - - - - 表示一个操作的返回结果信息 - - - - - 操作结果 - - - - - 返回数据 - - - - - 操作消息(包含错误原因等数据) - - - - - 装箱后的值类型(用于提高效率) - - - - - 控件库使用的所有命令(为了统一,不使用wpf自带的命令) - - - - - 搜索 - - - - - 清除 - - - - - 切换 - - - - - 右转 - - - - - 左转 - - - - - 小 - - - - - 大 - - - - - 还原 - - - - - 打开 - - - - - 保存 - - - - - 选中 - - - - - 关闭 - - - - - 取消 - - - - - 确定 - - - - - 是 - - - - - 否 - - - - - 关闭所有 - - - - - 关闭其他 - - - - - 上一个 - - - - - 下一个 - - - - - 上午 - - - - - 下午 - - - - - 确认 - - - - - 小时改变 - - - - - 分钟改变 - - - - - 秒改变 - - - - - 鼠标移动 - - - - - 打开链接 - - - - - 关闭程序 - - - - - 前置主窗口 - - - - - 一个强类型的资源类,用于查找本地化的字符串等。 - - - - - 返回此类使用的缓存的 ResourceManager 实例。 - - - - - 重写当前线程的 CurrentUICulture 属性 - 重写当前线程的 CurrentUICulture 属性。 - - - - - 查找类似 上午 的本地化字符串。 - - - - - 查找类似 取消 的本地化字符串。 - - - - - 查找类似 无法自注册复合命令 的本地化字符串。 - - - - - 查找类似 不能注册同一命令两次 的本地化字符串。 - - - - - 查找类似 清空 的本地化字符串。 - - - - - 查找类似 关闭 的本地化字符串。 - - - - - 查找类似 关闭所有 的本地化字符串。 - - - - - 查找类似 关闭其他 的本地化字符串。 - - - - - 查找类似 确定 的本地化字符串。 - - - - - 查找类似 错误的图片路径! 的本地化字符串。 - - - - - 查找类似 非法的图片尺寸! 的本地化字符串。 - - - - - 查找类似 格式错误 的本地化字符串。 - - - - - 查找类似 间隔10分钟 的本地化字符串。 - - - - - 查找类似 间隔1小时 的本地化字符串。 - - - - - 查找类似 间隔1分钟 的本地化字符串。 - - - - - 查找类似 间隔2小时 的本地化字符串。 - - - - - 查找类似 间隔30分钟 的本地化字符串。 - - - - - 查找类似 间隔30秒 的本地化字符串。 - - - - - 查找类似 间隔5分钟 的本地化字符串。 - - - - - 查找类似 不能为空 的本地化字符串。 - - - - - 查找类似 否 的本地化字符串。 - - - - - 查找类似 不在范围内 的本地化字符串。 - - - - - 查找类似 下午 的本地化字符串。 - - - - - 查找类似 PNG图片 的本地化字符串。 - - - - - 查找类似 提示 的本地化字符串。 - - - - - 查找类似 过大 的本地化字符串。 - - - - - 查找类似 未知 的本地化字符串。 - - - - - 查找类似 未知大小 的本地化字符串。 - - - - - 查找类似 是 的本地化字符串。 - - - - - 颜色扩展类 - - - - - 将颜色转换为10进制表示(rgb顺序颠倒) - - - - - - - 将颜色转换为10进制表示(rgb顺序颠倒) - - - - - - - 获取路径总长度 - - - - - - - 获取路径总长度 - - - - - - - - - 显示元素 - - - - - - 显示元素 - - - - - - - 不现实元素,但保留空间 - - - - - - 不显示元素,且不保留空间 - - - - - - 包含一些常用的动画辅助方法 - - - - - 创建一个Thickness动画 - - - - - - - - 创建一个Double动画 - - - - - - - - 包含内部使用的一些简单算法 - - - - - 平分一个整数到一个数组中 - - - - - - - - 计算控件在窗口中的可见坐标 - - - - - 获取布局范围框 - - - - - - - 计算两点的连线和x轴的夹角 - - - - - - - - 判断是否是有效的双精度浮点数 - - - - - - - 计算法线 - - - - - - - - - 资源帮助类 - - - - - 获取字符串 - - - - - - - 获取字符串 - - - - - - - - 获取字符串 - - - - - - - 获取资源 - - - - - - - 获取HandyControl皮肤 - - - - - - - 获取皮肤 - - - - - - - - - 该类可以为可视化元素提供单开的功能 - - - - - 根据指定的类型创建实例 - - - - - - - 验证帮助类 - - - - - 是否在浮点数范围内 - - - - - - - 是否在正浮点数范围内 - - - - - - - - 是否在正浮点数范围内 - - - - - - - - 获取当前应用中处于激活的一个窗口 - - - - - - 鼠标拖动行为,该类是反编译微软的System.Windows.Interactivity程序集得到的,并对其做了些扩展 - - - - - 是否固定住Y轴 - - - - - 是否固定住X轴 - - - - - 包含一些正则验证操作 - - - - - 判断字符串格式是否符合某种要求 - - 需要判断的字符串 - 正则表达式 - - - - - 判断字符串是否满足指定的格式 - - 需要判断的字符串 - 指定格式的文本 - - - - - 判断字符串格式是否为电子邮件 - - 需要判断的Email字符串 - 方法返回布尔值 - - - - 判断字符串格式是否为指定类型的IP地址 - - 需要判断的IP字符串 - 指定的IP类型 - 方法返回布尔值 - - - - 判断字符串格式是否为IP地址 - - 需要判断的IP字符串 - 方法返回布尔值 - - - - 判断字符串格式是否为单个汉字 - - 需要判断的单个汉字字符串 - 方法返回布尔值 - - - - 判断字符串格式是否为url - - 需要判断的url字符串 - 方法返回布尔值 - - - - 包含一些正则验证所需要的字符串 - - - - - 邮件正则匹配表达式 - - - - - 手机号正则匹配表达式 - - - - - IP正则匹配 - - - - - A类IP正则匹配 - - - - - B类IP正则匹配 - - - - - C类IP正则匹配 - - - - - D类IP正则匹配 - - - - - E类IP正则匹配 - - - - - 汉字正则匹配 - - - - - Url正则匹配 - - - - - 数字正则匹配 - - - - - 计算性质数字正则匹配 - - - - - 正整数正则匹配 - - - - - 负整数正则匹配 - - - - - 整数正则匹配 - - - - - 非负整数正则匹配 - - - - - 非正整数正则匹配 - - - - - 正浮点数正则匹配 - - - - - 负浮点数正则匹配 - - - - - 浮点数正则匹配 - - - - - 非负浮点数正则匹配 - - - - - 非正浮点数正则匹配 - - - - - 根据属性名称使用反射来获取值 - - - - - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - - - diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj index 8cf0c733..e7e5142f 100644 --- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj +++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj @@ -22,7 +22,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;netle45;netle40 prompt 4 v4.0 @@ -32,7 +32,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;netle45;netle40 prompt 4 v4.0 @@ -66,21 +66,6 @@ NoUserContent.xaml - - - - - - - - - - - - - - - diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/ChatBoxViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/ChatBoxViewModel.cs deleted file mode 100644 index 17cce6c0..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/ChatBoxViewModel.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Media; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media.Imaging; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Command; -using GalaSoft.MvvmLight.Messaging; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControl.Tools; -using HandyControlDemo.Data; -using HandyControlDemo.Tools; -using Microsoft.Win32; - -namespace HandyControlDemo.ViewModel -{ - public class ChatBoxViewModel : ViewModelBase - { - private static readonly string AudioCachePath = $"{AppDomain.CurrentDomain.BaseDirectory}Cache"; - - private readonly string _id = Guid.NewGuid().ToString(); - - private readonly Stopwatch _stopwatch = new Lazy(() => new Stopwatch()).Value; - - public ChatBoxViewModel() - { - Messenger.Default.Register(this, MessageToken.SendChatMessage, ReceiveMessage); - } - - private void ReceiveMessage(ChatInfoModel info) - { - if (_id.Equals(info.SenderId)) return; - info.Role = ChatRoleType.Receiver; - ChatInfos.Add(info); - } - - private string _chatString; - - public string ChatString - { - get => _chatString; - set => Set(nameof(ChatString), ref _chatString, value); - } - - public ObservableCollection ChatInfos { get; set; } = new ObservableCollection(); - - public RelayCommand SendStringCmd => new Lazy>(() => - new RelayCommand(SendString)).Value; - - private void SendString(KeyEventArgs e) - { - if (e.Key == Key.Enter) - { - if (string.IsNullOrEmpty(ChatString)) return; - var info = new ChatInfoModel - { - Message = ChatString, - SenderId = _id, - Type = ChatMessageType.String, - Role = ChatRoleType.Sender - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - ChatString = string.Empty; - } - } - - public RelayCommand ReadMessageCmd => new Lazy>(() => - new RelayCommand(ReadMessage)).Value; - - private void ReadMessage(RoutedEventArgs e) - { - if (e.OriginalSource is FrameworkElement element && element.Tag is ChatInfoModel info) - { - if (info.Type == ChatMessageType.Image) - { - new ImageBrowser(new Uri(info.Enclosure.ToString())) - { - Owner = VisualHelper.GetActiveWindow() - }.Show(); - } - else if (info.Type == ChatMessageType.Audio) - { - var player = new SoundPlayer(info.Enclosure.ToString()); - player.PlaySync(); - } - } - } - - public RelayCommand StartRecordCmd => new Lazy(() => - new RelayCommand(StartRecord)).Value; - - private void StartRecord() - { - ExternDllHelper.MciSendString("set wave bitpersample 8", "", 0, 0); - ExternDllHelper.MciSendString("set wave samplespersec 20000", "", 0, 0); - ExternDllHelper.MciSendString("set wave channels 2", "", 0, 0); - ExternDllHelper.MciSendString("set wave format tag pcm", "", 0, 0); - ExternDllHelper.MciSendString("open new type WAVEAudio alias movie", "", 0, 0); - ExternDllHelper.MciSendString("record movie", "", 0, 0); - - _stopwatch.Reset(); - _stopwatch.Start(); - } - - public RelayCommand StopRecordCmd => new Lazy(() => - new RelayCommand(StopRecord)).Value; - - private void StopRecord() - { - if (!Directory.Exists(AudioCachePath)) - { - try - { - Directory.CreateDirectory(AudioCachePath); - } - catch (Exception e) - { - Growl.Error(e.Message); - return; - } - } - - var cachePath = $"{AudioCachePath}\\{Guid.NewGuid().ToString()}"; - ExternDllHelper.MciSendString("stop movie", "", 0, 0); - ExternDllHelper.MciSendString($"save movie {cachePath}", "", 0, 0); - ExternDllHelper.MciSendString("close movie", "", 0, 0); - - _stopwatch.Stop(); - - var info = new ChatInfoModel - { - Message = $"{_stopwatch.Elapsed.Seconds.ToString()} {Properties.Langs.Lang.Second}", - SenderId = _id, - Type = ChatMessageType.Audio, - Role = ChatRoleType.Sender, - Enclosure = cachePath - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - } - - public RelayCommand OpenImageCmd => new Lazy(() => - new RelayCommand(OpenImage)).Value; - - private void OpenImage() - { - var dialog = new OpenFileDialog(); - if (dialog.ShowDialog() == true) - { - var fileName = dialog.FileName; - if (File.Exists(fileName)) - { - var info = new ChatInfoModel - { - Message = BitmapFrame.Create(new Uri(fileName)), - SenderId = _id, - Type = ChatMessageType.Image, - Role = ChatRoleType.Sender, - Enclosure = fileName - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - } - } - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/InteractiveDialogViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/InteractiveDialogViewModel.cs deleted file mode 100644 index 521be9de..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Basic/InteractiveDialogViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Command; -using HandyControl.Tools.Extension; - -namespace HandyControlDemo.ViewModel.Basic -{ - public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable - { - public Action CloseAction { get; set; } - - private string _result; - - public string Result - { - get => _result; - set => Set(nameof(Result), ref _result, value); - } - - private string _message; - - public string Message - { - get => _message; - set => Set(nameof(Message), ref _message, value); - } - - public RelayCommand CloseCmd => new Lazy(() => new RelayCommand(() => CloseAction?.Invoke())).Value; - } -} diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/BadgeDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/BadgeDemoViewModel.cs deleted file mode 100644 index 73204b80..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/BadgeDemoViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Command; - -namespace HandyControlDemo.ViewModel.Controls -{ - public class BadgeDemoViewModel : ViewModelBase - { - private int _count = 1; - - public int Count - { - get => _count; - set => Set(nameof(Count), ref _count, value); - } - - public RelayCommand CountCmd => new Lazy(() => - new RelayCommand(() => Count++)).Value; - } -} diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/DialogDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/DialogDemoViewModel.cs deleted file mode 100644 index 0b32e0d5..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/DialogDemoViewModel.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Command; -using HandyControl.Controls; -using HandyControl.Tools.Extension; -using HandyControlDemo.UserControl; -using HandyControlDemo.UserControl.Basic; -using HandyControlDemo.ViewModel.Basic; - -namespace HandyControlDemo.ViewModel -{ - public class DialogDemoViewModel : ViewModelBase - { - private string _dialogResult; - - public string DialogResult - { - get => _dialogResult; - set => Set(nameof(DialogResult), ref _dialogResult, value); - } - - public RelayCommand ShowTextCmd => new Lazy(() => - new RelayCommand(ShowText)).Value; - - private void ShowText() - { - Dialog.Show(new TextDialog()); - } - - public RelayCommand ShowInteractiveDialogCmd => new Lazy(() => - new RelayCommand(ShowInteractiveDialog)).Value; - - private void ShowInteractiveDialog() - { - Dialog.Show() - .Initialize(vm => vm.Message = DialogResult) - .GetResultAsync().ContinueWith(str => DialogResult = str.Result); - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/GrowlDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/GrowlDemoViewModel.cs deleted file mode 100644 index fe3ae8f7..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/GrowlDemoViewModel.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using GalaSoft.MvvmLight.Command; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControlDemo.Window; - -namespace HandyControlDemo.ViewModel -{ - public class GrowlDemoViewModel - { - private readonly string _token; - - public GrowlDemoViewModel() - { - - } - - public GrowlDemoViewModel(string token) - { - _token = token; - } - - public RelayCommand InfoCmd => new Lazy(() => - new RelayCommand(() => Growl.Info(Properties.Langs.Lang.GrowlInfo, _token))).Value; - - public RelayCommand SuccessCmd => new Lazy(() => - new RelayCommand(() => Growl.Success(Properties.Langs.Lang.GrowlSuccess, _token))).Value; - - public RelayCommand WarningCmd => new Lazy(() => - 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(() => - new RelayCommand(() => Growl.Error(Properties.Langs.Lang.GrowlError, _token))).Value; - - public RelayCommand AskCmd => new Lazy(() => - new RelayCommand(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, isConfirmed => - { - Growl.Info(isConfirmed.ToString()); - return true; - }, _token))).Value; - - public RelayCommand FatalCmd => new Lazy(() => - new RelayCommand(() => Growl.Fatal(new GrowlInfo - { - Message = Properties.Langs.Lang.GrowlFatal, - ShowDateTime = false, - Token = _token - }))).Value; - - public RelayCommand ClearCmd => new Lazy(() => - new RelayCommand(() => Growl.Clear(_token))).Value; - - public RelayCommand NewWindowCmd => new Lazy(() => - new RelayCommand(() => new GrowlDemoWindow().Show())).Value; - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/ImageBrowserDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/ImageBrowserDemoViewModel.cs deleted file mode 100644 index 2fa5120a..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/ImageBrowserDemoViewModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -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/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/NotifyIconDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/NotifyIconDemoViewModel.cs deleted file mode 100644 index 88c6c011..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/NotifyIconDemoViewModel.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Command; -using HandyControl.Controls; -using HandyControlDemo.Data; - -namespace HandyControlDemo.ViewModel -{ - public class NotifyIconDemoViewModel : ViewModelBase - { - private bool _contextMenuIsShow; - - public bool ContextMenuIsShow - { - get => _contextMenuIsShow; - set - { - Set(nameof(ContextMenuIsShow), ref _contextMenuIsShow, value); - GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; - } - } - - private bool _contextMenuIsBlink; - - public bool ContextMenuIsBlink - { - get => _contextMenuIsBlink; - set => Set(nameof(ContextMenuIsBlink), ref _contextMenuIsBlink, value); - } - - private bool _contextContentIsShow; - - public bool ContextContentIsShow - { - get => _contextContentIsShow; - set - { - Set(nameof(ContextContentIsShow), ref _contextContentIsShow, value); - GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; - } - } - - private bool _contextContentIsBlink; - - public bool ContextContentIsBlink - { - get => _contextContentIsBlink; - set => Set(nameof(ContextContentIsBlink), ref _contextContentIsBlink, value); - } - - public RelayCommand MouseCmd => new Lazy>(() => - new RelayCommand(str=> Growl.Info(str.ToString()))).Value; - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/PaginationDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/PaginationDemoViewModel.cs deleted file mode 100644 index 4bb65144..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/PaginationDemoViewModel.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using GalaSoft.MvvmLight.Command; -using HandyControl.Data; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class PaginationDemoViewModel : DemoViewModelBase - { - /// - /// 所有数据 - /// - private readonly List _totalDataList; - - /// - /// 页码 - /// - private int _pageIndex = 1; - - /// - /// 页码 - /// - public int PageIndex - { - get => _pageIndex; - set => Set(nameof(PageIndex), ref _pageIndex, value); - } - - public PaginationDemoViewModel(DataService dataService) - { - _totalDataList = dataService.GetDemoDataList(100); - DataList = _totalDataList.Take(10).ToList(); - } - - /// - /// 页码改变命令 - /// - public RelayCommand> PageUpdatedCmd => - new Lazy>>(() => - new RelayCommand>(PageUpdated)).Value; - - /// - /// 页码改变 - /// - private void PageUpdated(FunctionEventArgs info) - { - DataList = _totalDataList.Skip((info.Info - 1) * 10).Take(10).ToList(); - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/SearchBarDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/SearchBarDemoViewModel.cs deleted file mode 100644 index 75dccd5f..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/SearchBarDemoViewModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Command; -using HandyControl.Controls; - -namespace HandyControlDemo.ViewModel -{ - public class SearchBarDemoViewModel : ViewModelBase - { - public RelayCommand SearchCmd => new Lazy>(() => - new RelayCommand(Search)).Value; - - private void Search(string key) - { - Growl.Info(key); - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/StepBarDemoViewModel.cs deleted file mode 100644 index de0ecabf..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/StepBarDemoViewModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Linq; -using System.Windows.Controls; -using GalaSoft.MvvmLight.Command; -using HandyControl.Controls; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class StepBarDemoViewModel : DemoViewModelBase - { - public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList(); - - /// - /// 下一步 - /// - public RelayCommand NextCmd => new Lazy>(() => new RelayCommand(Next)).Value; - - /// - /// 上一步 - /// - public RelayCommand PrevCmd => new Lazy>(() => new RelayCommand(Prev)).Value; - - private void Next(Panel panel) - { - foreach (var stepBar in panel.Children.OfType()) - { - stepBar.Next(); - } - } - - private void Prev(Panel panel) - { - foreach (var stepBar in panel.Children.OfType()) - { - stepBar.Prev(); - } - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/WindowDemoViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/WindowDemoViewModel.cs deleted file mode 100644 index 6acc5fe4..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Controls/WindowDemoViewModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Windows; -using GalaSoft.MvvmLight.Command; -using HandyControlDemo.Tools; - -namespace HandyControlDemo.ViewModel -{ - public class WindowDemoViewModel - { - public RelayCommand OpenWindowCmd => new Lazy>(() => new RelayCommand(OpenWindow)).Value; - - private void OpenWindow(string windowTag) - { - if (AssemblyHelper.CreateInternalInstance($"Window.{windowTag}") is System.Windows.Window window) - { - window.Owner = Application.Current.MainWindow; - window.ShowDialog(); - } - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/DemoViewModelBase!1.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/DemoViewModelBase!1.cs deleted file mode 100644 index e394d971..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/DemoViewModelBase!1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using GalaSoft.MvvmLight; - -namespace HandyControlDemo.ViewModel -{ - public class DemoViewModelBase : ViewModelBase - { - /// - /// 数据列表 - /// - private IList _dataList; - - /// - /// 数据列表 - /// - public IList DataList - { - get => _dataList; - set => Set(nameof(DataList), ref _dataList, value); - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/ContributorsViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/ContributorsViewModel.cs deleted file mode 100644 index 64bed9f6..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/ContributorsViewModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Threading.Tasks; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class ContributorsViewModel : DemoViewModelBase - { - public ContributorsViewModel(DataService dataService) - { - Task.Factory.StartNew(() => DataList = dataService.GetContributorDataList()); - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/MainViewModel.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/MainViewModel.cs deleted file mode 100644 index ea0d3452..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/Main/MainViewModel.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Windows.Controls; -using GalaSoft.MvvmLight.Command; -using GalaSoft.MvvmLight.Messaging; -using HandyControlDemo.Data; -using HandyControlDemo.Service; -using HandyControlDemo.Tools; - -namespace HandyControlDemo.ViewModel -{ - public class MainViewModel : DemoViewModelBase - { - #region 字段 - - /// - /// 内容标题 - /// - private object _contentTitle; - - /// - /// 子内容 - /// - private object _subContent; - - /// - /// 当前选中的列表项 - /// - private ListBoxItem _listBoxItemCurrent; - - #endregion - - public MainViewModel(DataService dataService) - { - Messenger.Default.Register(this, MessageToken.LoadShowContent, obj => - { - if (SubContent is IDisposable disposable) - { - disposable.Dispose(); - } - SubContent = obj; - }); - Messenger.Default.Register(this, MessageToken.ClearLeftSelected, obj => - { - if (_listBoxItemCurrent == null) return; - _listBoxItemCurrent.IsSelected = false; - _listBoxItemCurrent = null; - }); - DataList = dataService.GetDemoDataList(); - } - - #region 属性 - - /// - /// 子内容 - /// - public object SubContent - { - get => _subContent; - set => Set(nameof(SubContent), ref _subContent, value); - } - - /// - /// 内容标题 - /// - public object ContentTitle - { - get => _contentTitle; - set => Set(nameof(ContentTitle), ref _contentTitle, value); - } - - #endregion - - #region 命令 - - /// - /// 切换例子命令 - /// - public RelayCommand SwitchDemoCmd => - new Lazy>(() => - new RelayCommand(SwitchDemo)).Value; - - #endregion - - #region 方法 - - /// - /// 切换例子 - /// - private void SwitchDemo(SelectionChangedEventArgs e) - { - if (e.AddedItems.Count == 0) return; - if (e.AddedItems[0] is ListBoxItem item) - { - if (item.Tag is string tag) - { - if (Equals(_listBoxItemCurrent, item)) return; - _listBoxItemCurrent = item; - ContentTitle = item.Content; - Messenger.Default.Send(false, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{tag}"), MessageToken.LoadShowContent); - } - else - { - _listBoxItemCurrent = null; - ContentTitle = null; - SubContent = null; - } - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/ViewModel/ViewModelLocator.cs b/src/Net_40/HandyControlDemo_Net_40/ViewModel/ViewModelLocator.cs deleted file mode 100644 index e7f59c12..00000000 --- a/src/Net_40/HandyControlDemo_Net_40/ViewModel/ViewModelLocator.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Windows; -using CommonServiceLocator; -using GalaSoft.MvvmLight.Ioc; -using HandyControlDemo.Data; -using HandyControlDemo.Service; -using HandyControlDemo.ViewModel.Basic; -using HandyControlDemo.ViewModel.Controls; - -namespace HandyControlDemo.ViewModel -{ - public class ViewModelLocator - { - public ViewModelLocator() - { - ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - - SimpleIoc.Default.Register(); - - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(() => new GrowlDemoViewModel(), "GrowlDemo"); - SimpleIoc.Default.Register(() => new GrowlDemoViewModel(MessageToken.GrowlDemoPanel), "GrowlDemoWithToken"); - 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 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("GrowlDemo"); - - public GrowlDemoViewModel GrowlDemoWithToken => ServiceLocator.Current.GetInstance("GrowlDemoWithToken"); - - public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance(); - - public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance(); - - public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance(); - - public ContributorsViewModel ContributorsView => ServiceLocator.Current.GetInstance(); - - public StepBarDemoViewModel StepBarDemo => ServiceLocator.Current.GetInstance(); - - public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance(); - - public ChatBoxViewModel ChatBox => new ChatBoxViewModel(); - - public CoverViewModel CoverView => ServiceLocator.Current.GetInstance(); - - public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance(); - - public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance(); - - public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance(); - - public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance(); - - public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance(); - #endregion - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControl_Net_40/Controls/Other/Growl.cs b/src/Net_40/HandyControl_Net_40/Controls/Other/Growl.cs deleted file mode 100644 index e2ac1b72..00000000 --- a/src/Net_40/HandyControl_Net_40/Controls/Other/Growl.cs +++ /dev/null @@ -1,601 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Threading; -using HandyControl.Data; -using HandyControl.Interactivity; -using HandyControl.Tools; -using HandyControl.Tools.Extension; - -namespace HandyControl.Controls -{ - /// - /// 消息提醒 - /// - [TemplatePart(Name = ElementPanelMore, Type = typeof(Panel))] - [TemplatePart(Name = ElementGridMain, Type = typeof(Grid))] - [TemplatePart(Name = ElementButtonClose, Type = typeof(Button))] - public class Growl : Control - { - #region Constants - - private const string ElementPanelMore = "PART_PanelMore"; - private const string ElementGridMain = "PART_GridMain"; - private const string ElementButtonClose = "PART_ButtonClose"; - - #endregion Constants - - #region Data - - private Panel _panelMore; - - private Grid _gridMain; - - private Button _buttonClose; - - private bool _showCloseButton; - - private bool _staysOpen; - - private int _waitTime = 6; - - /// - /// 计数 - /// - private int _tickCount; - - /// - /// 关闭计时器 - /// - private DispatcherTimer _timerClose; - - private static readonly Dictionary PanelDic = new Dictionary(); - - #endregion Data - - public Growl() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick)); - CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancel_OnClick)); - CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick)); - } - - public static void Register(string token, Panel panel) - { - if (string.IsNullOrEmpty(token) || panel == null) return; - PanelDic[token] = panel; - InitGrowlPanel(panel); - } - - public static void Unregister(string token, Panel panel) - { - if (string.IsNullOrEmpty(token) || panel == null) return; - - if (PanelDic.ContainsKey(token)) - { - if (ReferenceEquals(PanelDic[token], panel)) - { - PanelDic.Remove(token); - panel.ContextMenu = null; - panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue); - } - } - } - - public static void Unregister(Panel panel) - { - if (panel == null) return; - var first = PanelDic.FirstOrDefault(item => ReferenceEquals(panel, item.Value)); - if (!string.IsNullOrEmpty(first.Key)) - { - PanelDic.Remove(first.Key); - panel.ContextMenu = null; - panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue); - } - } - - protected override void OnMouseEnter(MouseEventArgs e) - { - base.OnMouseEnter(e); - - _buttonClose.Show(_showCloseButton); - } - - protected override void OnMouseLeave(MouseEventArgs e) - { - base.OnMouseLeave(e); - - _buttonClose.Collapse(); - } - - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - _panelMore = GetTemplateChild(ElementPanelMore) as Panel; - _gridMain = GetTemplateChild(ElementGridMain) as Grid; - _buttonClose = GetTemplateChild(ElementButtonClose) as Button; - - CheckNull(); - Update(); - } - - private void CheckNull() - { - if (_panelMore == null || _gridMain == null || _buttonClose == null) throw new Exception(); - } - - private Func ActionBeforeClose { get; set; } - - /// - /// 消息容器 - /// - public static Panel GrowlPanel { get; set; } - - internal static readonly DependencyProperty CancelStrProperty = DependencyProperty.Register( - "CancelStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); - - internal static readonly DependencyProperty ConfirmStrProperty = DependencyProperty.Register( - "ConfirmStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); - - public static readonly DependencyProperty ShowDateTimeProperty = DependencyProperty.Register( - "ShowDateTime", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.TrueBox)); - - 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))); - - public static readonly DependencyProperty TypeProperty = DependencyProperty.Register( - "Type", typeof(InfoType), typeof(Growl), new PropertyMetadata(default(InfoType))); - - public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached( - "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) => - { - if ((bool)args.NewValue && o is Panel panel) - { - SetGrowlPanel(panel); - } - })); - - public static readonly DependencyProperty TokenProperty = DependencyProperty.RegisterAttached( - "Token", typeof(string), typeof(Growl), new PropertyMetadata(default(string), OnTokenChanged)); - - private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is Panel panel) - { - if (e.NewValue == null) - { - Unregister(panel); - } - else - { - Register(e.NewValue.ToString(), panel); - } - } - } - - public static void SetToken(DependencyObject element, string value) - => element.SetValue(TokenProperty, value); - - public static string GetToken(DependencyObject element) - => (string)element.GetValue(TokenProperty); - - public static void SetGrowlParent(DependencyObject element, bool value) => element.SetValue(GrowlParentProperty, value); - - public static bool GetGrowlParent(DependencyObject element) => (bool)element.GetValue(GrowlParentProperty); - - public InfoType Type - { - get => (InfoType)GetValue(TypeProperty); - set => SetValue(TypeProperty, value); - } - - internal string CancelStr - { - get => (string)GetValue(CancelStrProperty); - set => SetValue(CancelStrProperty, value); - } - - internal string ConfirmStr - { - get => (string)GetValue(ConfirmStrProperty); - set => SetValue(ConfirmStrProperty, value); - } - - public bool ShowDateTime - { - get => (bool)GetValue(ShowDateTimeProperty); - set => SetValue(ShowDateTimeProperty, value); - } - - 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 >= _waitTime) Close(); - }; - _timerClose.Start(); - } - - /// - /// 消息容器 - /// - /// - private static void SetGrowlPanel(Panel panel) - { - GrowlPanel = panel; - InitGrowlPanel(panel); - } - - private static void InitGrowlPanel(Panel panel) - { - var menuItem = new MenuItem - { - Header = Properties.Langs.Lang.Clear - }; - menuItem.Click += (s, e) => - { - foreach (var item in panel.Children.OfType()) - { - item.Close(); - } - }; - panel.ContextMenu = new ContextMenu - { - Items = - { - menuItem - } - }; - - PanelElement.SetFluidMoveBehavior(panel, ResourceHelper.GetResource(ResourceToken.BehaviorXY400)); - } - - private void Update() - { - if (ActionBeforeClose != null) - { - _staysOpen = true; - _showCloseButton = false; - _panelMore.IsEnabled = true; - _panelMore.Show(); - } - - var transform = new TranslateTransform - { - X = MaxWidth - }; - _gridMain.RenderTransform = transform; - transform.BeginAnimation(TranslateTransform.XProperty, AnimationHelper.CreateAnimation(0)); - if (!_staysOpen) StartTimer(); - } - - /// - /// 显示信息 - /// - /// - private static void Show(GrowlInfo growlInfo) - { - Application.Current.Dispatcher.Invoke(new Action(() => - { - var ctl = new Growl - { - Message = growlInfo.Message, - Time = DateTime.Now, - Icon = ResourceHelper.GetResource(growlInfo.IconKey), - IconBrush = ResourceHelper.GetResource(growlInfo.IconBrushKey), - _showCloseButton = growlInfo.ShowCloseButton, - ActionBeforeClose = growlInfo.ActionBeforeClose, - _staysOpen = growlInfo.StaysOpen, - ShowDateTime = growlInfo.ShowDateTime, - ConfirmStr = growlInfo.ConfirmStr, - CancelStr = growlInfo.CancelStr, - Type = growlInfo.Type, - _waitTime = Math.Max(growlInfo.WaitTime, 2) - }; - if (!string.IsNullOrEmpty(growlInfo.Token)) - { - if (PanelDic.TryGetValue(growlInfo.Token, out var panel)) - { - panel?.Children.Insert(0, ctl); - } - } - else - { - GrowlPanel.Children.Insert(0, ctl); - } - })); - } - - /// - /// 成功 - /// - /// - /// - public static void Success(string message, string token = "") => Success(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 成功 - /// - /// - public static void Success(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.SuccessGeometry; - growlInfo.IconBrushKey = ResourceToken.SuccessBrush; - growlInfo.Type = InfoType.Success; - } - Show(growlInfo); - } - - /// - /// 消息 - /// - /// - /// - public static void Info(string message, string token = "") => Info(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 消息 - /// - /// - public static void Info(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.InfoGeometry; - growlInfo.IconBrushKey = ResourceToken.InfoBrush; - growlInfo.Type = InfoType.Info; - } - Show(growlInfo); - } - - /// - /// 警告 - /// - /// - /// - public static void Warning(string message, string token = "") => Warning(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 警告 - /// - /// - public static void Warning(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.WarningGeometry; - growlInfo.IconBrushKey = ResourceToken.WarningBrush; - growlInfo.Type = InfoType.Warning; - } - Show(growlInfo); - } - - /// - /// 错误 - /// - /// - /// - public static void Error(string message, string token = "") => Error(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 错误 - /// - /// - public static void Error(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.ErrorGeometry; - growlInfo.IconBrushKey = ResourceToken.DangerBrush; - growlInfo.StaysOpen = true; - growlInfo.Type = InfoType.Error; - } - Show(growlInfo); - } - - /// - /// 严重 - /// - /// - /// - public static void Fatal(string message, string token = "") => Fatal(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 严重 - /// - /// - public static void Fatal(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.FatalGeometry; - growlInfo.IconBrushKey = ResourceToken.PrimaryTextBrush; - growlInfo.StaysOpen = true; - growlInfo.ShowCloseButton = false; - growlInfo.Type = InfoType.Fatal; - if (GrowlPanel.ContextMenu != null) GrowlPanel.ContextMenu.Opacity = 0; - } - Show(growlInfo); - } - - /// - /// 询问 - /// - /// - /// - /// - public static void Ask(string message, Func actionBeforeClose, string token = "") => Ask(new GrowlInfo - { - Message = message, - ActionBeforeClose = actionBeforeClose, - Token = token - }); - - /// - /// 询问 - /// - /// - public static void Ask(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.AskGeometry; - growlInfo.IconBrushKey = ResourceToken.AccentBrush; - growlInfo.StaysOpen = true; - growlInfo.ShowCloseButton = false; - growlInfo.Type = InfoType.Ask; - } - Show(growlInfo); - } - - 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 += (s, e) => - { - if (Parent is Panel panel) - { - panel.Children.Remove(this); - } - }; - transform.BeginAnimation(TranslateTransform.XProperty, animation); - } - - /// - /// 清除 - /// - /// - public static void Clear(string token = "") - { - if (!string.IsNullOrEmpty(token)) - { - if (PanelDic.TryGetValue(token, out var panel)) - { - Clear(panel); - } - } - else - { - Clear(GrowlPanel); - } - } - - /// - /// 清除 - /// - /// - private static void Clear(Panel panel) - { - panel.Children.Clear(); - if (panel.ContextMenu != null) - { - panel.ContextMenu.IsOpen = false; - panel.ContextMenu.Opacity = 1; - } - } - - private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) - { - if (ActionBeforeClose?.Invoke(false) == true) - { - Close(); - } - } - - private void ButtonOk_OnClick(object sender, RoutedEventArgs e) - { - if (ActionBeforeClose?.Invoke(true) == true) - { - Close(); - } - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControl_Net_40/Controls/Window/MessageBox.cs b/src/Net_40/HandyControl_Net_40/Controls/Window/MessageBox.cs deleted file mode 100644 index 7afa3657..00000000 --- a/src/Net_40/HandyControl_Net_40/Controls/Window/MessageBox.cs +++ /dev/null @@ -1,390 +0,0 @@ -using System; -using System.ComponentModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Shapes; -using HandyControl.Data; -using HandyControl.Interactivity; -using HandyControl.Tools; -using HandyControl.Tools.Extension; - -namespace HandyControl.Controls -{ - /// - /// 消息框 - /// - public sealed class MessageBox : Window - { - #region Constants - - private const string ElementImage = "PART_Image"; - - private const string ElementMessage = "PART_Message"; - - #endregion Constants - - private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel; - - private bool _showOk; - - private bool _showCancel; - - private bool _showYes; - - private bool _showNo; - - private string _message; - - private Geometry _image; - - private Brush _imageBrush; - - private bool _showImage; - - private MessageBox() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, (s, e) => - { - _messageBoxResult = MessageBoxResult.OK; - Close(); - }, (s, e) => e.CanExecute = _showOk)); - CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, (s, e) => - { - _messageBoxResult = MessageBoxResult.Cancel; - Close(); - }, (s, e) => e.CanExecute = _showCancel)); - CommandBindings.Add(new CommandBinding(ControlCommands.Yes, (s, e) => - { - _messageBoxResult = MessageBoxResult.Yes; - Close(); - }, (s, e) => e.CanExecute = _showYes)); - CommandBindings.Add(new CommandBinding(ControlCommands.No, (s, e) => - { - _messageBoxResult = MessageBoxResult.No; - Close(); - }, (s, e) => e.CanExecute = _showNo)); - } - - protected override void OnSourceInitialized(EventArgs e) - { - base.OnSourceInitialized(e); - - if (LogicalTreeHelper.FindLogicalNode(this, ElementMessage) is TextBlock message) message.Text = _message; - - if (_showImage) - { - if (LogicalTreeHelper.FindLogicalNode(this, ElementImage) is Path image) - { - image.Data = _image; - image.Fill = _imageBrush; - image.Show(); - } - } - } - - /// - /// 成功 - /// - /// - /// - public static MessageBoxResult Success(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - messageBox._showImage = true; - messageBox._image = ResourceHelper.GetResource(ResourceToken.SuccessGeometry); - messageBox._imageBrush = ResourceHelper.GetResource(ResourceToken.SuccessBrush); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 消息 - /// - /// - /// - public static MessageBoxResult Info(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Information); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 警告 - /// - /// - /// - public static MessageBoxResult Warning(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Warning); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 错误 - /// - /// - /// - public static MessageBoxResult Error(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Error); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 严重 - /// - /// - /// - public static MessageBoxResult Fatal(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - messageBox._showImage = true; - messageBox._image = ResourceHelper.GetResource(ResourceToken.FatalGeometry); - messageBox._imageBrush = ResourceHelper.GetResource(ResourceToken.PrimaryTextBrush); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 询问 - /// - /// - /// - public static MessageBoxResult Ask(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); - SetButtonStatus(messageBox, MessageBoxButton.OKCancel); - SetImage(messageBox, MessageBoxImage.Question); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 自定义信息展示 - /// - /// - /// - public static MessageBoxResult Show(MessageBoxInfo info) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(null, info.MessageBoxText, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult); - SetButtonStatus(messageBox, info.Button); - - if (!string.IsNullOrEmpty(info.IconKey)) - { - messageBox._showImage = true; - messageBox._image = ResourceHelper.GetResource(info.IconKey); - messageBox._imageBrush = ResourceHelper.GetResource(info.IconBrushKey); - } - - messageBox.Style = info.Style; - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - /// - /// 信息展示 - /// - /// - /// - /// - /// - /// - /// - public static MessageBoxResult Show(string messageBoxText, string caption = null, - MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, - MessageBoxResult defaultResult = MessageBoxResult.None) => - Show(null, messageBoxText, caption, button, icon, defaultResult); - - /// - /// 信息展示 - /// - /// - /// - /// - /// - /// - /// - /// - public static MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption = null, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(new Action(() => - { - messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult); - SetButtonStatus(messageBox, button); - SetImage(messageBox, icon); - messageBox.ShowDialog(); - })); - - return messageBox._messageBoxResult; - } - - private static MessageBox CreateMessageBox( - System.Windows.Window owner, - string messageBoxText, - string caption, - MessageBoxButton button, - MessageBoxImage icon, - MessageBoxResult defaultResult) - { - if (!IsValidMessageBoxButton(button)) - { - throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(MessageBoxButton)); - } - if (!IsValidMessageBoxImage(icon)) - { - throw new InvalidEnumArgumentException(nameof(icon), (int)icon, typeof(MessageBoxImage)); - } - if (!IsValidMessageBoxResult(defaultResult)) - { - throw new InvalidEnumArgumentException(nameof(defaultResult), (int)defaultResult, typeof(MessageBoxResult)); - } - - var ownerWindow = owner ?? VisualHelper.GetActiveWindow(); - var ownerIsNull = ownerWindow is null; - - return new MessageBox - { - _message = messageBoxText, - Owner = ownerWindow, - WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner, - ShowTitle = true, - Title = caption ?? string.Empty, - Topmost = ownerIsNull, - _messageBoxResult = defaultResult - }; - } - - private static void SetButtonStatus(MessageBox messageBox, MessageBoxButton messageBoxButton) - { - switch (messageBoxButton) - { - case MessageBoxButton.OK: - messageBox._showOk = true; - break; - case MessageBoxButton.OKCancel: - messageBox._showOk = true; - messageBox._showCancel = true; - break; - case MessageBoxButton.YesNo: - messageBox._showYes = true; - messageBox._showNo = true; - break; - case MessageBoxButton.YesNoCancel: - messageBox._showYes = true; - messageBox._showNo = true; - messageBox._showCancel = true; - break; - } - } - - private static void SetImage(MessageBox messageBox, MessageBoxImage messageBoxImage) - { - var iconKey = string.Empty; - var iconBrushKey = string.Empty; - - switch (messageBoxImage) - { - case MessageBoxImage.Error: - iconKey = ResourceToken.ErrorGeometry; - iconBrushKey = ResourceToken.DangerBrush; - break; - case MessageBoxImage.Question: - iconKey = ResourceToken.AskGeometry; - iconBrushKey = ResourceToken.AccentBrush; - break; - case MessageBoxImage.Warning: - iconKey = ResourceToken.WarningGeometry; - iconBrushKey = ResourceToken.WarningBrush; - break; - case MessageBoxImage.Information: - iconKey = ResourceToken.InfoGeometry; - iconBrushKey = ResourceToken.InfoBrush; - break; - } - - if (string.IsNullOrEmpty(iconKey)) return; - messageBox._showImage = true; - messageBox._image = ResourceHelper.GetResource(iconKey); - messageBox._imageBrush = ResourceHelper.GetResource(iconBrushKey); - } - - private static bool IsValidMessageBoxButton(MessageBoxButton value) - { - return value == MessageBoxButton.OK - || value == MessageBoxButton.OKCancel - || value == MessageBoxButton.YesNo - || value == MessageBoxButton.YesNoCancel; - } - - private static bool IsValidMessageBoxImage(MessageBoxImage value) - { - return value == MessageBoxImage.Asterisk - || value == MessageBoxImage.Error - || value == MessageBoxImage.Exclamation - || value == MessageBoxImage.Hand - || value == MessageBoxImage.Information - || value == MessageBoxImage.None - || value == MessageBoxImage.Question - || value == MessageBoxImage.Stop - || value == MessageBoxImage.Warning; - } - - private static bool IsValidMessageBoxResult(MessageBoxResult value) - { - return value == MessageBoxResult.Cancel - || value == MessageBoxResult.No - || value == MessageBoxResult.None - || value == MessageBoxResult.OK - || value == MessageBoxResult.Yes; - } - } -} \ No newline at end of file diff --git a/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj b/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj index f1cc4dab..f214ec89 100644 --- a/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj +++ b/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj @@ -70,10 +70,6 @@ XamlIntelliSenseFileGenerator - - - - 3.0.1 diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj index 6316de29..605955ac 100644 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj +++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj @@ -93,21 +93,6 @@ NoUserContent.xaml - - - - - - - - - - - - - - - diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/ChatBoxViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/ChatBoxViewModel.cs deleted file mode 100644 index aa959105..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/ChatBoxViewModel.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Media; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media.Imaging; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using GalaSoft.MvvmLight.Messaging; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControl.Tools; -using HandyControlDemo.Data; -using HandyControlDemo.Tools; -using Microsoft.Win32; - -namespace HandyControlDemo.ViewModel -{ - public class ChatBoxViewModel : ViewModelBase - { - private static readonly string AudioCachePath = $"{AppDomain.CurrentDomain.BaseDirectory}Cache"; - - private readonly string _id = Guid.NewGuid().ToString(); - - private readonly Stopwatch _stopwatch = new Lazy(() => new Stopwatch()).Value; - - public ChatBoxViewModel() - { - Messenger.Default.Register(this, MessageToken.SendChatMessage, ReceiveMessage); - } - - private void ReceiveMessage(ChatInfoModel info) - { - if (_id.Equals(info.SenderId)) return; - info.Role = ChatRoleType.Receiver; - ChatInfos.Add(info); - } - - private string _chatString; - - public string ChatString - { - get => _chatString; - set => Set(ref _chatString, value); - } - - public ObservableCollection ChatInfos { get; set; } = new ObservableCollection(); - - public RelayCommand SendStringCmd => new Lazy>(() => - new RelayCommand(SendString)).Value; - - private void SendString(KeyEventArgs e) - { - if (e.Key == Key.Enter) - { - if (string.IsNullOrEmpty(ChatString)) return; - var info = new ChatInfoModel - { - Message = ChatString, - SenderId = _id, - Type = ChatMessageType.String, - Role = ChatRoleType.Sender - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - ChatString = string.Empty; - } - } - - public RelayCommand ReadMessageCmd => new Lazy>(() => - new RelayCommand(ReadMessage)).Value; - - private void ReadMessage(RoutedEventArgs e) - { - if (e.OriginalSource is FrameworkElement element && element.Tag is ChatInfoModel info) - { - if (info.Type == ChatMessageType.Image) - { - new ImageBrowser(new Uri(info.Enclosure.ToString())) - { - Owner = VisualHelper.GetActiveWindow() - }.Show(); - } - else if (info.Type == ChatMessageType.Audio) - { - var player = new SoundPlayer(info.Enclosure.ToString()); - player.PlaySync(); - } - } - } - - public RelayCommand StartRecordCmd => new Lazy(() => - new RelayCommand(StartRecord)).Value; - - private void StartRecord() - { - ExternDllHelper.MciSendString("set wave bitpersample 8", "", 0, 0); - ExternDllHelper.MciSendString("set wave samplespersec 20000", "", 0, 0); - ExternDllHelper.MciSendString("set wave channels 2", "", 0, 0); - ExternDllHelper.MciSendString("set wave format tag pcm", "", 0, 0); - ExternDllHelper.MciSendString("open new type WAVEAudio alias movie", "", 0, 0); - ExternDllHelper.MciSendString("record movie", "", 0, 0); - - _stopwatch.Reset(); - _stopwatch.Start(); - } - - public RelayCommand StopRecordCmd => new Lazy(() => - new RelayCommand(StopRecord)).Value; - - private void StopRecord() - { - if (!Directory.Exists(AudioCachePath)) - { - try - { - Directory.CreateDirectory(AudioCachePath); - } - catch (Exception e) - { - Growl.Error(e.Message); - return; - } - } - - var cachePath = $"{AudioCachePath}\\{Guid.NewGuid().ToString()}"; - ExternDllHelper.MciSendString("stop movie", "", 0, 0); - ExternDllHelper.MciSendString($"save movie {cachePath}", "", 0, 0); - ExternDllHelper.MciSendString("close movie", "", 0, 0); - - _stopwatch.Stop(); - - var info = new ChatInfoModel - { - Message = $"{_stopwatch.Elapsed.Seconds.ToString()} {Properties.Langs.Lang.Second}", - SenderId = _id, - Type = ChatMessageType.Audio, - Role = ChatRoleType.Sender, - Enclosure = cachePath - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - } - - public RelayCommand OpenImageCmd => new Lazy(() => - new RelayCommand(OpenImage)).Value; - - private void OpenImage() - { - var dialog = new OpenFileDialog(); - if (dialog.ShowDialog() == true) - { - var fileName = dialog.FileName; - if (File.Exists(fileName)) - { - var info = new ChatInfoModel - { - Message = BitmapFrame.Create(new Uri(fileName)), - SenderId = _id, - Type = ChatMessageType.Image, - Role = ChatRoleType.Sender, - Enclosure = fileName - }; - ChatInfos.Add(info); - Messenger.Default.Send(info, MessageToken.SendChatMessage); - } - } - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/InteractiveDialogViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/InteractiveDialogViewModel.cs deleted file mode 100644 index 6566c970..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Basic/InteractiveDialogViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Tools.Extension; - -namespace HandyControlDemo.ViewModel.Basic -{ - public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable - { - public Action CloseAction { get; set; } - - private string _result; - - public string Result - { - get => _result; - set => Set(ref _result, value); - } - - private string _message; - - public string Message - { - get => _message; - set => Set(ref _message, value); - } - - public RelayCommand CloseCmd => new Lazy(() => new RelayCommand(() => CloseAction?.Invoke())).Value; - } -} diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/BadgeDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/BadgeDemoViewModel.cs deleted file mode 100644 index d12b1d55..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/BadgeDemoViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; - -namespace HandyControlDemo.ViewModel.Controls -{ - public class BadgeDemoViewModel : ViewModelBase - { - private int _count = 1; - - public int Count - { - get => _count; - set => Set(ref _count, value); - } - - public RelayCommand CountCmd => new Lazy(() => - new RelayCommand(() => Count++)).Value; - } -} diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/DialogDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/DialogDemoViewModel.cs deleted file mode 100644 index 02048357..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/DialogDemoViewModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Threading.Tasks; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControl.Tools.Extension; -using HandyControlDemo.UserControl; -using HandyControlDemo.UserControl.Basic; -using HandyControlDemo.ViewModel.Basic; - -namespace HandyControlDemo.ViewModel -{ - public class DialogDemoViewModel : ViewModelBase - { - private string _dialogResult; - - public string DialogResult - { - get => _dialogResult; - set => Set(ref _dialogResult, value); - } - - public RelayCommand ShowTextCmd => new Lazy(() => - new RelayCommand(ShowText)).Value; - - private void ShowText() - { - Dialog.Show(new TextDialog()); - } - - public RelayCommand ShowInteractiveDialogCmd => new Lazy(() => - new RelayCommand(async () => await ShowInteractiveDialog())).Value; - - private async Task ShowInteractiveDialog() - { - DialogResult = await Dialog.Show() - .Initialize(vm => vm.Message = DialogResult) - .GetResultAsync(); - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/GrowlDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/GrowlDemoViewModel.cs deleted file mode 100644 index 567367a5..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/GrowlDemoViewModel.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControlDemo.Window; - -namespace HandyControlDemo.ViewModel -{ - public class GrowlDemoViewModel - { - private readonly string _token; - - public GrowlDemoViewModel() - { - - } - - public GrowlDemoViewModel(string token) - { - _token = token; - } - - public RelayCommand InfoCmd => new Lazy(() => - new RelayCommand(() => Growl.Info(Properties.Langs.Lang.GrowlInfo, _token))).Value; - - public RelayCommand SuccessCmd => new Lazy(() => - new RelayCommand(() => Growl.Success(Properties.Langs.Lang.GrowlSuccess, _token))).Value; - - public RelayCommand WarningCmd => new Lazy(() => - 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(() => - new RelayCommand(() => Growl.Error(Properties.Langs.Lang.GrowlError, _token))).Value; - - public RelayCommand AskCmd => new Lazy(() => - new RelayCommand(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, isConfirmed => - { - Growl.Info(isConfirmed.ToString()); - return true; - }, _token))).Value; - - public RelayCommand FatalCmd => new Lazy(() => - new RelayCommand(() => Growl.Fatal(new GrowlInfo - { - Message = Properties.Langs.Lang.GrowlFatal, - ShowDateTime = false, - Token = _token - }))).Value; - - public RelayCommand ClearCmd => new Lazy(() => - new RelayCommand(() => Growl.Clear(_token))).Value; - - public RelayCommand NewWindowCmd => new Lazy(() => - new RelayCommand(() => new GrowlDemoWindow().Show())).Value; - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/ImageBrowserDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/ImageBrowserDemoViewModel.cs deleted file mode 100644 index 2324a4e7..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/ImageBrowserDemoViewModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using GalaSoft.MvvmLight.CommandWpf; -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/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/NotifyIconDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/NotifyIconDemoViewModel.cs deleted file mode 100644 index 77456549..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/NotifyIconDemoViewModel.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControlDemo.Data; - -namespace HandyControlDemo.ViewModel -{ - public class NotifyIconDemoViewModel : ViewModelBase - { - private bool _contextMenuIsShow; - - public bool ContextMenuIsShow - { - get => _contextMenuIsShow; - set - { - Set(ref _contextMenuIsShow, value); - GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; - } - } - - private bool _contextMenuIsBlink; - - public bool ContextMenuIsBlink - { - get => _contextMenuIsBlink; - set => Set(ref _contextMenuIsBlink, value); - } - - private bool _contextContentIsShow; - - public bool ContextContentIsShow - { - get => _contextContentIsShow; - set - { - Set(ref _contextContentIsShow, value); - GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; - } - } - - private bool _contextContentIsBlink; - - public bool ContextContentIsBlink - { - get => _contextContentIsBlink; - set => Set(ref _contextContentIsBlink, value); - } - - public RelayCommand MouseCmd => new Lazy>(() => - new RelayCommand(str=> Growl.Info(str.ToString()))).Value; - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/PaginationDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/PaginationDemoViewModel.cs deleted file mode 100644 index 26420e20..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/PaginationDemoViewModel.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Data; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class PaginationDemoViewModel : DemoViewModelBase - { - /// - /// 所有数据 - /// - private readonly List _totalDataList; - - /// - /// 页码 - /// - private int _pageIndex = 1; - - /// - /// 页码 - /// - public int PageIndex - { - get => _pageIndex; - set => Set(ref _pageIndex, value); - } - - public PaginationDemoViewModel(DataService dataService) - { - _totalDataList = dataService.GetDemoDataList(100); - DataList = _totalDataList.Take(10).ToList(); - } - - /// - /// 页码改变命令 - /// - public RelayCommand> PageUpdatedCmd => - new Lazy>>(() => - new RelayCommand>(PageUpdated)).Value; - - /// - /// 页码改变 - /// - private void PageUpdated(FunctionEventArgs info) - { - DataList = _totalDataList.Skip((info.Info - 1) * 10).Take(10).ToList(); - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/SearchBarDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/SearchBarDemoViewModel.cs deleted file mode 100644 index d854c035..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/SearchBarDemoViewModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; - -namespace HandyControlDemo.ViewModel -{ - public class SearchBarDemoViewModel : ViewModelBase - { - public RelayCommand SearchCmd => new Lazy>(() => - new RelayCommand(Search)).Value; - - private void Search(string key) - { - Growl.Info(key); - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/StepBarDemoViewModel.cs deleted file mode 100644 index d2bba196..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/StepBarDemoViewModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Linq; -using System.Windows.Controls; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControl.Controls; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class StepBarDemoViewModel : DemoViewModelBase - { - public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList(); - - /// - /// 下一步 - /// - public RelayCommand NextCmd => new Lazy>(() => new RelayCommand(Next)).Value; - - /// - /// 上一步 - /// - public RelayCommand PrevCmd => new Lazy>(() => new RelayCommand(Prev)).Value; - - private void Next(Panel panel) - { - foreach (var stepBar in panel.Children.OfType()) - { - stepBar.Next(); - } - } - - private void Prev(Panel panel) - { - foreach (var stepBar in panel.Children.OfType()) - { - stepBar.Prev(); - } - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/WindowDemoViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/WindowDemoViewModel.cs deleted file mode 100644 index 9e694c94..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Controls/WindowDemoViewModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Windows; -using GalaSoft.MvvmLight.CommandWpf; -using HandyControlDemo.Tools; - -namespace HandyControlDemo.ViewModel -{ - public class WindowDemoViewModel - { - public RelayCommand OpenWindowCmd => new Lazy>(() => new RelayCommand(OpenWindow)).Value; - - private void OpenWindow(string windowTag) - { - if (AssemblyHelper.CreateInternalInstance($"Window.{windowTag}") is System.Windows.Window window) - { - window.Owner = Application.Current.MainWindow; - window.ShowDialog(); - } - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/DemoViewModelBase!1.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/DemoViewModelBase!1.cs deleted file mode 100644 index 7714d2db..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/DemoViewModelBase!1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using GalaSoft.MvvmLight; - -namespace HandyControlDemo.ViewModel -{ - public class DemoViewModelBase : ViewModelBase - { - /// - /// 数据列表 - /// - private IList _dataList; - - /// - /// 数据列表 - /// - public IList DataList - { - get => _dataList; - set => Set(ref _dataList, value); - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/ContributorsViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/ContributorsViewModel.cs deleted file mode 100644 index 5045e447..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/ContributorsViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Threading.Tasks; -using HandyControlDemo.Data; -using HandyControlDemo.Service; - -namespace HandyControlDemo.ViewModel -{ - public class ContributorsViewModel : DemoViewModelBase - { - public ContributorsViewModel(DataService dataService) - { - Task.Run(() => - { - DataList = dataService.GetContributorDataList(); - }); - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/MainViewModel.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/MainViewModel.cs deleted file mode 100644 index b580666f..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/Main/MainViewModel.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Windows.Controls; -using GalaSoft.MvvmLight.CommandWpf; -using GalaSoft.MvvmLight.Messaging; -using HandyControlDemo.Data; -using HandyControlDemo.Service; -using HandyControlDemo.Tools; - -namespace HandyControlDemo.ViewModel -{ - public class MainViewModel : DemoViewModelBase - { - #region 字段 - - /// - /// 内容标题 - /// - private object _contentTitle; - - /// - /// 子内容 - /// - private object _subContent; - - /// - /// 当前选中的列表项 - /// - private ListBoxItem _listBoxItemCurrent; - - #endregion - - public MainViewModel(DataService dataService) - { - Messenger.Default.Register(this, MessageToken.LoadShowContent, obj => - { - if (SubContent is IDisposable disposable) - { - disposable.Dispose(); - } - SubContent = obj; - }); - Messenger.Default.Register(this, MessageToken.ClearLeftSelected, obj => - { - if (_listBoxItemCurrent == null) return; - _listBoxItemCurrent.IsSelected = false; - _listBoxItemCurrent = null; - }); - DataList = dataService.GetDemoDataList(); - } - - #region 属性 - - /// - /// 子内容 - /// - 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(SelectionChangedEventArgs e) - { - if (e.AddedItems.Count == 0) return; - if (e.AddedItems[0] is ListBoxItem item) - { - if (item.Tag is string tag) - { - if (Equals(_listBoxItemCurrent, item)) return; - _listBoxItemCurrent = item; - ContentTitle = item.Content; - Messenger.Default.Send(false, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{tag}"), MessageToken.LoadShowContent); - } - else - { - _listBoxItemCurrent = null; - ContentTitle = null; - SubContent = null; - } - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/ViewModelLocator.cs b/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/ViewModelLocator.cs deleted file mode 100644 index e7f59c12..00000000 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/ViewModel/ViewModelLocator.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Windows; -using CommonServiceLocator; -using GalaSoft.MvvmLight.Ioc; -using HandyControlDemo.Data; -using HandyControlDemo.Service; -using HandyControlDemo.ViewModel.Basic; -using HandyControlDemo.ViewModel.Controls; - -namespace HandyControlDemo.ViewModel -{ - public class ViewModelLocator - { - public ViewModelLocator() - { - ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - - SimpleIoc.Default.Register(); - - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(() => new GrowlDemoViewModel(), "GrowlDemo"); - SimpleIoc.Default.Register(() => new GrowlDemoViewModel(MessageToken.GrowlDemoPanel), "GrowlDemoWithToken"); - 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 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("GrowlDemo"); - - public GrowlDemoViewModel GrowlDemoWithToken => ServiceLocator.Current.GetInstance("GrowlDemoWithToken"); - - public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance(); - - public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance(); - - public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance(); - - public ContributorsViewModel ContributorsView => ServiceLocator.Current.GetInstance(); - - public StepBarDemoViewModel StepBarDemo => ServiceLocator.Current.GetInstance(); - - public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance(); - - public ChatBoxViewModel ChatBox => new ChatBoxViewModel(); - - public CoverViewModel CoverView => ServiceLocator.Current.GetInstance(); - - public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance(); - - public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance(); - - public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance(); - - public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance(); - - public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance(); - #endregion - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControl_Net_GE45/Controls/Other/Growl.cs b/src/Net_GE45/HandyControl_Net_GE45/Controls/Other/Growl.cs deleted file mode 100644 index 31b3c932..00000000 --- a/src/Net_GE45/HandyControl_Net_GE45/Controls/Other/Growl.cs +++ /dev/null @@ -1,601 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Threading; -using HandyControl.Data; -using HandyControl.Interactivity; -using HandyControl.Tools; -using HandyControl.Tools.Extension; - -namespace HandyControl.Controls -{ - /// - /// 消息提醒 - /// - [TemplatePart(Name = ElementPanelMore, Type = typeof(Panel))] - [TemplatePart(Name = ElementGridMain, Type = typeof(Grid))] - [TemplatePart(Name = ElementButtonClose, Type = typeof(Button))] - public class Growl : Control - { - #region Constants - - private const string ElementPanelMore = "PART_PanelMore"; - private const string ElementGridMain = "PART_GridMain"; - private const string ElementButtonClose = "PART_ButtonClose"; - - #endregion Constants - - #region Data - - private Panel _panelMore; - - private Grid _gridMain; - - private Button _buttonClose; - - private bool _showCloseButton; - - private bool _staysOpen; - - private int _waitTime = 6; - - /// - /// 计数 - /// - private int _tickCount; - - /// - /// 关闭计时器 - /// - private DispatcherTimer _timerClose; - - private static readonly Dictionary PanelDic = new Dictionary(); - - #endregion Data - - public Growl() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick)); - CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancel_OnClick)); - CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick)); - } - - public static void Register(string token, Panel panel) - { - if (string.IsNullOrEmpty(token) || panel == null) return; - PanelDic[token] = panel; - InitGrowlPanel(panel); - } - - public static void Unregister(string token, Panel panel) - { - if (string.IsNullOrEmpty(token) || panel == null) return; - - if (PanelDic.ContainsKey(token)) - { - if (ReferenceEquals(PanelDic[token], panel)) - { - PanelDic.Remove(token); - panel.ContextMenu = null; - panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue); - } - } - } - - public static void Unregister(Panel panel) - { - if (panel == null) return; - var first = PanelDic.FirstOrDefault(item => ReferenceEquals(panel, item.Value)); - if (!string.IsNullOrEmpty(first.Key)) - { - PanelDic.Remove(first.Key); - panel.ContextMenu = null; - panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue); - } - } - - protected override void OnMouseEnter(MouseEventArgs e) - { - base.OnMouseEnter(e); - - _buttonClose.Show(_showCloseButton); - } - - protected override void OnMouseLeave(MouseEventArgs e) - { - base.OnMouseLeave(e); - - _buttonClose.Collapse(); - } - - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - _panelMore = GetTemplateChild(ElementPanelMore) as Panel; - _gridMain = GetTemplateChild(ElementGridMain) as Grid; - _buttonClose = GetTemplateChild(ElementButtonClose) as Button; - - CheckNull(); - Update(); - } - - private void CheckNull() - { - if (_panelMore == null || _gridMain == null || _buttonClose == null) throw new Exception(); - } - - private Func ActionBeforeClose { get; set; } - - /// - /// 消息容器 - /// - public static Panel GrowlPanel { get; set; } - - internal static readonly DependencyProperty CancelStrProperty = DependencyProperty.Register( - "CancelStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); - - internal static readonly DependencyProperty ConfirmStrProperty = DependencyProperty.Register( - "ConfirmStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); - - public static readonly DependencyProperty ShowDateTimeProperty = DependencyProperty.Register( - "ShowDateTime", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.TrueBox)); - - 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))); - - public static readonly DependencyProperty TypeProperty = DependencyProperty.Register( - "Type", typeof(InfoType), typeof(Growl), new PropertyMetadata(default(InfoType))); - - public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached( - "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) => - { - if ((bool)args.NewValue && o is Panel panel) - { - SetGrowlPanel(panel); - } - })); - - public static readonly DependencyProperty TokenProperty = DependencyProperty.RegisterAttached( - "Token", typeof(string), typeof(Growl), new PropertyMetadata(default(string), OnTokenChanged)); - - private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is Panel panel) - { - if (e.NewValue == null) - { - Unregister(panel); - } - else - { - Register(e.NewValue.ToString(), panel); - } - } - } - - public static void SetToken(DependencyObject element, string value) - => element.SetValue(TokenProperty, value); - - public static string GetToken(DependencyObject element) - => (string) element.GetValue(TokenProperty); - - public static void SetGrowlParent(DependencyObject element, bool value) => element.SetValue(GrowlParentProperty, value); - - public static bool GetGrowlParent(DependencyObject element) => (bool)element.GetValue(GrowlParentProperty); - - public InfoType Type - { - get => (InfoType)GetValue(TypeProperty); - set => SetValue(TypeProperty, value); - } - - internal string CancelStr - { - get => (string)GetValue(CancelStrProperty); - set => SetValue(CancelStrProperty, value); - } - - internal string ConfirmStr - { - get => (string)GetValue(ConfirmStrProperty); - set => SetValue(ConfirmStrProperty, value); - } - - public bool ShowDateTime - { - get => (bool)GetValue(ShowDateTimeProperty); - set => SetValue(ShowDateTimeProperty, value); - } - - 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 >= _waitTime) Close(); - }; - _timerClose.Start(); - } - - /// - /// 消息容器 - /// - /// - private static void SetGrowlPanel(Panel panel) - { - GrowlPanel = panel; - InitGrowlPanel(panel); - } - - private static void InitGrowlPanel(Panel panel) - { - var menuItem = new MenuItem - { - Header = Properties.Langs.Lang.Clear - }; - menuItem.Click += (s, e) => - { - foreach (var item in panel.Children.OfType()) - { - item.Close(); - } - }; - panel.ContextMenu = new ContextMenu - { - Items = - { - menuItem - } - }; - - PanelElement.SetFluidMoveBehavior(panel, ResourceHelper.GetResource(ResourceToken.BehaviorXY400)); - } - - private void Update() - { - if (ActionBeforeClose != null) - { - _staysOpen = true; - _showCloseButton = false; - _panelMore.IsEnabled = true; - _panelMore.Show(); - } - - var transform = new TranslateTransform - { - X = MaxWidth - }; - _gridMain.RenderTransform = transform; - transform.BeginAnimation(TranslateTransform.XProperty, AnimationHelper.CreateAnimation(0)); - if (!_staysOpen) StartTimer(); - } - - /// - /// 显示信息 - /// - /// - private static void Show(GrowlInfo growlInfo) - { - Application.Current.Dispatcher.Invoke(() => - { - var ctl = new Growl - { - Message = growlInfo.Message, - Time = DateTime.Now, - Icon = ResourceHelper.GetResource(growlInfo.IconKey), - IconBrush = ResourceHelper.GetResource(growlInfo.IconBrushKey), - _showCloseButton = growlInfo.ShowCloseButton, - ActionBeforeClose = growlInfo.ActionBeforeClose, - _staysOpen = growlInfo.StaysOpen, - ShowDateTime = growlInfo.ShowDateTime, - ConfirmStr = growlInfo.ConfirmStr, - CancelStr = growlInfo.CancelStr, - Type = growlInfo.Type, - _waitTime = Math.Max(growlInfo.WaitTime, 2) - }; - if (!string.IsNullOrEmpty(growlInfo.Token)) - { - if (PanelDic.TryGetValue(growlInfo.Token, out var panel)) - { - panel?.Children.Insert(0, ctl); - } - } - else - { - GrowlPanel.Children.Insert(0, ctl); - } - }); - } - - /// - /// 成功 - /// - /// - /// - public static void Success(string message, string token = "") => Success(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 成功 - /// - /// - public static void Success(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.SuccessGeometry; - growlInfo.IconBrushKey = ResourceToken.SuccessBrush; - growlInfo.Type = InfoType.Success; - } - Show(growlInfo); - } - - /// - /// 消息 - /// - /// - /// - public static void Info(string message, string token = "") => Info(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 消息 - /// - /// - public static void Info(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.InfoGeometry; - growlInfo.IconBrushKey = ResourceToken.InfoBrush; - growlInfo.Type = InfoType.Info; - } - Show(growlInfo); - } - - /// - /// 警告 - /// - /// - /// - public static void Warning(string message, string token = "") => Warning(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 警告 - /// - /// - public static void Warning(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.WarningGeometry; - growlInfo.IconBrushKey = ResourceToken.WarningBrush; - growlInfo.Type = InfoType.Warning; - } - Show(growlInfo); - } - - /// - /// 错误 - /// - /// - /// - public static void Error(string message, string token = "") => Error(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 错误 - /// - /// - public static void Error(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.ErrorGeometry; - growlInfo.IconBrushKey = ResourceToken.DangerBrush; - growlInfo.StaysOpen = true; - growlInfo.Type = InfoType.Error; - } - Show(growlInfo); - } - - /// - /// 严重 - /// - /// - /// - public static void Fatal(string message, string token = "") => Fatal(new GrowlInfo - { - Message = message, - Token = token - }); - - /// - /// 严重 - /// - /// - public static void Fatal(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.FatalGeometry; - growlInfo.IconBrushKey = ResourceToken.PrimaryTextBrush; - growlInfo.StaysOpen = true; - growlInfo.ShowCloseButton = false; - growlInfo.Type = InfoType.Fatal; - if (GrowlPanel.ContextMenu != null) GrowlPanel.ContextMenu.Opacity = 0; - } - Show(growlInfo); - } - - /// - /// 询问 - /// - /// - /// - /// - public static void Ask(string message, Func actionBeforeClose, string token = "") => Ask(new GrowlInfo - { - Message = message, - ActionBeforeClose = actionBeforeClose, - Token = token - }); - - /// - /// 询问 - /// - /// - public static void Ask(GrowlInfo growlInfo) - { - if (growlInfo == null) throw new ArgumentNullException(nameof(growlInfo)); - if (!growlInfo.IsCustom) - { - growlInfo.IconKey = ResourceToken.AskGeometry; - growlInfo.IconBrushKey = ResourceToken.AccentBrush; - growlInfo.StaysOpen = true; - growlInfo.ShowCloseButton = false; - growlInfo.Type = InfoType.Ask; - } - Show(growlInfo); - } - - 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 += (s, e) => - { - if (Parent is Panel panel) - { - panel.Children.Remove(this); - } - }; - transform.BeginAnimation(TranslateTransform.XProperty, animation); - } - - /// - /// 清除 - /// - /// - public static void Clear(string token = "") - { - if (!string.IsNullOrEmpty(token)) - { - if (PanelDic.TryGetValue(token, out var panel)) - { - Clear(panel); - } - } - else - { - Clear(GrowlPanel); - } - } - - /// - /// 清除 - /// - /// - private static void Clear(Panel panel) - { - panel.Children.Clear(); - if (panel.ContextMenu != null) - { - panel.ContextMenu.IsOpen = false; - panel.ContextMenu.Opacity = 1; - } - } - - private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) - { - if (ActionBeforeClose?.Invoke(false) == true) - { - Close(); - } - } - - private void ButtonOk_OnClick(object sender, RoutedEventArgs e) - { - if (ActionBeforeClose?.Invoke(true) == true) - { - Close(); - } - } - } -} \ No newline at end of file diff --git a/src/Net_GE45/HandyControl_Net_GE45/Controls/Window/MessageBox.cs b/src/Net_GE45/HandyControl_Net_GE45/Controls/Window/MessageBox.cs deleted file mode 100644 index 67342fd7..00000000 --- a/src/Net_GE45/HandyControl_Net_GE45/Controls/Window/MessageBox.cs +++ /dev/null @@ -1,436 +0,0 @@ -using System; -using System.ComponentModel; -using System.Text; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media; -using HandyControl.Data; -using HandyControl.Interactivity; -using HandyControl.Tools; - -namespace HandyControl.Controls -{ - /// - /// 消息框 - /// - public sealed class MessageBox : Window - { - private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel; - - private bool _showOk; - - private bool _showCancel; - - private bool _showYes; - - private bool _showNo; - - public static readonly DependencyProperty MessageProperty = DependencyProperty.Register( - "Message", typeof(string), typeof(MessageBox), new PropertyMetadata(default(string))); - - public string Message - { - get => (string) GetValue(MessageProperty); - set => SetValue(MessageProperty, value); - } - - public static readonly DependencyProperty ImageProperty = DependencyProperty.Register( - "Image", typeof(Geometry), typeof(MessageBox), new PropertyMetadata(default(Geometry))); - - public Geometry Image - { - get => (Geometry) GetValue(ImageProperty); - set => SetValue(ImageProperty, value); - } - - public static readonly DependencyProperty ImageBrushProperty = DependencyProperty.Register( - "ImageBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(default(Brush))); - - public Brush ImageBrush - { - get => (Brush) GetValue(ImageBrushProperty); - set => SetValue(ImageBrushProperty, value); - } - - public static readonly DependencyProperty ShowImageProperty = DependencyProperty.Register( - "ShowImage", typeof(bool), typeof(MessageBox), new PropertyMetadata(ValueBoxes.FalseBox)); - - public bool ShowImage - { - get => (bool) GetValue(ShowImageProperty); - set => SetValue(ShowImageProperty, value); - } - - private MessageBox() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, (s, e) => - { - _messageBoxResult = MessageBoxResult.OK; - Close(); - }, (s, e) => e.CanExecute = _showOk)); - CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, (s, e) => - { - _messageBoxResult = MessageBoxResult.Cancel; - Close(); - }, (s, e) => e.CanExecute = _showCancel)); - CommandBindings.Add(new CommandBinding(ControlCommands.Yes, (s, e) => - { - _messageBoxResult = MessageBoxResult.Yes; - Close(); - }, (s, e) => e.CanExecute = _showYes)); - CommandBindings.Add(new CommandBinding(ControlCommands.No, (s, e) => - { - _messageBoxResult = MessageBoxResult.No; - Close(); - }, (s, e) => e.CanExecute = _showNo)); - } - - protected override void OnPreviewKeyDown(KeyEventArgs e) - { - base.OnPreviewKeyDown(e); - - if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.C) - { - var builder = new StringBuilder(); - var line = new string('-', 27); - builder.Append(line); - builder.Append(Environment.NewLine); - builder.Append(Title); - builder.Append(Environment.NewLine); - builder.Append(line); - builder.Append(Environment.NewLine); - builder.Append(Message); - builder.Append(Environment.NewLine); - builder.Append(line); - builder.Append(Environment.NewLine); - if (_showOk) - { - builder.Append(Properties.Langs.Lang.Confirm); - builder.Append(" "); - } - if (_showYes) - { - builder.Append(Properties.Langs.Lang.Yes); - builder.Append(" "); - } - if (_showNo) - { - builder.Append(Properties.Langs.Lang.No); - builder.Append(" "); - } - if (_showCancel) - { - builder.Append(Properties.Langs.Lang.Cancel); - builder.Append(" "); - } - builder.Append(Environment.NewLine); - builder.Append(line); - builder.Append(Environment.NewLine); - Clipboard.SetText(builder.ToString()); - } - } - - /// - /// 成功 - /// - /// - /// - public static MessageBoxResult Success(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(ResourceToken.SuccessGeometry); - messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.SuccessBrush); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 消息 - /// - /// - /// - public static MessageBoxResult Info(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Information); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 警告 - /// - /// - /// - public static MessageBoxResult Warning(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Warning); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 错误 - /// - /// - /// - public static MessageBoxResult Error(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - SetImage(messageBox, MessageBoxImage.Error); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 严重 - /// - /// - /// - public static MessageBoxResult Fatal(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - SetButtonStatus(messageBox, MessageBoxButton.OK); - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(ResourceToken.FatalGeometry); - messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.PrimaryTextBrush); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 询问 - /// - /// - /// - public static MessageBoxResult Ask(string messageBoxText, string caption = null) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); - SetButtonStatus(messageBox, MessageBoxButton.OKCancel); - SetImage(messageBox, MessageBoxImage.Question); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 自定义信息展示 - /// - /// - /// - public static MessageBoxResult Show(MessageBoxInfo info) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(null, info.MessageBoxText, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult); - SetButtonStatus(messageBox, info.Button); - - if (!string.IsNullOrEmpty(info.IconKey)) - { - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(info.IconKey); - messageBox.ImageBrush = ResourceHelper.GetResource(info.IconBrushKey); - } - - messageBox.Style = info.Style; - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - /// - /// 信息展示 - /// - /// - /// - /// - /// - /// - /// - public static MessageBoxResult Show(string messageBoxText, string caption = null, - MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, - MessageBoxResult defaultResult = MessageBoxResult.None) => - Show(null, messageBoxText, caption, button, icon, defaultResult); - - /// - /// 信息展示 - /// - /// - /// - /// - /// - /// - /// - /// - public static MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption = null, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) - { - MessageBox messageBox = null; - Application.Current.Dispatcher.Invoke(() => - { - messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult); - SetButtonStatus(messageBox, button); - SetImage(messageBox, icon); - messageBox.ShowDialog(); - }); - - return messageBox._messageBoxResult; - } - - private static MessageBox CreateMessageBox( - System.Windows.Window owner, - string messageBoxText, - string caption, - MessageBoxButton button, - MessageBoxImage icon, - MessageBoxResult defaultResult) - { - if (!IsValidMessageBoxButton(button)) - { - throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(MessageBoxButton)); - } - if (!IsValidMessageBoxImage(icon)) - { - throw new InvalidEnumArgumentException(nameof(icon), (int)icon, typeof(MessageBoxImage)); - } - if (!IsValidMessageBoxResult(defaultResult)) - { - throw new InvalidEnumArgumentException(nameof(defaultResult), (int)defaultResult, typeof(MessageBoxResult)); - } - - var ownerWindow = owner ?? VisualHelper.GetActiveWindow(); - var ownerIsNull = ownerWindow is null; - - return new MessageBox - { - Message = messageBoxText, - Owner = ownerWindow, - WindowStartupLocation = WindowStartupLocation.CenterScreen, - ShowTitle = true, - Title = caption ?? string.Empty, - Topmost = ownerIsNull, - _messageBoxResult = defaultResult - }; - } - - private static void SetButtonStatus(MessageBox messageBox, MessageBoxButton messageBoxButton) - { - switch (messageBoxButton) - { - case MessageBoxButton.OK: - messageBox._showOk = true; - break; - case MessageBoxButton.OKCancel: - messageBox._showOk = true; - messageBox._showCancel = true; - break; - case MessageBoxButton.YesNo: - messageBox._showYes = true; - messageBox._showNo = true; - break; - case MessageBoxButton.YesNoCancel: - messageBox._showYes = true; - messageBox._showNo = true; - messageBox._showCancel = true; - break; - } - } - - private static void SetImage(MessageBox messageBox, MessageBoxImage messageBoxImage) - { - var iconKey = string.Empty; - var iconBrushKey = string.Empty; - - switch (messageBoxImage) - { - case MessageBoxImage.Error: - iconKey = ResourceToken.ErrorGeometry; - iconBrushKey = ResourceToken.DangerBrush; - break; - case MessageBoxImage.Question: - iconKey = ResourceToken.AskGeometry; - iconBrushKey = ResourceToken.AccentBrush; - break; - case MessageBoxImage.Warning: - iconKey = ResourceToken.WarningGeometry; - iconBrushKey = ResourceToken.WarningBrush; - break; - case MessageBoxImage.Information: - iconKey = ResourceToken.InfoGeometry; - iconBrushKey = ResourceToken.InfoBrush; - break; - } - - if (string.IsNullOrEmpty(iconKey)) return; - messageBox.ShowImage = true; - messageBox.Image = ResourceHelper.GetResource(iconKey); - messageBox.ImageBrush = ResourceHelper.GetResource(iconBrushKey); - } - - private static bool IsValidMessageBoxButton(MessageBoxButton value) - { - return value == MessageBoxButton.OK - || value == MessageBoxButton.OKCancel - || value == MessageBoxButton.YesNo - || value == MessageBoxButton.YesNoCancel; - } - - private static bool IsValidMessageBoxImage(MessageBoxImage value) - { - return value == MessageBoxImage.Asterisk - || value == MessageBoxImage.Error - || value == MessageBoxImage.Exclamation - || value == MessageBoxImage.Hand - || value == MessageBoxImage.Information - || value == MessageBoxImage.None - || value == MessageBoxImage.Question - || value == MessageBoxImage.Stop - || value == MessageBoxImage.Warning; - } - - private static bool IsValidMessageBoxResult(MessageBoxResult value) - { - return value == MessageBoxResult.Cancel - || value == MessageBoxResult.No - || value == MessageBoxResult.None - || value == MessageBoxResult.OK - || value == MessageBoxResult.Yes; - } - } -} diff --git a/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj b/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj index eaebb56e..034c95ab 100644 --- a/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj +++ b/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj @@ -116,10 +116,6 @@ Designer - - - - \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems index 018f5d85..a217f899 100644 --- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems +++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems @@ -273,8 +273,23 @@ TreeViewDemoCtl.xaml + + + + + + + + + + + + + + + AboutWindow.xaml diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml deleted file mode 100644 index b55926bd..00000000 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs deleted file mode 100644 index 8815da97..00000000 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.Diagnostics; -using System.Reflection; -using System.Windows; -using System.Windows.Controls; -using GalaSoft.MvvmLight.Messaging; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControlDemo.Data; -using HandyControlDemo.Tools; -using HandyControlDemo.Window; - - -namespace HandyControlDemo.UserControl -{ - public partial class NoUserContent - { - public NoUserContent() - { - InitializeComponent(); - } - - private void ButtonLangs_OnClick(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is Button button && button.Tag is string tag) - { - PopupConfig.IsOpen = false; - if (tag.Equals(GlobalData.Config.Lang)) return; - Growl.Ask(Properties.Langs.Lang.ChangeLangAsk, b => - { - if (!b) return true; - GlobalData.Config.Lang = tag; - GlobalData.Save(); - Process.Start(Process.GetCurrentProcess().MainModule.FileName); - Application.Current.Shutdown(); - return true; - }); - } - } - - private void ButtonConfig_OnClick(object sender, RoutedEventArgs e) => PopupConfig.IsOpen = true; - - private void ButtonSkins_OnClick(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is Button button && button.Tag is SkinType tag) - { - PopupConfig.IsOpen = false; - if (tag.Equals(GlobalData.Config.Skin)) return; - GlobalData.Config.Skin = tag; - GlobalData.Save(); - ((App)Application.Current).UpdateSkin(tag); - } - } - - private void MenuItemLinks_OnClick(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is MenuItem menuItem && menuItem.Tag is string tag) - { - Process.Start(tag); - } - } - - private void MenuItemQQGroup_OnClick(object sender, RoutedEventArgs e) - { - Messenger.Default.Send(null, MessageToken.ClearLeftSelected); - Messenger.Default.Send(true, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.QQGroupView}"), MessageToken.LoadShowContent); - } - - private void MenuItemContributors_OnClick(object sender, RoutedEventArgs e) - { - Messenger.Default.Send(null, MessageToken.ClearLeftSelected); - Messenger.Default.Send(true, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.ContributorsView}"), MessageToken.LoadShowContent); - } - - private void MenuAbout_OnClick(object sender, RoutedEventArgs e) - { - new AboutWindow - { - Owner = Application.Current.MainWindow - }.ShowDialog(); - } - } -} diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs index aa959105..4bc00623 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs @@ -7,7 +7,11 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media.Imaging; using GalaSoft.MvvmLight; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +#endif using GalaSoft.MvvmLight.Messaging; using HandyControl.Controls; using HandyControl.Data; @@ -43,7 +47,11 @@ namespace HandyControlDemo.ViewModel public string ChatString { get => _chatString; +#if netle40 + set => Set(nameof(ChatString), ref _chatString, value); +#else set => Set(ref _chatString, value); +#endif } public ObservableCollection ChatInfos { get; set; } = new ObservableCollection(); diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs index 6566c970..2406d7a3 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs @@ -1,6 +1,10 @@ using System; using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.CommandWpf; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif using HandyControl.Tools.Extension; namespace HandyControlDemo.ViewModel.Basic @@ -14,7 +18,11 @@ namespace HandyControlDemo.ViewModel.Basic public string Result { get => _result; - set => Set(ref _result, value); +#if netle40 + set => Set(nameof(Result), ref _result, value); +#else + set => Set(ref _result, value); +#endif } private string _message; @@ -22,7 +30,11 @@ namespace HandyControlDemo.ViewModel.Basic public string Message { get => _message; +#if netle40 + set => Set(nameof(Message), ref _message, value); +#else set => Set(ref _message, value); +#endif } public RelayCommand CloseCmd => new Lazy(() => new RelayCommand(() => CloseAction?.Invoke())).Value; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs index d12b1d55..ada4f4fe 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs @@ -1,6 +1,10 @@ using System; using GalaSoft.MvvmLight; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +#endif namespace HandyControlDemo.ViewModel.Controls { @@ -11,7 +15,11 @@ namespace HandyControlDemo.ViewModel.Controls public int Count { get => _count; +#if netle40 + set => Set(nameof(Count), ref _count, value); +#else set => Set(ref _count, value); +#endif } public RelayCommand CountCmd => new Lazy(() => diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs index 02048357..578939ea 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs @@ -1,7 +1,11 @@ using System; -using System.Threading.Tasks; using GalaSoft.MvvmLight; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else +using System.Threading.Tasks; using GalaSoft.MvvmLight.CommandWpf; +#endif using HandyControl.Controls; using HandyControl.Tools.Extension; using HandyControlDemo.UserControl; @@ -17,7 +21,11 @@ namespace HandyControlDemo.ViewModel public string DialogResult { get => _dialogResult; +#if netle40 + set => Set(nameof(DialogResult), ref _dialogResult, value); +#else set => Set(ref _dialogResult, value); +#endif } public RelayCommand ShowTextCmd => new Lazy(() => @@ -28,6 +36,17 @@ namespace HandyControlDemo.ViewModel Dialog.Show(new TextDialog()); } +#if netle40 + public RelayCommand ShowInteractiveDialogCmd => new Lazy(() => + new RelayCommand(ShowInteractiveDialog)).Value; + + private void ShowInteractiveDialog() + { + Dialog.Show() + .Initialize(vm => vm.Message = DialogResult) + .GetResultAsync().ContinueWith(str => DialogResult = str.Result); + } +#else public RelayCommand ShowInteractiveDialogCmd => new Lazy(() => new RelayCommand(async () => await ShowInteractiveDialog())).Value; @@ -37,5 +56,6 @@ namespace HandyControlDemo.ViewModel .Initialize(vm => vm.Message = DialogResult) .GetResultAsync(); } +#endif } } \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs index 1dc4ea54..384e3071 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs @@ -1,5 +1,9 @@ using System; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControl.Controls; using HandyControl.Data; using HandyControlDemo.Window; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs index 2324a4e7..fb1fa279 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs @@ -1,5 +1,9 @@ using System; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControl.Controls; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs index 77456549..72ae46b6 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs @@ -1,6 +1,10 @@ using System; using GalaSoft.MvvmLight; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControl.Controls; using HandyControlDemo.Data; @@ -15,7 +19,11 @@ namespace HandyControlDemo.ViewModel get => _contextMenuIsShow; set { +#if netle40 + Set(nameof(ContextMenuIsShow), ref _contextMenuIsShow, value); +#else Set(ref _contextMenuIsShow, value); +#endif GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; } } @@ -25,7 +33,11 @@ namespace HandyControlDemo.ViewModel public bool ContextMenuIsBlink { get => _contextMenuIsBlink; +#if netle40 + set => Set(nameof(ContextMenuIsBlink), ref _contextMenuIsBlink, value); +#else set => Set(ref _contextMenuIsBlink, value); +#endif } private bool _contextContentIsShow; @@ -35,7 +47,11 @@ namespace HandyControlDemo.ViewModel get => _contextContentIsShow; set { +#if netle40 + Set(nameof(ContextContentIsShow), ref _contextContentIsShow, value); +#else Set(ref _contextContentIsShow, value); +#endif GlobalData.NotifyIconIsShow = ContextMenuIsShow || ContextContentIsShow; } } @@ -45,7 +61,11 @@ namespace HandyControlDemo.ViewModel public bool ContextContentIsBlink { get => _contextContentIsBlink; +#if netle40 + set => Set(nameof(ContextContentIsBlink), ref _contextContentIsBlink, value); +#else set => Set(ref _contextContentIsBlink, value); +#endif } public RelayCommand MouseCmd => new Lazy>(() => diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs index 26420e20..29db0a61 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs @@ -1,7 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControl.Data; using HandyControlDemo.Data; using HandyControlDemo.Service; @@ -26,7 +30,11 @@ namespace HandyControlDemo.ViewModel public int PageIndex { get => _pageIndex; +#if netle40 + set => Set(nameof(PageIndex), ref _pageIndex, value); +#else set => Set(ref _pageIndex, value); +#endif } public PaginationDemoViewModel(DataService dataService) diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs index d854c035..61ff2dbb 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs @@ -1,6 +1,10 @@ using System; using GalaSoft.MvvmLight; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControl.Controls; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs index d2bba196..8c2032c1 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs @@ -1,7 +1,11 @@ using System; using System.Linq; using System.Windows.Controls; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControl.Controls; using HandyControlDemo.Data; using HandyControlDemo.Service; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs index 9e694c94..a6246c52 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs @@ -1,6 +1,10 @@ using System; using System.Windows; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +# endif using HandyControlDemo.Tools; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase!1.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase!1.cs index 7714d2db..229ecc1d 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase!1.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase!1.cs @@ -16,7 +16,11 @@ namespace HandyControlDemo.ViewModel public IList DataList { get => _dataList; +#if netle40 + set => Set(nameof(DataList), ref _dataList, value); +#else set => Set(ref _dataList, value); +#endif } } } \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/ContributorsViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/ContributorsViewModel.cs index 5045e447..cd798729 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/ContributorsViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/ContributorsViewModel.cs @@ -8,10 +8,17 @@ namespace HandyControlDemo.ViewModel { public ContributorsViewModel(DataService dataService) { +#if netle40 + Task.Factory.StartNew(() => + { + DataList = dataService.GetContributorDataList(); + }); +#else Task.Run(() => { DataList = dataService.GetContributorDataList(); }); +#endif } } } \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs index b580666f..d3a3d1bc 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs @@ -1,6 +1,10 @@ using System; using System.Windows.Controls; +#if netle40 +using GalaSoft.MvvmLight.Command; +#else using GalaSoft.MvvmLight.CommandWpf; +#endif using GalaSoft.MvvmLight.Messaging; using HandyControlDemo.Data; using HandyControlDemo.Service; @@ -10,7 +14,7 @@ namespace HandyControlDemo.ViewModel { public class MainViewModel : DemoViewModelBase { - #region 字段 +#region 字段 /// /// 内容标题 @@ -27,7 +31,7 @@ namespace HandyControlDemo.ViewModel /// private ListBoxItem _listBoxItemCurrent; - #endregion +#endregion public MainViewModel(DataService dataService) { @@ -48,7 +52,7 @@ namespace HandyControlDemo.ViewModel DataList = dataService.GetDemoDataList(); } - #region 属性 +#region 属性 /// /// 子内容 @@ -56,7 +60,11 @@ namespace HandyControlDemo.ViewModel public object SubContent { get => _subContent; +#if netle40 + set => Set(nameof(SubContent), ref _subContent, value); +#else set => Set(ref _subContent, value); +#endif } /// @@ -65,7 +73,11 @@ namespace HandyControlDemo.ViewModel public object ContentTitle { get => _contentTitle; +#if netle40 + set => Set(nameof(ContentTitle), ref _contentTitle, value); +#else set => Set(ref _contentTitle, value); +#endif } #endregion @@ -79,9 +91,9 @@ namespace HandyControlDemo.ViewModel new Lazy>(() => new RelayCommand(SwitchDemo)).Value; - #endregion +#endregion - #region 方法 +#region 方法 /// /// 切换例子 @@ -108,6 +120,6 @@ namespace HandyControlDemo.ViewModel } } - #endregion +#endregion } } \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Controls/Other/Growl.cs b/src/Shared/HandyControl_Shared/Controls/Other/Growl.cs index 31b3c932..de403529 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/Growl.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/Growl.cs @@ -327,6 +327,37 @@ namespace HandyControl.Controls /// private static void Show(GrowlInfo growlInfo) { +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + var ctl = new Growl + { + Message = growlInfo.Message, + Time = DateTime.Now, + Icon = ResourceHelper.GetResource(growlInfo.IconKey), + IconBrush = ResourceHelper.GetResource(growlInfo.IconBrushKey), + _showCloseButton = growlInfo.ShowCloseButton, + ActionBeforeClose = growlInfo.ActionBeforeClose, + _staysOpen = growlInfo.StaysOpen, + ShowDateTime = growlInfo.ShowDateTime, + ConfirmStr = growlInfo.ConfirmStr, + CancelStr = growlInfo.CancelStr, + Type = growlInfo.Type, + _waitTime = Math.Max(growlInfo.WaitTime, 2) + }; + if (!string.IsNullOrEmpty(growlInfo.Token)) + { + if (PanelDic.TryGetValue(growlInfo.Token, out var panel)) + { + panel?.Children.Insert(0, ctl); + } + } + else + { + GrowlPanel.Children.Insert(0, ctl); + } + })); +#else Application.Current.Dispatcher.Invoke(() => { var ctl = new Growl @@ -356,6 +387,7 @@ namespace HandyControl.Controls GrowlPanel.Children.Insert(0, ctl); } }); +#endif } /// diff --git a/src/Shared/HandyControl_Shared/Controls/Window/MessageBox.cs b/src/Shared/HandyControl_Shared/Controls/Window/MessageBox.cs index 67342fd7..80aa3224 100644 --- a/src/Shared/HandyControl_Shared/Controls/Window/MessageBox.cs +++ b/src/Shared/HandyControl_Shared/Controls/Window/MessageBox.cs @@ -138,6 +138,17 @@ namespace HandyControl.Controls public static MessageBoxResult Success(string messageBoxText, string caption = null) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); + SetButtonStatus(messageBox, MessageBoxButton.OK); + messageBox.ShowImage = true; + messageBox.Image = ResourceHelper.GetResource(ResourceToken.SuccessGeometry); + messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.SuccessBrush); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); @@ -147,6 +158,7 @@ namespace HandyControl.Controls messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.SuccessBrush); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -159,6 +171,15 @@ namespace HandyControl.Controls public static MessageBoxResult Info(string messageBoxText, string caption = null) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); + SetButtonStatus(messageBox, MessageBoxButton.OK); + SetImage(messageBox, MessageBoxImage.Information); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); @@ -166,6 +187,7 @@ namespace HandyControl.Controls SetImage(messageBox, MessageBoxImage.Information); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -178,6 +200,15 @@ namespace HandyControl.Controls public static MessageBoxResult Warning(string messageBoxText, string caption = null) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); + SetButtonStatus(messageBox, MessageBoxButton.OK); + SetImage(messageBox, MessageBoxImage.Warning); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); @@ -185,6 +216,7 @@ namespace HandyControl.Controls SetImage(messageBox, MessageBoxImage.Warning); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -197,6 +229,15 @@ namespace HandyControl.Controls public static MessageBoxResult Error(string messageBoxText, string caption = null) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); + SetButtonStatus(messageBox, MessageBoxButton.OK); + SetImage(messageBox, MessageBoxImage.Error); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); @@ -204,6 +245,7 @@ namespace HandyControl.Controls SetImage(messageBox, MessageBoxImage.Error); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -216,6 +258,17 @@ namespace HandyControl.Controls public static MessageBoxResult Fatal(string messageBoxText, string caption = null) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); + SetButtonStatus(messageBox, MessageBoxButton.OK); + messageBox.ShowImage = true; + messageBox.Image = ResourceHelper.GetResource(ResourceToken.FatalGeometry); + messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.PrimaryTextBrush); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); @@ -225,6 +278,7 @@ namespace HandyControl.Controls messageBox.ImageBrush = ResourceHelper.GetResource(ResourceToken.PrimaryTextBrush); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -237,6 +291,15 @@ namespace HandyControl.Controls public static MessageBoxResult Ask(string messageBoxText, string caption = null) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); + SetButtonStatus(messageBox, MessageBoxButton.OKCancel); + SetImage(messageBox, MessageBoxImage.Question); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); @@ -244,6 +307,7 @@ namespace HandyControl.Controls SetImage(messageBox, MessageBoxImage.Question); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -256,6 +320,23 @@ namespace HandyControl.Controls public static MessageBoxResult Show(MessageBoxInfo info) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(null, info.MessageBoxText, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult); + SetButtonStatus(messageBox, info.Button); + + if (!string.IsNullOrEmpty(info.IconKey)) + { + messageBox.ShowImage = true; + messageBox.Image = ResourceHelper.GetResource(info.IconKey); + messageBox.ImageBrush = ResourceHelper.GetResource(info.IconBrushKey); + } + + messageBox.Style = info.Style; + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(null, info.MessageBoxText, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult); @@ -271,6 +352,7 @@ namespace HandyControl.Controls messageBox.Style = info.Style; messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } @@ -302,6 +384,15 @@ namespace HandyControl.Controls public static MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption = null, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) { MessageBox messageBox = null; +#if netle40 + Application.Current.Dispatcher.Invoke(new Action(() => + { + messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult); + SetButtonStatus(messageBox, button); + SetImage(messageBox, icon); + messageBox.ShowDialog(); + })); +#else Application.Current.Dispatcher.Invoke(() => { messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult); @@ -309,6 +400,7 @@ namespace HandyControl.Controls SetImage(messageBox, icon); messageBox.ShowDialog(); }); +#endif return messageBox._messageBoxResult; } diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index f45ae4ba..c14ba4cd 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -63,6 +63,7 @@ + @@ -99,6 +100,7 @@ + diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ComboBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ComboBoxBaseStyle.xaml deleted file mode 100644 index 90d37234..00000000 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ComboBoxBaseStyle.xaml +++ /dev/null @@ -1,1040 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -