From a9788eb9e82a9691aca37aa3651f73f35b8f88ae Mon Sep 17 00:00:00 2001 From: yamachu Date: Tue, 11 May 2021 02:50:24 +0900 Subject: [PATCH] tmp --- UmaMadoManager.Core/Models/Settings.cs | 2 +- .../Models/WindowFittingStandard.cs | 1 + .../Services/IApplicationService.cs | 9 + .../ViewModels/AxisStandardViewModel.cs | 42 +- UmaMadoManager.Windows/App.xaml | 13 + UmaMadoManager.Windows/App.xaml.cs | 57 ++ UmaMadoManager.Windows/AssemblyInfo.cs | 10 + .../Converters/AxisStandardEnumConverter.cs | 23 + .../Converters/MuteConditionEnumConveter.cs | 23 + .../WindowFittingStandardEnumConverter.cs | 23 + UmaMadoManager.Windows/Program.cs | 45 -- .../Services/ApplicationService.cs | 14 + .../UmaMadoManager.Windows.csproj | 3 + .../Views/UmaMadoManagerUI.cs | 683 +++++++++--------- .../Views/UmaMadoManagerUI.xaml | 121 ++++ 15 files changed, 676 insertions(+), 393 deletions(-) create mode 100644 UmaMadoManager.Core/Services/IApplicationService.cs create mode 100644 UmaMadoManager.Windows/App.xaml create mode 100644 UmaMadoManager.Windows/App.xaml.cs create mode 100644 UmaMadoManager.Windows/AssemblyInfo.cs create mode 100644 UmaMadoManager.Windows/Converters/AxisStandardEnumConverter.cs create mode 100644 UmaMadoManager.Windows/Converters/MuteConditionEnumConveter.cs create mode 100644 UmaMadoManager.Windows/Converters/WindowFittingStandardEnumConverter.cs delete mode 100644 UmaMadoManager.Windows/Program.cs create mode 100644 UmaMadoManager.Windows/Services/ApplicationService.cs create mode 100644 UmaMadoManager.Windows/Views/UmaMadoManagerUI.xaml diff --git a/UmaMadoManager.Core/Models/Settings.cs b/UmaMadoManager.Core/Models/Settings.cs index 7f13aec..be2d646 100644 --- a/UmaMadoManager.Core/Models/Settings.cs +++ b/UmaMadoManager.Core/Models/Settings.cs @@ -76,7 +76,7 @@ public WindowRect UserDefinedHorizontalWindowRect [System.Configuration.UserScopedSettingAttribute()] public WindowFittingStandard WindowFittingStandard { - get { return this["WindowFittingStandard"] == null ? WindowFittingStandard.LeftTop : (WindowFittingStandard)this["WindowFittingStandard"]; } + get { return this["WindowFittingStandard"] == null ? WindowFittingStandard.Unset : (WindowFittingStandard)this["WindowFittingStandard"]; } set { this["WindowFittingStandard"] = value; } } diff --git a/UmaMadoManager.Core/Models/WindowFittingStandard.cs b/UmaMadoManager.Core/Models/WindowFittingStandard.cs index 01e2c49..2db1f65 100644 --- a/UmaMadoManager.Core/Models/WindowFittingStandard.cs +++ b/UmaMadoManager.Core/Models/WindowFittingStandard.cs @@ -6,5 +6,6 @@ public enum WindowFittingStandard { LeftTop, RightTop, + Unset } } diff --git a/UmaMadoManager.Core/Services/IApplicationService.cs b/UmaMadoManager.Core/Services/IApplicationService.cs new file mode 100644 index 0000000..04fbdf7 --- /dev/null +++ b/UmaMadoManager.Core/Services/IApplicationService.cs @@ -0,0 +1,9 @@ +using System; + +namespace UmaMadoManager.Core.Services +{ + public interface IApplicationService + { + void Shutdown(); + } +} diff --git a/UmaMadoManager.Core/ViewModels/AxisStandardViewModel.cs b/UmaMadoManager.Core/ViewModels/AxisStandardViewModel.cs index 463676f..1163bd5 100644 --- a/UmaMadoManager.Core/ViewModels/AxisStandardViewModel.cs +++ b/UmaMadoManager.Core/ViewModels/AxisStandardViewModel.cs @@ -10,7 +10,7 @@ namespace UmaMadoManager.Core.ViewModels { - public class AxisStandardViewModel + public class AxisStandardViewModel : IDisposable { private CompositeDisposable Disposable { get; } = new CompositeDisposable(); @@ -45,7 +45,12 @@ private ReactiveProperty BindSettings(T val, string nameofParameter, React }); } - public Action OnExit; + public void Dispose() + { + Disposable.Dispose(); + } + + public ReactiveCommand OnExit { get; } public Action OnAllocateDebugConsoleClicked; // FIXME: VMでやることじゃない @@ -54,7 +59,8 @@ public AxisStandardViewModel( IScreenManager screenManager, IAudioManager audioManager, IVersionRepository versionRepository, - ISettingService settingService) + ISettingService settingService, + IApplicationService applicationService) { settings = settingService.Instance(); Vertical = BindSettings(settings.Vertical, nameof(settings.Vertical)); @@ -72,7 +78,7 @@ public AxisStandardViewModel( IsRemoveBorder = BindSettings(settings.IsRemoveBorder, nameof(settings.IsRemoveBorder)); // FIXME: PollingじゃなくてGlobalHookとかでやりたい - targetWindowHandle = Observable.Interval(TimeSpan.FromSeconds(1)) + targetWindowHandle = Observable.Interval(TimeSpan.FromSeconds(5)) .CombineLatest(TargetApplicationName) .Select(x => nativeWindowManager.GetWindowHandle(x.Second)) .Distinct() @@ -183,9 +189,9 @@ public AxisStandardViewModel( .Subscribe(x => { var containsScreen = screenManager.GetScreens() - .Where(s => s.ContainsWindow(x.First.Item1)) - .Cast() - .FirstOrDefault(); + .Where(s => s.ContainsWindow(x.First.Item1)) + .Cast() + .FirstOrDefault(); if (containsScreen == null) { return; @@ -272,10 +278,28 @@ public AxisStandardViewModel( nativeWindowManager.SetTopMost(handle, doTop); })); - OnExit = () => + OnExit = new ReactiveCommand(); + OnExit.Subscribe(_ => { settingService.Save(); - }; + applicationService.Shutdown(); + }); + + Vertical.Subscribe(x => + { + if (x != AxisStandard.Full) + { + WindowFittingStandard.Value = Models.WindowFittingStandard.Unset; + } + }); + + WindowFittingStandard.Subscribe(x => + { + if (x != Models.WindowFittingStandard.Unset) + { + Vertical.Value = AxisStandard.Full; + } + }); } } } diff --git a/UmaMadoManager.Windows/App.xaml b/UmaMadoManager.Windows/App.xaml new file mode 100644 index 0000000..2a542c4 --- /dev/null +++ b/UmaMadoManager.Windows/App.xaml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/UmaMadoManager.Windows/App.xaml.cs b/UmaMadoManager.Windows/App.xaml.cs new file mode 100644 index 0000000..009785b --- /dev/null +++ b/UmaMadoManager.Windows/App.xaml.cs @@ -0,0 +1,57 @@ +using System; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Windows; +using Hardcodet.Wpf.TaskbarNotification; +using UmaMadoManager.Windows.Services; + +namespace UmaMadoManager.Windows +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + private TaskbarIcon notifyIcon; + private Core.ViewModels.AxisStandardViewModel viewModel; + + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + var nativeWindowManager = new NativeWindowManager(); + var screenManager = new ScreenManager(); + var audioManager = new AudioManager(); + var versionRepository = new VersionRepository(); + var settingService = new SettingService(); + var debugService = new DebugService(); + var applicationService = new ApplicationService(); + settingService.Init(); + + var isDebugMode = System.Environment.GetCommandLineArgs().Count(v => v == "--debug") == 1; + if (isDebugMode) { + debugService.AllocConsole(); + } + + viewModel = new Core.ViewModels.AxisStandardViewModel( + nativeWindowManager, + screenManager, + audioManager, + versionRepository, + settingService, + applicationService); + + notifyIcon = (TaskbarIcon) FindResource("NotifyIcon"); + var icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("UmaMadoManager.Windows.Resources.TrayIcon.ico")); + notifyIcon.Icon = icon; + notifyIcon.DataContext = viewModel; + } + + protected override void OnExit(ExitEventArgs e) + { + notifyIcon.Dispose(); + base.OnExit(e); + } + } +} diff --git a/UmaMadoManager.Windows/AssemblyInfo.cs b/UmaMadoManager.Windows/AssemblyInfo.cs new file mode 100644 index 0000000..3c50569 --- /dev/null +++ b/UmaMadoManager.Windows/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/UmaMadoManager.Windows/Converters/AxisStandardEnumConverter.cs b/UmaMadoManager.Windows/Converters/AxisStandardEnumConverter.cs new file mode 100644 index 0000000..5c2c6a5 --- /dev/null +++ b/UmaMadoManager.Windows/Converters/AxisStandardEnumConverter.cs @@ -0,0 +1,23 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using UmaMadoManager.Core.Models; + +namespace UmaMadoManager.Windows.Converters +{ + class AxisStandardEnumBoolConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var targetEnum = (AxisStandard)parameter; + var passedEnum = (AxisStandard)value; + + return targetEnum == passedEnum; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return parameter; + } + } +} diff --git a/UmaMadoManager.Windows/Converters/MuteConditionEnumConveter.cs b/UmaMadoManager.Windows/Converters/MuteConditionEnumConveter.cs new file mode 100644 index 0000000..06feb67 --- /dev/null +++ b/UmaMadoManager.Windows/Converters/MuteConditionEnumConveter.cs @@ -0,0 +1,23 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using UmaMadoManager.Core.Models; + +namespace UmaMadoManager.Windows.Converters +{ + class MuteConditionEnumConveter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var targetEnum = (MuteCondition)parameter; + var passedEnum = (MuteCondition)value; + + return targetEnum == passedEnum; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return parameter; + } + } +} diff --git a/UmaMadoManager.Windows/Converters/WindowFittingStandardEnumConverter.cs b/UmaMadoManager.Windows/Converters/WindowFittingStandardEnumConverter.cs new file mode 100644 index 0000000..c6e03d4 --- /dev/null +++ b/UmaMadoManager.Windows/Converters/WindowFittingStandardEnumConverter.cs @@ -0,0 +1,23 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using UmaMadoManager.Core.Models; + +namespace UmaMadoManager.Windows.Converters +{ + class WindowFittingStandardEnumConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var targetEnum = (WindowFittingStandard)parameter; + var passedEnum = (WindowFittingStandard)value; + + return targetEnum == passedEnum; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return parameter; + } + } +} diff --git a/UmaMadoManager.Windows/Program.cs b/UmaMadoManager.Windows/Program.cs deleted file mode 100644 index ed37678..0000000 --- a/UmaMadoManager.Windows/Program.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Reflection; -using System.Windows.Forms; -using System.Linq; -using UmaMadoManager.Windows.Services; - -[assembly:AssemblyKeyFileAttribute("keyfile.snk")] -namespace UmaMadoManager.Windows -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.SetHighDpiMode(HighDpiMode.SystemAware); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - - var nativeWindowManager = new NativeWindowManager(); - var screenManager = new ScreenManager(); - var audioManager = new AudioManager(); - var versionRepository = new VersionRepository(); - var settingService = new SettingService(); - var debugService = new DebugService(); - settingService.Init(); - - var isDebugMode = System.Environment.GetCommandLineArgs().Count(v => v == "--debug") == 1; - if (isDebugMode) { - debugService.AllocConsole(); - } - - var _ = new Views.UmaMadoManagerUI( - new Core.ViewModels.AxisStandardViewModel( - nativeWindowManager, - screenManager, - audioManager, - versionRepository, - settingService)); - Application.Run(); - } - } -} diff --git a/UmaMadoManager.Windows/Services/ApplicationService.cs b/UmaMadoManager.Windows/Services/ApplicationService.cs new file mode 100644 index 0000000..92a3b6c --- /dev/null +++ b/UmaMadoManager.Windows/Services/ApplicationService.cs @@ -0,0 +1,14 @@ +using System; +using System.Windows; +using UmaMadoManager.Core.Services; + +namespace UmaMadoManager.Windows.Services +{ + public class ApplicationService : IApplicationService + { + public void Shutdown() + { + Application.Current.Shutdown(); + } + } +} diff --git a/UmaMadoManager.Windows/UmaMadoManager.Windows.csproj b/UmaMadoManager.Windows/UmaMadoManager.Windows.csproj index 306ae2c..28f2531 100644 --- a/UmaMadoManager.Windows/UmaMadoManager.Windows.csproj +++ b/UmaMadoManager.Windows/UmaMadoManager.Windows.csproj @@ -8,6 +8,8 @@ WinExe net5.0-windows true + true + enable 1.5.0-pre2 true true @@ -22,6 +24,7 @@ + diff --git a/UmaMadoManager.Windows/Views/UmaMadoManagerUI.cs b/UmaMadoManager.Windows/Views/UmaMadoManagerUI.cs index 410ed4f..2e9b146 100644 --- a/UmaMadoManager.Windows/Views/UmaMadoManagerUI.cs +++ b/UmaMadoManager.Windows/Views/UmaMadoManagerUI.cs @@ -1,355 +1,362 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using System.Reactive.Linq; -using System.Reactive.Disposables; -using UmaMadoManager.Core.ViewModels; -using UmaMadoManager.Core.Extensions; -using UmaMadoManager.Core.Models; -using System.Reflection; +// using System; +// using System.Drawing; +// using System.Reactive.Disposables; +// using System.Reactive.Linq; +// using System.Reflection; +// using System.Threading; +// using System.Windows.Forms; +// using UmaMadoManager.Core.Extensions; +// using UmaMadoManager.Core.Models; +// using UmaMadoManager.Core.ViewModels; -namespace UmaMadoManager.Windows.Views -{ - public class UmaMadoManagerUI - { - private CompositeDisposable Disposable { get; } = new CompositeDisposable(); +// namespace UmaMadoManager.Windows.Views +// { +// public class UmaMadoManagerUI : Form +// { +// private CompositeDisposable Disposable { get; } = new CompositeDisposable(); - private Form VerticalUserPositionSettingModal; - private Form HorizontalUserPositionSettingModal; +// private Form VerticalUserPositionSettingModal; +// private Form HorizontalUserPositionSettingModal; - public UmaMadoManagerUI(AxisStandardViewModel viewModel) - { - var _VM = viewModel; - var trayNotifyIcon = new NotifyIcon() - { - Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("UmaMadoManager.Windows.Resources.TrayIcon.ico")), - Visible = true, - }; +// public UmaMadoManagerUI(AxisStandardViewModel viewModel) +// { +// var _VM = viewModel; +// var trayNotifyIcon = new NotifyIcon() +// { +// Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("UmaMadoManager.Windows.Resources.TrayIcon.ico")), +// Visible = true, +// }; - this.Disposable.Add(_VM.Vertical.CombineLatest(_VM.Horizontal).Subscribe((x) => - { - trayNotifyIcon.Text = $"V => {x.First}: H => {x.Second}"; // もうちょいわかりやすく - })); +// this.Disposable.Add(_VM.Vertical.CombineLatest(_VM.Horizontal)/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe((x) => +// { +// trayNotifyIcon.Text = $"V => {x.First}: H => {x.Second}"; // もうちょいわかりやすく +// })); - var contextMenu = new ContextMenuStrip(); +// var contextMenu = new ContextMenuStrip(); - var verticalSettingMenus = new ToolStripMenuItem() - { - Text = "Vertical", - }; - verticalSettingMenus.DropDownItems.AddRange(new ToolStripItem[]{ - new ToolStripMenuItem("Application default").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.Vertical.Value = AxisStandard.Application; - })); - this.Disposable.Add(_VM.Vertical.Subscribe(x => { - v.Checked = x == AxisStandard.Application; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("User defined").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - if (!VerticalUserPositionSettingModal.Visible) - { - // 動かせるように - _VM.Vertical.Value = AxisStandard.Application; - VerticalUserPositionSettingModal.Show(); - } - })); - this.Disposable.Add(_VM.Vertical.Subscribe(x => { - v.Checked = x == AxisStandard.User; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("Full height").Also(v => { - v.DropDownItems.AddRange(new ToolStripItem[]{ - new ToolStripMenuItem("Left Top").Also(vv => { - this.Disposable.Add(Observable.FromEventPattern(vv, nameof(vv.Click)).Subscribe(x => { - _VM.Vertical.Value = AxisStandard.Full; - _VM.WindowFittingStandard.Value = WindowFittingStandard.LeftTop; - })); - this.Disposable.Add(_VM.Vertical.CombineLatest(_VM.WindowFittingStandard).Subscribe(x => { - vv.Checked = x == (AxisStandard.Full, WindowFittingStandard.LeftTop); - })); - vv.CheckOnClick = true; - }), - new ToolStripMenuItem("Right Top").Also(vv => { - this.Disposable.Add(Observable.FromEventPattern(vv, nameof(vv.Click)).Subscribe(x => { - _VM.Vertical.Value = AxisStandard.Full; - _VM.WindowFittingStandard.Value = WindowFittingStandard.RightTop; - })); - this.Disposable.Add(_VM.Vertical.CombineLatest(_VM.WindowFittingStandard).Subscribe(x => { - vv.Checked = x == (AxisStandard.Full, WindowFittingStandard.RightTop); - })); - vv.CheckOnClick = true; - }) - }); - }), - }); +// var verticalSettingMenus = new ToolStripMenuItem() +// { +// Text = "Vertical", +// }; +// verticalSettingMenus.DropDownItems.AddRange(new ToolStripItem[]{ +// new ToolStripMenuItem("Application default").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.Vertical.Value = AxisStandard.Application; +// })); +// // this.Disposable.Add(_VM.Vertical/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == AxisStandard.Application; +// // })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("User defined").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// if (!VerticalUserPositionSettingModal.Visible) +// { +// // 動かせるように +// _VM.Vertical.Value = AxisStandard.Application; +// VerticalUserPositionSettingModal.Show(); +// } +// })); +// // this.Disposable.Add(_VM.Vertical/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == AxisStandard.User; +// // })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("Full height").Also(v => { +// v.DropDownItems.AddRange(new ToolStripItem[]{ +// new ToolStripMenuItem("Left Top").Also(vv => { +// this.Disposable.Add(Observable.FromEventPattern(vv, nameof(vv.Click)).Subscribe(x => { +// _VM.Vertical.Value = AxisStandard.Full; +// _VM.WindowFittingStandard.Value = WindowFittingStandard.LeftTop; +// })); +// // this.Disposable.Add(_VM.Vertical.CombineLatest(_VM.WindowFittingStandard)/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // vv.Checked = x == (AxisStandard.Full, WindowFittingStandard.LeftTop); +// // })); +// vv.CheckOnClick = true; +// }), +// new ToolStripMenuItem("Right Top").Also(vv => { +// this.Disposable.Add(Observable.FromEventPattern(vv, nameof(vv.Click)).Subscribe(x => { +// _VM.Vertical.Value = AxisStandard.Full; +// _VM.WindowFittingStandard.Value = WindowFittingStandard.RightTop; +// })); +// // this.Disposable.Add(_VM.Vertical.CombineLatest(_VM.WindowFittingStandard)/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // vv.Checked = x == (AxisStandard.Full, WindowFittingStandard.RightTop); +// // })); +// vv.CheckOnClick = true; +// }) +// }); +// }), +// }); - var horizontalSettingMenus = new ToolStripMenuItem() - { - Text = "Horizontal", - }; - horizontalSettingMenus.DropDownItems.AddRange(new ToolStripItem[]{ - new ToolStripMenuItem("Application default").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.Horizontal.Value = AxisStandard.Application; - })); - this.Disposable.Add(_VM.Horizontal.Subscribe(x => { - v.Checked = x == AxisStandard.Application; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("User defined").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - if (!HorizontalUserPositionSettingModal.Visible) - { - _VM.Horizontal.Value = AxisStandard.Application; - HorizontalUserPositionSettingModal.Show(); - } - })); - this.Disposable.Add(_VM.Horizontal.Subscribe(x => { - v.Checked = x == AxisStandard.User; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("Full width").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.Horizontal.Value = AxisStandard.Full; - })); - this.Disposable.Add(_VM.Horizontal.Subscribe(x => { - v.Checked = x == AxisStandard.Full; - })); - v.CheckOnClick = true; - }), - }); +// var horizontalSettingMenus = new ToolStripMenuItem() +// { +// Text = "Horizontal", +// }; +// horizontalSettingMenus.DropDownItems.AddRange(new ToolStripItem[]{ +// new ToolStripMenuItem("Application default").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.Horizontal.Value = AxisStandard.Application; +// })); +// // this.Disposable.Add(_VM.Horizontal/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == AxisStandard.Application; +// // })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("User defined").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// if (!HorizontalUserPositionSettingModal.Visible) +// { +// _VM.Horizontal.Value = AxisStandard.Application; +// HorizontalUserPositionSettingModal.Show(); +// } +// })); +// // this.Disposable.Add(_VM.Horizontal/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == AxisStandard.User; +// // })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("Full width").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.Horizontal.Value = AxisStandard.Full; +// })); +// // this.Disposable.Add(_VM.Horizontal/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == AxisStandard.Full; +// // })); +// v.CheckOnClick = true; +// }), +// }); - var muteSettingMenus = new ToolStripMenuItem() - { - Text = "Mute", - }; - muteSettingMenus.DropDownItems.AddRange(new ToolStripItem[]{ - new ToolStripMenuItem("Nop").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.MuteCondition.Value = MuteCondition.Nop; - })); - this.Disposable.Add(_VM.MuteCondition.Subscribe(x => { - v.Checked = x == MuteCondition.Nop; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("Always").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.MuteCondition.Value = MuteCondition.Always; - })); - this.Disposable.Add(_VM.MuteCondition.Subscribe(x => { - v.Checked = x == MuteCondition.Always; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("When Background").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.MuteCondition.Value = MuteCondition.WhenBackground; - })); - this.Disposable.Add(_VM.MuteCondition.Subscribe(x => { - v.Checked = x == MuteCondition.WhenBackground; - })); - v.CheckOnClick = true; - }), - new ToolStripMenuItem("When Minimized").Also(v => { - this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { - _VM.MuteCondition.Value = MuteCondition.WhenMinimize; - })); - this.Disposable.Add(_VM.MuteCondition.Subscribe(x => { - v.Checked = x == MuteCondition.WhenMinimize; - })); - v.CheckOnClick = true; - }), - }); +// var muteSettingMenus = new ToolStripMenuItem() +// { +// Text = "Mute", +// }; +// muteSettingMenus.DropDownItems.AddRange(new ToolStripItem[]{ +// new ToolStripMenuItem("Nop").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.MuteCondition.Value = MuteCondition.Nop; +// })); +// // this.Disposable.Add(_VM.MuteCondition/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == MuteCondition.Nop; +// // })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("Always").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.MuteCondition.Value = MuteCondition.Always; +// })); +// this.Disposable.Add(_VM.MuteCondition +// .Do(_ => System.Diagnostics.Debug.Print("Before ThreadId: {0}", Thread.CurrentThread.ManagedThreadId)) - Action navigateToHostingSite = () => - { - var url = "https://yamachu.booth.pm/items/2811984"; +// /*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/ +// .Do(_ => System.Diagnostics.Debug.Print("After ThreadId: {0}", Thread.CurrentThread.ManagedThreadId)) - try - { - // see: https://brockallen.com/2016/09/24/process-start-for-urls-on-net-core/ - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); - } - catch (Exception e) - { - System.Console.WriteLine(e); - } - }; +// .Subscribe(x => { +// v.Checked = x == MuteCondition.Always; +// })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("When Background").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.MuteCondition.Value = MuteCondition.WhenBackground; +// })); +// // this.Disposable.Add(_VM.MuteCondition/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == MuteCondition.WhenBackground; +// // })); +// v.CheckOnClick = true; +// }), +// new ToolStripMenuItem("When Minimized").Also(v => { +// this.Disposable.Add(Observable.FromEventPattern(v, nameof(v.Click)).Subscribe(x => { +// _VM.MuteCondition.Value = MuteCondition.WhenMinimize; +// })); +// // this.Disposable.Add(_VM.MuteCondition/*.ObserveOn(System.Reactive.Concurrency.Scheduler.Default)*/.Subscribe(x => { +// // v.Checked = x == MuteCondition.WhenMinimize; +// // })); +// v.CheckOnClick = true; +// }), +// }); - contextMenu.Items.AddRange(new ToolStripItem[]{ - verticalSettingMenus, - horizontalSettingMenus, - new ToolStripSeparator(), - muteSettingMenus, - new ToolStripSeparator(), - new ToolStripMenuItem("Extension").Also(v => { - v.DropDownItems.Add(new ToolStripMenuItem("AlwaysTop").Also(vv => { - this.Disposable.Add(Observable.FromEventPattern(vv, nameof(vv.Click)).Subscribe(x => { - _VM.IsMostTop.Value = !_VM.IsMostTop.Value; - })); - this.Disposable.Add(_VM.IsMostTop.Subscribe(x => { - vv.Checked = _VM.IsMostTop.Value; - })); - vv.CheckOnClick = true; - })); - v.DropDownItems.Add(new ToolStripMenuItem("RemoveBorder").Also(vv => { - this.Disposable.Add(Observable.FromEventPattern(vv, nameof(vv.Click)).Subscribe(x => { - _VM.IsRemoveBorder.Value = !_VM.IsRemoveBorder.Value; - })); - this.Disposable.Add(_VM.IsRemoveBorder.Subscribe(x => { - vv.Checked = _VM.IsRemoveBorder.Value; - })); - vv.CheckOnClick = true; - })); - }), - new ToolStripSeparator(), - new ToolStripMenuItem("Help").Also(v => { - v.Click += (_, _) => { - navigateToHostingSite(); - }; - }), - new ToolStripMenuItem("New Version Released").Also(v => { - Disposable.Add(_VM.LatestVersion.Subscribe(version => { - if (version == "") { - v.Visible = false; - return; - } - var currentVersionWithoutRevision = Assembly.GetExecutingAssembly().GetName().Version.Let(currentVersion => { - return new Version(currentVersion.Major, currentVersion.Minor, currentVersion.Build); - }); - var formattedVersion = Version.Parse(version); - v.Visible = currentVersionWithoutRevision != formattedVersion; - })); - v.Click += (_, _) => { - navigateToHostingSite(); - }; - }), - new ToolStripSeparator(), - new ToolStripMenuItem("Exit").Also(v => { - v.Click += (_, _) => { - trayNotifyIcon.Icon = null; - trayNotifyIcon.Dispose(); - this.Disposable.Dispose(); - Application.Exit(); - }; - }) - }); +// Action navigateToHostingSite = () => +// { +// var url = "https://yamachu.booth.pm/items/2811984"; - Func, Action