From a80c14a0fb7c2879f22c29249cbe8db41013d59a Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 21 Jun 2024 16:31:51 +1000 Subject: [PATCH 01/40] Remove unused regions --- .../StringToViewRegionIconsConverter.cs | 4 +- AdamStudio.Core/RegionNames.cs | 2 + AdamStudio.Core/SubRegionNames.cs | 16 ---- AdamStudio/ViewModels/MainWindowViewModel.cs | 66 ++++++++++++---- AdamStudio/Views/MainWindow.xaml | 3 +- .../ContentRegionModule.cs | 6 +- .../ViewModels/ContentRegionViewModel.cs | 75 ------------------- .../Views/ContentRegionView.xaml | 10 --- .../Views/ContentRegionView.xaml.cs | 12 --- .../ViewModels/MenuRegionViewModel.cs | 22 +++--- .../Views/MenuRegionView.xaml | 4 +- 11 files changed, 71 insertions(+), 149 deletions(-) delete mode 100644 AdamStudio.Core/SubRegionNames.cs delete mode 100644 Modules/AdamStudio.Modules.ContentRegion/ViewModels/ContentRegionViewModel.cs delete mode 100644 Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml delete mode 100644 Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml.cs diff --git a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs index 6b02a80..7d5d155 100644 --- a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs +++ b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs @@ -16,10 +16,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value != null) stringValue = (string)value; - if (stringValue == SubRegionNames.SubRegionVisualSettings) + if (stringValue == RegionNames.SettingsRegion) return PackIconSimpleIconsKind.Scratch; - if (stringValue == SubRegionNames.SubRegionScratch) + if (stringValue == RegionNames.ScratchRegion) return PackIconFeatherIconsKind.Settings; return PackIconSimpleIconsKind.AbbRobotStudio; diff --git a/AdamStudio.Core/RegionNames.cs b/AdamStudio.Core/RegionNames.cs index 6e06f11..94690d2 100644 --- a/AdamStudio.Core/RegionNames.cs +++ b/AdamStudio.Core/RegionNames.cs @@ -6,5 +6,7 @@ public class RegionNames public const string ContentRegion = $"{nameof(ContentRegion)}"; public const string FlayoutsRegion = $"{nameof(FlayoutsRegion)}"; public const string StatusBarRegion = $"{nameof(StatusBarRegion)}"; + public const string ScratchRegion = $"{nameof(ScratchRegion)}"; + public const string SettingsRegion = $"{nameof(SettingsRegion)}"; } } diff --git a/AdamStudio.Core/SubRegionNames.cs b/AdamStudio.Core/SubRegionNames.cs deleted file mode 100644 index a1e044f..0000000 --- a/AdamStudio.Core/SubRegionNames.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace AdamStudio.Core -{ - public class SubRegionNames - { - /// - /// region to switch SubRegionView inside ContentRegion - /// - public const string InsideConentRegion = $"{nameof(InsideConentRegion)}"; - - public const string SubRegionScratch = $"{nameof(SubRegionScratch)}"; - - public const string SubRegionComputerVisionControl = $"{nameof(SubRegionComputerVisionControl)}"; - - public const string SubRegionVisualSettings = $"{nameof(SubRegionVisualSettings)}"; - } -} diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index f2e772a..81bd711 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -13,13 +13,18 @@ using System.Linq; using System.Reflection; using System.Windows; +using System.ComponentModel.DataAnnotations; +using System.Windows.Controls.Primitives; +using AdamStudio.Modules.ContentRegion.Views; +using Prism.Ioc; +using System.Windows.Forms; namespace AdamStudio.ViewModels { public class MainWindowViewModel : ViewModelBase { #region DelegateCommands - + public DelegateCommand DeactivateViewDelegateCommand { get; } public DelegateCommand ShowRegionCommand { get; } public DelegateCommand MoveSplitterDelegateCommand { get; } public DelegateCommand SwitchToVideoDelegateCommand { get; } @@ -40,16 +45,18 @@ public class MainWindowViewModel : ViewModelBase private readonly IAvalonEditService mAvalonEditService; private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; + IContainerExtension _container; #endregion #region ~ - public MainWindowViewModel(IRegionManager regionManager, ISubRegionChangeAwareService subRegionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, + public MainWindowViewModel(IContainerExtension container, IRegionManager regionManager, ISubRegionChangeAwareService subRegionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, ICommunicationProviderService communicationProviderService, IFolderManagmentService folderManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, IThemeManagerService themeManager, ICultureProvider cultureProvider, IControlHelper controlHelper) { + _container = container; mRegionManager = regionManager; mWebApiService = webApiService; SubRegionChangeAwareService = subRegionChangeAwareService; @@ -61,6 +68,7 @@ public MainWindowViewModel(IRegionManager regionManager, ISubRegionChangeAwareSe mCultureProvider = cultureProvider; ControlHelper = controlHelper; + DeactivateViewDelegateCommand = new DelegateCommand(DeactivateView); ShowRegionCommand = new DelegateCommand(ShowRegion); MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute); @@ -70,6 +78,32 @@ public MainWindowViewModel(IRegionManager regionManager, ISubRegionChangeAwareSe Subscribe(); } + private void DeactivateView() + { + //IRegion region = mRegionManager.Regions[SubRegionNames.InsideConentRegion]; + + ScratchControlView view = _container.Resolve(); + SettingsControlView settings = _container.Resolve(); + + //bool isActive = region.ActiveViews.FirstOrDefault() != null; + + //var cratch = region.GetView(nameof(ScratchControlView)); + //var settings = region.GetView(nameof(SettingsControlView)); + + //object menu = region.Views.ToList(); + // (nameof(ScratchControlView)); + + /*if (true) + { + region.Deactivate(view); + region.Activate(settings); + } + else + { + + } */ + } + #endregion #region Public fields @@ -107,7 +141,7 @@ private void MoveSplitter(string commandArg) private bool MoveSplitterCanExecute(string arg) { var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; - return regionName == SubRegionNames.SubRegionScratch; + return regionName == RegionNames.ScratchRegion; } private void SwitchToVideo() @@ -125,13 +159,13 @@ private void SwitchToVideo() private bool SwitchToVideoCanExecute() { var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; - return regionName == SubRegionNames.SubRegionScratch; + return regionName == RegionNames.ScratchRegion; } private void SwitchToSettingsView() { - var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; + /*var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; if (regionName == SubRegionNames.SubRegionScratch) { @@ -143,7 +177,7 @@ private void SwitchToSettingsView() { ShowRegion(SubRegionNames.SubRegionScratch); return; - } + } */ } private bool SwitchToSettingsViewCanExecute() @@ -159,14 +193,14 @@ private void ShowRegion(string subRegionName) { switch (subRegionName) { - case SubRegionNames.SubRegionScratch: - mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionScratch); - break; - case SubRegionNames.SubRegionComputerVisionControl: - mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionComputerVisionControl); + case RegionNames.ScratchRegion: + mRegionManager.RequestNavigate(RegionNames.ContentRegion, RegionNames.ScratchRegion); break; - case SubRegionNames.SubRegionVisualSettings: - mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionVisualSettings); + //case SubRegionNames.SubRegionComputerVisionControl: + // mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionComputerVisionControl); + // break; + case RegionNames.SettingsRegion: + mRegionManager.RequestNavigate(RegionNames.ContentRegion, RegionNames.SettingsRegion); break; } @@ -237,8 +271,8 @@ private void Subscribe() mCommunicationProviderService.RaiseTcpServiceCientConnectedEvent += RaiseTcpServiceCientConnectedEvent; mCommunicationProviderService.RaiseUdpServiceServerReceivedEvent += RaiseUdpServiceServerReceivedEvent; - Application.Current.MainWindow.Loaded += MainWindowLoaded; - Application.Current.MainWindow.Closed += MainWindowClosed; + System.Windows.Application.Current.MainWindow.Loaded += MainWindowLoaded; + System.Windows.Application.Current.MainWindow.Closed += MainWindowClosed; } /// @@ -272,7 +306,7 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e) LoadCustomAvalonEditHighlighting(); LoadAppTheme(); - ShowRegionCommand.Execute(SubRegionNames.SubRegionScratch); + ShowRegionCommand.Execute(RegionNames.ScratchRegion); if (Settings.Default.AutoStartTcpConnect) mCommunicationProviderService.ConnectAllAsync(); diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 7b16b3b..335b50e 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -84,8 +84,9 @@ + - + diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index 06cacf1..c105a42 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -55,7 +55,7 @@ public class ScratchControlViewModel : RegionViewModelBase private readonly ISystemDialogService mSystemDialog; private readonly IControlHelper mControlHelper; private readonly IVideoViewProvider mVideoViewProvider; - private readonly ISubRegionChangeAwareService mRegionChangeAwareService; + private readonly IRegionChangeAwareService mRegionChangeAwareService; #endregion @@ -101,7 +101,7 @@ public ScratchControlViewModel(IRegionManager regionManager, ICommunicationProvi IStatusBarNotificationDeliveryService statusBarNotificationDelivery, IWebViewProvider webViewProvider, IFileManagmentService fileManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, ICultureProvider cultureProvider, ISystemDialogService systemDialogService, IControlHelper controlHelper, - IVideoViewProvider videoViewProvider, ISubRegionChangeAwareService regionChangeAwareService) : base(regionManager) + IVideoViewProvider videoViewProvider, IRegionChangeAwareService regionChangeAwareService) : base(regionManager) { mCommunicationProvider = communicationProvider; @@ -143,7 +143,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.InsideRegionNavigationRequestName = RegionNames.ScratchRegion; + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchRegion; Subscribe(); LoadResources(); diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs index 9e76dab..a5f285c 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs @@ -32,7 +32,7 @@ public class SettingsControlViewModel : RegionViewModelBase private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; private readonly IWebViewProvider mWebViewProvider; - private readonly ISubRegionChangeAwareService mRegionChangeAwareService; + private readonly IRegionChangeAwareService mRegionChangeAwareService; #endregion @@ -46,7 +46,7 @@ public class SettingsControlViewModel : RegionViewModelBase #region ~ public SettingsControlViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, - IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider, ISubRegionChangeAwareService subRegionChangeAwareService) : base(regionManager) + IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider, IRegionChangeAwareService subRegionChangeAwareService) : base(regionManager) { mFlyoutManager = flyoutManager; mThemeManager = themeManager; @@ -115,7 +115,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.InsideRegionNavigationRequestName = RegionNames.SettingsRegion; + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsRegion; ThemesCollection = mThemeManager.AppThemesCollection; SelectedTheme = mThemeManager.GetCurrentAppTheme(); diff --git a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs index 8352b6d..fb22d7a 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs @@ -20,13 +20,13 @@ public class MenuRegionViewModel : RegionViewModelBase #region Services - private readonly ISubRegionChangeAwareService mSubRegionChangeAware; + private readonly IRegionChangeAwareService mRegionChangeAware; #endregion - public MenuRegionViewModel(IRegionManager regionManager,ISubRegionChangeAwareService subRegionChangeAware) : base(regionManager) + public MenuRegionViewModel(IRegionManager regionManager, IRegionChangeAwareService regionChangeAware) : base(regionManager) { - mSubRegionChangeAware = subRegionChangeAware; + mRegionChangeAware = regionChangeAware; CloseAppCommand = new DelegateCommand(CloseApp); ShowRegionCommand = new DelegateCommand(ShowRegion); @@ -46,6 +46,7 @@ public override void OnNavigatedTo(NavigationContext navigationContext) base.OnNavigatedTo(navigationContext); } + public override void Destroy() { Unsubscribe(); @@ -62,13 +63,6 @@ public bool IsCheckedScratchMenuItem set => SetProperty(ref isCheckedScratchMenuItem, value); } - private bool isCheckedComputerVisionMenuItem; - public bool IsCheckedComputerVisionMenuItem - { - get => isCheckedComputerVisionMenuItem; - set => SetProperty(ref isCheckedComputerVisionMenuItem, value); - } - private bool isCheckedVisualSettingsMenuItem; public bool IsCheckedVisualSettingsMenuItem { @@ -80,18 +74,15 @@ public bool IsCheckedVisualSettingsMenuItem #region Private methods - private void ChangeCheckedMenuItem(string selectedSubRegionName) + private void ChangeCheckedMenuItem(string selectedRegionName) { ResetIsCheckedMenuItem(); - switch (selectedSubRegionName) + switch (selectedRegionName) { case RegionNames.ScratchRegion: IsCheckedScratchMenuItem = true; break; - //case SubRegionNames.SubRegionComputerVisionControl: - // IsCheckedComputerVisionMenuItem = true; - // break; case RegionNames.SettingsRegion: IsCheckedVisualSettingsMenuItem = true; break; @@ -101,7 +92,6 @@ private void ChangeCheckedMenuItem(string selectedSubRegionName) private void ResetIsCheckedMenuItem() { IsCheckedScratchMenuItem = false; - IsCheckedComputerVisionMenuItem = false; IsCheckedVisualSettingsMenuItem = false; } @@ -111,12 +101,12 @@ private void ResetIsCheckedMenuItem() private void Subscribe() { - mSubRegionChangeAware.RaiseSubRegionChangeEvent += RaiseSubRegionChangeEvent; + mRegionChangeAware.RaiseRegionChangeEvent += RaiseSubRegionChangeEvent; } private void Unsubscribe() { - mSubRegionChangeAware.RaiseSubRegionChangeEvent -= RaiseSubRegionChangeEvent; + mRegionChangeAware.RaiseRegionChangeEvent -= RaiseSubRegionChangeEvent; } #endregion @@ -125,27 +115,16 @@ private void Unsubscribe() private void RaiseSubRegionChangeEvent(object sender) { - ChangeCheckedMenuItem(mSubRegionChangeAware.InsideRegionNavigationRequestName); + ChangeCheckedMenuItem(mRegionChangeAware.RegionNavigationTargetName); } #endregion #region Command methods - private void ShowRegion(string subRegionName) + private void ShowRegion(string regionName) { - switch (subRegionName) - { - case RegionNames.ScratchRegion: - RegionManager.RequestNavigate(RegionNames.ContentRegion, RegionNames.ScratchRegion); - break; - /*case SubRegionNames.SubRegionComputerVisionControl: - RegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionComputerVisionControl); - break;*/ - case RegionNames.SettingsRegion: - RegionManager.RequestNavigate(RegionNames.ContentRegion, RegionNames.SettingsRegion); - break; - } + RegionManager.RequestNavigate(RegionNames.ContentRegion, regionName); } private void CloseApp() From cdce1975aad27a7c3c80ad6aebd0bc21e2e43b22 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Thu, 11 Jul 2024 16:08:46 +1000 Subject: [PATCH 05/40] Prepare work #91 --- .../AdamStudio.Services.csproj | 3 ++ AdamStudio/AdamStudio.csproj | 3 ++ AdamStudio/Bootstrapper.cs | 42 +++++++++++++------ AdamStudio/ViewModels/MainWindowViewModel.cs | 13 +++--- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/AdamStudio.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj index ae9fc3f..3a5fb9f 100644 --- a/AdamStudio.Services/AdamStudio.Services.csproj +++ b/AdamStudio.Services/AdamStudio.Services.csproj @@ -15,6 +15,9 @@ + + + diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index dbe3d4c..4eb93dd 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -30,6 +30,9 @@ 1701;1702;CA1416 + + + diff --git a/AdamStudio/Bootstrapper.cs b/AdamStudio/Bootstrapper.cs index 6c001ef..5767576 100644 --- a/AdamStudio/Bootstrapper.cs +++ b/AdamStudio/Bootstrapper.cs @@ -1,22 +1,25 @@ -using AdamStudio.Services.Interfaces; -using AdamStudio.Services; -using AdamStudio.Views; -using Prism.DryIoc; -using Prism.Ioc; -using System; -using System.Windows; +using AdamStudio.Controls.CustomControls.RegionAdapters; using AdamStudio.Controls.CustomControls.Services; using AdamStudio.Core.Properties; -using AdamStudio.Services.TcpClientDependency; -using Prism.Regions; -using System.Net; -using AdamStudio.Controls.CustomControls.RegionAdapters; -using MahApps.Metro.Controls; using AdamStudio.Modules.ContentRegion; using AdamStudio.Modules.FlayoutsRegion; using AdamStudio.Modules.MenuRegion; using AdamStudio.Modules.StatusBarRegion; +using AdamStudio.Services; +using AdamStudio.Services.Interfaces; +using AdamStudio.Services.TcpClientDependency; +using AdamStudio.Views; +using MahApps.Metro.Controls; +using Microsoft.Extensions.DependencyInjection; +using Prism.DryIoc; +using Prism.Ioc; using Prism.Modularity; +using Prism.Regions; +using Serilog; +using Serilog.Core; +using System; +using System.Net; +using System.Windows; namespace AdamStudio { @@ -27,9 +30,23 @@ protected override DependencyObject CreateShell() return Container.Resolve(); } + protected override void RegisterTypes(IContainerRegistry containerRegistry) { containerRegistry.RegisterSingleton(); + containerRegistry.RegisterServices(services => + { + Logger serilogLogger = new LoggerConfiguration() + .MinimumLevel.Verbose() + .WriteTo.File("logs/log-.txt", + rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}") + .CreateLogger(); + + + services.AddLogging(s => s.AddSerilog(serilogLogger, dispose:true)); + }); + containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); @@ -232,6 +249,7 @@ public void Dispose() Container.Resolve().Dispose(); Container.Resolve().Dispose(); + } } } diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 96a4f60..f1b8128 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -6,6 +6,8 @@ using AdamStudio.Core.Mvvm; using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; +using AdamStudio.Views; +using Microsoft.Extensions.Logging; using Prism.Commands; using Prism.Ioc; using Prism.Regions; @@ -41,18 +43,18 @@ public class MainWindowViewModel : ViewModelBase private readonly IAvalonEditService mAvalonEditService; private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; - IContainerExtension _container; + //IContainerExtension _container; #endregion #region ~ - public MainWindowViewModel(IContainerExtension container, IRegionManager regionManager, IRegionChangeAwareService regionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, + public MainWindowViewModel(ILogger loggerService, IRegionManager regionManager, IRegionChangeAwareService regionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, ICommunicationProviderService communicationProviderService, IFolderManagmentService folderManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, IThemeManagerService themeManager, ICultureProvider cultureProvider, IControlHelper controlHelper) { - _container = container; + //_container = container; mRegionManager = regionManager; mWebApiService = webApiService; RegionChangeAwareService = regionChangeAwareService; @@ -64,13 +66,14 @@ public MainWindowViewModel(IContainerExtension container, IRegionManager regionM mCultureProvider = cultureProvider; ControlHelper = controlHelper; + loggerService.LogInformation("Main window loaded"); + //DeactivateViewDelegateCommand = new DelegateCommand(DeactivateView); ShowRegionCommand = new DelegateCommand(ShowRegion); MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute); SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute); - SwitchToSettingsViewDelegateCommand = new DelegateCommand(SwitchToSettingsView, SwitchToSettingsViewCanExecute); - + SwitchToSettingsViewDelegateCommand = new DelegateCommand(SwitchToSettingsView, SwitchToSettingsViewCanExecute); Subscribe(); } From c0d55e0157cac9c32861a1b284d3546f78e2ed85 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 10:03:58 +1000 Subject: [PATCH 06/40] Close #91 --- .../AdamStudio.Services.csproj | 1 + .../Interfaces/ILogWriteEventAwareService.cs | 21 ++++++++ .../IStatusBarNotificationDeliveryService.cs | 6 +-- .../LogWriteEventAwareService.cs | 53 +++++++++++++++++++ .../StatusBarNotificationDeliveryService.cs | 10 ++-- AdamStudio/Bootstrapper.cs | 11 +++- AdamStudio/ViewModels/MainWindowViewModel.cs | 8 +-- .../ViewModels/ScratchControlViewModel.cs | 23 ++++---- .../Views/ScratchControlView.xaml.cs | 7 ++- .../ViewModels/StatusBarViewModel.cs | 21 ++++++-- 10 files changed, 131 insertions(+), 30 deletions(-) create mode 100644 AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs create mode 100644 AdamStudio.Services/LogWriteEventAwareService.cs diff --git a/AdamStudio.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj index 3a5fb9f..47a24b7 100644 --- a/AdamStudio.Services/AdamStudio.Services.csproj +++ b/AdamStudio.Services/AdamStudio.Services.csproj @@ -17,6 +17,7 @@ + diff --git a/AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs b/AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs new file mode 100644 index 0000000..d244c9d --- /dev/null +++ b/AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs @@ -0,0 +1,21 @@ +using System; + +namespace AdamStudio.Services.Interfaces +{ + #region Delegates + + public delegate void NewLogMessageWriteEventHandler(object sender, string message); + + #endregion + + public interface ILogWriteEventAwareService : IDisposable + { + #region Events + + public event NewLogMessageWriteEventHandler RaiseNewLogMessageWriteEvent; + + #endregion + + public void WriteToBuffer(string formattedLogMessage); + } +} diff --git a/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs b/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs index 734359c..eb80024 100644 --- a/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs +++ b/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs @@ -6,7 +6,7 @@ namespace AdamStudio.Services.Interfaces public delegate void ChangeProgressRingStateEventHandler(object sender, bool newState); public delegate void NewCompileLogMessageEventHandler(object sender, string message); - public delegate void NewAppLogMessageEventHandler(object sender, string message); + //public delegate void NewAppLogMessageEventHandler(object sender, string message); public delegate void UpdateNotificationCounterEventHandler(object sender, int counter); #endregion @@ -17,7 +17,7 @@ public interface IStatusBarNotificationDeliveryService : IDisposable public event ChangeProgressRingStateEventHandler RaiseChangeProgressRingStateEvent; public event NewCompileLogMessageEventHandler RaiseNewCompileLogMessageEvent; - public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; + //public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; public event UpdateNotificationCounterEventHandler RaiseUpdateNotificationCounterEvent; #endregion @@ -26,7 +26,7 @@ public interface IStatusBarNotificationDeliveryService : IDisposable public bool ProgressRingStart { get; set; } public string CompileLogMessage { get; set; } - public string AppLogMessage { get; set; } + //public string AppLogMessage { get; set; } public int NotificationCounter { get; set; } #endregion diff --git a/AdamStudio.Services/LogWriteEventAwareService.cs b/AdamStudio.Services/LogWriteEventAwareService.cs new file mode 100644 index 0000000..1e832b3 --- /dev/null +++ b/AdamStudio.Services/LogWriteEventAwareService.cs @@ -0,0 +1,53 @@ +using AdamStudio.Services.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdamStudio.Services +{ + public class LogWriteEventAwareService : ILogWriteEventAwareService + { + #region Events + + public event NewLogMessageWriteEventHandler RaiseNewLogMessageWriteEvent; + + #endregion + + private readonly StringBuilder mLogEventBuffer = new(); + + public LogWriteEventAwareService() { } + + + + public void Dispose() + { + mLogEventBuffer?.Clear(); + } + + public void WriteToBuffer(string formattedLogMessage) + { + var message = formattedLogMessage.TrimEnd(Environment.NewLine.ToCharArray()); + mLogEventBuffer.AppendLine(message); + + OnRaiseNewLogMessageWriteEvent(message); + } + + public string GetLogMessages() + { + return mLogEventBuffer.ToString(); + } + + public void ClearLogMessages() + { + mLogEventBuffer?.Clear(); + } + + protected virtual void OnRaiseNewLogMessageWriteEvent(string message) + { + NewLogMessageWriteEventHandler raiseEvent = RaiseNewLogMessageWriteEvent; + raiseEvent?.Invoke(this, message); + } + } +} diff --git a/AdamStudio.Services/StatusBarNotificationDeliveryService.cs b/AdamStudio.Services/StatusBarNotificationDeliveryService.cs index 77ba271..d2e4230 100644 --- a/AdamStudio.Services/StatusBarNotificationDeliveryService.cs +++ b/AdamStudio.Services/StatusBarNotificationDeliveryService.cs @@ -11,7 +11,7 @@ public class StatusBarNotificationDeliveryService : BindableBase, IStatusBarNoti public event ChangeProgressRingStateEventHandler RaiseChangeProgressRingStateEvent; public event NewCompileLogMessageEventHandler RaiseNewCompileLogMessageEvent; - public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; + //public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; public event UpdateNotificationCounterEventHandler RaiseUpdateNotificationCounterEvent; #endregion @@ -51,7 +51,7 @@ public string CompileLogMessage } } - private string appLogMessage = string.Empty; + /*private string appLogMessage = string.Empty; public string AppLogMessage { get => appLogMessage; @@ -62,7 +62,7 @@ public string AppLogMessage if (isNewValue) OnRaiseNewAppLogMessageEvent(AppLogMessage); } - } + }*/ private int notificationCounter; public int NotificationCounter @@ -107,11 +107,11 @@ protected virtual void OnRaiseNewCompileLogMessageEvent(string message) raiseEvent?.Invoke(this, message); } - protected virtual void OnRaiseNewAppLogMessageEvent(string message) + /*protected virtual void OnRaiseNewAppLogMessageEvent(string message) { NewAppLogMessageEventHandler raiseEvent = RaiseNewAppLogMessageEvent; raiseEvent?.Invoke(this, message); - } + }*/ protected virtual void OnRaiseUpdateNotificationCounterEvent(int counter) { diff --git a/AdamStudio/Bootstrapper.cs b/AdamStudio/Bootstrapper.cs index 5767576..86fc7c1 100644 --- a/AdamStudio/Bootstrapper.cs +++ b/AdamStudio/Bootstrapper.cs @@ -34,13 +34,20 @@ protected override DependencyObject CreateShell() protected override void RegisterTypes(IContainerRegistry containerRegistry) { containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterServices(services => { + ILogWriteEventAwareService logWriteEventAware = Container.Resolve(); + Logger serilogLogger = new LoggerConfiguration() .MinimumLevel.Verbose() + .WriteTo.DelegatingTextSink(writeAction => logWriteEventAware.WriteToBuffer(writeAction), + outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}") + .CreateLogger(); @@ -249,7 +256,9 @@ public void Dispose() Container.Resolve().Dispose(); Container.Resolve().Dispose(); - + + Container.Resolve().Dispose(); + } } } diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index f1b8128..23f136f 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -43,7 +43,7 @@ public class MainWindowViewModel : ViewModelBase private readonly IAvalonEditService mAvalonEditService; private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; - //IContainerExtension _container; + private readonly ILogger mLoggerService; #endregion @@ -54,7 +54,6 @@ public MainWindowViewModel(ILogger loggerService, IRegionMa IAvalonEditService avalonEditService, IThemeManagerService themeManager, ICultureProvider cultureProvider, IControlHelper controlHelper) { - //_container = container; mRegionManager = regionManager; mWebApiService = webApiService; RegionChangeAwareService = regionChangeAwareService; @@ -65,8 +64,7 @@ public MainWindowViewModel(ILogger loggerService, IRegionMa mThemeManager = themeManager; mCultureProvider = cultureProvider; ControlHelper = controlHelper; - - loggerService.LogInformation("Main window loaded"); + mLoggerService = loggerService; //DeactivateViewDelegateCommand = new DelegateCommand(DeactivateView); ShowRegionCommand = new DelegateCommand(ShowRegion); @@ -170,12 +168,14 @@ private void SwitchToSettingsView() if (regionName == RegionNames.SettingsRegion) { + mLoggerService.LogWarning("SwitchToScratchRegion"); ShowRegion(RegionNames.ScratchRegion); return; } if(regionName == RegionNames.ScratchRegion) { + mLoggerService.LogWarning("SwitchToSettingsRegion"); ShowRegion(RegionNames.SettingsRegion); return; } diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index c105a42..00f436b 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -23,6 +23,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; +using Microsoft.Extensions.Logging; namespace AdamStudio.Modules.ContentRegion.ViewModels { @@ -56,6 +57,7 @@ public class ScratchControlViewModel : RegionViewModelBase private readonly IControlHelper mControlHelper; private readonly IVideoViewProvider mVideoViewProvider; private readonly IRegionChangeAwareService mRegionChangeAwareService; + private readonly ILogger mLogger; #endregion @@ -97,13 +99,14 @@ public class ScratchControlViewModel : RegionViewModelBase #region ~ - public ScratchControlViewModel(IRegionManager regionManager, ICommunicationProviderService communicationProvider, IPythonRemoteRunnerService pythonRemoteRunner, + public ScratchControlViewModel(ILogger logger, IRegionManager regionManager, ICommunicationProviderService communicationProvider, IPythonRemoteRunnerService pythonRemoteRunner, IStatusBarNotificationDeliveryService statusBarNotificationDelivery, IWebViewProvider webViewProvider, IFileManagmentService fileManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, ICultureProvider cultureProvider, ISystemDialogService systemDialogService, IControlHelper controlHelper, IVideoViewProvider videoViewProvider, IRegionChangeAwareService regionChangeAwareService) : base(regionManager) { - + + mLogger = logger; mCommunicationProvider = communicationProvider; mPythonRemoteRunner = pythonRemoteRunner; mStatusBarNotificationDelivery = statusBarNotificationDelivery; @@ -404,7 +407,7 @@ private void ShowOpenFileDialog(string param) if (result.IsOpenFileCanceled) { - mStatusBarNotificationDelivery.AppLogMessage = mFileNotSelectedLogMessage; + mLogger.LogWarning(mFileNotSelectedLogMessage); return; } @@ -442,7 +445,7 @@ private void ShowSaveFileDialog(string param) if (result.IsSaveFileCanceled) { - mStatusBarNotificationDelivery.AppLogMessage = mFileNotSavedLogMessage; + mLogger.LogWarning(mFileNotSavedLogMessage); return; } @@ -744,16 +747,16 @@ private async void OpenSupportedFile(OpenFileDialogResult result) switch (result.OpenFileType) { case SupportFileType.Undefined: - mStatusBarNotificationDelivery.AppLogMessage = $"{mExtNotSupport1} {Path.GetExtension(path)} {mExtNotSupport2}"; + mLogger.LogInformation($"{mExtNotSupport1} {Path.GetExtension(path)} {mExtNotSupport2}"); break; case SupportFileType.Script: SourceTextEditor = await mFileManagment.ReadTextAsStringAsync(path); - mStatusBarNotificationDelivery.AppLogMessage = $"{mOpenFile} {path}"; + mLogger.LogInformation($"{mOpenFile} {path}"); break; case SupportFileType.Workspace: string xml = await mFileManagment.ReadTextAsStringAsync(path); _ = await ExecuteScriptFunctionAsync("loadSavedWorkspace", new object[] { xml }); - mStatusBarNotificationDelivery.AppLogMessage = $"{mOpenFile} {path}"; + mLogger.LogInformation($"{mOpenFile} {path}"); break; } } @@ -773,7 +776,7 @@ private async void SaveSupportedFile(SaveFileDialogResult result, SupportFileTyp await mFileManagment.WriteAsync(path, file); } - mStatusBarNotificationDelivery.AppLogMessage = $"{mFileSavedLogMessage} {path}"; + mLogger.LogInformation($"{mFileSavedLogMessage} {path}"); } private void RaiseDelegateCommandsCanExecuteChanged() @@ -912,11 +915,11 @@ private async void InitBlockly() await mWebViewProvider.ExecuteJavaScript(Scripts.RestoreSavedBlocks); } - mStatusBarNotificationDelivery.AppLogMessage = mScretchLoadedCompleteLogMessage; + mLogger.LogInformation(mScretchLoadedCompleteLogMessage); } catch { - mStatusBarNotificationDelivery.AppLogMessage = mScretchLoadedErrorLogMessage; + mLogger.LogWarning(mScretchLoadedErrorLogMessage); } } diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs index 4e20ec9..2296168 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs @@ -2,6 +2,7 @@ using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; using AdamStudio.Services.WebViewProviderDependency; +using Microsoft.Extensions.Logging; using Microsoft.Web.WebView2.Core; using System; using System.IO; @@ -24,6 +25,7 @@ public partial class ScratchControlView : UserControl private readonly IControlHelper mControlHelper; private readonly IWebSocketClientService mWebSocketClient; private readonly IVideoViewProvider mVideoViewProvider; + private readonly ILogger mLogger; #endregion @@ -33,12 +35,13 @@ public partial class ScratchControlView : UserControl #endregion - public ScratchControlView(IWebViewProvider webViewProvider, IStatusBarNotificationDeliveryService statusBarNotification, + public ScratchControlView(ILogger logger, IWebViewProvider webViewProvider, IStatusBarNotificationDeliveryService statusBarNotification, IFolderManagmentService folderManagment, IControlHelper controlHelper, IWebSocketClientService webSocketClient, IVideoViewProvider videoViewProvider) { InitializeComponent(); InitializeWebViewCore(); + mLogger = logger; mWebViewProvider = webViewProvider; mStatusBarNotification = statusBarNotification; mControlHelper = controlHelper; @@ -183,7 +186,7 @@ private void WebViewWebMessageReceived(object sender, CoreWebView2WebMessageRece } catch { - mStatusBarNotification.AppLogMessage = "Error reading blokly code"; + mLogger.LogError("Error reading blokly code"); receivedResult = new WebMessageJsonReceived { Action = string.Empty, Data = string.Empty }; } diff --git a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs index daa7cbb..da830ec 100644 --- a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs +++ b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs @@ -26,6 +26,7 @@ public class StatusBarViewModel : RegionViewModelBase private readonly IFlyoutStateChecker mFlyoutState; private readonly ICultureProvider mCultureProvider; private readonly IControlHelper mControlHelper; + private readonly ILogWriteEventAwareService mLogWriteEventAwareService; #endregion @@ -44,14 +45,15 @@ public class StatusBarViewModel : RegionViewModelBase #region ~ public StatusBarViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, IFlyoutStateChecker flyoutState, ICommunicationProviderService communicationProviderService, - IStatusBarNotificationDeliveryService statusBarNotification, ICultureProvider cultureProvider, IControlHelper controlHelper) : base(regionManager) - { + IStatusBarNotificationDeliveryService statusBarNotification, ICultureProvider cultureProvider, IControlHelper controlHelper, + ILogWriteEventAwareService logWriteEventAwareService) : base(regionManager) { mFlyoutManager = flyoutManager; mCommunicationProviderService = communicationProviderService; mStatusBarNotificationDelivery = statusBarNotification; mFlyoutState = flyoutState; mCultureProvider = cultureProvider; mControlHelper = controlHelper; + mLogWriteEventAwareService = logWriteEventAwareService; OpenNotificationPanelDelegateCommand = new DelegateCommand(OpenNotificationPanel, OpenNotificationPanelCanExecute); @@ -246,14 +248,17 @@ private void Subscribe() mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent += RaiseChangeProgressRingStateEvent; mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent += RaiseNewCompileLogMessageEvent; - mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent += RaiseNewAppLogMessageEvent; + //mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent += RaiseNewAppLogMessageEvent; mStatusBarNotificationDelivery.RaiseUpdateNotificationCounterEvent += RaiseUpdateNotificationCounterEvent; mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent += IsOpenedStateChangeEvent; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent; + mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent; } + + private void Unsubscribe() { mCommunicationProviderService.RaiseTcpServiceCientConnectedEvent -= RaiseAdamTcpCientConnectedEvent; @@ -262,11 +267,12 @@ private void Unsubscribe() mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent -= RaiseChangeProgressRingStateEvent; mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent -= RaiseNewCompileLogMessageEvent; - mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent -= RaiseNewAppLogMessageEvent; + //mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent -= RaiseNewAppLogMessageEvent; mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent -= IsOpenedStateChangeEvent; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent -= RaiseCurrentAppCultureLoadOrChangeEvent; + mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent; } #endregion @@ -325,8 +331,13 @@ private void RaiseCurrentAppCultureLoadOrChangeEvent(object sender) UpdateStatusConnectToolbar(); } + private void RaiseNewLogMessageWriteEvent(object sender, string message) + { + AppLogStatusBar = message; + } + #endregion - + } } From 275f38f266659a7a159d7c606314d9ca9132c340 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 10:11:55 +1000 Subject: [PATCH 07/40] Close #95 --- .../Interfaces/ISingleInstanceService.cs | 9 --- AdamStudio.Services/SingleInstanceService.cs | 79 ------------------- .../StatusBarNotificationDeliveryService.cs | 20 ----- AdamStudio/Bootstrapper.cs | 1 - AdamStudio/ViewModels/MainWindowViewModel.cs | 2 - 5 files changed, 111 deletions(-) delete mode 100644 AdamStudio.Services/Interfaces/ISingleInstanceService.cs delete mode 100644 AdamStudio.Services/SingleInstanceService.cs diff --git a/AdamStudio.Services/Interfaces/ISingleInstanceService.cs b/AdamStudio.Services/Interfaces/ISingleInstanceService.cs deleted file mode 100644 index 202e109..0000000 --- a/AdamStudio.Services/Interfaces/ISingleInstanceService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Windows; - -namespace AdamStudio.Services.Interfaces -{ - public interface ISingleInstanceService - { - public void Make(Application application, string appName, bool uniquePerUser = true); - } -} diff --git a/AdamStudio.Services/SingleInstanceService.cs b/AdamStudio.Services/SingleInstanceService.cs deleted file mode 100644 index 56223f3..0000000 --- a/AdamStudio.Services/SingleInstanceService.cs +++ /dev/null @@ -1,79 +0,0 @@ -using AdamStudio.Services.Interfaces; -using System; -using System.Threading; - -using System.Windows; - -namespace AdamStudio.Services -{ - public class SingleInstanceService : ISingleInstanceService - { - private static bool AlreadyProcessedOnThisInstance; - - public void Make(Application application, string appName, bool uniquePerUser = true) - { - if (AlreadyProcessedOnThisInstance) - { - return; - } - AlreadyProcessedOnThisInstance = true; - - string eventName = uniquePerUser - ? $"{appName}-{Environment.MachineName}-{Environment.UserDomainName}-{Environment.UserName}" - : $"{appName}-{Environment.MachineName}"; - - bool isSecondaryInstance = true; - - EventWaitHandle eventWaitHandle = null; - - try - { - eventWaitHandle = EventWaitHandle.OpenExisting(eventName); - } - catch - { - // This code only runs on the first instance. - isSecondaryInstance = false; - } - - if (isSecondaryInstance) - { - ActivateFirstInstanceWindow(eventWaitHandle); - - // Let's produce a non-interceptable exit (2009 year approach). - Environment.Exit(0); - } - - RegisterFirstInstanceWindowActivation(application, eventName); - } - - private void ActivateFirstInstanceWindow(EventWaitHandle eventWaitHandle) - { - // Let's notify the first instance to activate its main window. - _ = eventWaitHandle.Set(); - } - - private void RegisterFirstInstanceWindowActivation(Application app, string eventName) - { - EventWaitHandle eventWaitHandle = new( - false, - EventResetMode.AutoReset, - eventName); - - _ = ThreadPool.RegisterWaitForSingleObject(eventWaitHandle, WaitOrTimerCallback, app, Timeout.Infinite, false); - - eventWaitHandle.Close(); - } - - private void WaitOrTimerCallback(object state, bool timedOut) - { - Application app = (Application)state; - - _ = app.Dispatcher.BeginInvoke(new Action(() => - { - _ = Application.Current.MainWindow.WindowState = WindowState.Normal; - _ = Application.Current.MainWindow.Activate(); - })); - } - } -} diff --git a/AdamStudio.Services/StatusBarNotificationDeliveryService.cs b/AdamStudio.Services/StatusBarNotificationDeliveryService.cs index d2e4230..d95a53c 100644 --- a/AdamStudio.Services/StatusBarNotificationDeliveryService.cs +++ b/AdamStudio.Services/StatusBarNotificationDeliveryService.cs @@ -11,7 +11,6 @@ public class StatusBarNotificationDeliveryService : BindableBase, IStatusBarNoti public event ChangeProgressRingStateEventHandler RaiseChangeProgressRingStateEvent; public event NewCompileLogMessageEventHandler RaiseNewCompileLogMessageEvent; - //public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; public event UpdateNotificationCounterEventHandler RaiseUpdateNotificationCounterEvent; #endregion @@ -50,19 +49,6 @@ public string CompileLogMessage OnRaiseNewCompileLogMessageEvent(CompileLogMessage); } } - - /*private string appLogMessage = string.Empty; - public string AppLogMessage - { - get => appLogMessage; - set - { - bool isNewValue = SetProperty(ref appLogMessage, value); - - if (isNewValue) - OnRaiseNewAppLogMessageEvent(AppLogMessage); - } - }*/ private int notificationCounter; public int NotificationCounter @@ -107,12 +93,6 @@ protected virtual void OnRaiseNewCompileLogMessageEvent(string message) raiseEvent?.Invoke(this, message); } - /*protected virtual void OnRaiseNewAppLogMessageEvent(string message) - { - NewAppLogMessageEventHandler raiseEvent = RaiseNewAppLogMessageEvent; - raiseEvent?.Invoke(this, message); - }*/ - protected virtual void OnRaiseUpdateNotificationCounterEvent(int counter) { UpdateNotificationCounterEventHandler raiseEvent = RaiseUpdateNotificationCounterEvent; diff --git a/AdamStudio/Bootstrapper.cs b/AdamStudio/Bootstrapper.cs index 86fc7c1..3c6fc8f 100644 --- a/AdamStudio/Bootstrapper.cs +++ b/AdamStudio/Bootstrapper.cs @@ -33,7 +33,6 @@ protected override DependencyObject CreateShell() protected override void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterServices(services => diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 23f136f..1182f5d 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -168,14 +168,12 @@ private void SwitchToSettingsView() if (regionName == RegionNames.SettingsRegion) { - mLoggerService.LogWarning("SwitchToScratchRegion"); ShowRegion(RegionNames.ScratchRegion); return; } if(regionName == RegionNames.ScratchRegion) { - mLoggerService.LogWarning("SwitchToSettingsRegion"); ShowRegion(RegionNames.SettingsRegion); return; } From 2f8d5403ed4ddabe767b9655af107aa5a13408ea Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 11:25:48 +1000 Subject: [PATCH 08/40] Close #94 --- AdamStudio/App.xaml | 4 +- AdamStudio/App.xaml.cs | 255 +++++++++++++++++++++++++++++++++-- AdamStudio/Bootstrapper.cs | 263 ------------------------------------- 3 files changed, 248 insertions(+), 274 deletions(-) delete mode 100644 AdamStudio/Bootstrapper.cs diff --git a/AdamStudio/App.xaml b/AdamStudio/App.xaml index 9c2c3f0..98eeabc 100644 --- a/AdamStudio/App.xaml +++ b/AdamStudio/App.xaml @@ -1,4 +1,4 @@ - - + diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index 69c7fad..0a905d4 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -28,15 +28,28 @@ using System.ComponentModel; using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; +using AdamStudio.Views; +using AdamStudio.Controls.CustomControls.Services; +using AdamStudio.Services.TcpClientDependency; +using AdamStudio.Services; +using Microsoft.Extensions.DependencyInjection; +using Serilog; +using System.Net; +using Serilog.Core; +using AdamStudio.Controls.CustomControls.RegionAdapters; +using AdamStudio.Modules.ContentRegion; +using AdamStudio.Modules.FlayoutsRegion; +using AdamStudio.Modules.MenuRegion; +using AdamStudio.Modules.StatusBarRegion; #endregion namespace AdamStudio { - public partial class App : Application + public partial class App : PrismApplication { - private readonly Bootstrapper mBootstrapper = new(); + #region ~ public App() { @@ -44,14 +57,211 @@ public App() LoadSharedFFmpegLibrary(); } - protected override void OnStartup(StartupEventArgs e) + #endregion + + protected override Window CreateShell() + { + return Container.Resolve(); + } + + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + + containerRegistry.RegisterSingleton(containerRegistry => + { + IFileManagmentService fileManagment = containerRegistry.Resolve(); + AvalonEditService avalonService = new(fileManagment); + return avalonService; + }); + + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + + containerRegistry.RegisterSingleton(containerRegistry => + { + DryIoc.IContainer container = containerRegistry.GetContainer(); + IRegionManager regionManager = containerRegistry.Resolve(); + + return new FlyoutManager(container, regionManager); + }); + + containerRegistry.RegisterSingleton(() => + { + TcpClientOption option = new() + { + ReconnectCount = Settings.Default.ReconnectQtyComunicateTcpClient, + ReconnectTimeout = Settings.Default.ReconnectTimeoutComunicateTcpClient + }; + + string ip = Settings.Default.ServerIP; + int port = Settings.Default.TcpConnectStatePort; + + TcpClientService client; + + if (!string.IsNullOrEmpty(ip)) + { + client = new(ip, port, option); + } + else + { + client = new("127.0.0.1", port, option); + } + + + return client; + }); + + containerRegistry.RegisterSingleton(() => + { + IPAddress ip = IPAddress.Any; + int port = int.Parse(Settings.Default.MessageDataExchangePort); + + UdpClientService client = new(ip, port) + { + OptionDualMode = true, + OptionReuseAddress = true + }; + + return client; + }); + + containerRegistry.RegisterSingleton(() => + { + IPAddress ip = IPAddress.Any; + int port = Settings.Default.LogServerPort; + + UdpServerService server = new(ip, port) + { + OptionDualMode = true, + OptionReuseAddress = true + }; + + return server; + }); + + containerRegistry.RegisterSingleton(() => + { + string ip = Settings.Default.ServerIP; + int port = Settings.Default.SoketServerPort; + Uri uri; + + if (!string.IsNullOrEmpty(ip)) + { + uri = new($"ws://{ip}:{port}/adam-2.7/movement"); + } + else + { + uri = new($"ws://127.0.0.1:9001/adam-2.7/movement"); + } + + // debug, use only with debug server, which runs separately, not as a service + //Uri uri = new($"ws://{Settings.Default.ServerIP}:9001/adam-2.7/movement"); + + // work in production, connect to socket-server run as service + // Uri uri = new($"ws://{ip}:{port}/adam-2.7/movement"); + + WebSocketClientService client = new(uri); + return client; + }); + + containerRegistry.RegisterSingleton(() => + { + string ip = Settings.Default.ServerIP; + int port = Settings.Default.ApiPort; + string login = Settings.Default.ApiLogin; + string password = Settings.Default.ApiPassword; + + if (string.IsNullOrEmpty(ip)) + { + ip = "127.0.0.1"; + } + + WebApiService client = new(ip, port, login, password); + return client; + + }); + + containerRegistry.RegisterSingleton(containerRegistry => + { + ITcpClientService tcpClientService = containerRegistry.Resolve(); + IUdpClientService udpClientService = containerRegistry.Resolve(); + IUdpServerService udpServerService = containerRegistry.Resolve(); + IWebSocketClientService socketClientService = containerRegistry.Resolve(); + + CommunicationProviderService communicationProvider = new(tcpClientService, udpClientService, udpServerService, socketClientService); + + return communicationProvider; + }); + + containerRegistry.RegisterSingleton(containerRegistry => + { + IUdpClientService udpClient = containerRegistry.Resolve(); + + PythonRemoteRunnerService remoteRunnerService = new(udpClient); + return remoteRunnerService; + }); + + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(containerRegistry => + { + bool isVideoShowLastValue = Settings.Default.ShowVideo; + return new ControlHelper(isVideoShowLastValue); + }); + + containerRegistry.RegisterSingleton(); + + RegisterDialogs(containerRegistry); + RegisterService(containerRegistry); + } + + private void RegisterService(IContainerRegistry containerRegistry) { - mBootstrapper.Run(); - //mBootstrapper.Container.Resolve().Make(Current, "AdamStudio"); + containerRegistry.RegisterServices(services => + { + ILogWriteEventAwareService logWriteEventAware = Container.Resolve(); - base.OnStartup(e); - - + Logger mainLogger = new LoggerConfiguration() + .MinimumLevel.Verbose() + .WriteTo.DelegatingTextSink(writeAction => logWriteEventAware.WriteToBuffer(writeAction), + outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") + .WriteTo.File("logs/log-.txt", + rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}") + + .CreateLogger(); + + services.AddLogging(s => s.AddSerilog(mainLogger, dispose: true)); + }); + } + + private static void RegisterDialogs(IContainerRegistry containerRegistry) + { + // used for call system dialog for open save/open/select file/folder (Microsoft.Win32 dialogs) + containerRegistry.RegisterSingleton(); + + //Dialog boxes are not used, but implemented + //containerRegistry.RegisterDialog(); + } + + protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) + { + base.ConfigureRegionAdapterMappings(regionAdapterMappings); + + regionAdapterMappings.RegisterMapping(typeof(FlyoutsControl), Container.Resolve()); + } + + protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) + { + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); } protected override void OnExit(ExitEventArgs e) @@ -64,10 +274,37 @@ protected override void OnExit(ExitEventArgs e) private void OnAppCrashOrExit() { Unsubscribe(); - mBootstrapper.Dispose(); + Dispose(); Current.Shutdown(); } + public void Dispose() + { + IRegionManager regionManager = Container.Resolve(); + + //Called Destroy() in module + foreach (IRegion region in regionManager.Regions) + { + region.RemoveAll(); + } + + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + + } + #region Subscribes private void Subscribe() diff --git a/AdamStudio/Bootstrapper.cs b/AdamStudio/Bootstrapper.cs deleted file mode 100644 index 3c6fc8f..0000000 --- a/AdamStudio/Bootstrapper.cs +++ /dev/null @@ -1,263 +0,0 @@ -using AdamStudio.Controls.CustomControls.RegionAdapters; -using AdamStudio.Controls.CustomControls.Services; -using AdamStudio.Core.Properties; -using AdamStudio.Modules.ContentRegion; -using AdamStudio.Modules.FlayoutsRegion; -using AdamStudio.Modules.MenuRegion; -using AdamStudio.Modules.StatusBarRegion; -using AdamStudio.Services; -using AdamStudio.Services.Interfaces; -using AdamStudio.Services.TcpClientDependency; -using AdamStudio.Views; -using MahApps.Metro.Controls; -using Microsoft.Extensions.DependencyInjection; -using Prism.DryIoc; -using Prism.Ioc; -using Prism.Modularity; -using Prism.Regions; -using Serilog; -using Serilog.Core; -using System; -using System.Net; -using System.Windows; - -namespace AdamStudio -{ - internal class Bootstrapper : PrismBootstrapper, IDisposable - { - protected override DependencyObject CreateShell() - { - return Container.Resolve(); - } - - - protected override void RegisterTypes(IContainerRegistry containerRegistry) - { - containerRegistry.RegisterSingleton(); - - containerRegistry.RegisterServices(services => - { - ILogWriteEventAwareService logWriteEventAware = Container.Resolve(); - - Logger serilogLogger = new LoggerConfiguration() - .MinimumLevel.Verbose() - .WriteTo.DelegatingTextSink(writeAction => logWriteEventAware.WriteToBuffer(writeAction), - outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") - .WriteTo.File("logs/log-.txt", - rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10, - outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}") - - .CreateLogger(); - - - services.AddLogging(s => s.AddSerilog(serilogLogger, dispose:true)); - }); - - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - - containerRegistry.RegisterSingleton(containerRegistry => - { - IFileManagmentService fileManagment = containerRegistry.Resolve(); - AvalonEditService avalonService = new(fileManagment); - return avalonService; - }); - - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - - containerRegistry.RegisterSingleton(containerRegistry => - { - DryIoc.IContainer container = containerRegistry.GetContainer(); - IRegionManager regionManager = containerRegistry.Resolve(); - - return new FlyoutManager(container, regionManager); - }); - - containerRegistry.RegisterSingleton(() => - { - TcpClientOption option = new() - { - ReconnectCount = Settings.Default.ReconnectQtyComunicateTcpClient, - ReconnectTimeout = Settings.Default.ReconnectTimeoutComunicateTcpClient - }; - - string ip = Settings.Default.ServerIP; - int port = Settings.Default.TcpConnectStatePort; - - TcpClientService client; - - if (!string.IsNullOrEmpty(ip)) - { - client = new(ip, port, option); - } - else - { - client = new("127.0.0.1", port, option); - } - - - return client; - }); - - containerRegistry.RegisterSingleton(() => - { - IPAddress ip = IPAddress.Any; - int port = int.Parse(Settings.Default.MessageDataExchangePort); - - UdpClientService client = new(ip, port) - { - OptionDualMode = true, - OptionReuseAddress = true - }; - - return client; - }); - - containerRegistry.RegisterSingleton(() => - { - IPAddress ip = IPAddress.Any; - int port = Settings.Default.LogServerPort; - - UdpServerService server = new(ip, port) - { - OptionDualMode = true, - OptionReuseAddress = true - }; - - return server; - }); - - containerRegistry.RegisterSingleton(() => - { - string ip = Settings.Default.ServerIP; - int port = Settings.Default.SoketServerPort; - Uri uri; - - if (!string.IsNullOrEmpty(ip)) - { - uri = new($"ws://{ip}:{port}/adam-2.7/movement"); - } - else - { - uri = new($"ws://127.0.0.1:9001/adam-2.7/movement"); - } - - // debug, use only with debug server, which runs separately, not as a service - //Uri uri = new($"ws://{Settings.Default.ServerIP}:9001/adam-2.7/movement"); - - // work in production, connect to socket-server run as service - // Uri uri = new($"ws://{ip}:{port}/adam-2.7/movement"); - - WebSocketClientService client = new(uri); - return client; - }); - - containerRegistry.RegisterSingleton(() => - { - string ip = Settings.Default.ServerIP; - int port = Settings.Default.ApiPort; - string login = Settings.Default.ApiLogin; - string password = Settings.Default.ApiPassword; - - if (string.IsNullOrEmpty(ip)) - { - ip = "127.0.0.1"; - } - - WebApiService client = new(ip, port, login, password); - return client; - - }); - - containerRegistry.RegisterSingleton(containerRegistry => - { - ITcpClientService tcpClientService = containerRegistry.Resolve(); - IUdpClientService udpClientService = containerRegistry.Resolve(); - IUdpServerService udpServerService = containerRegistry.Resolve(); - IWebSocketClientService socketClientService = containerRegistry.Resolve(); - - CommunicationProviderService communicationProvider = new(tcpClientService, udpClientService, udpServerService, socketClientService); - - return communicationProvider; - }); - - containerRegistry.RegisterSingleton(containerRegistry => - { - IUdpClientService udpClient = containerRegistry.Resolve(); - - PythonRemoteRunnerService remoteRunnerService = new(udpClient); - return remoteRunnerService; - }); - - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(containerRegistry => - { - bool isVideoShowLastValue = Settings.Default.ShowVideo; - return new ControlHelper(isVideoShowLastValue); - }); - - containerRegistry.RegisterSingleton(); - - RegisterDialogs(containerRegistry); - } - - private static void RegisterDialogs(IContainerRegistry containerRegistry) - { - // used for call system dialog for open save/open/select file/folder (Microsoft.Win32 dialogs) - containerRegistry.RegisterSingleton(); - - //Dialog boxes are not used, but implemented - //containerRegistry.RegisterDialog(); - } - - protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) - { - base.ConfigureRegionAdapterMappings(regionAdapterMappings); - - regionAdapterMappings.RegisterMapping(typeof(FlyoutsControl), Container.Resolve()); - } - - protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) - { - moduleCatalog.AddModule(); - moduleCatalog.AddModule(); - moduleCatalog.AddModule(); - moduleCatalog.AddModule(); - } - - public void Dispose() - { - IRegionManager regionManager = Container.Resolve(); - - //Destroy() in module - foreach (IRegion region in regionManager.Regions) - { - region.RemoveAll(); - } - - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - - } - } -} From e295b9b9aab19814e8140937a9c437448c836aba Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 13:30:27 +1000 Subject: [PATCH 09/40] Prepare works #96 --- .../StringToViewRegionIconsConverter.cs | 4 +-- AdamStudio.Core/RegionNames.cs | 12 ++++--- .../LogWriteEventAwareService.cs | 3 -- AdamStudio.sln | 7 ++++ AdamStudio/AdamStudio.csproj | 1 + AdamStudio/App.xaml | 3 -- AdamStudio/App.xaml.cs | 2 ++ AdamStudio/ViewModels/MainWindowViewModel.cs | 33 +++++++++---------- AdamStudio/Views/MainWindow.xaml | 5 +++ .../ContentRegionModule.cs | 1 - .../ViewModels/ScratchControlViewModel.cs | 2 +- .../ViewModels/SettingsControlViewModel.cs | 2 +- .../MenuRegionModule.cs | 2 -- .../ViewModels/MenuRegionViewModel.cs | 4 +-- .../Views/MenuRegionView.xaml | 12 +++---- .../AdamStudio.Modules.ToolBarRegion.csproj | 12 +++++++ .../ToolBarRegionModule.cs | 28 ++++++++++++++++ .../ViewModels/ToolBarViewModel.cs | 17 ++++++++++ .../Views/ToolBarView.xaml | 14 ++++++++ .../Views/ToolBarView.xaml.cs | 12 +++++++ 20 files changed, 132 insertions(+), 44 deletions(-) create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs diff --git a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs index 7d5d155..407f470 100644 --- a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs +++ b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs @@ -16,10 +16,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value != null) stringValue = (string)value; - if (stringValue == RegionNames.SettingsRegion) + if (stringValue == RegionNames.SettingsView) return PackIconSimpleIconsKind.Scratch; - if (stringValue == RegionNames.ScratchRegion) + if (stringValue == RegionNames.ScratchView) return PackIconFeatherIconsKind.Settings; return PackIconSimpleIconsKind.AbbRobotStudio; diff --git a/AdamStudio.Core/RegionNames.cs b/AdamStudio.Core/RegionNames.cs index d0bf0d4..5b895a5 100644 --- a/AdamStudio.Core/RegionNames.cs +++ b/AdamStudio.Core/RegionNames.cs @@ -5,10 +5,12 @@ public class RegionNames public const string ContentRegion = $"{nameof(ContentRegion)}"; public const string FlayoutsRegion = $"{nameof(FlayoutsRegion)}"; - - public const string StatusBarRegion = "StatusBarView"; - public const string MenuRegion = "MenuRegionView"; - public const string ScratchRegion = "ScratchControlView"; - public const string SettingsRegion = "SettingsControlView"; + public const string ToolBarRegion = $"{nameof(ToolBarRegion)}"; + public const string StatusBarRegion = $"{nameof(StatusBarRegion)}"; + public const string MenuRegion = $"{nameof(MenuRegion)}"; + + + public const string ScratchView = "ScratchControlView"; + public const string SettingsView = "SettingsControlView"; } } diff --git a/AdamStudio.Services/LogWriteEventAwareService.cs b/AdamStudio.Services/LogWriteEventAwareService.cs index 1e832b3..a48a96b 100644 --- a/AdamStudio.Services/LogWriteEventAwareService.cs +++ b/AdamStudio.Services/LogWriteEventAwareService.cs @@ -1,9 +1,6 @@ using AdamStudio.Services.Interfaces; using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace AdamStudio.Services { diff --git a/AdamStudio.sln b/AdamStudio.sln index 62ce372..20d6b20 100644 --- a/AdamStudio.sln +++ b/AdamStudio.sln @@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamController.WebApi.Clien EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamStudio.Controls", "AdamStudio.Controls\AdamStudio.Controls.csproj", "{1BADFDB1-D66E-4580-8EAF-CAEE37761640}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdamStudio.Modules.ToolBarRegion", "Modules\AdamStudio.Modules.ToolBarRegion\AdamStudio.Modules.ToolBarRegion.csproj", "{AA601C7F-2233-47FE-911E-8221E8B861C8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -73,6 +75,10 @@ Global {1BADFDB1-D66E-4580-8EAF-CAEE37761640}.Debug|Any CPU.Build.0 = Debug|Any CPU {1BADFDB1-D66E-4580-8EAF-CAEE37761640}.Release|Any CPU.ActiveCfg = Release|Any CPU {1BADFDB1-D66E-4580-8EAF-CAEE37761640}.Release|Any CPU.Build.0 = Release|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,6 +90,7 @@ Global {D17BE826-5C86-4EAC-8424-534F9CF3DFE0} = {BF38E868-9FEB-4645-9B2B-15AC47844075} {941A4E7D-6A53-44F8-876C-6B33AAEDDA89} = {511F4919-C2FC-4775-92A4-C446E51B49DB} {771220FE-2F25-441B-815E-7DD63918BA95} = {511F4919-C2FC-4775-92A4-C446E51B49DB} + {AA601C7F-2233-47FE-911E-8221E8B861C8} = {BF38E868-9FEB-4645-9B2B-15AC47844075} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D00A029C-930D-44A8-8257-721FCA9202F6} diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index 4eb93dd..e7773d6 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -39,6 +39,7 @@ + diff --git a/AdamStudio/App.xaml b/AdamStudio/App.xaml index 98eeabc..3c4a6cf 100644 --- a/AdamStudio/App.xaml +++ b/AdamStudio/App.xaml @@ -51,9 +51,6 @@ - - - diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index 0a905d4..d22689a 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -41,6 +41,7 @@ using AdamStudio.Modules.FlayoutsRegion; using AdamStudio.Modules.MenuRegion; using AdamStudio.Modules.StatusBarRegion; +using AdamStudio.Modules.ToolBarRegion; #endregion @@ -262,6 +263,7 @@ protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) moduleCatalog.AddModule(); moduleCatalog.AddModule(); moduleCatalog.AddModule(); + moduleCatalog.AddModule(); } protected override void OnExit(ExitEventArgs e) diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 1182f5d..6d29a26 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -22,8 +22,7 @@ namespace AdamStudio.ViewModels public class MainWindowViewModel : ViewModelBase { #region DelegateCommands - //public DelegateCommand DeactivateViewDelegateCommand { get; } - public DelegateCommand ShowRegionCommand { get; } + public DelegateCommand MoveSplitterDelegateCommand { get; } public DelegateCommand SwitchToVideoDelegateCommand { get; } public DelegateCommand SwitchToSettingsViewDelegateCommand { get; } @@ -66,10 +65,7 @@ public MainWindowViewModel(ILogger loggerService, IRegionMa ControlHelper = controlHelper; mLoggerService = loggerService; - //DeactivateViewDelegateCommand = new DelegateCommand(DeactivateView); - ShowRegionCommand = new DelegateCommand(ShowRegion); MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute); - SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute); SwitchToSettingsViewDelegateCommand = new DelegateCommand(SwitchToSettingsView, SwitchToSettingsViewCanExecute); Subscribe(); @@ -140,7 +136,7 @@ private void MoveSplitter(string commandArg) private bool MoveSplitterCanExecute(string arg) { var regionName = RegionChangeAwareService.RegionNavigationTargetName; - return regionName == RegionNames.ScratchRegion; + return regionName == RegionNames.ScratchView; } private void SwitchToVideo() @@ -157,24 +153,24 @@ private void SwitchToVideo() private bool SwitchToVideoCanExecute() { + var regionName = RegionChangeAwareService.RegionNavigationTargetName; - return regionName == RegionNames.ScratchRegion; + return regionName == RegionNames.ScratchView; } private void SwitchToSettingsView() { + var activeViewName = RegionChangeAwareService.RegionNavigationTargetName; - var regionName = RegionChangeAwareService.RegionNavigationTargetName; - - if (regionName == RegionNames.SettingsRegion) + if (activeViewName == RegionNames.SettingsView) { - ShowRegion(RegionNames.ScratchRegion); + ShowView(RegionNames.ScratchView); return; } - if(regionName == RegionNames.ScratchRegion) + if(activeViewName == RegionNames.ScratchView) { - ShowRegion(RegionNames.SettingsRegion); + ShowView(RegionNames.SettingsView); return; } } @@ -188,9 +184,10 @@ private bool SwitchToSettingsViewCanExecute() #region Private methods - private void ShowRegion(string regionName) + private void ShowView(string viewName) { - mRegionManager.RequestNavigate(RegionNames.ContentRegion, regionName); + mRegionManager.RequestNavigate(RegionNames.ContentRegion, viewName); + MoveSplitterDelegateCommand.RaiseCanExecuteChanged(); SwitchToVideoDelegateCommand.RaiseCanExecuteChanged(); } @@ -288,13 +285,13 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e) mFolderManagment.CreateAppDataFolder(); SaveFolderPathToSettings(); } - + //Loaded resource + ShowView(RegionNames.ScratchView); + LoadCustomAvalonEditHighlighting(); LoadAppTheme(); - ShowRegionCommand.Execute(RegionNames.ScratchRegion); - if (Settings.Default.AutoStartTcpConnect) mCommunicationProviderService.ConnectAllAsync(); } diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 673e0b4..068d3d5 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -121,6 +121,7 @@ + @@ -139,6 +140,10 @@ prism:RegionManager.RegionName="{x:Static core:RegionNames.ContentRegion}" /> + + diff --git a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs index 0c7ddc3..7a0dfaa 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs @@ -23,7 +23,6 @@ public void OnInitialized(IContainerProvider containerProvider) public void RegisterTypes(IContainerRegistry containerRegistry) { containerRegistry.RegisterForNavigation(nameof(ScratchControlView)); - //containerRegistry.RegisterForNavigation(nameof(ComputerVisionControlView)); containerRegistry.RegisterForNavigation(nameof(SettingsControlView)); } } diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index 00f436b..8bdc08c 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -146,7 +146,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchRegion; + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchView; Subscribe(); LoadResources(); diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs index a5f285c..04a3dbf 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs @@ -115,7 +115,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsRegion; + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsView; ThemesCollection = mThemeManager.AppThemesCollection; SelectedTheme = mThemeManager.GetCurrentAppTheme(); diff --git a/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs b/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs index 19b7fd0..768828b 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs @@ -22,8 +22,6 @@ public void OnInitialized(IContainerProvider containerProvider) public void RegisterTypes(IContainerRegistry containerRegistry) { - //containerRegistry.RegisterForNavigation(); - containerRegistry.RegisterForNavigation(nameof(MenuRegionView)); } } diff --git a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs index fb22d7a..66c69c6 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs @@ -80,10 +80,10 @@ private void ChangeCheckedMenuItem(string selectedRegionName) switch (selectedRegionName) { - case RegionNames.ScratchRegion: + case RegionNames.ScratchView: IsCheckedScratchMenuItem = true; break; - case RegionNames.SettingsRegion: + case RegionNames.SettingsView: IsCheckedVisualSettingsMenuItem = true; break; } diff --git a/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml b/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml index 2cb9a28..61d653c 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml +++ b/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml @@ -20,14 +20,14 @@ Style="{DynamicResource MahApps.Styles.MenuItem}"> + Command="{Binding ShowRegionCommand}" + CommandParameter="{x:Static core:RegionNames.ScratchView}" + IsChecked="{Binding IsCheckedScratchMenuItem}" /> + Command="{Binding ShowRegionCommand}" + CommandParameter="{x:Static core:RegionNames.SettingsView}" + IsChecked="{Binding IsCheckedVisualSettingsMenuItem}"/> diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj b/Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj new file mode 100644 index 0000000..09d1682 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj @@ -0,0 +1,12 @@ + + + net8.0-windows7.0 + true + + + + + + + + \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs new file mode 100644 index 0000000..b69e893 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs @@ -0,0 +1,28 @@ +using AdamStudio.Core; +using AdamStudio.Modules.ToolBarRegion.Views; +using Prism.Ioc; +using Prism.Modularity; +using Prism.Regions; + +namespace AdamStudio.Modules.ToolBarRegion +{ + public class ToolBarRegionModule : IModule + { + private readonly IRegionManager mRegionManager; + + public ToolBarRegionModule(IRegionManager regionManager) + { + mRegionManager = regionManager; + } + + public void OnInitialized(IContainerProvider containerProvider) + { + mRegionManager.RequestNavigate(RegionNames.ToolBarRegion, nameof(ToolBarView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation(nameof(ToolBarView)); + } + } +} \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs new file mode 100644 index 0000000..12ead79 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs @@ -0,0 +1,17 @@ +using AdamStudio.Core.Mvvm; +using Microsoft.Extensions.Logging; +using Prism.Regions; + +namespace AdamStudio.Modules.ToolBarRegion.ViewModels +{ + public class ToolBarViewModel : RegionViewModelBase + { + private readonly ILogger mLogger; + public ToolBarViewModel(IRegionManager regionManager, ILogger logger) : base(regionManager) + { + mLogger = logger; + + mLogger.LogTrace("Load ~"); + } + } +} diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml new file mode 100644 index 0000000..afbdbf5 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs new file mode 100644 index 0000000..c525a11 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace AdamStudio.Modules.ToolBarRegion.Views +{ + public partial class ToolBarView : UserControl + { + public ToolBarView() + { + InitializeComponent(); + } + } +} From 78de8e964fde37137834d0f66b42258008a51080 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 15:20:44 +1000 Subject: [PATCH 10/40] Worked version with expander + popup --- AdamStudio/Views/MainWindow.xaml | 76 ++++++++++++++++--- .../Views/ScratchControlView.xaml | 21 +++-- .../Views/ScratchControlView.xaml.cs | 4 +- .../Views/ToolBarView.xaml | 71 +++++++++++++++-- 4 files changed, 145 insertions(+), 27 deletions(-) diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 068d3d5..89114ad 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -134,17 +134,75 @@ --> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml index 76cfcc6..b99359e 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml @@ -26,29 +26,29 @@ - + - - + + - + - + --> @@ -72,7 +72,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ee888b3bd35afdc69518beecbb33285686abe691 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 16:25:01 +1000 Subject: [PATCH 11/40] #96 worked version with tab --- AdamStudio/Views/MainWindow.xaml | 68 ++----------------- .../Views/ToolBarView.xaml | 41 ++++++++++- .../Views/ToolBarView.xaml.cs | 15 ++++ 3 files changed, 59 insertions(+), 65 deletions(-) diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 89114ad..1605f18 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -137,71 +137,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index bfd27b4..71a2c8e 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -9,7 +9,44 @@ xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" prism:ViewModelLocator.AutoWireViewModel="True" > - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs index c525a11..0b9854c 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs @@ -8,5 +8,20 @@ public ToolBarView() { InitializeComponent(); } + + private void Popup_Opened(object sender, System.EventArgs e) + { + + } + + private void Popup_Closed(object sender, System.EventArgs e) + { + + } + + private void ResultTab_MouseLeave_1(object sender, System.Windows.Input.MouseEventArgs e) + { + + } } } From ad3c71bf7824a5e2653344959a88e4fd7ae4a286 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 12 Jul 2024 16:51:30 +1000 Subject: [PATCH 12/40] #96 worked version with multiple expander --- .../Views/ToolBarView.xaml | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index 71a2c8e..70c47a0 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -9,25 +9,22 @@ xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" prism:ViewModelLocator.AutoWireViewModel="True" > - - - - - + + + + + Width="{Binding ActualWidth, ElementName=View}" + IsOpen="{Binding IsExpanded, ElementName=ResultEpander}"> @@ -42,10 +39,29 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AdamStudio.Controls/CustomControls/ResizablePopup.xaml.cs b/AdamStudio.Controls/CustomControls/ResizablePopup.xaml.cs new file mode 100644 index 0000000..abb6e87 --- /dev/null +++ b/AdamStudio.Controls/CustomControls/ResizablePopup.xaml.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace AdamStudio.Controls.CustomControls +{ + /// + /// Логика взаимодействия для ResizablePopup.xaml + /// + public partial class ResizablePopup : Popup + { + public ResizablePopup() + { + InitializeComponent(); + Resizing = false; + UpdateUi(); + } + + /// + /// Background DependencyProperty, which designates the background brush + public static DependencyProperty BackgroundProperty = DependencyProperty.Register("Background", typeof(Brush), typeof(ResizablePopup)); + /// + /// Get or set Background DependencyProperty, which designates the background brush + public Brush Background + { + get { return ((Brush)(base.GetValue(ResizablePopup.BackgroundProperty))); } + set { base.SetValue(ResizablePopup.BackgroundProperty, value); } + } + + /// + /// BorderBrush DependencyProperty, which designates the border brush + public static DependencyProperty BorderBrushProperty = DependencyProperty.Register("BorderBrush", typeof(Brush), typeof(ResizablePopup)); + /// + /// Get or set BorderBrush DependencyProperty, which designates the border brush + public Brush BorderBrush + { + get { return ((Brush)(base.GetValue(ResizablePopup.BorderBrushProperty))); } + set { base.SetValue(ResizablePopup.BorderBrushProperty, value); } + } + + /// + /// Gets whether the popup is being resized + public bool Resizing { get; private set; } + /// + /// Dock Side dependency property, which side the popup is docked to + public static DependencyProperty DockSideProperty = DependencyProperty.Register("DockSide", typeof(Dock), typeof(ResizablePopup)); + /// + /// Gets or sets the dock side of popup + public Dock DockSide + { + get { return ((Dock)(base.GetValue(ResizablePopup.DockSideProperty))); } + set + { + base.SetValue(ResizablePopup.DockSideProperty, value); + UpdateUi(); + } + } + /// + /// Content dependency property of popup + public static DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(UIElement), typeof(ResizablePopup)); + /// + /// Gets or sets the content of the popup + public UIElement Content + { + get { return ((UIElement)(base.GetValue(ResizablePopup.ContentProperty))); } + set { base.SetValue(ResizablePopup.ContentProperty, value); } + } + /// + /// Update the visibility of resize thumbs, depending on dock side + private void UpdateUi() + { + TopResizeThumb.Visibility = DockSide == Dock.Bottom ? Visibility.Visible : Visibility.Collapsed; + BottomResizeThumb.Visibility = DockSide == Dock.Top ? Visibility.Visible : Visibility.Collapsed; + LeftResizeThumb.Visibility = DockSide == Dock.Right ? Visibility.Visible : Visibility.Collapsed; + RightResizeThumb.Visibility = DockSide == Dock.Left ? Visibility.Visible : Visibility.Collapsed; + } + /// + /// Callback when the dragging position of the resize thumb changes + /// Thumb sender + /// Delta arguments + private void ThumbDragDelta(object sender, DragDeltaEventArgs e) + { + switch (DockSide) + { + case Dock.Top: + Height += e.VerticalChange; + break; + case Dock.Bottom: + Height -= e.VerticalChange; + break; + case Dock.Left: + Width += e.HorizontalChange; + break; + case Dock.Right: + Width -= e.HorizontalChange; + break; + } + Width = Math.Min(Width, MaxWidth); + Height = Math.Min(Height, MaxHeight); + Thumb t = sender as Thumb; + } + + /// + /// Callback when dragging of resize thumb starts (mouse down) + /// Thumb sender + /// Start arguments + private void ThumbDragStarted(object sender, DragStartedEventArgs e) + { + Resizing = true; + } + /// + /// Callback when dragging of resize thumb ends (mouse up) + /// Thumb sender + /// Completed arguments + private void ThumbDragCompleted(object sender, DragCompletedEventArgs e) + { + Resizing = false; + } + } +} diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 594b5e0..42dd0f1 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -8,7 +8,7 @@ xmlns:prism="http://prismlibrary.com/" xmlns:customusercontrol="clr-namespace:AdamStudio.Controls.CustomControls;assembly=AdamStudio.Controls" prism:ViewModelLocator.AutoWireViewModel="True" - xmlns:converters="clr-namespace:AdamStudio.Core.Converters;assembly=AdamStudio.Core" + xmlns:converters="clr-namespace:AdamStudio.Core.Converters;assembly=AdamStudio.Core" xmlns:controlzex="urn:controlzex" WindowTitleBrush="{DynamicResource MahApps.Brushes.Control.Background}" NonActiveWindowTitleBrush="{DynamicResource MahApps.Brushes.Control.Background}" NonActiveBorderBrush="{DynamicResource MahApps.Brushes.Text}" @@ -106,7 +106,7 @@ - + @@ -121,29 +121,64 @@ + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AdamStudio/Views/MainWindow.xaml.cs b/AdamStudio/Views/MainWindow.xaml.cs index 2ea64a2..3af71d2 100644 --- a/AdamStudio/Views/MainWindow.xaml.cs +++ b/AdamStudio/Views/MainWindow.xaml.cs @@ -1,4 +1,6 @@ using MahApps.Metro.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; namespace AdamStudio.Views { @@ -8,5 +10,22 @@ public MainWindow() { InitializeComponent(); } + + private void Thumb_DragStarted(object sender, DragStartedEventArgs e) + { + Thumb t = sender as Thumb; + t.Cursor = Cursors.Hand; + } + + private void Thumb_DragDelta(object sender, DragDeltaEventArgs e) + { + PopupWindow.Height = PopupWindow.Height - e.VerticalChange; + } + + private void Thumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e) + { + Thumb t = sender as Thumb; + t.Cursor = null; + } } } diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index 04cff71..294800b 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -27,19 +27,7 @@ - - - - - - + + Height="500"> @@ -97,35 +82,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AdamStudio.Controls/CustomControls/ResizablePopup.xaml.cs b/AdamStudio.Controls/CustomControls/ResizablePopup.xaml.cs deleted file mode 100644 index abb6e87..0000000 --- a/AdamStudio.Controls/CustomControls/ResizablePopup.xaml.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace AdamStudio.Controls.CustomControls -{ - /// - /// Логика взаимодействия для ResizablePopup.xaml - /// - public partial class ResizablePopup : Popup - { - public ResizablePopup() - { - InitializeComponent(); - Resizing = false; - UpdateUi(); - } - - /// - /// Background DependencyProperty, which designates the background brush - public static DependencyProperty BackgroundProperty = DependencyProperty.Register("Background", typeof(Brush), typeof(ResizablePopup)); - /// - /// Get or set Background DependencyProperty, which designates the background brush - public Brush Background - { - get { return ((Brush)(base.GetValue(ResizablePopup.BackgroundProperty))); } - set { base.SetValue(ResizablePopup.BackgroundProperty, value); } - } - - /// - /// BorderBrush DependencyProperty, which designates the border brush - public static DependencyProperty BorderBrushProperty = DependencyProperty.Register("BorderBrush", typeof(Brush), typeof(ResizablePopup)); - /// - /// Get or set BorderBrush DependencyProperty, which designates the border brush - public Brush BorderBrush - { - get { return ((Brush)(base.GetValue(ResizablePopup.BorderBrushProperty))); } - set { base.SetValue(ResizablePopup.BorderBrushProperty, value); } - } - - /// - /// Gets whether the popup is being resized - public bool Resizing { get; private set; } - /// - /// Dock Side dependency property, which side the popup is docked to - public static DependencyProperty DockSideProperty = DependencyProperty.Register("DockSide", typeof(Dock), typeof(ResizablePopup)); - /// - /// Gets or sets the dock side of popup - public Dock DockSide - { - get { return ((Dock)(base.GetValue(ResizablePopup.DockSideProperty))); } - set - { - base.SetValue(ResizablePopup.DockSideProperty, value); - UpdateUi(); - } - } - /// - /// Content dependency property of popup - public static DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(UIElement), typeof(ResizablePopup)); - /// - /// Gets or sets the content of the popup - public UIElement Content - { - get { return ((UIElement)(base.GetValue(ResizablePopup.ContentProperty))); } - set { base.SetValue(ResizablePopup.ContentProperty, value); } - } - /// - /// Update the visibility of resize thumbs, depending on dock side - private void UpdateUi() - { - TopResizeThumb.Visibility = DockSide == Dock.Bottom ? Visibility.Visible : Visibility.Collapsed; - BottomResizeThumb.Visibility = DockSide == Dock.Top ? Visibility.Visible : Visibility.Collapsed; - LeftResizeThumb.Visibility = DockSide == Dock.Right ? Visibility.Visible : Visibility.Collapsed; - RightResizeThumb.Visibility = DockSide == Dock.Left ? Visibility.Visible : Visibility.Collapsed; - } - /// - /// Callback when the dragging position of the resize thumb changes - /// Thumb sender - /// Delta arguments - private void ThumbDragDelta(object sender, DragDeltaEventArgs e) - { - switch (DockSide) - { - case Dock.Top: - Height += e.VerticalChange; - break; - case Dock.Bottom: - Height -= e.VerticalChange; - break; - case Dock.Left: - Width += e.HorizontalChange; - break; - case Dock.Right: - Width -= e.HorizontalChange; - break; - } - Width = Math.Min(Width, MaxWidth); - Height = Math.Min(Height, MaxHeight); - Thumb t = sender as Thumb; - } - - /// - /// Callback when dragging of resize thumb starts (mouse down) - /// Thumb sender - /// Start arguments - private void ThumbDragStarted(object sender, DragStartedEventArgs e) - { - Resizing = true; - } - /// - /// Callback when dragging of resize thumb ends (mouse up) - /// Thumb sender - /// Completed arguments - private void ThumbDragCompleted(object sender, DragCompletedEventArgs e) - { - Resizing = false; - } - } -} diff --git a/AdamStudio.Core/Properties/Settings.Designer.cs b/AdamStudio.Core/Properties/Settings.Designer.cs index 673ab5c..2445ce3 100644 --- a/AdamStudio.Core/Properties/Settings.Designer.cs +++ b/AdamStudio.Core/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace AdamStudio.Core.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -1138,5 +1138,17 @@ public bool ShowVideo { this["ShowVideo"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("500")] + public double PopupPanelHeight { + get { + return ((double)(this["PopupPanelHeight"])); + } + set { + this["PopupPanelHeight"] = value; + } + } } } diff --git a/AdamStudio.Core/Properties/Settings.settings b/AdamStudio.Core/Properties/Settings.settings index 467bddf..6d25b20 100644 --- a/AdamStudio.Core/Properties/Settings.settings +++ b/AdamStudio.Core/Properties/Settings.settings @@ -1,5 +1,5 @@  - + @@ -281,5 +281,8 @@ True + + 500 + \ No newline at end of file diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 42dd0f1..bce253c 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -121,7 +121,6 @@ - @@ -135,50 +134,10 @@ x:Name="ContentRegion" prism:RegionManager.RegionName="{x:Static core:RegionNames.ContentRegion}" /> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AdamStudio/Views/MainWindow.xaml.cs b/AdamStudio/Views/MainWindow.xaml.cs index 3af71d2..7ae14ed 100644 --- a/AdamStudio/Views/MainWindow.xaml.cs +++ b/AdamStudio/Views/MainWindow.xaml.cs @@ -11,21 +11,9 @@ public MainWindow() InitializeComponent(); } - private void Thumb_DragStarted(object sender, DragStartedEventArgs e) - { - Thumb t = sender as Thumb; - t.Cursor = Cursors.Hand; - } + + - private void Thumb_DragDelta(object sender, DragDeltaEventArgs e) - { - PopupWindow.Height = PopupWindow.Height - e.VerticalChange; - } - - private void Thumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e) - { - Thumb t = sender as Thumb; - t.Cursor = null; - } + } } diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index 294800b..636f810 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -8,7 +8,7 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:converters="clr-namespace:AdamStudio.Core.Converters;assembly=AdamStudio.Core" - xmlns:properties="clr-namespace:AdamStudio.Core.Properties;assembly=AdamStudio.Core" + xmlns:properties="clr-namespace:AdamStudio.Core.Properties;assembly=AdamStudio.Core" xmlns:controlzex="urn:controlzex" prism:ViewModelLocator.AutoWireViewModel="True" > @@ -27,19 +27,34 @@ - + + + + + + + + + Margin="5 5 5 0" + BorderThickness="1" + TabStripPlacement="Bottom" + mah:TabControlHelper.CloseButtonEnabled="False" + mah:HeaderedControlHelper.HeaderFontSize="13" + mah:TabControlHelper.Underlined="SelectedTabItem" + mah:TabControlHelper.UnderlinePlacement="Top" + mah:TabControlHelper.UnderlineSelectedBrush="{DynamicResource MahApps.Brushes.Text}" + mah:TabControlHelper.UnderlineBrush="{DynamicResource MahApps.Brushes.Text}" + BorderBrush="{DynamicResource MahApps.Brushes.Text}"> @@ -49,19 +64,18 @@ HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" IsReadOnly="True" - Text="{Binding ResultText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> + Text="{Binding ResultText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> - + - @@ -74,7 +88,6 @@ - @@ -82,8 +95,14 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + - + + - + + + - + - + - + + + + - + - - - + + + + - + - + - + + - - + + + - - + + + - - + + + - - + + + CommandParameter="{Binding StopDirrection}" /> - - - + + + - - + + + + - - - - + + + - - - + - + - + - + - - + + + - + - - - - + - - - - + - + @@ -619,102 +601,6 @@ - - - diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs index a750aa6..abacdf4 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs @@ -76,14 +76,9 @@ private async void VideoViewIsVisibleChanged(object sender, DependencyPropertyCh { if (VideoView.IsVisible) { - string ip = Settings.Default.ServerIP; string port = Settings.Default.VideoDataExchangePort; - var uri = new Uri($"http://{ip}:{port}/stream/0.mjpeg"); - //var docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\test.avi"; - //var uri = new Uri($"{docPath}"); - await VideoView.Open(uri); return; } @@ -99,7 +94,6 @@ private void VideoViewVideoFrameDecoded(object sender, FrameDecodedEventArgs e) private void VideoViewMediaOpening(object sender, MediaOpeningEventArgs e) { - e.Options.IsTimeSyncDisabled = true; e.Options.IsAudioDisabled = true; e.Options.MinimumPlaybackBufferPercent = 0; @@ -151,10 +145,10 @@ private void WebViewNavigationCompleted(object sender, CoreWebView2NavigationCom mWebViewProvider.NavigationComplete(); } - private void TextResulEditorTextChanged(object sender, EventArgs e) + /*private void TextResulEditorTextChanged(object sender, EventArgs e) { //Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(TextResulEditor.ScrollToEnd)); - } + }*/ private async void InitializeWebViewCore() { @@ -169,20 +163,22 @@ private void WebViewCoreWebView2InitializationCompleted(object sender, CoreWebVi WebView?.CoreWebView2?.SetVirtualHostNameToFolderMapping("localhost", mPathToSource, CoreWebView2HostResourceAccessKind.Allow); WebView?.CoreWebView2?.Navigate("https://localhost/index.html"); } - - private void WebViewWebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) + + private static readonly JsonSerializerOptions jsonSerializerOptions = new() { - JsonSerializerOptions options = new() - { - NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString - }; + NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString + }; + + private readonly JsonSerializerOptions mOptions = jsonSerializerOptions; + private void WebViewWebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) + { WebMessageJsonReceived receivedResult; try { string receivedString = e.TryGetWebMessageAsString(); - receivedResult = JsonSerializer.Deserialize(receivedString, options); + receivedResult = JsonSerializer.Deserialize(receivedString, mOptions); } catch { From fa0a2cbafb96a20be1dbd3463f74e844f400339c Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Thu, 8 Aug 2024 10:35:25 +1000 Subject: [PATCH 22/40] Revert --- .../StringToViewRegionIconsConverter.cs | 4 +- .../Properties/Settings.Designer.cs | 26 +- AdamStudio.Core/Properties/Settings.settings | 8 +- AdamStudio.Core/RegionNames.cs | 8 +- AdamStudio.Core/SubRegionNames.cs | 16 - .../AdamStudio.Services.csproj | 6 +- .../CommunicationProviderService.cs | 1 - .../Interfaces/ICultureProvider.cs | 1 - .../Interfaces/ILogWriteEventAwareService.cs | 21 + .../Interfaces/IRegionChangeAwareService.cs | 25 + .../Interfaces/ISingleInstanceService.cs | 9 - .../IStatusBarNotificationDeliveryService.cs | 6 +- .../ISubRegionChangeAwareService.cs | 25 - .../LogWriteEventAwareService.cs | 49 ++ ...Service.cs => RegionChangeAwareService.cs} | 16 +- AdamStudio.Services/SingleInstanceService.cs | 79 -- .../StatusBarNotificationDeliveryService.cs | 20 - AdamStudio.sln | 7 + AdamStudio/AdamStudio.csproj | 4 + AdamStudio/App.xaml | 7 +- AdamStudio/App.xaml.cs | 257 +++++- AdamStudio/Bootstrapper.cs | 237 ------ AdamStudio/ViewModels/MainWindowViewModel.cs | 96 ++- AdamStudio/Views/MainWindow.xaml | 31 +- .../ContentRegionModule.cs | 5 +- .../ViewModels/ContentRegionViewModel.cs | 75 -- .../ViewModels/ScratchControlViewModel.cs | 117 +-- .../ViewModels/SettingsControlViewModel.cs | 8 +- .../Views/ContentRegionView.xaml | 10 - .../Views/ContentRegionView.xaml.cs | 12 - .../Views/ScratchControlView.xaml | 735 ++++++++---------- .../Views/ScratchControlView.xaml.cs | 37 +- .../MenuRegionModule.cs | 2 - .../ViewModels/MenuRegionViewModel.cs | 47 +- .../Views/MenuRegionView.xaml | 12 +- .../StatusBarRegionModule.cs | 2 - .../ViewModels/StatusBarViewModel.cs | 27 +- .../AdamStudio.Modules.ToolBarRegion.csproj | 12 + .../Template/PopupWindow.xaml | 65 ++ .../Template/PopupWindow.xaml.cs | 51 ++ .../ToolBarRegionModule.cs | 28 + .../ViewModels/ToolBarViewModel.cs | 255 ++++++ .../Views/ToolBarView.xaml | 296 +++++++ .../Views/ToolBarView.xaml.cs | 13 + 44 files changed, 1645 insertions(+), 1123 deletions(-) delete mode 100644 AdamStudio.Core/SubRegionNames.cs create mode 100644 AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs create mode 100644 AdamStudio.Services/Interfaces/IRegionChangeAwareService.cs delete mode 100644 AdamStudio.Services/Interfaces/ISingleInstanceService.cs delete mode 100644 AdamStudio.Services/Interfaces/ISubRegionChangeAwareService.cs create mode 100644 AdamStudio.Services/LogWriteEventAwareService.cs rename AdamStudio.Services/{SubRegionChangeAwareService.cs => RegionChangeAwareService.cs} (51%) delete mode 100644 AdamStudio.Services/SingleInstanceService.cs delete mode 100644 AdamStudio/Bootstrapper.cs delete mode 100644 Modules/AdamStudio.Modules.ContentRegion/ViewModels/ContentRegionViewModel.cs delete mode 100644 Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml delete mode 100644 Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml.cs create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml.cs create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml create mode 100644 Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs diff --git a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs index 6b02a80..407f470 100644 --- a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs +++ b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs @@ -16,10 +16,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value != null) stringValue = (string)value; - if (stringValue == SubRegionNames.SubRegionVisualSettings) + if (stringValue == RegionNames.SettingsView) return PackIconSimpleIconsKind.Scratch; - if (stringValue == SubRegionNames.SubRegionScratch) + if (stringValue == RegionNames.ScratchView) return PackIconFeatherIconsKind.Settings; return PackIconSimpleIconsKind.AbbRobotStudio; diff --git a/AdamStudio.Core/Properties/Settings.Designer.cs b/AdamStudio.Core/Properties/Settings.Designer.cs index 673ab5c..9a3aeb3 100644 --- a/AdamStudio.Core/Properties/Settings.Designer.cs +++ b/AdamStudio.Core/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace AdamStudio.Core.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -1138,5 +1138,29 @@ public bool ShowVideo { this["ShowVideo"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("500")] + public double PopupPanelHeight { + get { + return ((double)(this["PopupPanelHeight"])); + } + set { + this["PopupPanelHeight"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("500")] + public double SSHPanelHeight { + get { + return ((double)(this["SSHPanelHeight"])); + } + set { + this["SSHPanelHeight"] = value; + } + } } } diff --git a/AdamStudio.Core/Properties/Settings.settings b/AdamStudio.Core/Properties/Settings.settings index 467bddf..d1f8ab1 100644 --- a/AdamStudio.Core/Properties/Settings.settings +++ b/AdamStudio.Core/Properties/Settings.settings @@ -1,5 +1,5 @@  - + @@ -281,5 +281,11 @@ True + + 500 + + + 500 + \ No newline at end of file diff --git a/AdamStudio.Core/RegionNames.cs b/AdamStudio.Core/RegionNames.cs index 6e06f11..5b895a5 100644 --- a/AdamStudio.Core/RegionNames.cs +++ b/AdamStudio.Core/RegionNames.cs @@ -2,9 +2,15 @@ { public class RegionNames { - public const string MenuRegion = $"{nameof(MenuRegion)}"; + public const string ContentRegion = $"{nameof(ContentRegion)}"; public const string FlayoutsRegion = $"{nameof(FlayoutsRegion)}"; + public const string ToolBarRegion = $"{nameof(ToolBarRegion)}"; public const string StatusBarRegion = $"{nameof(StatusBarRegion)}"; + public const string MenuRegion = $"{nameof(MenuRegion)}"; + + + public const string ScratchView = "ScratchControlView"; + public const string SettingsView = "SettingsControlView"; } } diff --git a/AdamStudio.Core/SubRegionNames.cs b/AdamStudio.Core/SubRegionNames.cs deleted file mode 100644 index a1e044f..0000000 --- a/AdamStudio.Core/SubRegionNames.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace AdamStudio.Core -{ - public class SubRegionNames - { - /// - /// region to switch SubRegionView inside ContentRegion - /// - public const string InsideConentRegion = $"{nameof(InsideConentRegion)}"; - - public const string SubRegionScratch = $"{nameof(SubRegionScratch)}"; - - public const string SubRegionComputerVisionControl = $"{nameof(SubRegionComputerVisionControl)}"; - - public const string SubRegionVisualSettings = $"{nameof(SubRegionVisualSettings)}"; - } -} diff --git a/AdamStudio.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj index ae9fc3f..1ce0b50 100644 --- a/AdamStudio.Services/AdamStudio.Services.csproj +++ b/AdamStudio.Services/AdamStudio.Services.csproj @@ -9,12 +9,16 @@ - + + + + + diff --git a/AdamStudio.Services/CommunicationProviderService.cs b/AdamStudio.Services/CommunicationProviderService.cs index d2f9ceb..2d3cc6b 100644 --- a/AdamStudio.Services/CommunicationProviderService.cs +++ b/AdamStudio.Services/CommunicationProviderService.cs @@ -102,7 +102,6 @@ public void Dispose() #endregion - #region Private methods #endregion diff --git a/AdamStudio.Services/Interfaces/ICultureProvider.cs b/AdamStudio.Services/Interfaces/ICultureProvider.cs index 52f3ca9..5047e2d 100644 --- a/AdamStudio.Services/Interfaces/ICultureProvider.cs +++ b/AdamStudio.Services/Interfaces/ICultureProvider.cs @@ -26,7 +26,6 @@ public interface ICultureProvider : IDisposable #endregion #region Public methods - public string FindResource(string resourcePath); public void ChangeAppCulture(CultureInfo culture); diff --git a/AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs b/AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs new file mode 100644 index 0000000..d244c9d --- /dev/null +++ b/AdamStudio.Services/Interfaces/ILogWriteEventAwareService.cs @@ -0,0 +1,21 @@ +using System; + +namespace AdamStudio.Services.Interfaces +{ + #region Delegates + + public delegate void NewLogMessageWriteEventHandler(object sender, string message); + + #endregion + + public interface ILogWriteEventAwareService : IDisposable + { + #region Events + + public event NewLogMessageWriteEventHandler RaiseNewLogMessageWriteEvent; + + #endregion + + public void WriteToBuffer(string formattedLogMessage); + } +} diff --git a/AdamStudio.Services/Interfaces/IRegionChangeAwareService.cs b/AdamStudio.Services/Interfaces/IRegionChangeAwareService.cs new file mode 100644 index 0000000..067935d --- /dev/null +++ b/AdamStudio.Services/Interfaces/IRegionChangeAwareService.cs @@ -0,0 +1,25 @@ +using System; + +namespace AdamStudio.Services.Interfaces +{ + #region Delegate + + public delegate void RegionChangeEventHandler(object sender); + + #endregion + + public interface IRegionChangeAwareService : IDisposable + { + #region Events + + public event RegionChangeEventHandler RaiseRegionChangeEvent; + + #endregion + + #region Public fields + + public string RegionNavigationTargetName { get; set; } + + #endregion + } +} diff --git a/AdamStudio.Services/Interfaces/ISingleInstanceService.cs b/AdamStudio.Services/Interfaces/ISingleInstanceService.cs deleted file mode 100644 index 202e109..0000000 --- a/AdamStudio.Services/Interfaces/ISingleInstanceService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Windows; - -namespace AdamStudio.Services.Interfaces -{ - public interface ISingleInstanceService - { - public void Make(Application application, string appName, bool uniquePerUser = true); - } -} diff --git a/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs b/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs index 734359c..eb80024 100644 --- a/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs +++ b/AdamStudio.Services/Interfaces/IStatusBarNotificationDeliveryService.cs @@ -6,7 +6,7 @@ namespace AdamStudio.Services.Interfaces public delegate void ChangeProgressRingStateEventHandler(object sender, bool newState); public delegate void NewCompileLogMessageEventHandler(object sender, string message); - public delegate void NewAppLogMessageEventHandler(object sender, string message); + //public delegate void NewAppLogMessageEventHandler(object sender, string message); public delegate void UpdateNotificationCounterEventHandler(object sender, int counter); #endregion @@ -17,7 +17,7 @@ public interface IStatusBarNotificationDeliveryService : IDisposable public event ChangeProgressRingStateEventHandler RaiseChangeProgressRingStateEvent; public event NewCompileLogMessageEventHandler RaiseNewCompileLogMessageEvent; - public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; + //public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; public event UpdateNotificationCounterEventHandler RaiseUpdateNotificationCounterEvent; #endregion @@ -26,7 +26,7 @@ public interface IStatusBarNotificationDeliveryService : IDisposable public bool ProgressRingStart { get; set; } public string CompileLogMessage { get; set; } - public string AppLogMessage { get; set; } + //public string AppLogMessage { get; set; } public int NotificationCounter { get; set; } #endregion diff --git a/AdamStudio.Services/Interfaces/ISubRegionChangeAwareService.cs b/AdamStudio.Services/Interfaces/ISubRegionChangeAwareService.cs deleted file mode 100644 index bd6fb96..0000000 --- a/AdamStudio.Services/Interfaces/ISubRegionChangeAwareService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace AdamStudio.Services.Interfaces -{ - #region Delegate - - public delegate void SubRegionChangeEventHandler(object sender); - - #endregion - - public interface ISubRegionChangeAwareService : IDisposable - { - #region Events - - public event SubRegionChangeEventHandler RaiseSubRegionChangeEvent; - - #endregion - - #region Public fields - - public string InsideRegionNavigationRequestName { get; set; } - - #endregion - } -} diff --git a/AdamStudio.Services/LogWriteEventAwareService.cs b/AdamStudio.Services/LogWriteEventAwareService.cs new file mode 100644 index 0000000..d2e8bf7 --- /dev/null +++ b/AdamStudio.Services/LogWriteEventAwareService.cs @@ -0,0 +1,49 @@ +using AdamStudio.Services.Interfaces; +using System; +using System.Text; + +namespace AdamStudio.Services +{ + public class LogWriteEventAwareService : ILogWriteEventAwareService + { + #region Events + + public event NewLogMessageWriteEventHandler RaiseNewLogMessageWriteEvent; + + #endregion + + private readonly StringBuilder mLogEventBuffer = new(); + + public LogWriteEventAwareService() { } + + + public void Dispose() + { + mLogEventBuffer?.Clear(); + } + + public void WriteToBuffer(string formattedLogMessage) + { + var message = formattedLogMessage.TrimEnd(Environment.NewLine.ToCharArray()); + mLogEventBuffer.AppendLine(message); + + OnRaiseNewLogMessageWriteEvent(message); + } + + public string GetLogMessages() + { + return mLogEventBuffer.ToString(); + } + + public void ClearLogMessages() + { + mLogEventBuffer?.Clear(); + } + + protected virtual void OnRaiseNewLogMessageWriteEvent(string message) + { + NewLogMessageWriteEventHandler raiseEvent = RaiseNewLogMessageWriteEvent; + raiseEvent?.Invoke(this, message); + } + } +} diff --git a/AdamStudio.Services/SubRegionChangeAwareService.cs b/AdamStudio.Services/RegionChangeAwareService.cs similarity index 51% rename from AdamStudio.Services/SubRegionChangeAwareService.cs rename to AdamStudio.Services/RegionChangeAwareService.cs index 1d972f4..2063c7e 100644 --- a/AdamStudio.Services/SubRegionChangeAwareService.cs +++ b/AdamStudio.Services/RegionChangeAwareService.cs @@ -3,28 +3,28 @@ namespace AdamStudio.Services { - public class SubRegionChangeAwareService : BindableBase, ISubRegionChangeAwareService + public class RegionChangeAwareService : BindableBase, IRegionChangeAwareService { #region Events - public event SubRegionChangeEventHandler RaiseSubRegionChangeEvent; + public event RegionChangeEventHandler RaiseRegionChangeEvent; #endregion #region ~ - public SubRegionChangeAwareService() { } + public RegionChangeAwareService() { } #endregion #region Public fields - private string insideRegionNavigationRequestName; - public string InsideRegionNavigationRequestName + private string regionNavigationRequestName; + public string RegionNavigationTargetName { - get { return insideRegionNavigationRequestName; } + get { return regionNavigationRequestName; } set { - bool isNewValue = SetProperty(ref insideRegionNavigationRequestName, value); + bool isNewValue = SetProperty(ref regionNavigationRequestName, value); if (isNewValue) OnRaiseRegionChangeEvent(); @@ -39,7 +39,7 @@ public void Dispose() { } protected virtual void OnRaiseRegionChangeEvent() { - SubRegionChangeEventHandler raiseEvent = RaiseSubRegionChangeEvent; + RegionChangeEventHandler raiseEvent = RaiseRegionChangeEvent; raiseEvent?.Invoke(this); } diff --git a/AdamStudio.Services/SingleInstanceService.cs b/AdamStudio.Services/SingleInstanceService.cs deleted file mode 100644 index 56223f3..0000000 --- a/AdamStudio.Services/SingleInstanceService.cs +++ /dev/null @@ -1,79 +0,0 @@ -using AdamStudio.Services.Interfaces; -using System; -using System.Threading; - -using System.Windows; - -namespace AdamStudio.Services -{ - public class SingleInstanceService : ISingleInstanceService - { - private static bool AlreadyProcessedOnThisInstance; - - public void Make(Application application, string appName, bool uniquePerUser = true) - { - if (AlreadyProcessedOnThisInstance) - { - return; - } - AlreadyProcessedOnThisInstance = true; - - string eventName = uniquePerUser - ? $"{appName}-{Environment.MachineName}-{Environment.UserDomainName}-{Environment.UserName}" - : $"{appName}-{Environment.MachineName}"; - - bool isSecondaryInstance = true; - - EventWaitHandle eventWaitHandle = null; - - try - { - eventWaitHandle = EventWaitHandle.OpenExisting(eventName); - } - catch - { - // This code only runs on the first instance. - isSecondaryInstance = false; - } - - if (isSecondaryInstance) - { - ActivateFirstInstanceWindow(eventWaitHandle); - - // Let's produce a non-interceptable exit (2009 year approach). - Environment.Exit(0); - } - - RegisterFirstInstanceWindowActivation(application, eventName); - } - - private void ActivateFirstInstanceWindow(EventWaitHandle eventWaitHandle) - { - // Let's notify the first instance to activate its main window. - _ = eventWaitHandle.Set(); - } - - private void RegisterFirstInstanceWindowActivation(Application app, string eventName) - { - EventWaitHandle eventWaitHandle = new( - false, - EventResetMode.AutoReset, - eventName); - - _ = ThreadPool.RegisterWaitForSingleObject(eventWaitHandle, WaitOrTimerCallback, app, Timeout.Infinite, false); - - eventWaitHandle.Close(); - } - - private void WaitOrTimerCallback(object state, bool timedOut) - { - Application app = (Application)state; - - _ = app.Dispatcher.BeginInvoke(new Action(() => - { - _ = Application.Current.MainWindow.WindowState = WindowState.Normal; - _ = Application.Current.MainWindow.Activate(); - })); - } - } -} diff --git a/AdamStudio.Services/StatusBarNotificationDeliveryService.cs b/AdamStudio.Services/StatusBarNotificationDeliveryService.cs index 77ba271..d95a53c 100644 --- a/AdamStudio.Services/StatusBarNotificationDeliveryService.cs +++ b/AdamStudio.Services/StatusBarNotificationDeliveryService.cs @@ -11,7 +11,6 @@ public class StatusBarNotificationDeliveryService : BindableBase, IStatusBarNoti public event ChangeProgressRingStateEventHandler RaiseChangeProgressRingStateEvent; public event NewCompileLogMessageEventHandler RaiseNewCompileLogMessageEvent; - public event NewAppLogMessageEventHandler RaiseNewAppLogMessageEvent; public event UpdateNotificationCounterEventHandler RaiseUpdateNotificationCounterEvent; #endregion @@ -50,19 +49,6 @@ public string CompileLogMessage OnRaiseNewCompileLogMessageEvent(CompileLogMessage); } } - - private string appLogMessage = string.Empty; - public string AppLogMessage - { - get => appLogMessage; - set - { - bool isNewValue = SetProperty(ref appLogMessage, value); - - if (isNewValue) - OnRaiseNewAppLogMessageEvent(AppLogMessage); - } - } private int notificationCounter; public int NotificationCounter @@ -107,12 +93,6 @@ protected virtual void OnRaiseNewCompileLogMessageEvent(string message) raiseEvent?.Invoke(this, message); } - protected virtual void OnRaiseNewAppLogMessageEvent(string message) - { - NewAppLogMessageEventHandler raiseEvent = RaiseNewAppLogMessageEvent; - raiseEvent?.Invoke(this, message); - } - protected virtual void OnRaiseUpdateNotificationCounterEvent(int counter) { UpdateNotificationCounterEventHandler raiseEvent = RaiseUpdateNotificationCounterEvent; diff --git a/AdamStudio.sln b/AdamStudio.sln index 62ce372..20d6b20 100644 --- a/AdamStudio.sln +++ b/AdamStudio.sln @@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamController.WebApi.Clien EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamStudio.Controls", "AdamStudio.Controls\AdamStudio.Controls.csproj", "{1BADFDB1-D66E-4580-8EAF-CAEE37761640}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdamStudio.Modules.ToolBarRegion", "Modules\AdamStudio.Modules.ToolBarRegion\AdamStudio.Modules.ToolBarRegion.csproj", "{AA601C7F-2233-47FE-911E-8221E8B861C8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -73,6 +75,10 @@ Global {1BADFDB1-D66E-4580-8EAF-CAEE37761640}.Debug|Any CPU.Build.0 = Debug|Any CPU {1BADFDB1-D66E-4580-8EAF-CAEE37761640}.Release|Any CPU.ActiveCfg = Release|Any CPU {1BADFDB1-D66E-4580-8EAF-CAEE37761640}.Release|Any CPU.Build.0 = Release|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA601C7F-2233-47FE-911E-8221E8B861C8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,6 +90,7 @@ Global {D17BE826-5C86-4EAC-8424-534F9CF3DFE0} = {BF38E868-9FEB-4645-9B2B-15AC47844075} {941A4E7D-6A53-44F8-876C-6B33AAEDDA89} = {511F4919-C2FC-4775-92A4-C446E51B49DB} {771220FE-2F25-441B-815E-7DD63918BA95} = {511F4919-C2FC-4775-92A4-C446E51B49DB} + {AA601C7F-2233-47FE-911E-8221E8B861C8} = {BF38E868-9FEB-4645-9B2B-15AC47844075} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D00A029C-930D-44A8-8257-721FCA9202F6} diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index dbe3d4c..e7773d6 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -30,12 +30,16 @@ 1701;1702;CA1416 + + + + diff --git a/AdamStudio/App.xaml b/AdamStudio/App.xaml index 9c2c3f0..3c4a6cf 100644 --- a/AdamStudio/App.xaml +++ b/AdamStudio/App.xaml @@ -1,4 +1,4 @@ - - - - - + diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index 69c7fad..d22689a 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -28,15 +28,29 @@ using System.ComponentModel; using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; +using AdamStudio.Views; +using AdamStudio.Controls.CustomControls.Services; +using AdamStudio.Services.TcpClientDependency; +using AdamStudio.Services; +using Microsoft.Extensions.DependencyInjection; +using Serilog; +using System.Net; +using Serilog.Core; +using AdamStudio.Controls.CustomControls.RegionAdapters; +using AdamStudio.Modules.ContentRegion; +using AdamStudio.Modules.FlayoutsRegion; +using AdamStudio.Modules.MenuRegion; +using AdamStudio.Modules.StatusBarRegion; +using AdamStudio.Modules.ToolBarRegion; #endregion namespace AdamStudio { - public partial class App : Application + public partial class App : PrismApplication { - private readonly Bootstrapper mBootstrapper = new(); + #region ~ public App() { @@ -44,14 +58,212 @@ public App() LoadSharedFFmpegLibrary(); } - protected override void OnStartup(StartupEventArgs e) + #endregion + + protected override Window CreateShell() + { + return Container.Resolve(); + } + + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + + containerRegistry.RegisterSingleton(containerRegistry => + { + IFileManagmentService fileManagment = containerRegistry.Resolve(); + AvalonEditService avalonService = new(fileManagment); + return avalonService; + }); + + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + + containerRegistry.RegisterSingleton(containerRegistry => + { + DryIoc.IContainer container = containerRegistry.GetContainer(); + IRegionManager regionManager = containerRegistry.Resolve(); + + return new FlyoutManager(container, regionManager); + }); + + containerRegistry.RegisterSingleton(() => + { + TcpClientOption option = new() + { + ReconnectCount = Settings.Default.ReconnectQtyComunicateTcpClient, + ReconnectTimeout = Settings.Default.ReconnectTimeoutComunicateTcpClient + }; + + string ip = Settings.Default.ServerIP; + int port = Settings.Default.TcpConnectStatePort; + + TcpClientService client; + + if (!string.IsNullOrEmpty(ip)) + { + client = new(ip, port, option); + } + else + { + client = new("127.0.0.1", port, option); + } + + + return client; + }); + + containerRegistry.RegisterSingleton(() => + { + IPAddress ip = IPAddress.Any; + int port = int.Parse(Settings.Default.MessageDataExchangePort); + + UdpClientService client = new(ip, port) + { + OptionDualMode = true, + OptionReuseAddress = true + }; + + return client; + }); + + containerRegistry.RegisterSingleton(() => + { + IPAddress ip = IPAddress.Any; + int port = Settings.Default.LogServerPort; + + UdpServerService server = new(ip, port) + { + OptionDualMode = true, + OptionReuseAddress = true + }; + + return server; + }); + + containerRegistry.RegisterSingleton(() => + { + string ip = Settings.Default.ServerIP; + int port = Settings.Default.SoketServerPort; + Uri uri; + + if (!string.IsNullOrEmpty(ip)) + { + uri = new($"ws://{ip}:{port}/adam-2.7/movement"); + } + else + { + uri = new($"ws://127.0.0.1:9001/adam-2.7/movement"); + } + + // debug, use only with debug server, which runs separately, not as a service + //Uri uri = new($"ws://{Settings.Default.ServerIP}:9001/adam-2.7/movement"); + + // work in production, connect to socket-server run as service + // Uri uri = new($"ws://{ip}:{port}/adam-2.7/movement"); + + WebSocketClientService client = new(uri); + return client; + }); + + containerRegistry.RegisterSingleton(() => + { + string ip = Settings.Default.ServerIP; + int port = Settings.Default.ApiPort; + string login = Settings.Default.ApiLogin; + string password = Settings.Default.ApiPassword; + + if (string.IsNullOrEmpty(ip)) + { + ip = "127.0.0.1"; + } + + WebApiService client = new(ip, port, login, password); + return client; + + }); + + containerRegistry.RegisterSingleton(containerRegistry => + { + ITcpClientService tcpClientService = containerRegistry.Resolve(); + IUdpClientService udpClientService = containerRegistry.Resolve(); + IUdpServerService udpServerService = containerRegistry.Resolve(); + IWebSocketClientService socketClientService = containerRegistry.Resolve(); + + CommunicationProviderService communicationProvider = new(tcpClientService, udpClientService, udpServerService, socketClientService); + + return communicationProvider; + }); + + containerRegistry.RegisterSingleton(containerRegistry => + { + IUdpClientService udpClient = containerRegistry.Resolve(); + + PythonRemoteRunnerService remoteRunnerService = new(udpClient); + return remoteRunnerService; + }); + + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(containerRegistry => + { + bool isVideoShowLastValue = Settings.Default.ShowVideo; + return new ControlHelper(isVideoShowLastValue); + }); + + containerRegistry.RegisterSingleton(); + + RegisterDialogs(containerRegistry); + RegisterService(containerRegistry); + } + + private void RegisterService(IContainerRegistry containerRegistry) { - mBootstrapper.Run(); - //mBootstrapper.Container.Resolve().Make(Current, "AdamStudio"); + containerRegistry.RegisterServices(services => + { + ILogWriteEventAwareService logWriteEventAware = Container.Resolve(); - base.OnStartup(e); - - + Logger mainLogger = new LoggerConfiguration() + .MinimumLevel.Verbose() + .WriteTo.DelegatingTextSink(writeAction => logWriteEventAware.WriteToBuffer(writeAction), + outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") + .WriteTo.File("logs/log-.txt", + rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}") + + .CreateLogger(); + + services.AddLogging(s => s.AddSerilog(mainLogger, dispose: true)); + }); + } + + private static void RegisterDialogs(IContainerRegistry containerRegistry) + { + // used for call system dialog for open save/open/select file/folder (Microsoft.Win32 dialogs) + containerRegistry.RegisterSingleton(); + + //Dialog boxes are not used, but implemented + //containerRegistry.RegisterDialog(); + } + + protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) + { + base.ConfigureRegionAdapterMappings(regionAdapterMappings); + + regionAdapterMappings.RegisterMapping(typeof(FlyoutsControl), Container.Resolve()); + } + + protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) + { + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); + moduleCatalog.AddModule(); } protected override void OnExit(ExitEventArgs e) @@ -64,10 +276,37 @@ protected override void OnExit(ExitEventArgs e) private void OnAppCrashOrExit() { Unsubscribe(); - mBootstrapper.Dispose(); + Dispose(); Current.Shutdown(); } + public void Dispose() + { + IRegionManager regionManager = Container.Resolve(); + + //Called Destroy() in module + foreach (IRegion region in regionManager.Regions) + { + region.RemoveAll(); + } + + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + Container.Resolve().Dispose(); + + } + #region Subscribes private void Subscribe() diff --git a/AdamStudio/Bootstrapper.cs b/AdamStudio/Bootstrapper.cs deleted file mode 100644 index bf80468..0000000 --- a/AdamStudio/Bootstrapper.cs +++ /dev/null @@ -1,237 +0,0 @@ -using AdamStudio.Services.Interfaces; -using AdamStudio.Services; -using AdamStudio.Views; -using Prism.DryIoc; -using Prism.Ioc; -using System; -using System.Windows; -using AdamStudio.Controls.CustomControls.Services; -using AdamStudio.Core.Properties; -using AdamStudio.Services.TcpClientDependency; -using Prism.Regions; -using System.Net; -using AdamStudio.Controls.CustomControls.RegionAdapters; -using MahApps.Metro.Controls; -using AdamStudio.Modules.ContentRegion; -using AdamStudio.Modules.FlayoutsRegion; -using AdamStudio.Modules.MenuRegion; -using AdamStudio.Modules.StatusBarRegion; -using Prism.Modularity; - -namespace AdamStudio -{ - internal class Bootstrapper : PrismBootstrapper, IDisposable - { - protected override DependencyObject CreateShell() - { - return Container.Resolve(); - } - - protected override void RegisterTypes(IContainerRegistry containerRegistry) - { - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - - containerRegistry.RegisterSingleton(containerRegistry => - { - IFileManagmentService fileManagment = containerRegistry.Resolve(); - AvalonEditService avalonService = new(fileManagment); - return avalonService; - }); - - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - - containerRegistry.RegisterSingleton(containerRegistry => - { - DryIoc.IContainer container = containerRegistry.GetContainer(); - IRegionManager regionManager = containerRegistry.Resolve(); - - return new FlyoutManager(container, regionManager); - }); - - containerRegistry.RegisterSingleton(() => - { - TcpClientOption option = new() - { - ReconnectCount = Settings.Default.ReconnectQtyComunicateTcpClient, - ReconnectTimeout = Settings.Default.ReconnectTimeoutComunicateTcpClient - }; - - string ip = Settings.Default.ServerIP; - int port = Settings.Default.TcpConnectStatePort; - - TcpClientService client; - - if (!string.IsNullOrEmpty(ip)) - { - client = new(ip, port, option); - } - else - { - client = new("127.0.0.1", port, option); - } - - - return client; - }); - - containerRegistry.RegisterSingleton(() => - { - IPAddress ip = IPAddress.Any; - int port = int.Parse(Settings.Default.MessageDataExchangePort); - - UdpClientService client = new(ip, port) - { - OptionDualMode = true, - OptionReuseAddress = true - }; - - return client; - }); - - containerRegistry.RegisterSingleton(() => - { - IPAddress ip = IPAddress.Any; - int port = Settings.Default.LogServerPort; - - UdpServerService server = new(ip, port) - { - OptionDualMode = true, - OptionReuseAddress = true - }; - - return server; - }); - - containerRegistry.RegisterSingleton(() => - { - string ip = Settings.Default.ServerIP; - int port = Settings.Default.SoketServerPort; - Uri uri; - - if (!string.IsNullOrEmpty(ip)) - { - uri = new($"ws://{ip}:{port}/adam-2.7/movement"); - } - else - { - uri = new($"ws://127.0.0.1:9001/adam-2.7/movement"); - } - - // debug, use only with debug server, which runs separately, not as a service - //Uri uri = new($"ws://{Settings.Default.ServerIP}:9001/adam-2.7/movement"); - - // work in production, connect to socket-server run as service - // Uri uri = new($"ws://{ip}:{port}/adam-2.7/movement"); - - WebSocketClientService client = new(uri); - return client; - }); - - containerRegistry.RegisterSingleton(() => - { - string ip = Settings.Default.ServerIP; - int port = Settings.Default.ApiPort; - string login = Settings.Default.ApiLogin; - string password = Settings.Default.ApiPassword; - - if (string.IsNullOrEmpty(ip)) - { - ip = "127.0.0.1"; - } - - WebApiService client = new(ip, port, login, password); - return client; - - }); - - containerRegistry.RegisterSingleton(containerRegistry => - { - ITcpClientService tcpClientService = containerRegistry.Resolve(); - IUdpClientService udpClientService = containerRegistry.Resolve(); - IUdpServerService udpServerService = containerRegistry.Resolve(); - IWebSocketClientService socketClientService = containerRegistry.Resolve(); - - CommunicationProviderService communicationProvider = new(tcpClientService, udpClientService, udpServerService, socketClientService); - - return communicationProvider; - }); - - containerRegistry.RegisterSingleton(containerRegistry => - { - IUdpClientService udpClient = containerRegistry.Resolve(); - - PythonRemoteRunnerService remoteRunnerService = new(udpClient); - return remoteRunnerService; - }); - - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(containerRegistry => - { - bool isVideoShowLastValue = Settings.Default.ShowVideo; - return new ControlHelper(isVideoShowLastValue); - }); - - containerRegistry.RegisterSingleton(); - - RegisterDialogs(containerRegistry); - } - - private static void RegisterDialogs(IContainerRegistry containerRegistry) - { - // used for call system dialog for open save/open/select file/folder (Microsoft.Win32 dialogs) - containerRegistry.RegisterSingleton(); - - //Dialog boxes are not used, but implemented - //containerRegistry.RegisterDialog(); - } - - protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) - { - base.ConfigureRegionAdapterMappings(regionAdapterMappings); - - regionAdapterMappings.RegisterMapping(typeof(FlyoutsControl), Container.Resolve()); - } - - protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) - { - moduleCatalog.AddModule(); - moduleCatalog.AddModule(); - moduleCatalog.AddModule(); - moduleCatalog.AddModule(); - } - - public void Dispose() - { - IRegionManager regionManager = Container.Resolve(); - - //Destroy() in module - foreach (IRegion region in regionManager.Regions) - { - region.RemoveAll(); - } - - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - Container.Resolve().Dispose(); - - Container.Resolve().Dispose(); - } - } -} diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index f2e772a..2230711 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -4,9 +4,12 @@ using AdamStudio.Core.Extensions; using AdamStudio.Core.Model; using AdamStudio.Core.Mvvm; -using AdamStudio.Services.Interfaces; using AdamStudio.Core.Properties; +using AdamStudio.Services.Interfaces; +using AdamStudio.Views; +using Microsoft.Extensions.Logging; using Prism.Commands; +using Prism.Ioc; using Prism.Regions; using System; using System.Globalization; @@ -19,8 +22,7 @@ namespace AdamStudio.ViewModels public class MainWindowViewModel : ViewModelBase { #region DelegateCommands - - public DelegateCommand ShowRegionCommand { get; } + public DelegateCommand MoveSplitterDelegateCommand { get; } public DelegateCommand SwitchToVideoDelegateCommand { get; } public DelegateCommand SwitchToSettingsViewDelegateCommand { get; } @@ -29,7 +31,7 @@ public class MainWindowViewModel : ViewModelBase #region Services - public ISubRegionChangeAwareService SubRegionChangeAwareService { get; } + public IRegionChangeAwareService RegionChangeAwareService { get; } public IControlHelper ControlHelper { get; } private readonly IRegionManager mRegionManager; @@ -40,19 +42,20 @@ public class MainWindowViewModel : ViewModelBase private readonly IAvalonEditService mAvalonEditService; private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; + private readonly ILogger mLoggerService; #endregion #region ~ - public MainWindowViewModel(IRegionManager regionManager, ISubRegionChangeAwareService subRegionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, + public MainWindowViewModel(ILogger loggerService, IRegionManager regionManager, IRegionChangeAwareService regionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, ICommunicationProviderService communicationProviderService, IFolderManagmentService folderManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, IThemeManagerService themeManager, ICultureProvider cultureProvider, IControlHelper controlHelper) { mRegionManager = regionManager; mWebApiService = webApiService; - SubRegionChangeAwareService = subRegionChangeAwareService; + RegionChangeAwareService = regionChangeAwareService; mStatusBarNotification = statusBarNotification; mCommunicationProviderService = communicationProviderService; mFolderManagment = folderManagment; @@ -60,16 +63,42 @@ public MainWindowViewModel(IRegionManager regionManager, ISubRegionChangeAwareSe mThemeManager = themeManager; mCultureProvider = cultureProvider; ControlHelper = controlHelper; + mLoggerService = loggerService; - ShowRegionCommand = new DelegateCommand(ShowRegion); MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute); - SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute); - SwitchToSettingsViewDelegateCommand = new DelegateCommand(SwitchToSettingsView, SwitchToSettingsViewCanExecute); - + SwitchToSettingsViewDelegateCommand = new DelegateCommand(SwitchToSettingsView, SwitchToSettingsViewCanExecute); Subscribe(); } + + /*Test*/ + /*private void DeactivateView() + { + //IRegion region = mRegionManager.Regions[SubRegionNames.InsideConentRegion]; + + ScratchControlView view = _container.Resolve(); + SettingsControlView settings = _container.Resolve(); + + //bool isActive = region.ActiveViews.FirstOrDefault() != null; + + //var cratch = region.GetView(nameof(ScratchControlView)); + //var settings = region.GetView(nameof(SettingsControlView)); + + //object menu = region.Views.ToList(); + // (nameof(ScratchControlView)); + + /*if (true) + { + region.Deactivate(view); + region.Activate(settings); + } + else + { + + } */ + //} + #endregion #region Public fields @@ -106,8 +135,8 @@ private void MoveSplitter(string commandArg) private bool MoveSplitterCanExecute(string arg) { - var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; - return regionName == SubRegionNames.SubRegionScratch; + var regionName = RegionChangeAwareService.RegionNavigationTargetName; + return regionName == RegionNames.ScratchView; } private void SwitchToVideo() @@ -124,26 +153,25 @@ private void SwitchToVideo() private bool SwitchToVideoCanExecute() { - var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; - return regionName == SubRegionNames.SubRegionScratch; + var regionName = RegionChangeAwareService.RegionNavigationTargetName; + return regionName == RegionNames.ScratchView; } private void SwitchToSettingsView() { + var activeViewName = RegionChangeAwareService.RegionNavigationTargetName; - var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName; - - if (regionName == SubRegionNames.SubRegionScratch) + if (activeViewName == RegionNames.SettingsView) { - ShowRegion(SubRegionNames.SubRegionVisualSettings); + ShowView(RegionNames.ScratchView); return; } - if(regionName == SubRegionNames.SubRegionVisualSettings) + if(activeViewName == RegionNames.ScratchView) { - ShowRegion(SubRegionNames.SubRegionScratch); + ShowView(RegionNames.SettingsView); return; - } + } } private bool SwitchToSettingsViewCanExecute() @@ -155,20 +183,9 @@ private bool SwitchToSettingsViewCanExecute() #region Private methods - private void ShowRegion(string subRegionName) + private void ShowView(string viewName) { - switch (subRegionName) - { - case SubRegionNames.SubRegionScratch: - mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionScratch); - break; - case SubRegionNames.SubRegionComputerVisionControl: - mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionComputerVisionControl); - break; - case SubRegionNames.SubRegionVisualSettings: - mRegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionVisualSettings); - break; - } + mRegionManager.RequestNavigate(RegionNames.ContentRegion, viewName); MoveSplitterDelegateCommand.RaiseCanExecuteChanged(); SwitchToVideoDelegateCommand.RaiseCanExecuteChanged(); @@ -209,6 +226,7 @@ private void ParseSyslogMessage(string message) private void LoadCustomAvalonEditHighlighting() { mAvalonEditService.RegisterHighlighting(HighlightingName.AdamPython, Resource.AdamPython); + mLoggerService.LogInformation("Loaded highlighting"); } private void LoadAppTheme() @@ -237,8 +255,8 @@ private void Subscribe() mCommunicationProviderService.RaiseTcpServiceCientConnectedEvent += RaiseTcpServiceCientConnectedEvent; mCommunicationProviderService.RaiseUdpServiceServerReceivedEvent += RaiseUdpServiceServerReceivedEvent; - Application.Current.MainWindow.Loaded += MainWindowLoaded; - Application.Current.MainWindow.Closed += MainWindowClosed; + System.Windows.Application.Current.MainWindow.Loaded += MainWindowLoaded; + System.Windows.Application.Current.MainWindow.Closed += MainWindowClosed; } /// @@ -267,13 +285,13 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e) mFolderManagment.CreateAppDataFolder(); SaveFolderPathToSettings(); } - + //Loaded resource + ShowView(RegionNames.ScratchView); + LoadCustomAvalonEditHighlighting(); LoadAppTheme(); - ShowRegionCommand.Execute(SubRegionNames.SubRegionScratch); - if (Settings.Default.AutoStartTcpConnect) mCommunicationProviderService.ConnectAllAsync(); } diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 7b16b3b..564861e 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -8,7 +8,7 @@ xmlns:prism="http://prismlibrary.com/" xmlns:customusercontrol="clr-namespace:AdamStudio.Controls.CustomControls;assembly=AdamStudio.Controls" prism:ViewModelLocator.AutoWireViewModel="True" - xmlns:converters="clr-namespace:AdamStudio.Core.Converters;assembly=AdamStudio.Core" + xmlns:converters="clr-namespace:AdamStudio.Core.Converters;assembly=AdamStudio.Core" xmlns:controlzex="urn:controlzex" WindowTitleBrush="{DynamicResource MahApps.Brushes.Control.Background}" NonActiveWindowTitleBrush="{DynamicResource MahApps.Brushes.Control.Background}" NonActiveBorderBrush="{DynamicResource MahApps.Brushes.Text}" @@ -84,6 +84,7 @@ + @@ -105,7 +106,7 @@ - + @@ -120,26 +121,26 @@ + + + + - + - - - - - + diff --git a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs index 354af9b..7a0dfaa 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs @@ -17,15 +17,12 @@ public ContentRegionModule(IRegionManager regionManager) public void OnInitialized(IContainerProvider containerProvider) { - mRegionManager.RequestNavigate(RegionNames.ContentRegion, nameof(ContentRegionView)); + mRegionManager.RequestNavigate(RegionNames.ContentRegion, nameof(ScratchControlView)); } public void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterForNavigation(nameof(ContentRegionView)); - containerRegistry.RegisterForNavigation(nameof(ScratchControlView)); - containerRegistry.RegisterForNavigation(nameof(ComputerVisionControlView)); containerRegistry.RegisterForNavigation(nameof(SettingsControlView)); } } diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ContentRegionViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ContentRegionViewModel.cs deleted file mode 100644 index 235b2fa..0000000 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ContentRegionViewModel.cs +++ /dev/null @@ -1,75 +0,0 @@ -using AdamStudio.Core; -using AdamStudio.Core.Mvvm; -using AdamStudio.Modules.ContentRegion.Views; -using AdamStudio.Services.Interfaces; -using Prism.Regions; -using System; - -namespace AdamStudio.Modules.ContentRegion.ViewModels -{ - public class ContentRegionViewModel : RegionViewModelBase - { - private ISubRegionChangeAwareService RegionChangeAwareService { get; } - - public ContentRegionViewModel(IRegionManager regionManager, ISubRegionChangeAwareService regionChangeAwareService) : base(regionManager) - { - RegionChangeAwareService = regionChangeAwareService; - } - - #region Navigation - - public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) - { - if (navigationContext.NavigationService.Region.Name == RegionNames.ContentRegion) - { - string insideRegionName = navigationContext.Uri.OriginalString; - - RegionChangeAwareService.InsideRegionNavigationRequestName = insideRegionName; - SubRegionsRequestNavigate(insideRegionName, navigationContext.Parameters); - } - - base.ConfirmNavigationRequest(navigationContext, continuationCallback); - } - - public override void OnNavigatedTo(NavigationContext navigationContext) - { - base.OnNavigatedTo(navigationContext); - - } - - public override void Destroy() - { - base.Destroy(); - } - - #endregion - - #region Private methods - - private void SubRegionsRequestNavigate(string uri, NavigationParameters parameters) - { - if (string.IsNullOrEmpty(uri)) - return; - - - switch (uri) - { - case SubRegionNames.SubRegionScratch: - - RegionManager.RequestNavigate(SubRegionNames.InsideConentRegion, nameof(ScratchControlView), parameters); - break; - - case SubRegionNames.SubRegionComputerVisionControl: - RegionManager.RequestNavigate(SubRegionNames.InsideConentRegion, nameof(ComputerVisionControlView), parameters); - break; - - case SubRegionNames.SubRegionVisualSettings: - RegionManager.RequestNavigate(SubRegionNames.InsideConentRegion, nameof(SettingsControlView), parameters); - break; - - } - } - - #endregion - } -} diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index 2ec02db..fc5aa00 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -23,6 +23,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; +using Microsoft.Extensions.Logging; namespace AdamStudio.Modules.ContentRegion.ViewModels { @@ -55,6 +56,8 @@ public class ScratchControlViewModel : RegionViewModelBase private readonly ISystemDialogService mSystemDialog; private readonly IControlHelper mControlHelper; private readonly IVideoViewProvider mVideoViewProvider; + private readonly IRegionChangeAwareService mRegionChangeAwareService; + private readonly ILogger mLogger; #endregion @@ -66,14 +69,14 @@ public class ScratchControlViewModel : RegionViewModelBase #region Var - private bool mIsWarningStackOwerflowAlreadyShow; + //private bool mIsWarningStackOwerflowAlreadyShow; private string mCompileLogMessageStartDebug; private string mCompileLogMessageEndDebug; - private string mFinishAppExecute; - private string mWarningStackOwerflow1; - private string mWarningStackOwerflow2; - private string mWarningStackOwerflow3; + //private string mFinishAppExecute; + //private string mWarningStackOwerflow1; + //private string mWarningStackOwerflow2; + //private string mWarningStackOwerflow3; private string mSaveWorkspaceDialogTitle; private string mSaveScriptFileDialogTitle; @@ -96,13 +99,14 @@ public class ScratchControlViewModel : RegionViewModelBase #region ~ - public ScratchControlViewModel(IRegionManager regionManager, ICommunicationProviderService communicationProvider, IPythonRemoteRunnerService pythonRemoteRunner, + public ScratchControlViewModel(ILogger logger, IRegionManager regionManager, ICommunicationProviderService communicationProvider, IPythonRemoteRunnerService pythonRemoteRunner, IStatusBarNotificationDeliveryService statusBarNotificationDelivery, IWebViewProvider webViewProvider, IFileManagmentService fileManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, ICultureProvider cultureProvider, ISystemDialogService systemDialogService, IControlHelper controlHelper, - IVideoViewProvider videoViewProvider) : base(regionManager) + IVideoViewProvider videoViewProvider, IRegionChangeAwareService regionChangeAwareService) : base(regionManager) { - + + mLogger = logger; mCommunicationProvider = communicationProvider; mPythonRemoteRunner = pythonRemoteRunner; mStatusBarNotificationDelivery = statusBarNotificationDelivery; @@ -113,6 +117,7 @@ public ScratchControlViewModel(IRegionManager regionManager, ICommunicationProvi mSystemDialog = systemDialogService; mControlHelper = controlHelper; mVideoViewProvider = videoViewProvider; + mRegionChangeAwareService = regionChangeAwareService; ShowSaveFileDialogDelegateCommand = new DelegateCommand(ShowSaveFileDialog, ShowSaveFileDialogCanExecute); ShowOpenFileDialogDelegateCommand = new DelegateCommand(ShowOpenFileDialog, ShowOpenFileDialogCanExecute); @@ -141,6 +146,8 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchView; + Subscribe(); LoadResources(); UpdateIsShowVideo(Settings.Default.ShowVideo); @@ -168,7 +175,7 @@ public string VideoFrameRate set { SetProperty(ref videoFrameRate, value); } } - private bool isShowVideo; //= Settings.Default.ShowVideo; + private bool isShowVideo; public bool IsShowVideo { get => isShowVideo; @@ -229,7 +236,7 @@ public string SourceTextEditor } } - private string resultText; + /*private string resultText; public string ResultText { get => resultText; @@ -254,7 +261,7 @@ public ExtendedCommandExecuteResult ResultInitilizationTime { get => resultInitilizationTime; set => SetProperty(ref resultInitilizationTime, value); - } + }*/ private string pythonVersion; public string PythonVersion @@ -318,9 +325,9 @@ private void Subscribe() mCommunicationProvider.RaiseTcpServiceCientConnectedEvent += OnRaiseTcpServiceCientConnected; mCommunicationProvider.RaiseTcpServiceClientDisconnectEvent += OnRaiseTcpServiceClientDisconnect; - mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart; - mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput; - mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; + //mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart; + //mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput; + //mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; mWebViewProvider.RaiseWebViewMessageReceivedEvent += RaiseWebViewbMessageReceivedEvent; mWebViewProvider.RaiseWebViewNavigationCompleteEvent += RaiseWebViewNavigationCompleteEvent; @@ -335,9 +342,9 @@ private void Unsubscribe() mCommunicationProvider.RaiseTcpServiceCientConnectedEvent -= OnRaiseTcpServiceCientConnected; mCommunicationProvider.RaiseTcpServiceClientDisconnectEvent -= OnRaiseTcpServiceClientDisconnect; - mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart; - mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput; - mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; + //mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart; + //mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput; + //mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; mWebViewProvider.RaiseWebViewMessageReceivedEvent -= RaiseWebViewbMessageReceivedEvent; mWebViewProvider.RaiseWebViewNavigationCompleteEvent -= RaiseWebViewNavigationCompleteEvent; @@ -398,7 +405,7 @@ private void ShowOpenFileDialog(string param) if (result.IsOpenFileCanceled) { - mStatusBarNotificationDelivery.AppLogMessage = mFileNotSelectedLogMessage; + mLogger.LogWarning(mFileNotSelectedLogMessage); return; } @@ -436,7 +443,7 @@ private void ShowSaveFileDialog(string param) if (result.IsSaveFileCanceled) { - mStatusBarNotificationDelivery.AppLogMessage = mFileNotSavedLogMessage; + mLogger.LogWarning(mFileNotSavedLogMessage); return; } @@ -459,14 +466,14 @@ private bool ShowOpenFileDialogCanExecute(string param) private void CleanExecuteEditor() { - ClearResultText(); + //ClearResultText(); } private bool CleanExecuteEditorCanExecute() { bool isPythonCodeNotExecute = !IsPythonCodeExecute; - var isResultNotEmpty = ResultText?.Length > 0; - return isPythonCodeNotExecute && isResultNotEmpty; + //var isResultNotEmpty = ResultText?.Length > 0; + return isPythonCodeNotExecute;// && isResultNotEmpty; } private async void RunPythonCode() @@ -476,23 +483,28 @@ private async void RunPythonCode() try { - ClearResultText(); + //ClearResultText(); + var command = new AdamController.WebApi.Client.v1.RequestModel.PythonCommandModel { Command = source }; - ExtendedCommandExecuteResult executeResult = await mWebApiService.PythonExecuteAsync(command); - UpdateResultInitilizationTimeText(executeResult); + IsPythonCodeExecute = true; + + _ = await mWebApiService.PythonExecuteAsync(command); + + //ExtendedCommandExecuteResult executeResult = await mWebApiService.PythonExecuteAsync(command); + //UpdateResultInitilizationTimeText(executeResult); } catch { - + //IsPythonCodeExecute = false; } finally { - + //IsPythonCodeExecute = false; } } @@ -621,7 +633,7 @@ private void UpdateIsShowVideo(bool isShowVideo) IsShowVideo = isShowVideo; } - private void UpdateResultText(string text, bool isFinishMessage = false) + /*rivate void UpdateResultText(string text, bool isFinishMessage = false) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { @@ -648,9 +660,9 @@ private void UpdateResultText(string text, bool isFinishMessage = false) ResultText += text; } })); - } + }*/ - private void UpdateResultExecutionTimeText(ExtendedCommandExecuteResult executeResult) + /*private void UpdateResultExecutionTimeText(ExtendedCommandExecuteResult executeResult) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => @@ -674,19 +686,19 @@ private void UpdateResultExecutionTimeText(ExtendedCommandExecuteResult executeR ResultExecutionTime = fixResult; IsPythonCodeExecute = false; })); - } + }*/ - private void UpdateResultInitilizationTimeText(ExtendedCommandExecuteResult executeResult) + /*private void UpdateResultInitilizationTimeText(ExtendedCommandExecuteResult executeResult) { ResultInitilizationTime = executeResult; - } + }*/ - private void ClearResultText() + /*private void ClearResultText() { ResultText = string.Empty; ResultExecutionTime = null; ResultInitilizationTime = null; - } + }*/ private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) { @@ -703,7 +715,7 @@ private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) return; } - mIsWarningStackOwerflowAlreadyShow = false; + //mIsWarningStackOwerflowAlreadyShow = false; mStatusBarNotificationDelivery.CompileLogMessage = mCompileLogMessageStartDebug; mStatusBarNotificationDelivery.ProgressRingStart = true; @@ -738,16 +750,16 @@ private async void OpenSupportedFile(OpenFileDialogResult result) switch (result.OpenFileType) { case SupportFileType.Undefined: - mStatusBarNotificationDelivery.AppLogMessage = $"{mExtNotSupport1} {Path.GetExtension(path)} {mExtNotSupport2}"; + mLogger.LogInformation($"{mExtNotSupport1} {Path.GetExtension(path)} {mExtNotSupport2}"); break; case SupportFileType.Script: SourceTextEditor = await mFileManagment.ReadTextAsStringAsync(path); - mStatusBarNotificationDelivery.AppLogMessage = $"{mOpenFile} {path}"; + mLogger.LogInformation($"{mOpenFile} {path}"); break; case SupportFileType.Workspace: string xml = await mFileManagment.ReadTextAsStringAsync(path); _ = await ExecuteScriptFunctionAsync("loadSavedWorkspace", new object[] { xml }); - mStatusBarNotificationDelivery.AppLogMessage = $"{mOpenFile} {path}"; + mLogger.LogInformation($"{mOpenFile} {path}"); break; } } @@ -767,7 +779,7 @@ private async void SaveSupportedFile(SaveFileDialogResult result, SupportFileTyp await mFileManagment.WriteAsync(path, file); } - mStatusBarNotificationDelivery.AppLogMessage = $"{mFileSavedLogMessage} {path}"; + mLogger.LogInformation($"{mFileSavedLogMessage} {path}"); } private void RaiseDelegateCommandsCanExecuteChanged() @@ -786,11 +798,11 @@ private void LoadResources() { mCompileLogMessageStartDebug = mCultureProvider.FindResource("DebuggerMessages.CompileLogMessageStartDebug"); mCompileLogMessageEndDebug = mCultureProvider.FindResource("DebuggerMessages.CompileLogMessageEndDebug"); - mFinishAppExecute = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.FinishAppExecute"); + //mFinishAppExecute = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.FinishAppExecute"); - mWarningStackOwerflow1 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow1"); - mWarningStackOwerflow2 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow2"); - mWarningStackOwerflow3 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow3"); + //mWarningStackOwerflow1 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow1"); + //mWarningStackOwerflow2 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow2"); + //mWarningStackOwerflow3 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow3"); mSaveWorkspaceDialogTitle = mCultureProvider.FindResource("ScratchControlViewModel.SaveWorkspaceFileDialog.DialogTitle"); mSaveScriptFileDialogTitle = mCultureProvider.FindResource("ScratchControlViewModel.SaveScriptFileDialog.DialogTitle"); @@ -815,6 +827,7 @@ private void LoadResources() private void RaiseWebViewNavigationCompleteEvent(object sender) { InitBlockly(); + mLogger.LogTrace("Called RaiseWebViewNavigationCompleteEvent"); } private void RaiseWebViewbMessageReceivedEvent(object sender, WebMessageJsonReceived webMessageReceived) @@ -847,24 +860,24 @@ private void OnRaiseTcpServiceClientDisconnect(object sender, bool isUserRequest UpdatePythonInfo(); } - private void OnRaisePythonScriptExecuteStart(object sender) + /*private void OnRaisePythonScriptExecuteStart(object sender) { IsPythonCodeExecute = true; - } + }*/ - private void OnRaisePythonStandartOutput(object sender, string message) + /*private void OnRaisePythonStandartOutput(object sender, string message) { UpdateResultText(message); - } + }*/ - private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult) + /*private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult) { if (remoteCommandExecuteResult == null) return; UpdateResultText("", true); UpdateResultExecutionTimeText(remoteCommandExecuteResult); - } + }*/ private void OnRaiseIsVideoShowChangeEvent(object sender) { @@ -906,11 +919,11 @@ private async void InitBlockly() await mWebViewProvider.ExecuteJavaScript(Scripts.RestoreSavedBlocks); } - mStatusBarNotificationDelivery.AppLogMessage = mScretchLoadedCompleteLogMessage; + //mLogger.LogInformation(mScretchLoadedCompleteLogMessage); } catch { - mStatusBarNotificationDelivery.AppLogMessage = mScretchLoadedErrorLogMessage; + mLogger.LogWarning(mScretchLoadedErrorLogMessage); } } diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs index 369605d..04a3dbf 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs @@ -32,6 +32,7 @@ public class SettingsControlViewModel : RegionViewModelBase private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; private readonly IWebViewProvider mWebViewProvider; + private readonly IRegionChangeAwareService mRegionChangeAwareService; #endregion @@ -45,12 +46,13 @@ public class SettingsControlViewModel : RegionViewModelBase #region ~ public SettingsControlViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, - IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider) : base(regionManager) + IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider, IRegionChangeAwareService subRegionChangeAwareService) : base(regionManager) { mFlyoutManager = flyoutManager; mThemeManager = themeManager; mCultureProvider = cultureProvider; mWebViewProvider = webViewProvider; + mRegionChangeAwareService = subRegionChangeAwareService; ChangeSpacingToggleSwitchDelegateCommand = new DelegateCommand(ChangeSpacingToggleSwitch, ChangeSpacingToggleSwitchCanExecute); OpenPortSettingsDelegateCommand = new DelegateCommand(OpenPortSettings, OpenPortSettingsCanExecute); @@ -113,13 +115,15 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - base.OnNavigatedTo(navigationContext); + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsView; ThemesCollection = mThemeManager.AppThemesCollection; SelectedTheme = mThemeManager.GetCurrentAppTheme(); LanguageApp = mCultureProvider.SupportAppCultures; SelectedLanguageApp = mCultureProvider.CurrentAppCulture; + + base.OnNavigatedTo(navigationContext); } public override void Destroy() diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml deleted file mode 100644 index a9348ff..0000000 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml.cs deleted file mode 100644 index c09d023..0000000 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ContentRegionView.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Windows.Controls; - -namespace AdamStudio.Modules.ContentRegion.Views -{ - public partial class ContentRegionView : UserControl - { - public ContentRegionView() - { - InitializeComponent(); - } - } -} diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml index 76cfcc6..e9868c9 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml @@ -22,57 +22,33 @@ - - - - - - - - - - - - - - - - - - - + + + + + - - - + + + + - + - + + + + + + + + - + + - + + + - + - + - + + + + - + - - - + + + + - + - + - + + - - + + + + + + + + + + + - - + + + + - - - - + + + - - - + - + - + - + - - + + + - + - - - - + - - - - + - + @@ -620,102 +601,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs index 4e20ec9..abacdf4 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs @@ -2,6 +2,7 @@ using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; using AdamStudio.Services.WebViewProviderDependency; +using Microsoft.Extensions.Logging; using Microsoft.Web.WebView2.Core; using System; using System.IO; @@ -24,6 +25,7 @@ public partial class ScratchControlView : UserControl private readonly IControlHelper mControlHelper; private readonly IWebSocketClientService mWebSocketClient; private readonly IVideoViewProvider mVideoViewProvider; + private readonly ILogger mLogger; #endregion @@ -33,12 +35,13 @@ public partial class ScratchControlView : UserControl #endregion - public ScratchControlView(IWebViewProvider webViewProvider, IStatusBarNotificationDeliveryService statusBarNotification, + public ScratchControlView(ILogger logger, IWebViewProvider webViewProvider, IStatusBarNotificationDeliveryService statusBarNotification, IFolderManagmentService folderManagment, IControlHelper controlHelper, IWebSocketClientService webSocketClient, IVideoViewProvider videoViewProvider) { InitializeComponent(); InitializeWebViewCore(); + mLogger = logger; mWebViewProvider = webViewProvider; mStatusBarNotification = statusBarNotification; mControlHelper = controlHelper; @@ -53,7 +56,7 @@ public ScratchControlView(IWebViewProvider webViewProvider, IStatusBarNotificati mWebViewProvider.RaiseExecuteReloadWebViewEvent += RaiseExecuteReloadWebViewEvent; /*element event */ - TextResulEditor.TextChanged += TextResulEditorTextChanged; + //TextResulEditor.TextChanged += TextResulEditorTextChanged; MainGrid.SizeChanged += MainGridSizeChanged; SourceEditor.SizeChanged += TextResulEditorSizeChanged; @@ -73,14 +76,9 @@ private async void VideoViewIsVisibleChanged(object sender, DependencyPropertyCh { if (VideoView.IsVisible) { - string ip = Settings.Default.ServerIP; string port = Settings.Default.VideoDataExchangePort; - var uri = new Uri($"http://{ip}:{port}/stream/0.mjpeg"); - //var docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\test.avi"; - //var uri = new Uri($"{docPath}"); - await VideoView.Open(uri); return; } @@ -96,7 +94,6 @@ private void VideoViewVideoFrameDecoded(object sender, FrameDecodedEventArgs e) private void VideoViewMediaOpening(object sender, MediaOpeningEventArgs e) { - e.Options.IsTimeSyncDisabled = true; e.Options.IsAudioDisabled = true; e.Options.MinimumPlaybackBufferPercent = 0; @@ -148,10 +145,10 @@ private void WebViewNavigationCompleted(object sender, CoreWebView2NavigationCom mWebViewProvider.NavigationComplete(); } - private void TextResulEditorTextChanged(object sender, EventArgs e) + /*private void TextResulEditorTextChanged(object sender, EventArgs e) { - Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(TextResulEditor.ScrollToEnd)); - } + //Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(TextResulEditor.ScrollToEnd)); + }*/ private async void InitializeWebViewCore() { @@ -166,24 +163,26 @@ private void WebViewCoreWebView2InitializationCompleted(object sender, CoreWebVi WebView?.CoreWebView2?.SetVirtualHostNameToFolderMapping("localhost", mPathToSource, CoreWebView2HostResourceAccessKind.Allow); WebView?.CoreWebView2?.Navigate("https://localhost/index.html"); } - - private void WebViewWebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) + + private static readonly JsonSerializerOptions jsonSerializerOptions = new() { - JsonSerializerOptions options = new() - { - NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString - }; + NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString + }; + + private readonly JsonSerializerOptions mOptions = jsonSerializerOptions; + private void WebViewWebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) + { WebMessageJsonReceived receivedResult; try { string receivedString = e.TryGetWebMessageAsString(); - receivedResult = JsonSerializer.Deserialize(receivedString, options); + receivedResult = JsonSerializer.Deserialize(receivedString, mOptions); } catch { - mStatusBarNotification.AppLogMessage = "Error reading blokly code"; + mLogger.LogError("Error reading blokly code"); receivedResult = new WebMessageJsonReceived { Action = string.Empty, Data = string.Empty }; } diff --git a/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs b/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs index 9a77138..768828b 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/MenuRegionModule.cs @@ -22,8 +22,6 @@ public void OnInitialized(IContainerProvider containerProvider) public void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterForNavigation(); - containerRegistry.RegisterForNavigation(nameof(MenuRegionView)); } } diff --git a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs index 06af194..66c69c6 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs @@ -20,13 +20,13 @@ public class MenuRegionViewModel : RegionViewModelBase #region Services - private readonly ISubRegionChangeAwareService mSubRegionChangeAware; + private readonly IRegionChangeAwareService mRegionChangeAware; #endregion - public MenuRegionViewModel(IRegionManager regionManager,ISubRegionChangeAwareService subRegionChangeAware) : base(regionManager) + public MenuRegionViewModel(IRegionManager regionManager, IRegionChangeAwareService regionChangeAware) : base(regionManager) { - mSubRegionChangeAware = subRegionChangeAware; + mRegionChangeAware = regionChangeAware; CloseAppCommand = new DelegateCommand(CloseApp); ShowRegionCommand = new DelegateCommand(ShowRegion); @@ -46,6 +46,7 @@ public override void OnNavigatedTo(NavigationContext navigationContext) base.OnNavigatedTo(navigationContext); } + public override void Destroy() { Unsubscribe(); @@ -62,13 +63,6 @@ public bool IsCheckedScratchMenuItem set => SetProperty(ref isCheckedScratchMenuItem, value); } - private bool isCheckedComputerVisionMenuItem; - public bool IsCheckedComputerVisionMenuItem - { - get => isCheckedComputerVisionMenuItem; - set => SetProperty(ref isCheckedComputerVisionMenuItem, value); - } - private bool isCheckedVisualSettingsMenuItem; public bool IsCheckedVisualSettingsMenuItem { @@ -80,19 +74,16 @@ public bool IsCheckedVisualSettingsMenuItem #region Private methods - private void ChangeCheckedMenuItem(string selectedSubRegionName) + private void ChangeCheckedMenuItem(string selectedRegionName) { ResetIsCheckedMenuItem(); - switch (selectedSubRegionName) + switch (selectedRegionName) { - case SubRegionNames.SubRegionScratch: + case RegionNames.ScratchView: IsCheckedScratchMenuItem = true; break; - case SubRegionNames.SubRegionComputerVisionControl: - IsCheckedComputerVisionMenuItem = true; - break; - case SubRegionNames.SubRegionVisualSettings: + case RegionNames.SettingsView: IsCheckedVisualSettingsMenuItem = true; break; } @@ -101,7 +92,6 @@ private void ChangeCheckedMenuItem(string selectedSubRegionName) private void ResetIsCheckedMenuItem() { IsCheckedScratchMenuItem = false; - IsCheckedComputerVisionMenuItem = false; IsCheckedVisualSettingsMenuItem = false; } @@ -111,12 +101,12 @@ private void ResetIsCheckedMenuItem() private void Subscribe() { - mSubRegionChangeAware.RaiseSubRegionChangeEvent += RaiseSubRegionChangeEvent; + mRegionChangeAware.RaiseRegionChangeEvent += RaiseSubRegionChangeEvent; } private void Unsubscribe() { - mSubRegionChangeAware.RaiseSubRegionChangeEvent -= RaiseSubRegionChangeEvent; + mRegionChangeAware.RaiseRegionChangeEvent -= RaiseSubRegionChangeEvent; } #endregion @@ -125,27 +115,16 @@ private void Unsubscribe() private void RaiseSubRegionChangeEvent(object sender) { - ChangeCheckedMenuItem(mSubRegionChangeAware.InsideRegionNavigationRequestName); + ChangeCheckedMenuItem(mRegionChangeAware.RegionNavigationTargetName); } #endregion #region Command methods - private void ShowRegion(string subRegionName) + private void ShowRegion(string regionName) { - switch (subRegionName) - { - case SubRegionNames.SubRegionScratch: - RegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionScratch); - break; - case SubRegionNames.SubRegionComputerVisionControl: - RegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionComputerVisionControl); - break; - case SubRegionNames.SubRegionVisualSettings: - RegionManager.RequestNavigate(RegionNames.ContentRegion, SubRegionNames.SubRegionVisualSettings); - break; - } + RegionManager.RequestNavigate(RegionNames.ContentRegion, regionName); } private void CloseApp() diff --git a/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml b/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml index 50540cd..61d653c 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml +++ b/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml @@ -20,14 +20,14 @@ Style="{DynamicResource MahApps.Styles.MenuItem}"> + Command="{Binding ShowRegionCommand}" + CommandParameter="{x:Static core:RegionNames.ScratchView}" + IsChecked="{Binding IsCheckedScratchMenuItem}" /> + Command="{Binding ShowRegionCommand}" + CommandParameter="{x:Static core:RegionNames.SettingsView}" + IsChecked="{Binding IsCheckedVisualSettingsMenuItem}"/> diff --git a/Modules/AdamStudio.Modules.StatusBar/StatusBarRegionModule.cs b/Modules/AdamStudio.Modules.StatusBar/StatusBarRegionModule.cs index b84a7ad..1e526df 100644 --- a/Modules/AdamStudio.Modules.StatusBar/StatusBarRegionModule.cs +++ b/Modules/AdamStudio.Modules.StatusBar/StatusBarRegionModule.cs @@ -22,8 +22,6 @@ public void OnInitialized(IContainerProvider containerProvider) public void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterForNavigation(); - containerRegistry.RegisterForNavigation(nameof(StatusBarView)); } } diff --git a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs index daa7cbb..0cf7ce1 100644 --- a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs +++ b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs @@ -4,6 +4,7 @@ using AdamStudio.Core.Mvvm; using AdamStudio.Services.Interfaces; using MahApps.Metro.IconPacks; +using Microsoft.Extensions.Logging; using Prism.Commands; using Prism.Regions; using System; @@ -26,6 +27,8 @@ public class StatusBarViewModel : RegionViewModelBase private readonly IFlyoutStateChecker mFlyoutState; private readonly ICultureProvider mCultureProvider; private readonly IControlHelper mControlHelper; + private readonly ILogWriteEventAwareService mLogWriteEventAwareService; + private readonly ILogger mLogger; #endregion @@ -44,18 +47,20 @@ public class StatusBarViewModel : RegionViewModelBase #region ~ public StatusBarViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, IFlyoutStateChecker flyoutState, ICommunicationProviderService communicationProviderService, - IStatusBarNotificationDeliveryService statusBarNotification, ICultureProvider cultureProvider, IControlHelper controlHelper) : base(regionManager) - { + IStatusBarNotificationDeliveryService statusBarNotification, ICultureProvider cultureProvider, IControlHelper controlHelper, + ILogWriteEventAwareService logWriteEventAwareService, ILogger logger) : base(regionManager) { mFlyoutManager = flyoutManager; mCommunicationProviderService = communicationProviderService; mStatusBarNotificationDelivery = statusBarNotification; mFlyoutState = flyoutState; mCultureProvider = cultureProvider; mControlHelper = controlHelper; + mLogWriteEventAwareService = logWriteEventAwareService; + mLogger = logger; OpenNotificationPanelDelegateCommand = new DelegateCommand(OpenNotificationPanel, OpenNotificationPanelCanExecute); - LoadResource(); + //LoadResource(); LoadDefaultFieldValue(); } @@ -214,6 +219,7 @@ private void LoadResource() mCompileLogStatusBar = mCultureProvider.FindResource("StatusBarViewModel.CompileLogStatusBar"); mAppLogStatusBar = mCultureProvider.FindResource("StatusBarViewModel.AppLogStatusBar"); + mChangAppLanguageLogMessage = mCultureProvider.FindResource("StatusBarViewModel.ChangAppLanguage.LogMessage"); } @@ -231,7 +237,7 @@ private void UpdateStatusConnectToolbar() ConnectIcon = PackIconModernKind.Connect; } - AppLogStatusBar = mChangAppLanguageLogMessage; + mLogger.LogInformation(mChangAppLanguageLogMessage); } #endregion @@ -246,14 +252,16 @@ private void Subscribe() mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent += RaiseChangeProgressRingStateEvent; mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent += RaiseNewCompileLogMessageEvent; - mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent += RaiseNewAppLogMessageEvent; mStatusBarNotificationDelivery.RaiseUpdateNotificationCounterEvent += RaiseUpdateNotificationCounterEvent; mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent += IsOpenedStateChangeEvent; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent; + mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent; } + + private void Unsubscribe() { mCommunicationProviderService.RaiseTcpServiceCientConnectedEvent -= RaiseAdamTcpCientConnectedEvent; @@ -262,11 +270,11 @@ private void Unsubscribe() mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent -= RaiseChangeProgressRingStateEvent; mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent -= RaiseNewCompileLogMessageEvent; - mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent -= RaiseNewAppLogMessageEvent; mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent -= IsOpenedStateChangeEvent; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent -= RaiseCurrentAppCultureLoadOrChangeEvent; + mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent; } #endregion @@ -325,8 +333,13 @@ private void RaiseCurrentAppCultureLoadOrChangeEvent(object sender) UpdateStatusConnectToolbar(); } + private void RaiseNewLogMessageWriteEvent(object sender, string message) + { + AppLogStatusBar = message; + } + #endregion - + } } diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj b/Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj new file mode 100644 index 0000000..09d1682 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/AdamStudio.Modules.ToolBarRegion.csproj @@ -0,0 +1,12 @@ + + + net8.0-windows7.0 + true + + + + + + + + \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml new file mode 100644 index 0000000..271133b --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml.cs b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml.cs new file mode 100644 index 0000000..e263087 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml.cs @@ -0,0 +1,51 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; + +namespace AdamStudio.Modules.ToolBarRegion.Template +{ + public partial class PopupWindow : UserControl + { + public PopupWindow() + { + InitializeComponent(); + } + + #region DependencyProperty + + public bool IsOpen + { + get { return (bool)GetValue(IsOpenProperty); } + set { SetValue(IsOpenProperty, value); } + } + private static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register(nameof(IsOpen), typeof(bool), typeof(PopupWindow), null); + + public ControlTemplate PopupWindowTemplate + { + get { return (ControlTemplate)GetValue(PopupWindowTemplateProperty); } + set { SetValue(PopupWindowTemplateProperty, value); } + } + + private static readonly DependencyProperty PopupWindowTemplateProperty = DependencyProperty.Register(nameof(PopupWindowTemplate), typeof(ControlTemplate), typeof(PopupWindow), null); + + #endregion + + private void ThumbDragDelta(object sender, DragDeltaEventArgs e) + { + double newSize = PopupExWindow.Height - e.VerticalChange; + + if (newSize > 0) + { + if (newSize > PopupExWindow.MaxHeight) + return; + + PopupExWindow.Height = newSize; + } + } + + private void CloseButtonClick(object sender, RoutedEventArgs e) + { + IsOpen = false; + } + } +} diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs new file mode 100644 index 0000000..b69e893 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ToolBarRegionModule.cs @@ -0,0 +1,28 @@ +using AdamStudio.Core; +using AdamStudio.Modules.ToolBarRegion.Views; +using Prism.Ioc; +using Prism.Modularity; +using Prism.Regions; + +namespace AdamStudio.Modules.ToolBarRegion +{ + public class ToolBarRegionModule : IModule + { + private readonly IRegionManager mRegionManager; + + public ToolBarRegionModule(IRegionManager regionManager) + { + mRegionManager = regionManager; + } + + public void OnInitialized(IContainerProvider containerProvider) + { + mRegionManager.RequestNavigate(RegionNames.ToolBarRegion, nameof(ToolBarView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation(nameof(ToolBarView)); + } + } +} \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs new file mode 100644 index 0000000..2126f7c --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs @@ -0,0 +1,255 @@ +using AdamController.WebApi.Client.v1.ResponseModel; +using AdamStudio.Core.Mvvm; +using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.Logging; +using Prism.Regions; +using System; +using System.Windows; +using System.Windows.Threading; + +namespace AdamStudio.Modules.ToolBarRegion.ViewModels +{ + public class ToolBarViewModel : RegionViewModelBase + { + private readonly ILogger mLogger; + private readonly ILogWriteEventAwareService mLogWriteEventAware; + private readonly IPythonRemoteRunnerService mPythonRemoteRunner; + private readonly ICultureProvider mCultureProvider; + + private bool mIsWarningStackOwerflowAlreadyShow; + private string mFinishAppExecute; + private string mWarningStackOwerflow1; + private string mWarningStackOwerflow2; + private string mWarningStackOwerflow3; + + public ToolBarViewModel(IRegionManager regionManager, ILogger logger, ILogWriteEventAwareService logWriteEventAware, IPythonRemoteRunnerService pythonRemoteRunner, ICultureProvider cultureProvider) : base(regionManager) + { + mLogger = logger; + mLogWriteEventAware = logWriteEventAware; + mPythonRemoteRunner = pythonRemoteRunner; + mCultureProvider = cultureProvider; + + //LoadResources(); + mLogger.LogTrace("Load ~"); + } + + #region Navigation + + public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) + { + base.ConfirmNavigationRequest(navigationContext, continuationCallback); + } + + public override void OnNavigatedTo(NavigationContext navigationContext) + { + Subscribe(); + //LoadResources(); + + base.OnNavigatedTo(navigationContext); + } + + public override void Destroy() + { + Unsubscribe(); + + base.Destroy(); + } + + #endregion + + #region Public fields + + private string logs; + public string ApplicationLogs + { + get => logs; + set => SetProperty(ref logs, value); + } + + private string resultText; + public string ResultText + { + get => resultText; + set + { + bool isNewValue = SetProperty(ref resultText, value); + + //if (isNewValue) + //CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); + } + } + + private ExtendedCommandExecuteResult resultExecutionTime; + public ExtendedCommandExecuteResult ResultExecutionTime + { + get => resultExecutionTime; + set => SetProperty(ref resultExecutionTime, value); + } + + private ExtendedCommandExecuteResult resultInitilizationTime; + public ExtendedCommandExecuteResult ResultInitilizationTime + { + get => resultInitilizationTime; + set => SetProperty(ref resultInitilizationTime, value); + } + + private bool isPythonCodeExecute; + public bool IsPythonCodeExecute + { + get => isPythonCodeExecute; + set + { + bool isNewValue = SetProperty(ref isPythonCodeExecute, value); + + if (isNewValue) + { + //OnPythonCodeExecuteStatusChange(IsPythonCodeExecute); + //RaiseDelegateCommandsCanExecuteChanged(); + } + } + } + + #endregion + + #region PrivateMethods + + private void UpdateResultText(string text, bool isFinishMessage = false) + { + Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => + { + if (isFinishMessage) + { + ResultText += "\n======================\n"; + ResultText += $"<<{mFinishAppExecute}>>\n"; + } + + if (!isFinishMessage) + { + if (ResultText?.Length > 500) + { + if (!mIsWarningStackOwerflowAlreadyShow) + { + string warningMessage = $"\n{mWarningStackOwerflow1}\n{mWarningStackOwerflow2}\n{mWarningStackOwerflow3}\n"; + ResultText += warningMessage; + mIsWarningStackOwerflowAlreadyShow = true; + } + + return; + } + + ResultText += text; + } + })); + } + + private void UpdateResultExecutionTimeText(ExtendedCommandExecuteResult executeResult) + { + + Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => + { + ExtendedCommandExecuteResult fixResult = new() + { + StandardOutput = executeResult.StandardOutput, + StandardError = executeResult.StandardError, + + StartTime = executeResult.StartTime, + EndTime = executeResult.EndTime, + RunTime = executeResult.RunTime, + + ExitCode = executeResult.ExitCode, + + // The server always returns False + // Therefore, the success of completion is determined by the exit code + Succeesed = executeResult.ExitCode == 0 + }; + + ResultExecutionTime = fixResult; + IsPythonCodeExecute = false; + })); + } + + private void UpdateResultInitilizationTimeText(ExtendedCommandExecuteResult executeResult) + { + ResultInitilizationTime = executeResult; + } + + private void ClearResultText() + { + ResultText = string.Empty; + ResultExecutionTime = null; + ResultInitilizationTime = null; + } + + private void LoadResources() + { + mFinishAppExecute = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.FinishAppExecute"); + + mWarningStackOwerflow1 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow1"); + mWarningStackOwerflow2 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow2"); + mWarningStackOwerflow3 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow3"); + } + + #endregion + + #region Events + + private void RaiseNewLogMessageWriteEvent(object sender, string message) + { + ApplicationLogs += $"{message}\n"; + } + + private void OnRaisePythonScriptExecuteStart(object sender) + { + IsPythonCodeExecute = true; + } + + private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult) + { + if (remoteCommandExecuteResult == null) + return; + + UpdateResultText("", true); + UpdateResultExecutionTimeText(remoteCommandExecuteResult); + } + + private void OnRaisePythonStandartOutput(object sender, string message) + { + UpdateResultText(message); + } + + + private void RaiseCurrentAppCultureLoadOrChangeEvent(object sender) + { + LoadResources(); + + } + + #endregion + + #region Subscribes + + private void Subscribe() + { + mLogWriteEventAware.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent; + + mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart; + mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput; + mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; + + mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent; + } + + private void Unsubscribe() + { + mLogWriteEventAware.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent; + + mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart; + mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput; + mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; + + mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent -= RaiseCurrentAppCultureLoadOrChangeEvent; + } + + #endregion + } +} diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml new file mode 100644 index 0000000..f20128a --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs new file mode 100644 index 0000000..73f87a1 --- /dev/null +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs @@ -0,0 +1,13 @@ +using System.Windows.Controls; +using System.Windows.Controls.Primitives; + +namespace AdamStudio.Modules.ToolBarRegion.Views +{ + public partial class ToolBarView : UserControl + { + public ToolBarView() + { + InitializeComponent(); + } + } +} From fcec597e5d92566d1366d372bb37313d7b338046 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Thu, 8 Aug 2024 12:41:00 +1000 Subject: [PATCH 23/40] Fix scratch error --- .../Converters/StringToViewRegionIconsConverter.cs | 4 ++-- AdamStudio.Core/RegionNames.cs | 3 +++ AdamStudio/ViewModels/MainWindowViewModel.cs | 14 +++++++------- .../ViewModels/ScratchControlViewModel.cs | 2 +- .../ViewModels/SettingsControlViewModel.cs | 2 +- .../ViewModels/MenuRegionViewModel.cs | 9 +++++---- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs index 407f470..7d5d155 100644 --- a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs +++ b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs @@ -16,10 +16,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value != null) stringValue = (string)value; - if (stringValue == RegionNames.SettingsView) + if (stringValue == RegionNames.SettingsRegion) return PackIconSimpleIconsKind.Scratch; - if (stringValue == RegionNames.ScratchView) + if (stringValue == RegionNames.ScratchRegion) return PackIconFeatherIconsKind.Settings; return PackIconSimpleIconsKind.AbbRobotStudio; diff --git a/AdamStudio.Core/RegionNames.cs b/AdamStudio.Core/RegionNames.cs index 5b895a5..00f246e 100644 --- a/AdamStudio.Core/RegionNames.cs +++ b/AdamStudio.Core/RegionNames.cs @@ -10,6 +10,9 @@ public class RegionNames public const string MenuRegion = $"{nameof(MenuRegion)}"; + public const string ScratchRegion = "ScratchRegion"; + public const string SettingsRegion = "SettingsRegion"; + public const string ScratchView = "ScratchControlView"; public const string SettingsView = "SettingsControlView"; } diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 2230711..30f0d6a 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -136,7 +136,7 @@ private void MoveSplitter(string commandArg) private bool MoveSplitterCanExecute(string arg) { var regionName = RegionChangeAwareService.RegionNavigationTargetName; - return regionName == RegionNames.ScratchView; + return regionName == RegionNames.ScratchRegion; } private void SwitchToVideo() @@ -154,22 +154,22 @@ private void SwitchToVideo() private bool SwitchToVideoCanExecute() { var regionName = RegionChangeAwareService.RegionNavigationTargetName; - return regionName == RegionNames.ScratchView; + return regionName == RegionNames.ScratchRegion; } private void SwitchToSettingsView() { var activeViewName = RegionChangeAwareService.RegionNavigationTargetName; - if (activeViewName == RegionNames.SettingsView) + if (activeViewName == RegionNames.ScratchRegion) { - ShowView(RegionNames.ScratchView); + ShowView(RegionNames.SettingsView); return; } - if(activeViewName == RegionNames.ScratchView) + if(activeViewName == RegionNames.SettingsRegion) { - ShowView(RegionNames.SettingsView); + ShowView(RegionNames.ScratchView); return; } } @@ -287,7 +287,7 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e) } //Loaded resource - ShowView(RegionNames.ScratchView); + ShowView(RegionNames.ScratchRegion); LoadCustomAvalonEditHighlighting(); LoadAppTheme(); diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index fc5aa00..97575e0 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -146,7 +146,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchView; + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchRegion; Subscribe(); LoadResources(); diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs index 04a3dbf..a5f285c 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs @@ -115,7 +115,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsView; + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsRegion; ThemesCollection = mThemeManager.AppThemesCollection; SelectedTheme = mThemeManager.GetCurrentAppTheme(); diff --git a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs index 66c69c6..8c66297 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs @@ -80,10 +80,10 @@ private void ChangeCheckedMenuItem(string selectedRegionName) switch (selectedRegionName) { - case RegionNames.ScratchView: + case RegionNames.ScratchRegion: IsCheckedScratchMenuItem = true; break; - case RegionNames.SettingsView: + case RegionNames.SettingsRegion: IsCheckedVisualSettingsMenuItem = true; break; } @@ -122,9 +122,10 @@ private void RaiseSubRegionChangeEvent(object sender) #region Command methods - private void ShowRegion(string regionName) + private void ShowRegion(string viewName) { - RegionManager.RequestNavigate(RegionNames.ContentRegion, regionName); + + RegionManager.RequestNavigate(RegionNames.ContentRegion, viewName); } private void CloseApp() From 8f98b2da9abd25192d46f886c9e845d8b85d724e Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Thu, 8 Aug 2024 13:56:47 +1000 Subject: [PATCH 24/40] Close #96 p. 1/2 --- .../AdamStudio.Services.csproj | 1 + AdamStudio/ViewModels/MainWindowViewModel.cs | 1 - .../Views/ScratchControlView.xaml.cs | 5 --- .../ViewModels/ToolBarViewModel.cs | 13 -------- .../Views/ToolBarView.xaml | 31 +++++++++++-------- .../Views/ToolBarView.xaml.cs | 2 +- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/AdamStudio.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj index 1ce0b50..9c1f406 100644 --- a/AdamStudio.Services/AdamStudio.Services.csproj +++ b/AdamStudio.Services/AdamStudio.Services.csproj @@ -21,6 +21,7 @@ + diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 30f0d6a..0370af5 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -105,7 +105,6 @@ public MainWindowViewModel(ILogger loggerService, IRegionMa public string WindowTitle => $"AdamStudio {Assembly.GetExecutingAssembly().GetName().Version}"; - #endregion #region DelegateCommands methods diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs index abacdf4..c7f695f 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs @@ -145,11 +145,6 @@ private void WebViewNavigationCompleted(object sender, CoreWebView2NavigationCom mWebViewProvider.NavigationComplete(); } - /*private void TextResulEditorTextChanged(object sender, EventArgs e) - { - //Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(TextResulEditor.ScrollToEnd)); - }*/ - private async void InitializeWebViewCore() { var tempPath = Path.Combine(Path.GetTempPath(), "AdamBrowser"); diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs index 2126f7c..eb7f16f 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs @@ -86,13 +86,6 @@ public ExtendedCommandExecuteResult ResultExecutionTime set => SetProperty(ref resultExecutionTime, value); } - private ExtendedCommandExecuteResult resultInitilizationTime; - public ExtendedCommandExecuteResult ResultInitilizationTime - { - get => resultInitilizationTime; - set => SetProperty(ref resultInitilizationTime, value); - } - private bool isPythonCodeExecute; public bool IsPythonCodeExecute { @@ -168,16 +161,10 @@ private void UpdateResultExecutionTimeText(ExtendedCommandExecuteResult executeR })); } - private void UpdateResultInitilizationTimeText(ExtendedCommandExecuteResult executeResult) - { - ResultInitilizationTime = executeResult; - } - private void ClearResultText() { ResultText = string.Empty; ResultExecutionTime = null; - ResultInitilizationTime = null; } private void LoadResources() diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index f20128a..7824ada 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -11,12 +11,16 @@ xmlns:converters="clr-namespace:AdamStudio.Core.Converters;assembly=AdamStudio.Core" xmlns:properties="clr-namespace:AdamStudio.Core.Properties;assembly=AdamStudio.Core" xmlns:controlzex="urn:controlzex" + xmlns:i="http://schemas.microsoft.com/xaml/behaviors" + xmlns:in="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" + xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" prism:ViewModelLocator.AutoWireViewModel="True" > + - + + + Text="{Binding ResultText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> + + + + + + + + + @@ -56,22 +71,12 @@ - - - - - - - - - - - + diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs index 73f87a1..4cbf5ab 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs @@ -1,5 +1,5 @@ using System.Windows.Controls; -using System.Windows.Controls.Primitives; + namespace AdamStudio.Modules.ToolBarRegion.Views { From 8776408b8483903472ff8b1075886fb2cd29a3eb Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 9 Aug 2024 10:09:27 +1000 Subject: [PATCH 25/40] Close #98 --- .../StringToViewRegionIconsConverter.cs | 4 +- AdamStudio.Core/RegionNames.cs | 8 - AdamStudio.Core/ViewNames.cs | 8 + AdamStudio.sln | 2 +- AdamStudio/ViewModels/MainWindowViewModel.cs | 14 +- .../ContentRegionModule.cs | 4 +- .../ViewModels/ScratchControlViewModel.cs | 46 +- .../ViewModels/SettingsControlViewModel.cs | 2 +- .../Views/ScratchControlView.xaml.cs | 1 - .../Views/SettingsControlView.xaml | 3 +- .../ViewModels/MenuRegionViewModel.cs | 9 +- .../Views/MenuRegionView.xaml | 4 +- .../AdamStudio.Modules.SettingsRegion.csproj | 12 + .../SettingsRegionModule.cs | 28 ++ .../ViewModels/SettingsControlViewModel.cs | 237 +++++++++++ .../Views/SettingsControlView.xaml | 395 ++++++++++++++++++ .../Views/SettingsControlView.xaml.cs | 12 + .../ViewModels/ToolBarViewModel.cs | 48 ++- .../Views/ToolBarView.xaml | 112 ++--- 19 files changed, 829 insertions(+), 120 deletions(-) create mode 100644 AdamStudio.Core/ViewNames.cs create mode 100644 Modules/AdamStudio.Modules.SettingsRegion/AdamStudio.Modules.SettingsRegion.csproj create mode 100644 Modules/AdamStudio.Modules.SettingsRegion/SettingsRegionModule.cs create mode 100644 Modules/AdamStudio.Modules.SettingsRegion/ViewModels/SettingsControlViewModel.cs create mode 100644 Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml create mode 100644 Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml.cs diff --git a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs index 7d5d155..0abd2a3 100644 --- a/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs +++ b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs @@ -16,10 +16,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value != null) stringValue = (string)value; - if (stringValue == RegionNames.SettingsRegion) + if (stringValue == ViewNames.SettingsView) return PackIconSimpleIconsKind.Scratch; - if (stringValue == RegionNames.ScratchRegion) + if (stringValue == ViewNames.ScratchView) return PackIconFeatherIconsKind.Settings; return PackIconSimpleIconsKind.AbbRobotStudio; diff --git a/AdamStudio.Core/RegionNames.cs b/AdamStudio.Core/RegionNames.cs index 00f246e..c55d76c 100644 --- a/AdamStudio.Core/RegionNames.cs +++ b/AdamStudio.Core/RegionNames.cs @@ -2,18 +2,10 @@ { public class RegionNames { - public const string ContentRegion = $"{nameof(ContentRegion)}"; public const string FlayoutsRegion = $"{nameof(FlayoutsRegion)}"; public const string ToolBarRegion = $"{nameof(ToolBarRegion)}"; public const string StatusBarRegion = $"{nameof(StatusBarRegion)}"; public const string MenuRegion = $"{nameof(MenuRegion)}"; - - - public const string ScratchRegion = "ScratchRegion"; - public const string SettingsRegion = "SettingsRegion"; - - public const string ScratchView = "ScratchControlView"; - public const string SettingsView = "SettingsControlView"; } } diff --git a/AdamStudio.Core/ViewNames.cs b/AdamStudio.Core/ViewNames.cs new file mode 100644 index 0000000..906622b --- /dev/null +++ b/AdamStudio.Core/ViewNames.cs @@ -0,0 +1,8 @@ +namespace AdamStudio.Core +{ + public class ViewNames + { + public const string ScratchView = "ScratchControlView"; + public const string SettingsView = "SettingsControlView"; + } +} diff --git a/AdamStudio.sln b/AdamStudio.sln index 20d6b20..447f028 100644 --- a/AdamStudio.sln +++ b/AdamStudio.sln @@ -27,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamController.WebApi.Clien EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamStudio.Controls", "AdamStudio.Controls\AdamStudio.Controls.csproj", "{1BADFDB1-D66E-4580-8EAF-CAEE37761640}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdamStudio.Modules.ToolBarRegion", "Modules\AdamStudio.Modules.ToolBarRegion\AdamStudio.Modules.ToolBarRegion.csproj", "{AA601C7F-2233-47FE-911E-8221E8B861C8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamStudio.Modules.ToolBarRegion", "Modules\AdamStudio.Modules.ToolBarRegion\AdamStudio.Modules.ToolBarRegion.csproj", "{AA601C7F-2233-47FE-911E-8221E8B861C8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 0370af5..b90fe3c 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -135,7 +135,7 @@ private void MoveSplitter(string commandArg) private bool MoveSplitterCanExecute(string arg) { var regionName = RegionChangeAwareService.RegionNavigationTargetName; - return regionName == RegionNames.ScratchRegion; + return regionName == ViewNames.ScratchView; } private void SwitchToVideo() @@ -153,22 +153,22 @@ private void SwitchToVideo() private bool SwitchToVideoCanExecute() { var regionName = RegionChangeAwareService.RegionNavigationTargetName; - return regionName == RegionNames.ScratchRegion; + return regionName == ViewNames.ScratchView; } private void SwitchToSettingsView() { var activeViewName = RegionChangeAwareService.RegionNavigationTargetName; - if (activeViewName == RegionNames.ScratchRegion) + if (activeViewName == ViewNames.ScratchView) { - ShowView(RegionNames.SettingsView); + ShowView(ViewNames.SettingsView); return; } - if(activeViewName == RegionNames.SettingsRegion) + if(activeViewName == ViewNames.SettingsView) { - ShowView(RegionNames.ScratchView); + ShowView(ViewNames.ScratchView); return; } } @@ -286,7 +286,7 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e) } //Loaded resource - ShowView(RegionNames.ScratchRegion); + ShowView(ViewNames.ScratchView); LoadCustomAvalonEditHighlighting(); LoadAppTheme(); diff --git a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs index 7a0dfaa..460042e 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs @@ -22,8 +22,8 @@ public void OnInitialized(IContainerProvider containerProvider) public void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterForNavigation(nameof(ScratchControlView)); - containerRegistry.RegisterForNavigation(nameof(SettingsControlView)); + containerRegistry.RegisterForNavigation(ViewNames.ScratchView); + containerRegistry.RegisterForNavigation(ViewNames.SettingsView); } } } \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index 97575e0..ce55689 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -35,7 +35,7 @@ public class ScratchControlViewModel : RegionViewModelBase public DelegateCommand ReloadWebViewDelegateCommand { get; } public DelegateCommand ShowSaveFileDialogDelegateCommand { get; } public DelegateCommand ShowOpenFileDialogDelegateCommand { get; } - public DelegateCommand CleanExecuteEditorDelegateCommand { get; } + //public DelegateCommand CleanExecuteEditorDelegateCommand { get; } public DelegateCommand RunPythonCodeDelegateCommand { get; } public DelegateCommand StopPythonCodeExecuteDelegateCommand { get; } public DelegateCommand ToZeroPositionDelegateCommand { get; } @@ -124,7 +124,7 @@ public ScratchControlViewModel(ILogger logger, IRegionM CopyToClipboardDelegateCommand = new DelegateCommand(CopyToClipboard, CopyToClipboardCanExecute); ReloadWebViewDelegateCommand = new DelegateCommand(ReloadWebView, ReloadWebViewCanExecute); - CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); + //CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); RunPythonCodeDelegateCommand = new DelegateCommand(RunPythonCode, RunPythonCodeCanExecute); StopPythonCodeExecuteDelegateCommand = new DelegateCommand(StopPythonCodeExecute, StopPythonCodeExecuteCanExecute); ToZeroPositionDelegateCommand = new DelegateCommand(ToZeroPosition, ToZeroPositionCanExecute); @@ -133,22 +133,18 @@ public ScratchControlViewModel(ILogger logger, IRegionM DirectionButtonUpDelegateCommand = new DelegateCommand(DirectionButtonUp, DirectionButtonUpCanExecute); HighlightingDefinition = avalonEditService.GetDefinition(HighlightingName.AdamPython); + + Subscribe(); } #endregion #region Navigation - public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) - { - base.ConfirmNavigationRequest(navigationContext, continuationCallback); - } - public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.ScratchRegion; + mRegionChangeAwareService.RegionNavigationTargetName = ViewNames.ScratchView; - Subscribe(); LoadResources(); UpdateIsShowVideo(Settings.Default.ShowVideo); @@ -327,7 +323,7 @@ private void Subscribe() //mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart; //mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput; - //mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; + mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; mWebViewProvider.RaiseWebViewMessageReceivedEvent += RaiseWebViewbMessageReceivedEvent; mWebViewProvider.RaiseWebViewNavigationCompleteEvent += RaiseWebViewNavigationCompleteEvent; @@ -344,7 +340,7 @@ private void Unsubscribe() //mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart; //mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput; - //mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; + mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; mWebViewProvider.RaiseWebViewMessageReceivedEvent -= RaiseWebViewbMessageReceivedEvent; mWebViewProvider.RaiseWebViewNavigationCompleteEvent -= RaiseWebViewNavigationCompleteEvent; @@ -464,17 +460,17 @@ private bool ShowOpenFileDialogCanExecute(string param) return isPythonCodeNotExecute; } - private void CleanExecuteEditor() + /*private void CleanExecuteEditor() { - //ClearResultText(); - } + ClearResultText(); + }*/ - private bool CleanExecuteEditorCanExecute() + /*private bool CleanExecuteEditorCanExecute() { bool isPythonCodeNotExecute = !IsPythonCodeExecute; //var isResultNotEmpty = ResultText?.Length > 0; return isPythonCodeNotExecute;// && isResultNotEmpty; - } + }*/ private async void RunPythonCode() { @@ -710,13 +706,13 @@ private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) await mWebViewProvider.ExecuteJavaScript(Scripts.ShadowDisable); })); - mStatusBarNotificationDelivery.CompileLogMessage = mCompileLogMessageEndDebug; + mLogger.LogInformation(mCompileLogMessageEndDebug); mStatusBarNotificationDelivery.ProgressRingStart = false; return; } //mIsWarningStackOwerflowAlreadyShow = false; - mStatusBarNotificationDelivery.CompileLogMessage = mCompileLogMessageStartDebug; + mLogger.LogInformation(mCompileLogMessageStartDebug); mStatusBarNotificationDelivery.ProgressRingStart = true; @@ -788,7 +784,7 @@ private void RaiseDelegateCommandsCanExecuteChanged() ReloadWebViewDelegateCommand.RaiseCanExecuteChanged(); ShowSaveFileDialogDelegateCommand.RaiseCanExecuteChanged(); ShowOpenFileDialogDelegateCommand.RaiseCanExecuteChanged(); - CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); + //CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); RunPythonCodeDelegateCommand.RaiseCanExecuteChanged(); StopPythonCodeExecuteDelegateCommand.RaiseCanExecuteChanged(); ToZeroPositionDelegateCommand.RaiseCanExecuteChanged(); @@ -870,14 +866,10 @@ private void OnRaiseTcpServiceClientDisconnect(object sender, bool isUserRequest UpdateResultText(message); }*/ - /*private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult) + private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult) { - if (remoteCommandExecuteResult == null) - return; - - UpdateResultText("", true); - UpdateResultExecutionTimeText(remoteCommandExecuteResult); - }*/ + IsPythonCodeExecute = false; + } private void OnRaiseIsVideoShowChangeEvent(object sender) { @@ -919,7 +911,7 @@ private async void InitBlockly() await mWebViewProvider.ExecuteJavaScript(Scripts.RestoreSavedBlocks); } - //mLogger.LogInformation(mScretchLoadedCompleteLogMessage); + mLogger.LogInformation(mScretchLoadedCompleteLogMessage); } catch { diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs index a5f285c..d8d3016 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs @@ -115,7 +115,7 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex public override void OnNavigatedTo(NavigationContext navigationContext) { - mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsRegion; + mRegionChangeAwareService.RegionNavigationTargetName = ViewNames.SettingsView; ThemesCollection = mThemeManager.AppThemesCollection; SelectedTheme = mThemeManager.GetCurrentAppTheme(); diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs index c7f695f..872a5e4 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs @@ -56,7 +56,6 @@ public ScratchControlView(ILogger logger, IWebViewProvider w mWebViewProvider.RaiseExecuteReloadWebViewEvent += RaiseExecuteReloadWebViewEvent; /*element event */ - //TextResulEditor.TextChanged += TextResulEditorTextChanged; MainGrid.SizeChanged += MainGridSizeChanged; SourceEditor.SizeChanged += TextResulEditorSizeChanged; diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/SettingsControlView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/SettingsControlView.xaml index a2db3fe..e059633 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/SettingsControlView.xaml +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/SettingsControlView.xaml @@ -55,8 +55,7 @@ - - + diff --git a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs index 8c66297..2d599b2 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs @@ -80,10 +80,10 @@ private void ChangeCheckedMenuItem(string selectedRegionName) switch (selectedRegionName) { - case RegionNames.ScratchRegion: + case ViewNames.ScratchView: IsCheckedScratchMenuItem = true; break; - case RegionNames.SettingsRegion: + case ViewNames.SettingsView: IsCheckedVisualSettingsMenuItem = true; break; } @@ -122,10 +122,9 @@ private void RaiseSubRegionChangeEvent(object sender) #region Command methods - private void ShowRegion(string viewName) + private void ShowRegion(string regionName) { - - RegionManager.RequestNavigate(RegionNames.ContentRegion, viewName); + RegionManager.RequestNavigate(RegionNames.ContentRegion, regionName); } private void CloseApp() diff --git a/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml b/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml index 61d653c..078296b 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml +++ b/Modules/AdamStudio.Modules.MenuRegion/Views/MenuRegionView.xaml @@ -21,12 +21,12 @@ diff --git a/Modules/AdamStudio.Modules.SettingsRegion/AdamStudio.Modules.SettingsRegion.csproj b/Modules/AdamStudio.Modules.SettingsRegion/AdamStudio.Modules.SettingsRegion.csproj new file mode 100644 index 0000000..09d1682 --- /dev/null +++ b/Modules/AdamStudio.Modules.SettingsRegion/AdamStudio.Modules.SettingsRegion.csproj @@ -0,0 +1,12 @@ + + + net8.0-windows7.0 + true + + + + + + + + \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.SettingsRegion/SettingsRegionModule.cs b/Modules/AdamStudio.Modules.SettingsRegion/SettingsRegionModule.cs new file mode 100644 index 0000000..66c1b2d --- /dev/null +++ b/Modules/AdamStudio.Modules.SettingsRegion/SettingsRegionModule.cs @@ -0,0 +1,28 @@ +using AdamStudio.Core; +using AdamStudio.Modules.SettingsRegion.Views; +using Prism.Ioc; +using Prism.Modularity; +using Prism.Regions; + +namespace AdamStudio.Modules.SettingsRegion +{ + public class SettingsRegionModule : IModule + { + private readonly IRegionManager mRegionManager; + + public SettingsRegionModule(IRegionManager regionManager) + { + mRegionManager = regionManager; + } + + public void OnInitialized(IContainerProvider containerProvider) + { + //mRegionManager.RequestNavigate(RegionNames.ContentRegion, nameof(SettingsControlView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation(nameof(SettingsControlView)); + } + } +} \ No newline at end of file diff --git a/Modules/AdamStudio.Modules.SettingsRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.SettingsRegion/ViewModels/SettingsControlViewModel.cs new file mode 100644 index 0000000..4b0c084 --- /dev/null +++ b/Modules/AdamStudio.Modules.SettingsRegion/ViewModels/SettingsControlViewModel.cs @@ -0,0 +1,237 @@ +using AdamBlocklyLibrary.Enum; +using AdamStudio.Controls.CustomControls.Services; +using AdamStudio.Core; +using AdamStudio.Core.Mvvm; +using AdamStudio.Core.Properties; +using AdamStudio.Services.Interfaces; +using ControlzEx.Theming; +using Prism.Commands; +using Prism.Regions; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Windows.Media; + +namespace AdamStudio.Modules.SettingsRegion.ViewModels +{ + public class SettingsControlViewModel : RegionViewModelBase + { + #region DelegateCommands + + public DelegateCommand ChangeSpacingToggleSwitchDelegateCommand { get; } + public DelegateCommand OpenPortSettingsDelegateCommand { get; } + public DelegateCommand OpenWebApiSettingsDelegateCommand { get; } + public DelegateCommand OpenUserFolderSettingsDelegateCommand { get; } + + #endregion + + #region Services + + private readonly IFlyoutManager mFlyoutManager; + private readonly IThemeManagerService mThemeManager; + private readonly ICultureProvider mCultureProvider; + private readonly IWebViewProvider mWebViewProvider; + private readonly IRegionChangeAwareService mRegionChangeAwareService; + + #endregion + + #region Const + + private const string cBaseColorAppThemeLightName = "Light"; + private const string cBaseColorAppDarkLightName = "Dark"; + + #endregion + + #region ~ + + public SettingsControlViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, + IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider, IRegionChangeAwareService subRegionChangeAwareService) : base(regionManager) + { + mFlyoutManager = flyoutManager; + mThemeManager = themeManager; + mCultureProvider = cultureProvider; + mWebViewProvider = webViewProvider; + mRegionChangeAwareService = subRegionChangeAwareService; + + ChangeSpacingToggleSwitchDelegateCommand = new DelegateCommand(ChangeSpacingToggleSwitch, ChangeSpacingToggleSwitchCanExecute); + OpenPortSettingsDelegateCommand = new DelegateCommand(OpenPortSettings, OpenPortSettingsCanExecute); + OpenWebApiSettingsDelegateCommand = new DelegateCommand(OpenWebApiSettings, OpenWebApiSettingsCanExecute); + OpenUserFolderSettingsDelegateCommand = new DelegateCommand(OpenUserFolderSettings, OpenUserFolderSettingsCanExecute); + } + + #endregion + + #region DelegateCommand methods + + private void ChangeSpacingToggleSwitch() + { + Settings.Default.BlocklyGridSpacing = 20; + } + + private bool ChangeSpacingToggleSwitchCanExecute() + { + return true; + } + + private void OpenPortSettings() + { + mFlyoutManager.OpenFlyout(FlyoutNames.FlyoutPortSettings); + } + + private bool OpenPortSettingsCanExecute() + { + return true; + } + + private void OpenWebApiSettings() + { + mFlyoutManager.OpenFlyout(FlyoutNames.FlyoutWebApiSettings); + } + + private bool OpenWebApiSettingsCanExecute() + { + return true; + } + + private void OpenUserFolderSettings() + { + mFlyoutManager.OpenFlyout(FlyoutNames.FlyoutUserFoldersSettings); + } + + private bool OpenUserFolderSettingsCanExecute() + { + return true; + } + + #endregion + + #region Navigation + + public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) + { + base.ConfirmNavigationRequest(navigationContext, continuationCallback); + } + + public override void OnNavigatedTo(NavigationContext navigationContext) + { + mRegionChangeAwareService.RegionNavigationTargetName = RegionNames.SettingsRegion; + + ThemesCollection = mThemeManager.AppThemesCollection; + SelectedTheme = mThemeManager.GetCurrentAppTheme(); + + LanguageApp = mCultureProvider.SupportAppCultures; + SelectedLanguageApp = mCultureProvider.CurrentAppCulture; + + base.OnNavigatedTo(navigationContext); + } + + public override void Destroy() + { + base.Destroy(); + } + + #endregion + + #region Public fields + + private List languageApp; + public List LanguageApp + { + get => languageApp; + private set => SetProperty(ref languageApp, value); + } + + private CultureInfo selectedLanguageApp; + public CultureInfo SelectedLanguageApp + { + get => selectedLanguageApp; + set + { + bool isNewValue = SetProperty(ref selectedLanguageApp, value); + + if (isNewValue) + { + mWebViewProvider.NeedReloadOnLoad = true; + ChangeAppLanguage(SelectedLanguageApp); + } + } + } + + public ReadOnlyObservableCollection themesCollection; + public ReadOnlyObservableCollection ThemesCollection + { + get => themesCollection; + set => SetProperty(ref themesCollection, value); + } + + public Theme selectedTheme; + public Theme SelectedTheme + { + get => selectedTheme; + set + { + bool isNewValue = SetProperty(ref selectedTheme, value); + + if (isNewValue) + { + mWebViewProvider.NeedReloadOnLoad = true; + ChangeTheme(SelectedTheme); + } + } + } + + #endregion + + #region Private methods + + private void ChangeTheme(Theme theme) + { + Theme chagedTheme = mThemeManager.ChangeAppTheme(theme); + ChangeBlockllyTheme(chagedTheme.BaseColorScheme); + + Settings.Default.AppThemeName = chagedTheme.Name; + } + + private void ChangeBlockllyTheme(string baseColorAppTheme) + { + if (baseColorAppTheme == cBaseColorAppDarkLightName) + { + Settings.Default.BlocklyTheme = BlocklyTheme.Dark; + Settings.Default.BlocklyGridColour = Colors.White.ToString(); + } + + if (baseColorAppTheme == cBaseColorAppThemeLightName) + { + Settings.Default.BlocklyTheme = BlocklyTheme.Classic; + Settings.Default.BlocklyGridColour = Colors.Black.ToString(); + } + + } + + private void ChangeAppLanguage(CultureInfo cultureInfo) + { + mCultureProvider.ChangeAppCulture(cultureInfo); + ChangeBlocklyLanguage(cultureInfo); + + Settings.Default.AppLanguage = cultureInfo.Name; + } + + private void ChangeBlocklyLanguage(CultureInfo cultureInfo) + { + if (cultureInfo.TwoLetterISOLanguageName == "en") + { + Settings.Default.BlocklyWorkspaceLanguage = BlocklyLanguage.en; + Settings.Default.BlocklyToolboxLanguage = BlocklyLanguage.en; + } + + if (cultureInfo.TwoLetterISOLanguageName == "ru") + { + Settings.Default.BlocklyWorkspaceLanguage = BlocklyLanguage.ru; + Settings.Default.BlocklyToolboxLanguage = BlocklyLanguage.ru; + } + } + + #endregion + } +} diff --git a/Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml b/Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml new file mode 100644 index 0000000..2ac43fc --- /dev/null +++ b/Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3fc9e0b9460cdb16c6f030d177d4d1e143e6d09c Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 9 Aug 2024 11:51:38 +1000 Subject: [PATCH 26/40] Close #99 --- .../CustomControls/FlyoutContainer.xaml | 3 +- AdamStudio/Views/MainWindow.xaml | 8 +- .../ViewModels/ScratchControlViewModel.cs | 197 +----------------- .../Views/ScratchControlView.xaml | 4 +- .../Template/PopupWindow.xaml | 3 +- .../ViewModels/ToolBarViewModel.cs | 76 ++++++- .../Views/ToolBarView.xaml | 10 + 7 files changed, 99 insertions(+), 202 deletions(-) diff --git a/AdamStudio.Controls/CustomControls/FlyoutContainer.xaml b/AdamStudio.Controls/CustomControls/FlyoutContainer.xaml index 28c81e8..539604f 100644 --- a/AdamStudio.Controls/CustomControls/FlyoutContainer.xaml +++ b/AdamStudio.Controls/CustomControls/FlyoutContainer.xaml @@ -1,7 +1,8 @@  + xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls" + > diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index 564861e..cefa1d6 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -32,7 +32,8 @@ - + @@ -110,7 +111,8 @@ - + @@ -136,7 +138,7 @@ prism:RegionManager.RegionName="{x:Static core:RegionNames.ContentRegion}" /> + prism:RegionManager.RegionName="{x:Static core:RegionNames.ToolBarRegion}" /> ShowSaveFileDialogDelegateCommand { get; } public DelegateCommand ShowOpenFileDialogDelegateCommand { get; } - //public DelegateCommand CleanExecuteEditorDelegateCommand { get; } public DelegateCommand RunPythonCodeDelegateCommand { get; } public DelegateCommand StopPythonCodeExecuteDelegateCommand { get; } public DelegateCommand ToZeroPositionDelegateCommand { get; } @@ -69,14 +68,8 @@ public class ScratchControlViewModel : RegionViewModelBase #region Var - //private bool mIsWarningStackOwerflowAlreadyShow; - private string mCompileLogMessageStartDebug; private string mCompileLogMessageEndDebug; - //private string mFinishAppExecute; - //private string mWarningStackOwerflow1; - //private string mWarningStackOwerflow2; - //private string mWarningStackOwerflow3; private string mSaveWorkspaceDialogTitle; private string mSaveScriptFileDialogTitle; @@ -124,7 +117,7 @@ public ScratchControlViewModel(ILogger logger, IRegionM CopyToClipboardDelegateCommand = new DelegateCommand(CopyToClipboard, CopyToClipboardCanExecute); ReloadWebViewDelegateCommand = new DelegateCommand(ReloadWebView, ReloadWebViewCanExecute); - //CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); + RunPythonCodeDelegateCommand = new DelegateCommand(RunPythonCode, RunPythonCodeCanExecute); StopPythonCodeExecuteDelegateCommand = new DelegateCommand(StopPythonCodeExecute, StopPythonCodeExecuteCanExecute); ToZeroPositionDelegateCommand = new DelegateCommand(ToZeroPosition, ToZeroPositionCanExecute); @@ -232,40 +225,6 @@ public string SourceTextEditor } } - /*private string resultText; - public string ResultText - { - get => resultText; - set - { - bool isNewValue = SetProperty(ref resultText, value); - - if(isNewValue) - CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); - } - } - - private ExtendedCommandExecuteResult resultExecutionTime; - public ExtendedCommandExecuteResult ResultExecutionTime - { - get => resultExecutionTime; - set => SetProperty(ref resultExecutionTime, value); - } - - private ExtendedCommandExecuteResult resultInitilizationTime; - public ExtendedCommandExecuteResult ResultInitilizationTime - { - get => resultInitilizationTime; - set => SetProperty(ref resultInitilizationTime, value); - }*/ - - private string pythonVersion; - public string PythonVersion - { - get => pythonVersion; - set => SetProperty(ref pythonVersion, value); - } - private float sliderValue; public float SliderValue { @@ -273,20 +232,6 @@ public float SliderValue set => SetProperty(ref sliderValue, value); } - /*private string pythonBinPath; - public string PythonBinPath - { - get => pythonBinPath; - set => SetProperty(ref pythonBinPath, value); - } - - private string pythonWorkDir; - public string PythonWorkDir - { - get => pythonWorkDir; - set => SetProperty(ref pythonWorkDir, value); - }*/ - private IHighlightingDefinition highlightingDefinition; public IHighlightingDefinition HighlightingDefinition { @@ -321,8 +266,6 @@ private void Subscribe() mCommunicationProvider.RaiseTcpServiceCientConnectedEvent += OnRaiseTcpServiceCientConnected; mCommunicationProvider.RaiseTcpServiceClientDisconnectEvent += OnRaiseTcpServiceClientDisconnect; - //mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart; - //mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput; mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; mWebViewProvider.RaiseWebViewMessageReceivedEvent += RaiseWebViewbMessageReceivedEvent; @@ -338,8 +281,6 @@ private void Unsubscribe() mCommunicationProvider.RaiseTcpServiceCientConnectedEvent -= OnRaiseTcpServiceCientConnected; mCommunicationProvider.RaiseTcpServiceClientDisconnectEvent -= OnRaiseTcpServiceClientDisconnect; - //mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart; - //mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput; mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; mWebViewProvider.RaiseWebViewMessageReceivedEvent -= RaiseWebViewbMessageReceivedEvent; @@ -460,18 +401,6 @@ private bool ShowOpenFileDialogCanExecute(string param) return isPythonCodeNotExecute; } - /*private void CleanExecuteEditor() - { - ClearResultText(); - }*/ - - /*private bool CleanExecuteEditorCanExecute() - { - bool isPythonCodeNotExecute = !IsPythonCodeExecute; - //var isResultNotEmpty = ResultText?.Length > 0; - return isPythonCodeNotExecute;// && isResultNotEmpty; - }*/ - private async void RunPythonCode() { @@ -479,9 +408,6 @@ private async void RunPythonCode() try { - //ClearResultText(); - - var command = new AdamController.WebApi.Client.v1.RequestModel.PythonCommandModel { Command = source @@ -490,17 +416,10 @@ private async void RunPythonCode() IsPythonCodeExecute = true; _ = await mWebApiService.PythonExecuteAsync(command); - - //ExtendedCommandExecuteResult executeResult = await mWebApiService.PythonExecuteAsync(command); - //UpdateResultInitilizationTimeText(executeResult); } catch { - //IsPythonCodeExecute = false; - } - finally - { - //IsPythonCodeExecute = false; + } } @@ -629,73 +548,6 @@ private void UpdateIsShowVideo(bool isShowVideo) IsShowVideo = isShowVideo; } - /*rivate void UpdateResultText(string text, bool isFinishMessage = false) - { - Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => - { - if (isFinishMessage) - { - ResultText += "\n======================\n"; - ResultText += $"<<{mFinishAppExecute}>>\n"; - } - - if(!isFinishMessage) - { - if (ResultText?.Length > 500) - { - if (!mIsWarningStackOwerflowAlreadyShow) - { - string warningMessage = $"\n{mWarningStackOwerflow1}\n{mWarningStackOwerflow2}\n{mWarningStackOwerflow3}\n"; - ResultText += warningMessage; - mIsWarningStackOwerflowAlreadyShow = true; - } - - return; - } - - ResultText += text; - } - })); - }*/ - - /*private void UpdateResultExecutionTimeText(ExtendedCommandExecuteResult executeResult) - { - - Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => - { - ExtendedCommandExecuteResult fixResult = new() - { - StandardOutput = executeResult.StandardOutput, - StandardError = executeResult.StandardError, - - StartTime = executeResult.StartTime, - EndTime = executeResult.EndTime, - RunTime = executeResult.RunTime, - - ExitCode = executeResult.ExitCode, - - // The server always returns False - // Therefore, the success of completion is determined by the exit code - Succeesed = executeResult.ExitCode == 0 - }; - - ResultExecutionTime = fixResult; - IsPythonCodeExecute = false; - })); - }*/ - - /*private void UpdateResultInitilizationTimeText(ExtendedCommandExecuteResult executeResult) - { - ResultInitilizationTime = executeResult; - }*/ - - /*private void ClearResultText() - { - ResultText = string.Empty; - ResultExecutionTime = null; - ResultInitilizationTime = null; - }*/ - private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) { @@ -711,11 +563,9 @@ private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) return; } - //mIsWarningStackOwerflowAlreadyShow = false; mLogger.LogInformation(mCompileLogMessageStartDebug); mStatusBarNotificationDelivery.ProgressRingStart = true; - if (!Settings.Default.ShadowWorkspaceInDebug) return; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(async () => @@ -724,20 +574,7 @@ private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) })); } - private void UpdatePythonInfo(string pythonVersion = "", string pythonBinPath = "", string pythonWorkDir = "") - { - if (string.IsNullOrEmpty(pythonVersion)) - { - PythonVersion = string.Empty; - //PythonBinPath = string.Empty; - //PythonWorkDir = string.Empty; - return; - } - PythonVersion = pythonVersion; - //PythonBinPath = $"[{pythonBinPath}]"; - //PythonWorkDir = $"Рабочая дирректория {pythonWorkDir}"; - } private async void OpenSupportedFile(OpenFileDialogResult result) { @@ -784,7 +621,6 @@ private void RaiseDelegateCommandsCanExecuteChanged() ReloadWebViewDelegateCommand.RaiseCanExecuteChanged(); ShowSaveFileDialogDelegateCommand.RaiseCanExecuteChanged(); ShowOpenFileDialogDelegateCommand.RaiseCanExecuteChanged(); - //CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); RunPythonCodeDelegateCommand.RaiseCanExecuteChanged(); StopPythonCodeExecuteDelegateCommand.RaiseCanExecuteChanged(); ToZeroPositionDelegateCommand.RaiseCanExecuteChanged(); @@ -794,11 +630,6 @@ private void LoadResources() { mCompileLogMessageStartDebug = mCultureProvider.FindResource("DebuggerMessages.CompileLogMessageStartDebug"); mCompileLogMessageEndDebug = mCultureProvider.FindResource("DebuggerMessages.CompileLogMessageEndDebug"); - //mFinishAppExecute = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.FinishAppExecute"); - - //mWarningStackOwerflow1 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow1"); - //mWarningStackOwerflow2 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow2"); - //mWarningStackOwerflow3 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow3"); mSaveWorkspaceDialogTitle = mCultureProvider.FindResource("ScratchControlViewModel.SaveWorkspaceFileDialog.DialogTitle"); mSaveScriptFileDialogTitle = mCultureProvider.FindResource("ScratchControlViewModel.SaveScriptFileDialog.DialogTitle"); @@ -834,38 +665,16 @@ private void RaiseWebViewbMessageReceivedEvent(object sender, WebMessageJsonRece } } - private async void OnRaiseTcpServiceCientConnected(object sender) + private void OnRaiseTcpServiceCientConnected(object sender) { IsTcpClientConnected = mCommunicationProvider.IsTcpClientConnected; - - var pythonVersionResult = await mWebApiService.GetPythonVersion(); - var pythonBinPathResult = await mWebApiService.GetPythonBinDir(); - var pythonWorkDirResult = await mWebApiService.GetPythonWorkDir(); - - string pythonVersion = pythonVersionResult?.StandardOutput?.Replace("\n", ""); - string pythonBinPath = pythonBinPathResult?.StandardOutput?.Replace("\n", ""); - string pythonWorkDir = pythonWorkDirResult?.StandardOutput?.Replace("\n", ""); - - UpdatePythonInfo(pythonVersion, pythonBinPath, pythonWorkDir); } private void OnRaiseTcpServiceClientDisconnect(object sender, bool isUserRequest) { IsTcpClientConnected = mCommunicationProvider.IsTcpClientConnected; - - UpdatePythonInfo(); } - /*private void OnRaisePythonScriptExecuteStart(object sender) - { - IsPythonCodeExecute = true; - }*/ - - /*private void OnRaisePythonStandartOutput(object sender, string message) - { - UpdateResultText(message); - }*/ - private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult) { IsPythonCodeExecute = false; diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml index e9868c9..7f09143 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml @@ -565,11 +565,11 @@ - + Style="{DynamicResource MahApps.Styles.TextBlock.Watermark}"/>--> diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml index 271133b..ddaf27c 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml @@ -15,7 +15,8 @@ CloseOnMouseLeftButtonDown="False" Height="{Binding Height, ElementName=popupWindow, Mode=TwoWay}" Width="{Binding Width, ElementName=popupWindow}" - IsOpen="{Binding IsOpen, ElementName=popupWindow}"> + IsOpen="{Binding IsOpen, ElementName=popupWindow}" + > mLogger; private readonly ILogWriteEventAwareService mLogWriteEventAware; private readonly IPythonRemoteRunnerService mPythonRemoteRunner; private readonly ICultureProvider mCultureProvider; + private readonly ITcpClientService mTcpClientService; + private readonly IWebApiService mWebApiService; + + #endregion + + #region Var private bool mIsWarningStackOwerflowAlreadyShow; private string mFinishAppExecute; @@ -29,12 +38,17 @@ public class ToolBarViewModel : RegionViewModelBase private string mWarningStackOwerflow2; private string mWarningStackOwerflow3; - public ToolBarViewModel(IRegionManager regionManager, ILogger logger, ILogWriteEventAwareService logWriteEventAware, IPythonRemoteRunnerService pythonRemoteRunner, ICultureProvider cultureProvider) : base(regionManager) + #endregion + + public ToolBarViewModel(IRegionManager regionManager, ILogger logger, ILogWriteEventAwareService logWriteEventAware, IPythonRemoteRunnerService pythonRemoteRunner, ICultureProvider cultureProvider, + ITcpClientService tcpClientService, IWebApiService webApiService) : base(regionManager) { mLogger = logger; mLogWriteEventAware = logWriteEventAware; mPythonRemoteRunner = pythonRemoteRunner; mCultureProvider = cultureProvider; + mTcpClientService = tcpClientService; + mWebApiService = webApiService; CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); @@ -190,6 +204,42 @@ private void ClearResults() ResultExecutionTime = null; } + private string mPythonVersion; + public string PythonVersion + { + get => mPythonVersion; + set => SetProperty(ref mPythonVersion, value); + } + + private string mPythonBinPath; + public string PythonBinPath + { + get => mPythonBinPath; + set => SetProperty(ref mPythonBinPath, value); + } + + private string mPythonWorkDir; + public string PythonWorkDir + { + get => mPythonWorkDir; + set => SetProperty(ref mPythonWorkDir, value); + } + + private void UpdatePythonInfo(string pythonVersion = null, string pythonBinPath = null, string pythonWorkDir = null) + { + /*if (string.IsNullOrEmpty(pythonVersion)) + { + //PythonVersion = string.Empty; + //PythonBinPath = string.Empty; + //PythonWorkDir = string.Empty; + return; + }*/ + + PythonVersion = pythonVersion; + PythonBinPath = pythonBinPath; + PythonWorkDir = pythonWorkDir; + } + private void LoadResources() { mFinishAppExecute = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.FinishAppExecute"); @@ -235,12 +285,33 @@ private void RaiseCurrentAppCultureLoadOrChangeEvent(object sender) LoadResources(); } + private async void RaiseTcpCientConnectedEvent(object sender) + { + var pythonVersionResult = await mWebApiService.GetPythonVersion(); + var pythonBinPathResult = await mWebApiService.GetPythonBinDir(); + var pythonWorkDirResult = await mWebApiService.GetPythonWorkDir(); + + string pythonVersion = pythonVersionResult?.StandardOutput?.Replace("\n", ""); + string pythonBinPath = pythonBinPathResult?.StandardOutput?.Replace("\n", ""); + string pythonWorkDir = pythonWorkDirResult?.StandardOutput?.Replace("\n", ""); + + UpdatePythonInfo(pythonVersion, pythonBinPath, pythonWorkDir); + } + + private void RaiseTcpClientDisconnectedEvent(object sender) + { + UpdatePythonInfo(); + } + #endregion #region Subscribes private void Subscribe() { + mTcpClientService.RaiseTcpCientConnectedEvent += RaiseTcpCientConnectedEvent; + mTcpClientService.RaiseTcpClientDisconnectedEvent += RaiseTcpClientDisconnectedEvent; + mLogWriteEventAware.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent; mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart; @@ -252,6 +323,9 @@ private void Subscribe() private void Unsubscribe() { + mTcpClientService.RaiseTcpCientConnectedEvent -= RaiseTcpCientConnectedEvent; + mTcpClientService.RaiseTcpClientDisconnectedEvent -= RaiseTcpClientDisconnectedEvent; + mLogWriteEventAware.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent; mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart; diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index 551263f..982b298 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -81,6 +81,16 @@ + + + + + + + + + + From 19eab6b451e1eed2170351e94f736fb7693a4ad9 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 9 Aug 2024 14:58:25 +1000 Subject: [PATCH 27/40] Prepare woks #102 --- .../Views/ToolBarView.xaml | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index 982b298..d621ca5 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -25,13 +25,23 @@ - + + + + + + + From 2ea075f2e086e746eac20399ad0849b60a410eb5 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 23 Aug 2024 14:03:22 +1000 Subject: [PATCH 28/40] Moved Prism.Container.Extensions to services project --- AdamStudio.Services/AdamStudio.Services.csproj | 1 + AdamStudio/AdamStudio.csproj | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/AdamStudio.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj index 9c1f406..e34e1dc 100644 --- a/AdamStudio.Services/AdamStudio.Services.csproj +++ b/AdamStudio.Services/AdamStudio.Services.csproj @@ -12,6 +12,7 @@ + diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index e7773d6..65f9c1d 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -30,9 +30,6 @@ 1701;1702;CA1416 - - - From d9709bcb9e0a585714c9fedcf2dc7621b9def5b5 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 30 Aug 2024 12:54:12 +1000 Subject: [PATCH 29/40] Cosmetic fix --- AdamStudio/App.xaml.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index d22689a..6cabcd2 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -26,22 +26,23 @@ using System.Diagnostics; using System.Threading.Tasks; using System.ComponentModel; -using AdamStudio.Core.Properties; -using AdamStudio.Services.Interfaces; -using AdamStudio.Views; -using AdamStudio.Controls.CustomControls.Services; -using AdamStudio.Services.TcpClientDependency; -using AdamStudio.Services; using Microsoft.Extensions.DependencyInjection; using Serilog; using System.Net; using Serilog.Core; + using AdamStudio.Controls.CustomControls.RegionAdapters; using AdamStudio.Modules.ContentRegion; using AdamStudio.Modules.FlayoutsRegion; using AdamStudio.Modules.MenuRegion; using AdamStudio.Modules.StatusBarRegion; using AdamStudio.Modules.ToolBarRegion; +using AdamStudio.Core.Properties; +using AdamStudio.Services.Interfaces; +using AdamStudio.Views; +using AdamStudio.Controls.CustomControls.Services; +using AdamStudio.Services.TcpClientDependency; +using AdamStudio.Services; #endregion @@ -223,6 +224,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) private void RegisterService(IContainerRegistry containerRegistry) { + containerRegistry.RegisterServices(services => { ILogWriteEventAwareService logWriteEventAware = Container.Resolve(); From 8220f26415867b80b48c5436f5ce813fe38ae66c Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 1 Nov 2024 15:30:47 +1000 Subject: [PATCH 30/40] Close #104 p1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Связанные рабочие элементы: #10 --- .../FlyoutContainer/FlyoutBase.cs | 5 +- AdamStudio.Core/Mvvm/RegionViewModelBase.cs | 7 +-- AdamStudio.Services/FileManagmentService.cs | 10 +++- AdamStudio.Services/FolderManagmentService.cs | 6 ++- AdamStudio/App.xaml.cs | 1 - AdamStudio/ViewModels/MainWindowViewModel.cs | 40 +++++++-------- .../ComputerVisionControlViewModel.cs | 8 +-- .../ViewModels/ScratchControlViewModel.cs | 50 +++++++------------ .../ViewModels/SettingsControlViewModel.cs | 14 +++--- .../Views/ComputerVisionControlView.xaml.cs | 2 +- .../ViewModels/NotificationViewModel.cs | 13 +++-- .../ViewModels/PortSettingsViewModel.cs | 6 ++- .../UserFoldersSettingsViewModel.cs | 11 ++-- .../ViewModels/MenuRegionViewModel.cs | 10 ++-- .../ViewModels/StatusBarViewModel.cs | 25 +++++----- .../ViewModels/ToolBarViewModel.cs | 46 ++++++++--------- 16 files changed, 128 insertions(+), 126 deletions(-) diff --git a/AdamStudio.Controls/CustomControls.Mvvm/FlyoutContainer/FlyoutBase.cs b/AdamStudio.Controls/CustomControls.Mvvm/FlyoutContainer/FlyoutBase.cs index b0ee84d..90e1d30 100644 --- a/AdamStudio.Controls/CustomControls.Mvvm/FlyoutContainer/FlyoutBase.cs +++ b/AdamStudio.Controls/CustomControls.Mvvm/FlyoutContainer/FlyoutBase.cs @@ -1,7 +1,4 @@ -using MahApps.Metro.Controls; -using Prism.Mvvm; -using System.Drawing; -using System.Windows; +using Prism.Mvvm; using System.Windows.Input; namespace AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer diff --git a/AdamStudio.Core/Mvvm/RegionViewModelBase.cs b/AdamStudio.Core/Mvvm/RegionViewModelBase.cs index 691513d..7104f3a 100644 --- a/AdamStudio.Core/Mvvm/RegionViewModelBase.cs +++ b/AdamStudio.Core/Mvvm/RegionViewModelBase.cs @@ -1,4 +1,5 @@ -using Prism.Regions; +using Microsoft.Extensions.DependencyInjection; +using Prism.Regions; using System; @@ -15,9 +16,9 @@ public class RegionViewModelBase : ViewModelBase, INavigationAware, IConfirmNavi #region ~ - public RegionViewModelBase(IRegionManager regionManager) + public RegionViewModelBase(IServiceProvider serviceProvider) { - RegionManager = regionManager; + RegionManager = serviceProvider.GetService(); } #endregion diff --git a/AdamStudio.Services/FileManagmentService.cs b/AdamStudio.Services/FileManagmentService.cs index f849929..761167c 100644 --- a/AdamStudio.Services/FileManagmentService.cs +++ b/AdamStudio.Services/FileManagmentService.cs @@ -1,6 +1,10 @@ using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Prism.DryIoc; using System; using System.IO; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Xml; @@ -17,7 +21,11 @@ public class FileManagmentService : IFileManagmentService #region ~ - public FileManagmentService() { } + public FileManagmentService() + { + + + } #endregion diff --git a/AdamStudio.Services/FolderManagmentService.cs b/AdamStudio.Services/FolderManagmentService.cs index fab3cf8..c8d589f 100644 --- a/AdamStudio.Services/FolderManagmentService.cs +++ b/AdamStudio.Services/FolderManagmentService.cs @@ -1,4 +1,6 @@ using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using System; using System.Globalization; using System.IO; @@ -16,8 +18,10 @@ public class FolderManagmentService : IFolderManagmentService #region ~ - public FolderManagmentService() + public FolderManagmentService(IServiceProvider serviceProvider) { + ILogger logger = serviceProvider.GetService>(); + logger.LogTrace("Init FolderManagmentService"); } #endregion diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index 6cabcd2..d936362 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -236,7 +236,6 @@ private void RegisterService(IContainerRegistry containerRegistry) .WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}") - .CreateLogger(); services.AddLogging(s => s.AddSerilog(mainLogger, dispose: true)); diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index b90fe3c..7d52028 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -3,13 +3,12 @@ using AdamStudio.Core; using AdamStudio.Core.Extensions; using AdamStudio.Core.Model; -using AdamStudio.Core.Mvvm; using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; -using AdamStudio.Views; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Prism.Commands; -using Prism.Ioc; +using Prism.Mvvm; using Prism.Regions; using System; using System.Globalization; @@ -19,7 +18,7 @@ namespace AdamStudio.ViewModels { - public class MainWindowViewModel : ViewModelBase + public class MainWindowViewModel : BindableBase { #region DelegateCommands @@ -34,6 +33,7 @@ public class MainWindowViewModel : ViewModelBase public IRegionChangeAwareService RegionChangeAwareService { get; } public IControlHelper ControlHelper { get; } + private readonly ILogger mLoggerService; private readonly IRegionManager mRegionManager; private readonly IStatusBarNotificationDeliveryService mStatusBarNotification; private readonly ICommunicationProviderService mCommunicationProviderService; @@ -42,28 +42,24 @@ public class MainWindowViewModel : ViewModelBase private readonly IAvalonEditService mAvalonEditService; private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; - private readonly ILogger mLoggerService; #endregion #region ~ - public MainWindowViewModel(ILogger loggerService, IRegionManager regionManager, IRegionChangeAwareService regionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification, - ICommunicationProviderService communicationProviderService, IFolderManagmentService folderManagment, IWebApiService webApiService, - IAvalonEditService avalonEditService, IThemeManagerService themeManager, ICultureProvider cultureProvider, - IControlHelper controlHelper) + public MainWindowViewModel(IServiceProvider serviceProvider) { - mRegionManager = regionManager; - mWebApiService = webApiService; - RegionChangeAwareService = regionChangeAwareService; - mStatusBarNotification = statusBarNotification; - mCommunicationProviderService = communicationProviderService; - mFolderManagment = folderManagment; - mAvalonEditService = avalonEditService; - mThemeManager = themeManager; - mCultureProvider = cultureProvider; - ControlHelper = controlHelper; - mLoggerService = loggerService; + mRegionManager = serviceProvider.GetService(); + mWebApiService = serviceProvider.GetService(); + RegionChangeAwareService = serviceProvider.GetService(); + mStatusBarNotification = serviceProvider.GetService(); + mCommunicationProviderService = serviceProvider.GetService(); + mFolderManagment = serviceProvider.GetService(); + mAvalonEditService = serviceProvider.GetService(); + mThemeManager = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); + ControlHelper = serviceProvider.GetService(); + mLoggerService = serviceProvider.GetService>(); MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute); SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute); @@ -254,8 +250,8 @@ private void Subscribe() mCommunicationProviderService.RaiseTcpServiceCientConnectedEvent += RaiseTcpServiceCientConnectedEvent; mCommunicationProviderService.RaiseUdpServiceServerReceivedEvent += RaiseUdpServiceServerReceivedEvent; - System.Windows.Application.Current.MainWindow.Loaded += MainWindowLoaded; - System.Windows.Application.Current.MainWindow.Closed += MainWindowClosed; + Application.Current.MainWindow.Loaded += MainWindowLoaded; + Application.Current.MainWindow.Closed += MainWindowClosed; } /// diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ComputerVisionControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ComputerVisionControlViewModel.cs index a3f4577..7135a87 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ComputerVisionControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ComputerVisionControlViewModel.cs @@ -1,6 +1,7 @@ using AdamStudio.Core.Model; using AdamStudio.Core.Mvvm; using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; using Prism.Commands; using Prism.Regions; using System; @@ -26,11 +27,10 @@ public class ComputerVisionControlViewModel : RegionViewModelBase #region ~ - public ComputerVisionControlViewModel(IRegionManager regionManager, ICommunicationProviderService communicationProvider, - IWebApiService webApiService, IVideoViewProvider videoViewProvider) : base(regionManager) + public ComputerVisionControlViewModel(IServiceProvider serviceProvider) : base(serviceProvider) { - mCommunicationProvider = communicationProvider; - mWebApiService = webApiService; + mCommunicationProvider = serviceProvider.GetService(); + mWebApiService = serviceProvider.GetService(); } #endregion diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index 920bcc9..899d640 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -24,6 +24,7 @@ using System.Windows; using System.Windows.Threading; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; namespace AdamStudio.Modules.ContentRegion.ViewModels { @@ -45,6 +46,7 @@ public class ScratchControlViewModel : RegionViewModelBase #region Services + private readonly ILogger mLogger; private readonly ICommunicationProviderService mCommunicationProvider; private readonly IPythonRemoteRunnerService mPythonRemoteRunner; private readonly IStatusBarNotificationDeliveryService mStatusBarNotificationDelivery; @@ -56,7 +58,6 @@ public class ScratchControlViewModel : RegionViewModelBase private readonly IControlHelper mControlHelper; private readonly IVideoViewProvider mVideoViewProvider; private readonly IRegionChangeAwareService mRegionChangeAwareService; - private readonly ILogger mLogger; #endregion @@ -92,25 +93,20 @@ public class ScratchControlViewModel : RegionViewModelBase #region ~ - public ScratchControlViewModel(ILogger logger, IRegionManager regionManager, ICommunicationProviderService communicationProvider, IPythonRemoteRunnerService pythonRemoteRunner, - IStatusBarNotificationDeliveryService statusBarNotificationDelivery, IWebViewProvider webViewProvider, - IFileManagmentService fileManagment, IWebApiService webApiService, IAvalonEditService avalonEditService, - ICultureProvider cultureProvider, ISystemDialogService systemDialogService, IControlHelper controlHelper, - IVideoViewProvider videoViewProvider, IRegionChangeAwareService regionChangeAwareService) : base(regionManager) - { - - mLogger = logger; - mCommunicationProvider = communicationProvider; - mPythonRemoteRunner = pythonRemoteRunner; - mStatusBarNotificationDelivery = statusBarNotificationDelivery; - mWebViewProvider = webViewProvider; - mFileManagment = fileManagment; - mWebApiService = webApiService; - mCultureProvider = cultureProvider; - mSystemDialog = systemDialogService; - mControlHelper = controlHelper; - mVideoViewProvider = videoViewProvider; - mRegionChangeAwareService = regionChangeAwareService; + public ScratchControlViewModel(IServiceProvider serviceProvider) : base(serviceProvider) + { + mLogger = serviceProvider.GetService>(); + mCommunicationProvider = serviceProvider.GetService(); + mPythonRemoteRunner = serviceProvider.GetService(); + mStatusBarNotificationDelivery = serviceProvider.GetService(); + mWebViewProvider = serviceProvider.GetService(); + mFileManagment = serviceProvider.GetService(); + mWebApiService = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); + mSystemDialog = serviceProvider.GetService(); + mControlHelper = serviceProvider.GetService(); + mVideoViewProvider = serviceProvider.GetService(); + mRegionChangeAwareService = serviceProvider.GetService(); ShowSaveFileDialogDelegateCommand = new DelegateCommand(ShowSaveFileDialog, ShowSaveFileDialogCanExecute); ShowOpenFileDialogDelegateCommand = new DelegateCommand(ShowOpenFileDialog, ShowOpenFileDialogCanExecute); @@ -125,7 +121,7 @@ public ScratchControlViewModel(ILogger logger, IRegionM DirectionButtonDownDelegateCommand = new DelegateCommand(DirectionButtonDown, DirectionButtonDownCanExecute); DirectionButtonUpDelegateCommand = new DelegateCommand(DirectionButtonUp, DirectionButtonUpCanExecute); - HighlightingDefinition = avalonEditService.GetDefinition(HighlightingName.AdamPython); + HighlightingDefinition = serviceProvider.GetService().GetDefinition(HighlightingName.AdamPython); Subscribe(); } @@ -440,10 +436,7 @@ private async void StopPythonCodeExecute() { await mWebApiService.StopPythonExecute(); } - catch - { - - } + catch {} } private bool StopPythonCodeExecuteCanExecute() @@ -461,10 +454,7 @@ private async void ToZeroPosition() await mWebApiService.StopPythonExecute(); await mWebApiService.MoveToZeroPosition(); } - catch - { - - } + catch {} } private bool ToZeroPositionCanExecute() @@ -574,8 +564,6 @@ private void OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute) })); } - - private async void OpenSupportedFile(OpenFileDialogResult result) { string path = result.OpenFilePath; diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs index d8d3016..c057a71 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/SettingsControlViewModel.cs @@ -5,6 +5,7 @@ using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; using ControlzEx.Theming; +using Microsoft.Extensions.DependencyInjection; using Prism.Commands; using Prism.Regions; using System; @@ -45,14 +46,13 @@ public class SettingsControlViewModel : RegionViewModelBase #region ~ - public SettingsControlViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, - IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider, IRegionChangeAwareService subRegionChangeAwareService) : base(regionManager) + public SettingsControlViewModel(IServiceProvider serviceProvider) : base(serviceProvider) { - mFlyoutManager = flyoutManager; - mThemeManager = themeManager; - mCultureProvider = cultureProvider; - mWebViewProvider = webViewProvider; - mRegionChangeAwareService = subRegionChangeAwareService; + mFlyoutManager = serviceProvider.GetService(); + mThemeManager = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); + mWebViewProvider = serviceProvider.GetService(); + mRegionChangeAwareService = serviceProvider.GetService(); ChangeSpacingToggleSwitchDelegateCommand = new DelegateCommand(ChangeSpacingToggleSwitch, ChangeSpacingToggleSwitchCanExecute); OpenPortSettingsDelegateCommand = new DelegateCommand(OpenPortSettings, OpenPortSettingsCanExecute); diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ComputerVisionControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ComputerVisionControlView.xaml.cs index a082235..b31457d 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ComputerVisionControlView.xaml.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ComputerVisionControlView.xaml.cs @@ -63,7 +63,7 @@ private async void UserControlUnloaded(object sender, RoutedEventArgs e) } //? - //public string DownRightDirection { get; private set; } = "{\"move\":{\"x\": 0, \"y\": 1, \"z\": 0}}"; + public string DownRightDirection { get; private set; } = "{\"move\":{\"x\": 0, \"y\": 1, \"z\": 0}}"; //private void Button_KeyDown(object sender, KeyEventArgs e) //{ diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs index 8dbf77e..d914b90 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs @@ -3,7 +3,10 @@ using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; using MahApps.Metro.IconPacks; +using Microsoft.Extensions.DependencyInjection; using Prism.Commands; +using Prism.Regions; +using System; using System.Drawing; using System.Windows; @@ -41,12 +44,12 @@ public class NotificationViewModel : FlyoutBase #region ~ - public NotificationViewModel(ICommunicationProviderService communicationProvider, IStatusBarNotificationDeliveryService statusBarNotificationDelivery, IFlyoutStateChecker flyoutState, ICultureProvider cultureProvider) + public NotificationViewModel(IServiceProvider serviceProvider) { - mCommunicationProvider = communicationProvider; - mStatusBarNotificationDeliveryService = statusBarNotificationDelivery; - mFlyoutState = flyoutState; - mCultureProvider = cultureProvider; + mCommunicationProvider = serviceProvider.GetService(); ; + mStatusBarNotificationDeliveryService = serviceProvider.GetService(); + mFlyoutState = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); ConnectButtonDelegateCommand = new(ConnectButton, ConnectButtonCanExecute); ReconnectNotificationButtonDelegateCommand = new(ReconnectNotificationButton, ReconnectNotificationButtonCanExecute); diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs index aeb591d..f96a2cf 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs @@ -1,5 +1,7 @@ using AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer; using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; using System.Windows; namespace AdamStudio.Modules.FlayoutsRegion.ViewModels @@ -13,10 +15,10 @@ public class PortSettingsViewModel : FlyoutBase #endregion - public PortSettingsViewModel(ICultureProvider cultureProvider) + public PortSettingsViewModel(IServiceProvider serviceProvider) { BorderThickness = 1; - mCultureProvider = cultureProvider; + mCultureProvider = serviceProvider.GetService(); } protected override void OnChanging(bool isOpening) diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs index 67d2350..a9760a2 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs @@ -3,8 +3,11 @@ using AdamStudio.Services.Interfaces; using AdamStudio.Services.SystemDialogServiceDependency; using AdamStudio.Services.SystemDialogServiceDependency; +using Microsoft.Extensions.DependencyInjection; using Prism.Commands; +using Prism.Regions; using Prism.Services.Dialogs; +using System; using System.Windows; namespace AdamStudio.Modules.FlayoutsRegion.ViewModels @@ -39,13 +42,13 @@ public class UserFoldersSettingsViewModel : FlyoutBase #endregion - public UserFoldersSettingsViewModel(IFolderManagmentService folderManagment, ICultureProvider cultureProvider, ISystemDialogService systemDialogService) + public UserFoldersSettingsViewModel(IServiceProvider serviceProvider) { ShowOpenFolderDialogDelegateCommand = new DelegateCommand(ShowOpenFolderDialog, ShowOpenFolderDialogCanExecute); - mFolderManagment = folderManagment; - mCultureProvider = cultureProvider; - mSystemDialogService = systemDialogService; + mFolderManagment = serviceProvider.GetService(); ; + mCultureProvider = serviceProvider.GetService(); ; + mSystemDialogService = serviceProvider.GetService(); ; BorderThickness = 1; } diff --git a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs index 2d599b2..08a2fbc 100644 --- a/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs +++ b/Modules/AdamStudio.Modules.MenuRegion/ViewModels/MenuRegionViewModel.cs @@ -5,12 +5,12 @@ using System.Windows; using System; using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; namespace AdamStudio.Modules.MenuRegion.ViewModels { public class MenuRegionViewModel : RegionViewModelBase { - #region DelegateCommands public DelegateCommand CloseAppCommand { get; } @@ -24,14 +24,18 @@ public class MenuRegionViewModel : RegionViewModelBase #endregion - public MenuRegionViewModel(IRegionManager regionManager, IRegionChangeAwareService regionChangeAware) : base(regionManager) + #region ~ + + public MenuRegionViewModel(IServiceProvider serviceProvider) : base(serviceProvider) { - mRegionChangeAware = regionChangeAware; + mRegionChangeAware = serviceProvider.GetService(); CloseAppCommand = new DelegateCommand(CloseApp); ShowRegionCommand = new DelegateCommand(ShowRegion); } + #endregion + #region Navigation public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) diff --git a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs index 0cf7ce1..b1da259 100644 --- a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs +++ b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs @@ -4,6 +4,7 @@ using AdamStudio.Core.Mvvm; using AdamStudio.Services.Interfaces; using MahApps.Metro.IconPacks; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Prism.Commands; using Prism.Regions; @@ -46,21 +47,19 @@ public class StatusBarViewModel : RegionViewModelBase #region ~ - public StatusBarViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, IFlyoutStateChecker flyoutState, ICommunicationProviderService communicationProviderService, - IStatusBarNotificationDeliveryService statusBarNotification, ICultureProvider cultureProvider, IControlHelper controlHelper, - ILogWriteEventAwareService logWriteEventAwareService, ILogger logger) : base(regionManager) { - mFlyoutManager = flyoutManager; - mCommunicationProviderService = communicationProviderService; - mStatusBarNotificationDelivery = statusBarNotification; - mFlyoutState = flyoutState; - mCultureProvider = cultureProvider; - mControlHelper = controlHelper; - mLogWriteEventAwareService = logWriteEventAwareService; - mLogger = logger; - + public StatusBarViewModel(IServiceProvider serviceProvider) : base(serviceProvider) + { + mLogger = serviceProvider.GetService>(); + mFlyoutManager = serviceProvider.GetService(); + mCommunicationProviderService = serviceProvider.GetService(); + mStatusBarNotificationDelivery = serviceProvider.GetService(); + mFlyoutState = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); + mControlHelper = serviceProvider.GetService(); + mLogWriteEventAwareService = serviceProvider.GetService(); + OpenNotificationPanelDelegateCommand = new DelegateCommand(OpenNotificationPanel, OpenNotificationPanelCanExecute); - //LoadResource(); LoadDefaultFieldValue(); } diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs index ba7abdd..8a36f28 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs @@ -1,7 +1,7 @@ using AdamController.WebApi.Client.v1.ResponseModel; using AdamStudio.Core.Mvvm; -using AdamStudio.Services; using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Prism.Commands; using Prism.Regions; @@ -40,21 +40,26 @@ public class ToolBarViewModel : RegionViewModelBase #endregion - public ToolBarViewModel(IRegionManager regionManager, ILogger logger, ILogWriteEventAwareService logWriteEventAware, IPythonRemoteRunnerService pythonRemoteRunner, ICultureProvider cultureProvider, - ITcpClientService tcpClientService, IWebApiService webApiService) : base(regionManager) + #region ~ + + public ToolBarViewModel(IServiceProvider serviceProvider) : base(serviceProvider) { - mLogger = logger; - mLogWriteEventAware = logWriteEventAware; - mPythonRemoteRunner = pythonRemoteRunner; - mCultureProvider = cultureProvider; - mTcpClientService = tcpClientService; - mWebApiService = webApiService; + mLogger = serviceProvider.GetService>(); + mLogWriteEventAware = serviceProvider.GetService(); + mPythonRemoteRunner = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); + mTcpClientService = serviceProvider.GetService(); + mWebApiService = serviceProvider.GetService(); CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); mLogger.LogTrace("Load ~"); } + #endregion + + #region Commands method + private void CleanExecuteEditor() { ResultText = string.Empty; @@ -63,15 +68,11 @@ private void CleanExecuteEditor() private bool CleanExecuteEditorCanExecute() { - //bool isPythonCodeNotExecute = !IsPythonCodeExecute; bool isResultNotEmpty = ResultText?.Length > 0; - return /*isPythonCodeNotExecute &&*/ isResultNotEmpty; + return isResultNotEmpty; } - private void RaiseDelegateCommandsCanExecuteChanged() - { - CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); - } + #endregion #region Navigation @@ -143,7 +144,7 @@ public bool IsPythonCodeExecute #endregion - #region PrivateMethods + #region Private Methods private void UpdateResultText(string text, bool isFinishMessage = false) { @@ -227,14 +228,6 @@ public string PythonWorkDir private void UpdatePythonInfo(string pythonVersion = null, string pythonBinPath = null, string pythonWorkDir = null) { - /*if (string.IsNullOrEmpty(pythonVersion)) - { - //PythonVersion = string.Empty; - //PythonBinPath = string.Empty; - //PythonWorkDir = string.Empty; - return; - }*/ - PythonVersion = pythonVersion; PythonBinPath = pythonBinPath; PythonWorkDir = pythonWorkDir; @@ -249,6 +242,11 @@ private void LoadResources() mWarningStackOwerflow3 = mCultureProvider.FindResource("DebuggerMessages.ResultMessages.WarningStackOwerflow3"); } + private void RaiseDelegateCommandsCanExecuteChanged() + { + CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged(); + } + #endregion #region Events From 80c4aa85c46f1dc7ebb7247bafb329108fe7172d Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 1 Nov 2024 16:07:41 +1000 Subject: [PATCH 31/40] Close #104 p.2/3 --- .../CustomControls.Services/FlyoutManager.cs | 15 ++++++-- AdamStudio.Services/AvalonEditService.cs | 8 ++-- .../CommunicationProviderService.cs | 20 ++++------ AdamStudio.Services/FileManagmentService.cs | 10 +---- .../PythonRemoteRunnerService.cs | 10 ++--- .../SystemDialogParametrsKeysName.cs | 3 -- AdamStudio.Services/UdpClientService.cs | 2 - AdamStudio/App.xaml.cs | 38 ++----------------- 8 files changed, 33 insertions(+), 73 deletions(-) diff --git a/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs b/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs index 7cb3b57..ec14057 100644 --- a/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs +++ b/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs @@ -1,5 +1,6 @@ using AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer; using DryIoc; +using Microsoft.Extensions.DependencyInjection; using Prism.Regions; using System.Windows; @@ -28,10 +29,18 @@ public class FlyoutManager : IFlyoutManager /// /// DryIoc container, generally passed by dependency injection. /// Region manager, generally passed by dependency injection. - public FlyoutManager(IContainer container, IRegionManager regionManager) + //public FlyoutManager(IContainer container, IRegionManager regionManager) + //{ + // mDryIocContainer = container; + // RegionManager = regionManager; + + // mFlyouts = new Dictionary(); + //} + + public FlyoutManager(IServiceProvider serviceProvider) { - mDryIocContainer = container; - RegionManager = regionManager; + mDryIocContainer = serviceProvider.GetService(); + RegionManager = serviceProvider.GetService(); mFlyouts = new Dictionary(); } diff --git a/AdamStudio.Services/AvalonEditService.cs b/AdamStudio.Services/AvalonEditService.cs index d0cfe4e..c7e270b 100644 --- a/AdamStudio.Services/AvalonEditService.cs +++ b/AdamStudio.Services/AvalonEditService.cs @@ -1,7 +1,7 @@ -using AdamBlocklyLibrary.Properties; -using AdamStudio.Services.Interfaces; +using AdamStudio.Services.Interfaces; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting.Xshd; +using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.ObjectModel; @@ -18,9 +18,9 @@ public class AvalonEditService : IAvalonEditService #region ~ - public AvalonEditService(IFileManagmentService fileManagmentService) + public AvalonEditService(IServiceProvider serviceProvider) { - mFileManagmentService = fileManagmentService; + mFileManagmentService = serviceProvider.GetService(); mHighlightingManager = HighlightingManager.Instance; } diff --git a/AdamStudio.Services/CommunicationProviderService.cs b/AdamStudio.Services/CommunicationProviderService.cs index 2d3cc6b..31003f7 100644 --- a/AdamStudio.Services/CommunicationProviderService.cs +++ b/AdamStudio.Services/CommunicationProviderService.cs @@ -1,5 +1,7 @@ using AdamStudio.Services.Interfaces; using AdamStudio.Services.UdpClientServiceDependency; +using Microsoft.Extensions.DependencyInjection; +using System; using System.Net; using System.Text; using System.Threading.Tasks; @@ -35,13 +37,12 @@ public class CommunicationProviderService : ICommunicationProviderService #region ~ - public CommunicationProviderService(ITcpClientService adamTcpClientService, IUdpClientService adamUdpClientService, - IUdpServerService adamUdpServerService, IWebSocketClientService adamWebSocketClientService) + public CommunicationProviderService(IServiceProvider serviceProvider) { - mTcpClientService = adamTcpClientService; - mUdpClientService = adamUdpClientService; - mUdpServerService = adamUdpServerService; - mWebSocketClientService = adamWebSocketClientService; + mTcpClientService = serviceProvider.GetService(); + mUdpClientService = serviceProvider.GetService(); + mUdpServerService = serviceProvider.GetService(); + mWebSocketClientService = serviceProvider.GetService(); Subscribe(); } @@ -102,10 +103,6 @@ public void Dispose() #endregion - #region Private methods - - #endregion - #region Subscriptions private void Subscribe() @@ -115,11 +112,9 @@ private void Subscribe() mTcpClientService.RaiseTcpClientDisconnectedEvent += RaiseTcpClientDisconnected; mUdpClientService.RaiseUdpClientMessageEnqueueEvent += RaiseUdpClientMessageEnqueueEvent; - mUdpServerService.RaiseUdpServerReceivedEvent += RaiseServiceUdpServerReceived; } - private void Unsubscribe() { mTcpClientService.RaiseTcpClientReconnectedEvent -= RaiseServiceTcpClientReconnected; @@ -127,7 +122,6 @@ private void Unsubscribe() mTcpClientService.RaiseTcpClientDisconnectedEvent -= RaiseTcpClientDisconnected; mUdpClientService.RaiseUdpClientMessageEnqueueEvent -= RaiseUdpClientMessageEnqueueEvent; - mUdpServerService.RaiseUdpServerReceivedEvent -= RaiseServiceUdpServerReceived; } diff --git a/AdamStudio.Services/FileManagmentService.cs b/AdamStudio.Services/FileManagmentService.cs index 761167c..96d01cc 100644 --- a/AdamStudio.Services/FileManagmentService.cs +++ b/AdamStudio.Services/FileManagmentService.cs @@ -1,10 +1,6 @@ using AdamStudio.Services.Interfaces; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Prism.DryIoc; using System; using System.IO; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Xml; @@ -21,11 +17,7 @@ public class FileManagmentService : IFileManagmentService #region ~ - public FileManagmentService() - { - - - } + public FileManagmentService() {} #endregion diff --git a/AdamStudio.Services/PythonRemoteRunnerService.cs b/AdamStudio.Services/PythonRemoteRunnerService.cs index c80932b..12cd720 100644 --- a/AdamStudio.Services/PythonRemoteRunnerService.cs +++ b/AdamStudio.Services/PythonRemoteRunnerService.cs @@ -4,7 +4,8 @@ using AdamController.WebApi.Client.Common; using System.Linq; using System.Text.RegularExpressions; - +using System; +using Microsoft.Extensions.DependencyInjection; namespace AdamStudio.Services { @@ -44,10 +45,10 @@ public partial class PythonRemoteRunnerService : IPythonRemoteRunnerService #region ~ - public PythonRemoteRunnerService(IUdpClientService udpClientService) + public PythonRemoteRunnerService(IServiceProvider serviceProvider) { - mUdpClientService = udpClientService; - + mUdpClientService = serviceProvider.GetService(); ; + Subscribe(); mRegex = MyRegex(); @@ -56,7 +57,6 @@ public PythonRemoteRunnerService(IUdpClientService udpClientService) #endregion - #region Public method public void Dispose() diff --git a/AdamStudio.Services/SystemDialogServiceDependency/SystemDialogParametrsKeysName.cs b/AdamStudio.Services/SystemDialogServiceDependency/SystemDialogParametrsKeysName.cs index 9b31f88..db72034 100644 --- a/AdamStudio.Services/SystemDialogServiceDependency/SystemDialogParametrsKeysName.cs +++ b/AdamStudio.Services/SystemDialogServiceDependency/SystemDialogParametrsKeysName.cs @@ -4,9 +4,6 @@ public class DialogParametrsKeysName { public const string TitleParametr = "Title"; public const string InitialDirectoryParametr = "InitialDirectory"; - public const string SavedFileTypeParametr = "SavedFileType"; - - } } diff --git a/AdamStudio.Services/UdpClientService.cs b/AdamStudio.Services/UdpClientService.cs index b3e4297..8b2778c 100644 --- a/AdamStudio.Services/UdpClientService.cs +++ b/AdamStudio.Services/UdpClientService.cs @@ -1,9 +1,7 @@ using AdamStudio.Services.Interfaces; using AdamStudio.Services.UdpClientServiceDependency; -using System.Collections.Generic; using System.Net; using System.Threading.Tasks; -using System.Windows.Forms; namespace AdamStudio.Services { diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index d936362..c28922c 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -74,24 +74,12 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(containerRegistry => - { - IFileManagmentService fileManagment = containerRegistry.Resolve(); - AvalonEditService avalonService = new(fileManagment); - return avalonService; - }); + containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - - containerRegistry.RegisterSingleton(containerRegistry => - { - DryIoc.IContainer container = containerRegistry.GetContainer(); - IRegionManager regionManager = containerRegistry.Resolve(); - - return new FlyoutManager(container, regionManager); - }); + containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(() => { @@ -189,26 +177,8 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) }); - containerRegistry.RegisterSingleton(containerRegistry => - { - ITcpClientService tcpClientService = containerRegistry.Resolve(); - IUdpClientService udpClientService = containerRegistry.Resolve(); - IUdpServerService udpServerService = containerRegistry.Resolve(); - IWebSocketClientService socketClientService = containerRegistry.Resolve(); - - CommunicationProviderService communicationProvider = new(tcpClientService, udpClientService, udpServerService, socketClientService); - - return communicationProvider; - }); - - containerRegistry.RegisterSingleton(containerRegistry => - { - IUdpClientService udpClient = containerRegistry.Resolve(); - - PythonRemoteRunnerService remoteRunnerService = new(udpClient); - return remoteRunnerService; - }); - + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(containerRegistry => { From 6625e929298c9106dacca3a24c24b2d9e91ecf88 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 1 Nov 2024 16:32:23 +1000 Subject: [PATCH 32/40] Update package --- AdamStudio.Services/AdamStudio.Services.csproj | 8 ++++---- AdamStudio/App.xaml.cs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/AdamStudio.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj index e34e1dc..190f095 100644 --- a/AdamStudio.Services/AdamStudio.Services.csproj +++ b/AdamStudio.Services/AdamStudio.Services.csproj @@ -8,22 +8,22 @@ - + - + - + - + diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index c28922c..52775c6 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -43,6 +43,7 @@ using AdamStudio.Controls.CustomControls.Services; using AdamStudio.Services.TcpClientDependency; using AdamStudio.Services; +using Microsoft.Extensions.Options; #endregion @@ -182,6 +183,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(containerRegistry => { + bool isVideoShowLastValue = Settings.Default.ShowVideo; return new ControlHelper(isVideoShowLastValue); }); From 527fc8acc920e0fa411fbdd5b076401e16994eef Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Sat, 2 Nov 2024 10:31:23 +1000 Subject: [PATCH 33/40] Fixed: many minor user interface bugs --- AdamStudio/Views/MainWindow.xaml | 4 +- .../Views/ScratchControlView.xaml | 2 +- .../Views/NotificationView.xaml | 5 +- .../Views/StatusBarView.xaml | 32 ++- .../Template/PopupWindow.xaml | 15 +- .../Views/ToolBarView.xaml | 212 ++---------------- 6 files changed, 43 insertions(+), 227 deletions(-) diff --git a/AdamStudio/Views/MainWindow.xaml b/AdamStudio/Views/MainWindow.xaml index cefa1d6..883fc70 100644 --- a/AdamStudio/Views/MainWindow.xaml +++ b/AdamStudio/Views/MainWindow.xaml @@ -111,7 +111,7 @@ - @@ -130,7 +130,7 @@ - + diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/Views/NotificationView.xaml b/Modules/AdamStudio.Modules.FlayoutsRegion/Views/NotificationView.xaml index 2660f8b..4677a4b 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/Views/NotificationView.xaml +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/Views/NotificationView.xaml @@ -9,7 +9,7 @@ - + @@ -34,7 +34,8 @@ + + BorderThickness="1"> diff --git a/Modules/AdamStudio.Modules.StatusBar/Views/StatusBarView.xaml b/Modules/AdamStudio.Modules.StatusBar/Views/StatusBarView.xaml index 395cd6a..c3eef96 100644 --- a/Modules/AdamStudio.Modules.StatusBar/Views/StatusBarView.xaml +++ b/Modules/AdamStudio.Modules.StatusBar/Views/StatusBarView.xaml @@ -9,8 +9,12 @@ - + + + @@ -34,11 +38,6 @@ - - diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml index ddaf27c..cc91303 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Template/PopupWindow.xaml @@ -23,16 +23,15 @@ Background="{DynamicResource MahApps.Brushes.Window.Background}"> + Height="2" + BorderBrush="White" + Background="{DynamicResource MahApps.Brushes.Text}" + Cursor="SizeNS" + DragDelta="ThumbDragDelta"/> + BorderThickness="0 0 0 1" + BorderBrush="{DynamicResource MahApps.Brushes.Text}"> diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index d621ca5..b361742 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -25,7 +25,7 @@ - + - - - + + + @@ -122,7 +118,7 @@ - + - + - + Width="120" + HorizontalAlignment="Center" + Style="{StaticResource MahApps.Styles.ToggleButton.ExpanderHeader.Down.DataGrid.GroupItem}"/> + Width="120" + HorizontalAlignment="Center" + Style="{StaticResource MahApps.Styles.ToggleButton.ExpanderHeader.Down.DataGrid.GroupItem}"/> - - From 1db70498b19e07b21295d4f58f7cf53a77eefab7 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Sat, 2 Nov 2024 10:32:37 +1000 Subject: [PATCH 34/40] Up version --- AdamStudio/AdamStudio.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index 65f9c1d..3ae93f4 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -3,8 +3,8 @@ Dynamic False MIT-Modern-Variant - 2.0.0.9 - 2.0.0.9 + 2.0.1.0 + 2.0.1.0 net8.0-windows7.0 From aee05983ea25651bf6e1098173e80aebf29079ee Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Sat, 2 Nov 2024 13:51:52 +1000 Subject: [PATCH 35/40] Close #101 --- .../CustomControls.Services/FlyoutManager.cs | 6 +-- .../FlyoutStateChecker.cs | 6 +-- .../IFlyoutStateChecker.cs | 6 +-- AdamStudio/ViewModels/MainWindowViewModel.cs | 9 +++- .../Views/ScratchControlView.xaml | 7 ++-- .../ViewModels/NotificationViewModel.cs | 6 +-- .../ViewModels/PortSettingsViewModel.cs | 10 +++++ .../UserFoldersSettingsViewModel.cs | 20 +++++++-- .../ViewModels/WebApiSettingsViewModel.cs | 25 ++++++++++- .../ViewModels/StatusBarViewModel.cs | 6 +-- .../ViewModels/ToolBarViewModel.cs | 42 +++++++++++++++---- .../Views/ToolBarView.xaml | 2 + 12 files changed, 110 insertions(+), 35 deletions(-) diff --git a/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs b/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs index ec14057..5363205 100644 --- a/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs +++ b/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs @@ -157,7 +157,7 @@ public bool OpenFlyout(string key, bool forceOpen) /// The result of the identified flyout's CanOpen method. public bool OpenFlyout(string key, FlyoutParameters flyoutParameters, bool forceOpen) { - var flyoutToActivate = mFlyouts[key]; + IFlyout flyoutToActivate = mFlyouts[key]; bool canOpen = flyoutToActivate.CanOpen(flyoutParameters); if (!forceOpen && !canOpen) @@ -219,13 +219,13 @@ public bool CloseFlyout(string key, bool forceClose) /// The results of the indentified flyouts CanClose method. public bool CloseFlyout(string key, FlyoutParameters flyoutParameters, bool forceClose) { - var flyoutToClose = mFlyouts[key]; + IFlyout flyoutToClose = mFlyouts[key]; bool canClose = flyoutToClose.CanClose(flyoutParameters); if (!forceClose && !canClose) return false; - flyoutToClose.Open(flyoutParameters); + flyoutToClose.Close(flyoutParameters); return canClose; } diff --git a/AdamStudio.Controls/CustomControls.Services/FlyoutStateChecker.cs b/AdamStudio.Controls/CustomControls.Services/FlyoutStateChecker.cs index 548af03..21c5cfa 100644 --- a/AdamStudio.Controls/CustomControls.Services/FlyoutStateChecker.cs +++ b/AdamStudio.Controls/CustomControls.Services/FlyoutStateChecker.cs @@ -3,10 +3,10 @@ namespace AdamStudio.Controls.CustomControls.Services { public class FlyoutStateChecker : IFlyoutStateChecker { - public event IsNotificationFlyoutOpenedStateChangeEventHandler IsNotificationFlyoutOpenedStateChangeEvent; + public event IsFlyoutsOpenedStateChangeEventHandler IsFlyoutsOpenedStateChangeEvent; private bool isNotificationFlyoutOpened; - public bool IsNotificationFlyoutOpened + public bool IsFlyoutsOpened { get { return isNotificationFlyoutOpened; } set @@ -21,7 +21,7 @@ public bool IsNotificationFlyoutOpened protected void OnNotificationFlyoutOpenedStateChangeEvent() { - IsNotificationFlyoutOpenedStateChangeEventHandler raiseEvent = IsNotificationFlyoutOpenedStateChangeEvent; + IsFlyoutsOpenedStateChangeEventHandler raiseEvent = IsFlyoutsOpenedStateChangeEvent; raiseEvent?.Invoke(this); } } diff --git a/AdamStudio.Controls/CustomControls.Services/IFlyoutStateChecker.cs b/AdamStudio.Controls/CustomControls.Services/IFlyoutStateChecker.cs index 5c1b973..2b54cd9 100644 --- a/AdamStudio.Controls/CustomControls.Services/IFlyoutStateChecker.cs +++ b/AdamStudio.Controls/CustomControls.Services/IFlyoutStateChecker.cs @@ -1,11 +1,11 @@ namespace AdamStudio.Controls.CustomControls.Services { - public delegate void IsNotificationFlyoutOpenedStateChangeEventHandler(object sender); + public delegate void IsFlyoutsOpenedStateChangeEventHandler(object sender); public interface IFlyoutStateChecker { - public event IsNotificationFlyoutOpenedStateChangeEventHandler IsNotificationFlyoutOpenedStateChangeEvent; + public event IsFlyoutsOpenedStateChangeEventHandler IsFlyoutsOpenedStateChangeEvent; - public bool IsNotificationFlyoutOpened { get; set; } + public bool IsFlyoutsOpened { get; set; } } } diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 7d52028..6104b02 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -42,6 +42,7 @@ public class MainWindowViewModel : BindableBase private readonly IAvalonEditService mAvalonEditService; private readonly IThemeManagerService mThemeManager; private readonly ICultureProvider mCultureProvider; + private readonly IFlyoutManager mFlyoutManager; #endregion @@ -49,6 +50,7 @@ public class MainWindowViewModel : BindableBase public MainWindowViewModel(IServiceProvider serviceProvider) { + mLoggerService = serviceProvider.GetService>(); mRegionManager = serviceProvider.GetService(); mWebApiService = serviceProvider.GetService(); RegionChangeAwareService = serviceProvider.GetService(); @@ -59,7 +61,8 @@ public MainWindowViewModel(IServiceProvider serviceProvider) mThemeManager = serviceProvider.GetService(); mCultureProvider = serviceProvider.GetService(); ControlHelper = serviceProvider.GetService(); - mLoggerService = serviceProvider.GetService>(); + mFlyoutManager = serviceProvider.GetService(); + MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute); SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute); @@ -124,7 +127,11 @@ private void MoveSplitter(string commandArg) ControlHelper.CurrentBlocklyViewMode = BlocklyViewMode.MiddleScreen; if (currentViewMode == BlocklyViewMode.MiddleScreen) + { ControlHelper.CurrentBlocklyViewMode = BlocklyViewMode.FullScreen; + mFlyoutManager.CloseFlyout(FlyoutNames.FlyoutNotification, true); + } + } } diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml index 323a2c5..a9a30cf 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml @@ -32,13 +32,11 @@ Width="{Binding Path=BlocklyEditorWidth, Mode=TwoWay, Converter={StaticResource GridLengthConverter}, Source={x:Static properties:Settings.Default }}"/> - + - - diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs index d914b90..adb2e0c 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs @@ -5,9 +5,7 @@ using MahApps.Metro.IconPacks; using Microsoft.Extensions.DependencyInjection; using Prism.Commands; -using Prism.Regions; using System; -using System.Drawing; using System.Windows; namespace AdamStudio.Modules.FlayoutsRegion.ViewModels @@ -67,7 +65,7 @@ protected override void OnChanging(bool isOpening) LoadResources(); LoadFlyoutParametrs(); - mFlyoutState.IsNotificationFlyoutOpened = true; + mFlyoutState.IsFlyoutsOpened = true; Subscribe(); @@ -78,7 +76,7 @@ protected override void OnChanging(bool isOpening) if (!isOpening) { - mFlyoutState.IsNotificationFlyoutOpened = false; + mFlyoutState.IsFlyoutsOpened = false; Unsubscribe(); diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs index f96a2cf..4d9d467 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs @@ -1,4 +1,5 @@ using AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer; +using AdamStudio.Controls.CustomControls.Services; using AdamStudio.Services.Interfaces; using Microsoft.Extensions.DependencyInjection; using System; @@ -12,6 +13,7 @@ public class PortSettingsViewModel : FlyoutBase #region Services private readonly ICultureProvider mCultureProvider; + private readonly IFlyoutStateChecker mFlyoutState; #endregion @@ -19,6 +21,7 @@ public PortSettingsViewModel(IServiceProvider serviceProvider) { BorderThickness = 1; mCultureProvider = serviceProvider.GetService(); + mFlyoutState = serviceProvider.GetService(); } protected override void OnChanging(bool isOpening) @@ -27,6 +30,13 @@ protected override void OnChanging(bool isOpening) { Header = mCultureProvider.FindResource("PortSettingsView.ViewModel.Flyout.Header"); BorderBrush = Application.Current.TryFindResource("MahApps.Brushes.Text").ToString(); + mFlyoutState.IsFlyoutsOpened = true; + return; + } + + if (!isOpening) + { + mFlyoutState.IsFlyoutsOpened = false; return; } } diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs index a9760a2..81bd094 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs @@ -1,4 +1,5 @@ using AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer; +using AdamStudio.Controls.CustomControls.Services; using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; using AdamStudio.Services.SystemDialogServiceDependency; @@ -25,6 +26,7 @@ public class UserFoldersSettingsViewModel : FlyoutBase private readonly IFolderManagmentService mFolderManagment; private readonly ICultureProvider mCultureProvider; private readonly ISystemDialogService mSystemDialogService; + private readonly IFlyoutStateChecker mFlyoutState; #endregion @@ -42,17 +44,22 @@ public class UserFoldersSettingsViewModel : FlyoutBase #endregion + #region ~ + public UserFoldersSettingsViewModel(IServiceProvider serviceProvider) { ShowOpenFolderDialogDelegateCommand = new DelegateCommand(ShowOpenFolderDialog, ShowOpenFolderDialogCanExecute); - mFolderManagment = serviceProvider.GetService(); ; - mCultureProvider = serviceProvider.GetService(); ; - mSystemDialogService = serviceProvider.GetService(); ; + mFolderManagment = serviceProvider.GetService(); + mCultureProvider = serviceProvider.GetService(); + mSystemDialogService = serviceProvider.GetService(); + mFlyoutState = serviceProvider.GetService(); BorderThickness = 1; } + #endregion + #region Navigation protected override void OnChanging(bool isOpening) @@ -61,6 +68,13 @@ protected override void OnChanging(bool isOpening) { LoadResource(); BorderBrush = Application.Current.TryFindResource("MahApps.Brushes.Text").ToString(); + mFlyoutState.IsFlyoutsOpened = true; + return; + } + + if (!isOpening) + { + mFlyoutState.IsFlyoutsOpened = false; return; } } diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/WebApiSettingsViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/WebApiSettingsViewModel.cs index 472d653..3e1fd25 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/WebApiSettingsViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/WebApiSettingsViewModel.cs @@ -1,19 +1,33 @@ using AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer; +using AdamStudio.Controls.CustomControls.Services; using AdamStudio.Services.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; using System.Windows; namespace AdamStudio.Modules.FlayoutsRegion.ViewModels { public class WebApiSettingsViewModel : FlyoutBase { + #region Services + private readonly ICultureProvider mCultureProvider; + private readonly IFlyoutStateChecker mFlyoutState; + + #endregion - public WebApiSettingsViewModel(ICultureProvider cultureProvider) + #region ~ + + public WebApiSettingsViewModel(IServiceProvider serviceProvider) { - mCultureProvider = cultureProvider; + mCultureProvider = serviceProvider.GetService(); + mFlyoutState = serviceProvider.GetService(); + BorderThickness = 1; } + #endregion + #region Navigation protected override void OnChanging(bool isOpening) @@ -22,6 +36,13 @@ protected override void OnChanging(bool isOpening) { Header = mCultureProvider.FindResource("WebApiSettingsView.ViewModel.Flyout.Header"); BorderBrush = Application.Current.TryFindResource("MahApps.Brushes.Text").ToString(); + mFlyoutState.IsFlyoutsOpened = true; + return; + } + + if (!isOpening) + { + mFlyoutState.IsFlyoutsOpened = false; return; } } diff --git a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs index b1da259..8ae4a42 100644 --- a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs +++ b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs @@ -80,7 +80,7 @@ private void OpenNotificationPanel() private bool OpenNotificationPanelCanExecute() { - return !mFlyoutState.IsNotificationFlyoutOpened; + return !mFlyoutState.IsFlyoutsOpened; } #endregion @@ -253,7 +253,7 @@ private void Subscribe() mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent += RaiseNewCompileLogMessageEvent; mStatusBarNotificationDelivery.RaiseUpdateNotificationCounterEvent += RaiseUpdateNotificationCounterEvent; - mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent += IsOpenedStateChangeEvent; + mFlyoutState.IsFlyoutsOpenedStateChangeEvent += IsOpenedStateChangeEvent; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent; mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent; @@ -270,7 +270,7 @@ private void Unsubscribe() mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent -= RaiseChangeProgressRingStateEvent; mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent -= RaiseNewCompileLogMessageEvent; - mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent -= IsOpenedStateChangeEvent; + mFlyoutState.IsFlyoutsOpenedStateChangeEvent -= IsOpenedStateChangeEvent; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent -= RaiseCurrentAppCultureLoadOrChangeEvent; mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent; diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs index 8a36f28..86b3204 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs @@ -1,4 +1,5 @@ using AdamController.WebApi.Client.v1.ResponseModel; +using AdamStudio.Controls.CustomControls.Services; using AdamStudio.Core.Mvvm; using AdamStudio.Services.Interfaces; using Microsoft.Extensions.DependencyInjection; @@ -27,6 +28,7 @@ public class ToolBarViewModel : RegionViewModelBase private readonly ICultureProvider mCultureProvider; private readonly ITcpClientService mTcpClientService; private readonly IWebApiService mWebApiService; + private readonly IFlyoutStateChecker mFlyoutStateChecker; #endregion @@ -50,6 +52,7 @@ public ToolBarViewModel(IServiceProvider serviceProvider) : base(serviceProvider mCultureProvider = serviceProvider.GetService(); mTcpClientService = serviceProvider.GetService(); mWebApiService = serviceProvider.GetService(); + mFlyoutStateChecker = serviceProvider.GetService(); CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); @@ -132,16 +135,25 @@ public bool IsPythonCodeExecute get => isPythonCodeExecute; set { - bool isNewValue = SetProperty(ref isPythonCodeExecute, value); - - /*if (isNewValue) - { - //OnPythonCodeExecuteStatusChange(IsPythonCodeExecute); - RaiseDelegateCommandsCanExecuteChanged(); - }*/ + SetProperty(ref isPythonCodeExecute, value); } } + private bool mResultButtonIsChecked; + public bool ResultButtonIsChecked + { + get { return mResultButtonIsChecked; } + set { SetProperty(ref mResultButtonIsChecked, value); } + } + + private bool mLogsButtonIsChecked; + public bool LogsButtonIsChecked + { + get { return mLogsButtonIsChecked; } + set { SetProperty(ref mLogsButtonIsChecked, value); } + } + + #endregion #region Private Methods @@ -298,13 +310,21 @@ private async void RaiseTcpCientConnectedEvent(object sender) private void RaiseTcpClientDisconnectedEvent(object sender) { - UpdatePythonInfo(); + + } + + private void IsNotificationFlyoutOpenedStateChangeEvent(object sender) + { + if (mFlyoutStateChecker.IsFlyoutsOpened) + { + LogsButtonIsChecked = false; + ResultButtonIsChecked = false; + } } #endregion #region Subscribes - private void Subscribe() { mTcpClientService.RaiseTcpCientConnectedEvent += RaiseTcpCientConnectedEvent; @@ -317,6 +337,8 @@ private void Subscribe() mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent; + + mFlyoutStateChecker.IsFlyoutsOpenedStateChangeEvent += IsNotificationFlyoutOpenedStateChangeEvent; } private void Unsubscribe() @@ -331,6 +353,8 @@ private void Unsubscribe() mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish; mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent -= RaiseCurrentAppCultureLoadOrChangeEvent; + + mFlyoutStateChecker.IsFlyoutsOpenedStateChangeEvent -= IsNotificationFlyoutOpenedStateChangeEvent; } #endregion diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index b361742..c4cf462 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -141,12 +141,14 @@ Content="Результат" Width="120" HorizontalAlignment="Center" + IsChecked="{Binding ResultButtonIsChecked}" Style="{StaticResource MahApps.Styles.ToggleButton.ExpanderHeader.Down.DataGrid.GroupItem}"/> From 2a8266cbeef16bafed08a80f86bce59b0b6edc99 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Sat, 2 Nov 2024 14:32:47 +1000 Subject: [PATCH 36/40] Close#105 --- AdamStudio.Services/AvalonEditService.cs | 2 +- AdamStudio.Services/TcpClientService.cs | 1 - AdamStudio/App.xaml.cs | 11 +++++-- AdamStudio/ViewModels/MainWindowViewModel.cs | 12 ++++---- .../ViewModels/ScratchControlViewModel.cs | 1 + .../Views/ScratchControlView.xaml | 30 +++++++++---------- .../UserFoldersSettingsViewModel.cs | 2 -- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/AdamStudio.Services/AvalonEditService.cs b/AdamStudio.Services/AvalonEditService.cs index c7e270b..2aff2fe 100644 --- a/AdamStudio.Services/AvalonEditService.cs +++ b/AdamStudio.Services/AvalonEditService.cs @@ -41,7 +41,7 @@ public void RegisterHighlighting(string highlightingName, byte[] xmlByteArray) { var xml = mFileManagmentService.ReadTextAsXml(xmlByteArray); var definition = HighlightingLoader.Load(xml, mHighlightingManager); - mHighlightingManager.RegisterHighlighting(highlightingName, Array.Empty(), definition); + mHighlightingManager.RegisterHighlighting(highlightingName, [], definition); } diff --git a/AdamStudio.Services/TcpClientService.cs b/AdamStudio.Services/TcpClientService.cs index afb6c32..57c2467 100644 --- a/AdamStudio.Services/TcpClientService.cs +++ b/AdamStudio.Services/TcpClientService.cs @@ -6,7 +6,6 @@ namespace AdamStudio.Services { - public class TcpClientService : NetCoreServer.TcpClient, ITcpClientService { #region Events diff --git a/AdamStudio/App.xaml.cs b/AdamStudio/App.xaml.cs index 52775c6..828641d 100644 --- a/AdamStudio/App.xaml.cs +++ b/AdamStudio/App.xaml.cs @@ -44,6 +44,8 @@ using AdamStudio.Services.TcpClientDependency; using AdamStudio.Services; using Microsoft.Extensions.Options; +using ICSharpCode.AvalonEdit.Highlighting; +using AdamStudio.Core; #endregion @@ -74,9 +76,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); @@ -192,6 +192,13 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) RegisterDialogs(containerRegistry); RegisterService(containerRegistry); + RegisterAvalonHighlightingDefinition(); + } + + private void RegisterAvalonHighlightingDefinition() + { + IAvalonEditService avalonService = Container.Resolve(); + avalonService.RegisterHighlighting(HighlightingName.AdamPython, Resource.AdamPython); } private void RegisterService(IContainerRegistry containerRegistry) diff --git a/AdamStudio/ViewModels/MainWindowViewModel.cs b/AdamStudio/ViewModels/MainWindowViewModel.cs index 6104b02..b953474 100644 --- a/AdamStudio/ViewModels/MainWindowViewModel.cs +++ b/AdamStudio/ViewModels/MainWindowViewModel.cs @@ -225,11 +225,11 @@ private void ParseSyslogMessage(string message) /// /// Register highlighting for AvalonEdit. You need to call before loading the regions /// - private void LoadCustomAvalonEditHighlighting() - { - mAvalonEditService.RegisterHighlighting(HighlightingName.AdamPython, Resource.AdamPython); - mLoggerService.LogInformation("Loaded highlighting"); - } + //private void LoadCustomAvalonEditHighlighting() + //{ + // mAvalonEditService.RegisterHighlighting(HighlightingName.AdamPython, Resource.AdamPython); + // mLoggerService.LogInformation("Loaded highlighting"); + //} private void LoadAppTheme() { @@ -291,7 +291,7 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e) //Loaded resource ShowView(ViewNames.ScratchView); - LoadCustomAvalonEditHighlighting(); + //LoadCustomAvalonEditHighlighting(); LoadAppTheme(); if (Settings.Default.AutoStartTcpConnect) diff --git a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs index 899d640..3af85b1 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs +++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs @@ -25,6 +25,7 @@ using System.Windows.Threading; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; +using AdamStudio.Services; namespace AdamStudio.Modules.ContentRegion.ViewModels { diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml index a9a30cf..73ecf77 100644 --- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml +++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml @@ -575,21 +575,21 @@ + Margin="7 5 0 0" + x:Name="SourceEditor" + FontFamily="Consolas" + FontSize="13pt" + FontStretch="Medium" + HorizontalScrollBarVisibility="Auto" + VerticalScrollBarVisibility="Auto" + ScrollViewer.PanningMode="HorizontalOnly" + IsReadOnly="{Binding IsChecked, ElementName=ReadOnlyButton, Converter={StaticResource InverseBooleanConverter}}" + ShowLineNumbers="{Binding IsChecked, ElementName=ShowLineNumberButton}" + SyntaxHighlighting="{Binding HighlightingDefinition, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" + IsEnabled="{Binding IsPythonCodeExecute, Converter={StaticResource InverseBooleanConverter}}" + Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}" + LineNumbersForeground="{DynamicResource MahApps.Brushes.ThemeForeground}" + Background="{DynamicResource MahApps.Brushes.ThemeBackground}"> diff --git a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs index 81bd094..7bf6d2f 100644 --- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs +++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs @@ -3,10 +3,8 @@ using AdamStudio.Core.Properties; using AdamStudio.Services.Interfaces; using AdamStudio.Services.SystemDialogServiceDependency; -using AdamStudio.Services.SystemDialogServiceDependency; using Microsoft.Extensions.DependencyInjection; using Prism.Commands; -using Prism.Regions; using Prism.Services.Dialogs; using System; using System.Windows; From eba6257a832dcb292729a1f8640bbd199e68e113 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Sat, 2 Nov 2024 15:53:01 +1000 Subject: [PATCH 37/40] Close #102 --- .../ViewModels/ToolBarViewModel.cs | 1 - .../Views/ToolBarView.xaml | 36 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs index 86b3204..295d590 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs +++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs @@ -55,7 +55,6 @@ public ToolBarViewModel(IServiceProvider serviceProvider) : base(serviceProvider mFlyoutStateChecker = serviceProvider.GetService(); CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute); - mLogger.LogTrace("Load ~"); } diff --git a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml index c4cf462..5cf37bf 100644 --- a/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml +++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml @@ -33,6 +33,19 @@ + + @@ -50,8 +63,10 @@ - - + - - - - - + mah:TextBoxHelper.IsSpellCheckContextMenuEnabled="True" + Text="{Binding ResultText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> - - - + + + + + + From 42f99526c9e2a28ea3cff4d09283055be6aed484 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Sat, 2 Nov 2024 16:08:54 +1000 Subject: [PATCH 38/40] Up version --- AdamStudio/AdamStudio.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index 3ae93f4..e174914 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -3,8 +3,8 @@ Dynamic False MIT-Modern-Variant - 2.0.1.0 - 2.0.1.0 + 2.0.1.1 + 2.0.1.1 net8.0-windows7.0 From 43b646e6183b6954cbc7334dcc19c325f6ff726d Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Tue, 5 Nov 2024 07:32:12 +1000 Subject: [PATCH 39/40] Fix path to blockly source in installation script (CRITICAL) --- AdamSetup.devel.iss | 2 +- AdamSetup.release.iss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AdamSetup.devel.iss b/AdamSetup.devel.iss index a24f574..11134cb 100644 --- a/AdamSetup.devel.iss +++ b/AdamSetup.devel.iss @@ -54,7 +54,7 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent; -Filename: "{tmp}\7za.exe"; Parameters: "x ""{tmp}\BlocklySource.zip"" -o""{commonappdata}\AdamStudio\BlocklySource"" * -r -aoa"; Flags: runasoriginaluser runhidden; +Filename: "{tmp}\7za.exe"; Parameters: "x ""{tmp}\BlocklySource.zip"" -o""{commonappdata}\{#MyAppName}\BlocklySource"" * -r -aoa"; Flags: runasoriginaluser runhidden; Filename: "{tmp}\MicrosoftEdgeWebView2RuntimeInstaller.125.0.2535.51.X64.exe"; Parameters: "/silent /install"; Filename: "{tmp}\VC_redist.14.29.30135.0.x64.exe"; Parameters: "/install /quiet /norestart"; Filename: "{tmp}\windowsdesktop-runtime-8.0.5-win-x64.exe"; Parameters: "/install /quiet /norestart"; diff --git a/AdamSetup.release.iss b/AdamSetup.release.iss index d91c629..4c983f8 100644 --- a/AdamSetup.release.iss +++ b/AdamSetup.release.iss @@ -56,7 +56,7 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent; -Filename: "{tmp}\7za.exe"; Parameters: "x ""{tmp}\BlocklySource.zip"" -o""{commonappdata}\AdamController\BlocklySource"" * -r -aoa"; Flags: runasoriginaluser runhidden; +Filename: "{tmp}\7za.exe"; Parameters: "x ""{tmp}\BlocklySource.zip"" -o""{commonappdata}\{#MyAppName}\BlocklySource"" * -r -aoa"; Flags: runasoriginaluser runhidden; Filename: "{tmp}\MicrosoftEdgeWebView2RuntimeInstaller.125.0.2535.51.X64.exe"; Parameters: "/silent /install"; Filename: "{tmp}\VC_redist.14.29.30135.0.x64.exe"; Parameters: "/install /quiet /norestart"; Filename: "{tmp}\windowsdesktop-runtime-8.0.5-win-x64.exe"; Parameters: "/install /quiet /norestart"; From 9b606bb92c9d8e3721f03a8ee68fa700310326f3 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Tue, 5 Nov 2024 08:03:10 +1000 Subject: [PATCH 40/40] Up version --- AdamStudio/AdamStudio.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AdamStudio/AdamStudio.csproj b/AdamStudio/AdamStudio.csproj index e174914..260bd65 100644 --- a/AdamStudio/AdamStudio.csproj +++ b/AdamStudio/AdamStudio.csproj @@ -3,8 +3,8 @@ Dynamic False MIT-Modern-Variant - 2.0.1.1 - 2.0.1.1 + 2.0.1.2 + 2.0.1.2 net8.0-windows7.0