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";
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.Controls/CustomControls.Services/FlyoutManager.cs b/AdamStudio.Controls/CustomControls.Services/FlyoutManager.cs
index 7cb3b57..5363205 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();
}
@@ -148,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)
@@ -210,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.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.Core/Converters/StringToViewRegionIconsConverter.cs b/AdamStudio.Core/Converters/StringToViewRegionIconsConverter.cs
index 6b02a80..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 == SubRegionNames.SubRegionVisualSettings)
+ if (stringValue == ViewNames.SettingsView)
return PackIconSimpleIconsKind.Scratch;
- if (stringValue == SubRegionNames.SubRegionScratch)
+ if (stringValue == ViewNames.ScratchView)
return PackIconFeatherIconsKind.Settings;
return PackIconSimpleIconsKind.AbbRobotStudio;
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.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..c55d76c 100644
--- a/AdamStudio.Core/RegionNames.cs
+++ b/AdamStudio.Core/RegionNames.cs
@@ -2,9 +2,10 @@
{
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)}";
}
}
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.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.Services/AdamStudio.Services.csproj b/AdamStudio.Services/AdamStudio.Services.csproj
index ae9fc3f..190f095 100644
--- a/AdamStudio.Services/AdamStudio.Services.csproj
+++ b/AdamStudio.Services/AdamStudio.Services.csproj
@@ -8,16 +8,22 @@
-
-
-
+
+
+
+
+
+
+
+
-
+
+
diff --git a/AdamStudio.Services/AvalonEditService.cs b/AdamStudio.Services/AvalonEditService.cs
index d0cfe4e..2aff2fe 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;
}
@@ -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/CommunicationProviderService.cs b/AdamStudio.Services/CommunicationProviderService.cs
index d2f9ceb..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,11 +103,6 @@ public void Dispose()
#endregion
-
- #region Private methods
-
- #endregion
-
#region Subscriptions
private void Subscribe()
@@ -116,11 +112,9 @@ private void Subscribe()
mTcpClientService.RaiseTcpClientDisconnectedEvent += RaiseTcpClientDisconnected;
mUdpClientService.RaiseUdpClientMessageEnqueueEvent += RaiseUdpClientMessageEnqueueEvent;
-
mUdpServerService.RaiseUdpServerReceivedEvent += RaiseServiceUdpServerReceived;
}
-
private void Unsubscribe()
{
mTcpClientService.RaiseTcpClientReconnectedEvent -= RaiseServiceTcpClientReconnected;
@@ -128,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 f849929..96d01cc 100644
--- a/AdamStudio.Services/FileManagmentService.cs
+++ b/AdamStudio.Services/FileManagmentService.cs
@@ -17,7 +17,7 @@ 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.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/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/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.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/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.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.sln b/AdamStudio.sln
index 62ce372..447f028 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("{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
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..260bd65 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.2
+ 2.0.1.2
net8.0-windows7.0
@@ -36,6 +36,7 @@
+
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..828641d 100644
--- a/AdamStudio/App.xaml.cs
+++ b/AdamStudio/App.xaml.cs
@@ -26,17 +26,35 @@
using System.Diagnostics;
using System.Threading.Tasks;
using System.ComponentModel;
+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;
+using Microsoft.Extensions.Options;
+using ICSharpCode.AvalonEdit.Highlighting;
+using AdamStudio.Core;
#endregion
namespace AdamStudio
{
- public partial class App : Application
+ public partial class App : PrismApplication
{
- private readonly Bootstrapper mBootstrapper = new();
+ #region ~
public App()
{
@@ -44,14 +62,188 @@ public App()
LoadSharedFFmpegLibrary();
}
- protected override void OnStartup(StartupEventArgs e)
+ #endregion
+
+ protected override Window CreateShell()
{
- mBootstrapper.Run();
- //mBootstrapper.Container.Resolve().Make(Current, "AdamStudio");
+ return Container.Resolve();
+ }
- base.OnStartup(e);
-
+ protected override void RegisterTypes(IContainerRegistry containerRegistry)
+ {
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+
+ 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.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton(containerRegistry =>
+ {
+
+ bool isVideoShowLastValue = Settings.Default.ShowVideo;
+ return new ControlHelper(isVideoShowLastValue);
+ });
+
+ containerRegistry.RegisterSingleton();
+
+ RegisterDialogs(containerRegistry);
+ RegisterService(containerRegistry);
+ RegisterAvalonHighlightingDefinition();
+ }
+
+ private void RegisterAvalonHighlightingDefinition()
+ {
+ IAvalonEditService avalonService = Container.Resolve();
+ avalonService.RegisterHighlighting(HighlightingName.AdamPython, Resource.AdamPython);
+ }
+
+ private void RegisterService(IContainerRegistry containerRegistry)
+ {
+ containerRegistry.RegisterServices(services =>
+ {
+ ILogWriteEventAwareService logWriteEventAware = Container.Resolve();
+
+ 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 +256,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..b953474 100644
--- a/AdamStudio/ViewModels/MainWindowViewModel.cs
+++ b/AdamStudio/ViewModels/MainWindowViewModel.cs
@@ -3,10 +3,12 @@
using AdamStudio.Core;
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 Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
using Prism.Commands;
+using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Globalization;
@@ -16,11 +18,10 @@
namespace AdamStudio.ViewModels
{
- public class MainWindowViewModel : ViewModelBase
+ public class MainWindowViewModel : BindableBase
{
#region DelegateCommands
-
- public DelegateCommand ShowRegionCommand { get; }
+
public DelegateCommand MoveSplitterDelegateCommand { get; }
public DelegateCommand SwitchToVideoDelegateCommand { get; }
public DelegateCommand SwitchToSettingsViewDelegateCommand { get; }
@@ -29,9 +30,10 @@ public class MainWindowViewModel : ViewModelBase
#region Services
- public ISubRegionChangeAwareService SubRegionChangeAwareService { get; }
+ public IRegionChangeAwareService RegionChangeAwareService { get; }
public IControlHelper ControlHelper { get; }
+ private readonly ILogger mLoggerService;
private readonly IRegionManager mRegionManager;
private readonly IStatusBarNotificationDeliveryService mStatusBarNotification;
private readonly ICommunicationProviderService mCommunicationProviderService;
@@ -40,43 +42,68 @@ public class MainWindowViewModel : ViewModelBase
private readonly IAvalonEditService mAvalonEditService;
private readonly IThemeManagerService mThemeManager;
private readonly ICultureProvider mCultureProvider;
+ private readonly IFlyoutManager mFlyoutManager;
#endregion
#region ~
- public MainWindowViewModel(IRegionManager regionManager, ISubRegionChangeAwareService subRegionChangeAwareService, IStatusBarNotificationDeliveryService statusBarNotification,
- ICommunicationProviderService communicationProviderService, IFolderManagmentService folderManagment, IWebApiService webApiService,
- IAvalonEditService avalonEditService, IThemeManagerService themeManager, ICultureProvider cultureProvider,
- IControlHelper controlHelper)
+ public MainWindowViewModel(IServiceProvider serviceProvider)
{
- mRegionManager = regionManager;
- mWebApiService = webApiService;
- SubRegionChangeAwareService = subRegionChangeAwareService;
- mStatusBarNotification = statusBarNotification;
- mCommunicationProviderService = communicationProviderService;
- mFolderManagment = folderManagment;
- mAvalonEditService = avalonEditService;
- mThemeManager = themeManager;
- mCultureProvider = cultureProvider;
- ControlHelper = controlHelper;
-
- ShowRegionCommand = new DelegateCommand(ShowRegion);
- MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute);
+ mLoggerService = serviceProvider.GetService>();
+ 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();
+ mFlyoutManager = serviceProvider.GetService();
- SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute);
- SwitchToSettingsViewDelegateCommand = new DelegateCommand(SwitchToSettingsView, SwitchToSettingsViewCanExecute);
+ MoveSplitterDelegateCommand = new DelegateCommand(MoveSplitter, MoveSplitterCanExecute);
+ SwitchToVideoDelegateCommand = new DelegateCommand(SwitchToVideo, SwitchToVideoCanExecute);
+ 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
public string WindowTitle => $"AdamStudio {Assembly.GetExecutingAssembly().GetName().Version}";
-
#endregion
#region DelegateCommands methods
@@ -100,14 +127,18 @@ private void MoveSplitter(string commandArg)
ControlHelper.CurrentBlocklyViewMode = BlocklyViewMode.MiddleScreen;
if (currentViewMode == BlocklyViewMode.MiddleScreen)
+ {
ControlHelper.CurrentBlocklyViewMode = BlocklyViewMode.FullScreen;
+ mFlyoutManager.CloseFlyout(FlyoutNames.FlyoutNotification, true);
+ }
+
}
}
private bool MoveSplitterCanExecute(string arg)
{
- var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName;
- return regionName == SubRegionNames.SubRegionScratch;
+ var regionName = RegionChangeAwareService.RegionNavigationTargetName;
+ return regionName == ViewNames.ScratchView;
}
private void SwitchToVideo()
@@ -124,26 +155,25 @@ private void SwitchToVideo()
private bool SwitchToVideoCanExecute()
{
- var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName;
- return regionName == SubRegionNames.SubRegionScratch;
+ var regionName = RegionChangeAwareService.RegionNavigationTargetName;
+ return regionName == ViewNames.ScratchView;
}
private void SwitchToSettingsView()
{
+ var activeViewName = RegionChangeAwareService.RegionNavigationTargetName;
- var regionName = SubRegionChangeAwareService.InsideRegionNavigationRequestName;
-
- if (regionName == SubRegionNames.SubRegionScratch)
+ if (activeViewName == ViewNames.ScratchView)
{
- ShowRegion(SubRegionNames.SubRegionVisualSettings);
+ ShowView(ViewNames.SettingsView);
return;
}
- if(regionName == SubRegionNames.SubRegionVisualSettings)
+ if(activeViewName == ViewNames.SettingsView)
{
- ShowRegion(SubRegionNames.SubRegionScratch);
+ ShowView(ViewNames.ScratchView);
return;
- }
+ }
}
private bool SwitchToSettingsViewCanExecute()
@@ -155,20 +185,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();
@@ -206,10 +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);
- }
+ //private void LoadCustomAvalonEditHighlighting()
+ //{
+ // mAvalonEditService.RegisterHighlighting(HighlightingName.AdamPython, Resource.AdamPython);
+ // mLoggerService.LogInformation("Loaded highlighting");
+ //}
private void LoadAppTheme()
{
@@ -267,13 +287,13 @@ private void MainWindowLoaded(object sender, RoutedEventArgs e)
mFolderManagment.CreateAppDataFolder();
SaveFolderPathToSettings();
}
-
- LoadCustomAvalonEditHighlighting();
+ //Loaded resource
+ ShowView(ViewNames.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..883fc70 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}"
@@ -32,7 +32,8 @@
-
+
@@ -84,6 +85,7 @@
+
@@ -105,11 +107,12 @@
-
+
-
+
@@ -120,26 +123,26 @@
+
+
+
+
-
-
-
-
-
+
-
+
diff --git a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs
index 354af9b..460042e 100644
--- a/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs
+++ b/Modules/AdamStudio.Modules.ContentRegion/ContentRegionModule.cs
@@ -17,16 +17,13 @@ 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));
+ containerRegistry.RegisterForNavigation(ViewNames.ScratchView);
+ containerRegistry.RegisterForNavigation(ViewNames.SettingsView);
}
}
}
\ No newline at end of file
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/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..3af85b1 100644
--- a/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs
+++ b/Modules/AdamStudio.Modules.ContentRegion/ViewModels/ScratchControlViewModel.cs
@@ -23,6 +23,9 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.DependencyInjection;
+using AdamStudio.Services;
namespace AdamStudio.Modules.ContentRegion.ViewModels
{
@@ -34,7 +37,6 @@ public class ScratchControlViewModel : RegionViewModelBase
public DelegateCommand ReloadWebViewDelegateCommand { get; }
public DelegateCommand ShowSaveFileDialogDelegateCommand { get; }
public DelegateCommand ShowOpenFileDialogDelegateCommand { get; }
- public DelegateCommand CleanExecuteEditorDelegateCommand { get; }
public DelegateCommand RunPythonCodeDelegateCommand { get; }
public DelegateCommand StopPythonCodeExecuteDelegateCommand { get; }
public DelegateCommand ToZeroPositionDelegateCommand { get; }
@@ -45,6 +47,7 @@ public class ScratchControlViewModel : RegionViewModelBase
#region Services
+ private readonly ILogger mLogger;
private readonly ICommunicationProviderService mCommunicationProvider;
private readonly IPythonRemoteRunnerService mPythonRemoteRunner;
private readonly IStatusBarNotificationDeliveryService mStatusBarNotificationDelivery;
@@ -55,6 +58,7 @@ public class ScratchControlViewModel : RegionViewModelBase
private readonly ISystemDialogService mSystemDialog;
private readonly IControlHelper mControlHelper;
private readonly IVideoViewProvider mVideoViewProvider;
+ private readonly IRegionChangeAwareService mRegionChangeAwareService;
#endregion
@@ -66,14 +70,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;
@@ -96,30 +94,27 @@ public class ScratchControlViewModel : RegionViewModelBase
#region ~
- public ScratchControlViewModel(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)
- {
-
- mCommunicationProvider = communicationProvider;
- mPythonRemoteRunner = pythonRemoteRunner;
- mStatusBarNotificationDelivery = statusBarNotificationDelivery;
- mWebViewProvider = webViewProvider;
- mFileManagment = fileManagment;
- mWebApiService = webApiService;
- mCultureProvider = cultureProvider;
- mSystemDialog = systemDialogService;
- mControlHelper = controlHelper;
- mVideoViewProvider = videoViewProvider;
+ 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);
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);
@@ -127,21 +122,19 @@ public ScratchControlViewModel(IRegionManager regionManager, ICommunicationProvi
DirectionButtonDownDelegateCommand = new DelegateCommand(DirectionButtonDown, DirectionButtonDownCanExecute);
DirectionButtonUpDelegateCommand = new DelegateCommand(DirectionButtonUp, DirectionButtonUpCanExecute);
- HighlightingDefinition = avalonEditService.GetDefinition(HighlightingName.AdamPython);
+ HighlightingDefinition = serviceProvider.GetService().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)
{
- Subscribe();
+ mRegionChangeAwareService.RegionNavigationTargetName = ViewNames.ScratchView;
+
LoadResources();
UpdateIsShowVideo(Settings.Default.ShowVideo);
@@ -168,7 +161,7 @@ public string VideoFrameRate
set { SetProperty(ref videoFrameRate, value); }
}
- private bool isShowVideo; //= Settings.Default.ShowVideo;
+ private bool isShowVideo;
public bool IsShowVideo
{
get => isShowVideo;
@@ -229,40 +222,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
{
@@ -270,20 +229,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
{
@@ -318,8 +263,6 @@ private void Subscribe()
mCommunicationProvider.RaiseTcpServiceCientConnectedEvent += OnRaiseTcpServiceCientConnected;
mCommunicationProvider.RaiseTcpServiceClientDisconnectEvent += OnRaiseTcpServiceClientDisconnect;
- mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart;
- mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput;
mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish;
mWebViewProvider.RaiseWebViewMessageReceivedEvent += RaiseWebViewbMessageReceivedEvent;
@@ -335,8 +278,6 @@ private void Unsubscribe()
mCommunicationProvider.RaiseTcpServiceCientConnectedEvent -= OnRaiseTcpServiceCientConnected;
mCommunicationProvider.RaiseTcpServiceClientDisconnectEvent -= OnRaiseTcpServiceClientDisconnect;
- mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart;
- mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput;
mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent -= OnRaisePythonScriptExecuteFinish;
mWebViewProvider.RaiseWebViewMessageReceivedEvent -= RaiseWebViewbMessageReceivedEvent;
@@ -398,7 +339,7 @@ private void ShowOpenFileDialog(string param)
if (result.IsOpenFileCanceled)
{
- mStatusBarNotificationDelivery.AppLogMessage = mFileNotSelectedLogMessage;
+ mLogger.LogWarning(mFileNotSelectedLogMessage);
return;
}
@@ -436,7 +377,7 @@ private void ShowSaveFileDialog(string param)
if (result.IsSaveFileCanceled)
{
- mStatusBarNotificationDelivery.AppLogMessage = mFileNotSavedLogMessage;
+ mLogger.LogWarning(mFileNotSavedLogMessage);
return;
}
@@ -457,18 +398,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()
{
@@ -476,23 +405,18 @@ private async void RunPythonCode()
try
{
- 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);
}
catch
{
- }
- finally
- {
-
}
}
@@ -513,10 +437,7 @@ private async void StopPythonCodeExecute()
{
await mWebApiService.StopPythonExecute();
}
- catch
- {
-
- }
+ catch {}
}
private bool StopPythonCodeExecuteCanExecute()
@@ -534,10 +455,7 @@ private async void ToZeroPosition()
await mWebApiService.StopPythonExecute();
await mWebApiService.MoveToZeroPosition();
}
- catch
- {
-
- }
+ catch {}
}
private bool ToZeroPositionCanExecute()
@@ -621,73 +539,6 @@ private void UpdateIsShowVideo(bool isShowVideo)
IsShowVideo = isShowVideo;
}
- 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 OnPythonCodeExecuteStatusChange(bool isPythonCodeExecute)
{
@@ -698,16 +549,14 @@ 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;
-
if (!Settings.Default.ShadowWorkspaceInDebug) return;
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(async () =>
@@ -716,21 +565,6 @@ 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)
{
string path = result.OpenFilePath;
@@ -738,16 +572,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 +601,7 @@ private async void SaveSupportedFile(SaveFileDialogResult result, SupportFileTyp
await mFileManagment.WriteAsync(path, file);
}
- mStatusBarNotificationDelivery.AppLogMessage = $"{mFileSavedLogMessage} {path}";
+ mLogger.LogInformation($"{mFileSavedLogMessage} {path}");
}
private void RaiseDelegateCommandsCanExecuteChanged()
@@ -776,7 +610,6 @@ private void RaiseDelegateCommandsCanExecuteChanged()
ReloadWebViewDelegateCommand.RaiseCanExecuteChanged();
ShowSaveFileDialogDelegateCommand.RaiseCanExecuteChanged();
ShowOpenFileDialogDelegateCommand.RaiseCanExecuteChanged();
- CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged();
RunPythonCodeDelegateCommand.RaiseCanExecuteChanged();
StopPythonCodeExecuteDelegateCommand.RaiseCanExecuteChanged();
ToZeroPositionDelegateCommand.RaiseCanExecuteChanged();
@@ -786,11 +619,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");
@@ -815,6 +643,7 @@ private void LoadResources()
private void RaiseWebViewNavigationCompleteEvent(object sender)
{
InitBlockly();
+ mLogger.LogTrace("Called RaiseWebViewNavigationCompleteEvent");
}
private void RaiseWebViewbMessageReceivedEvent(object sender, WebMessageJsonReceived webMessageReceived)
@@ -825,45 +654,19 @@ 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)
{
- if (remoteCommandExecuteResult == null)
- return;
-
- UpdateResultText("", true);
- UpdateResultExecutionTimeText(remoteCommandExecuteResult);
+ IsPythonCodeExecute = false;
}
private void OnRaiseIsVideoShowChangeEvent(object sender)
@@ -906,11 +709,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..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;
@@ -32,6 +33,7 @@ public class SettingsControlViewModel : RegionViewModelBase
private readonly IThemeManagerService mThemeManager;
private readonly ICultureProvider mCultureProvider;
private readonly IWebViewProvider mWebViewProvider;
+ private readonly IRegionChangeAwareService mRegionChangeAwareService;
#endregion
@@ -44,13 +46,13 @@ public class SettingsControlViewModel : RegionViewModelBase
#region ~
- public SettingsControlViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager,
- IThemeManagerService themeManager, ICultureProvider cultureProvider, IWebViewProvider webViewProvider) : base(regionManager)
+ public SettingsControlViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
{
- mFlyoutManager = flyoutManager;
- mThemeManager = themeManager;
- mCultureProvider = cultureProvider;
- mWebViewProvider = webViewProvider;
+ 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);
@@ -113,13 +115,15 @@ public override void ConfirmNavigationRequest(NavigationContext navigationContex
public override void OnNavigatedTo(NavigationContext navigationContext)
{
- base.OnNavigatedTo(navigationContext);
+ mRegionChangeAwareService.RegionNavigationTargetName = ViewNames.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/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.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..73ecf77 100644
--- a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml
+++ b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml
@@ -22,57 +22,31 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
-
-
+
+ Margin="0 0 0 1"/>
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -157,347 +132,357 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
-
+
-
+
-
+
-
+
-
-
+
-
+
+
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
+
+
-
+
-
+
-
+
+
-
-
-
+
+
-
+ CommandParameter="{Binding RotateLeftDirrection}" />
+
-
+
-
+
-
-
+
+
-
+
+
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
-
-
+
+
-
+
+
-
-
+
+
+
+
-
+ CommandParameter="{Binding BackDirection}" />
+
-
+
-
-
-
+
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
+ CommandParameter="{Binding StopDirrection}" />
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
-
+
-
-
-
+ IsEnabled="{Binding IsPythonCodeExecute, Converter={StaticResource InverseBooleanConverter}}">
+
+
-
+
-
-
-
-
-
-
+
-
+
+
+
+
-
-
+
-
+
+
-
-
-
+
+
+
+
-
+
+
-
-
-
-
-
+
-
+
+
+
-
-
-
-
+
-
+
+ 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}">
@@ -620,102 +600,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs b/Modules/AdamStudio.Modules.ContentRegion/Views/ScratchControlView.xaml.cs
index 4e20ec9..872a5e4 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,6 @@ public ScratchControlView(IWebViewProvider webViewProvider, IStatusBarNotificati
mWebViewProvider.RaiseExecuteReloadWebViewEvent += RaiseExecuteReloadWebViewEvent;
/*element event */
- TextResulEditor.TextChanged += TextResulEditorTextChanged;
MainGrid.SizeChanged += MainGridSizeChanged;
SourceEditor.SizeChanged += TextResulEditorSizeChanged;
@@ -73,14 +75,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 +93,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,11 +144,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");
@@ -166,24 +157,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.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.FlayoutsRegion/ViewModels/NotificationViewModel.cs b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs
index 8dbf77e..adb2e0c 100644
--- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs
+++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/NotificationViewModel.cs
@@ -3,8 +3,9 @@
using AdamStudio.Core.Properties;
using AdamStudio.Services.Interfaces;
using MahApps.Metro.IconPacks;
+using Microsoft.Extensions.DependencyInjection;
using Prism.Commands;
-using System.Drawing;
+using System;
using System.Windows;
namespace AdamStudio.Modules.FlayoutsRegion.ViewModels
@@ -41,12 +42,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);
@@ -64,7 +65,7 @@ protected override void OnChanging(bool isOpening)
LoadResources();
LoadFlyoutParametrs();
- mFlyoutState.IsNotificationFlyoutOpened = true;
+ mFlyoutState.IsFlyoutsOpened = true;
Subscribe();
@@ -75,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 aeb591d..4d9d467 100644
--- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs
+++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/PortSettingsViewModel.cs
@@ -1,5 +1,8 @@
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
@@ -10,13 +13,15 @@ public class PortSettingsViewModel : FlyoutBase
#region Services
private readonly ICultureProvider mCultureProvider;
+ private readonly IFlyoutStateChecker mFlyoutState;
#endregion
- public PortSettingsViewModel(ICultureProvider cultureProvider)
+ public PortSettingsViewModel(IServiceProvider serviceProvider)
{
BorderThickness = 1;
- mCultureProvider = cultureProvider;
+ mCultureProvider = serviceProvider.GetService();
+ mFlyoutState = serviceProvider.GetService();
}
protected override void OnChanging(bool isOpening)
@@ -25,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 67d2350..7bf6d2f 100644
--- a/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs
+++ b/Modules/AdamStudio.Modules.FlayoutsRegion/ViewModels/UserFoldersSettingsViewModel.cs
@@ -1,10 +1,12 @@
using AdamStudio.Controls.CustomControls.Mvvm.FlyoutContainer;
+using AdamStudio.Controls.CustomControls.Services;
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.Services.Dialogs;
+using System;
using System.Windows;
namespace AdamStudio.Modules.FlayoutsRegion.ViewModels
@@ -22,6 +24,7 @@ public class UserFoldersSettingsViewModel : FlyoutBase
private readonly IFolderManagmentService mFolderManagment;
private readonly ICultureProvider mCultureProvider;
private readonly ISystemDialogService mSystemDialogService;
+ private readonly IFlyoutStateChecker mFlyoutState;
#endregion
@@ -39,17 +42,22 @@ public class UserFoldersSettingsViewModel : FlyoutBase
#endregion
- public UserFoldersSettingsViewModel(IFolderManagmentService folderManagment, ICultureProvider cultureProvider, ISystemDialogService systemDialogService)
+ #region ~
+
+ public UserFoldersSettingsViewModel(IServiceProvider serviceProvider)
{
ShowOpenFolderDialogDelegateCommand = new DelegateCommand(ShowOpenFolderDialog, ShowOpenFolderDialogCanExecute);
- mFolderManagment = folderManagment;
- mCultureProvider = cultureProvider;
- mSystemDialogService = systemDialogService;
+ mFolderManagment = serviceProvider.GetService();
+ mCultureProvider = serviceProvider.GetService();
+ mSystemDialogService = serviceProvider.GetService();
+ mFlyoutState = serviceProvider.GetService();
BorderThickness = 1;
}
+ #endregion
+
#region Navigation
protected override void OnChanging(bool isOpening)
@@ -58,6 +66,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.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.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..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; }
@@ -20,18 +20,22 @@ public class MenuRegionViewModel : RegionViewModelBase
#region Services
- private readonly ISubRegionChangeAwareService mSubRegionChangeAware;
+ private readonly IRegionChangeAwareService mRegionChangeAware;
#endregion
- public MenuRegionViewModel(IRegionManager regionManager,ISubRegionChangeAwareService subRegionChangeAware) : base(regionManager)
+ #region ~
+
+ public MenuRegionViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
{
- mSubRegionChangeAware = subRegionChangeAware;
+ mRegionChangeAware = serviceProvider.GetService();
CloseAppCommand = new DelegateCommand(CloseApp);
ShowRegionCommand = new DelegateCommand(ShowRegion);
}
+ #endregion
+
#region Navigation
public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback)
@@ -46,6 +50,7 @@ public override void OnNavigatedTo(NavigationContext navigationContext)
base.OnNavigatedTo(navigationContext);
}
+
public override void Destroy()
{
Unsubscribe();
@@ -62,13 +67,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 +78,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 ViewNames.ScratchView:
IsCheckedScratchMenuItem = true;
break;
- case SubRegionNames.SubRegionComputerVisionControl:
- IsCheckedComputerVisionMenuItem = true;
- break;
- case SubRegionNames.SubRegionVisualSettings:
+ case ViewNames.SettingsView:
IsCheckedVisualSettingsMenuItem = true;
break;
}
@@ -101,7 +96,6 @@ private void ChangeCheckedMenuItem(string selectedSubRegionName)
private void ResetIsCheckedMenuItem()
{
IsCheckedScratchMenuItem = false;
- IsCheckedComputerVisionMenuItem = false;
IsCheckedVisualSettingsMenuItem = false;
}
@@ -111,12 +105,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 +119,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..078296b 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:ViewNames.ScratchView}"
+ IsChecked="{Binding IsCheckedScratchMenuItem}" />
+ Command="{Binding ShowRegionCommand}"
+ CommandParameter="{x:Static core:ViewNames.SettingsView}"
+ IsChecked="{Binding IsCheckedVisualSettingsMenuItem}"/>
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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml.cs b/Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml.cs
new file mode 100644
index 0000000..efbb24d
--- /dev/null
+++ b/Modules/AdamStudio.Modules.SettingsRegion/Views/SettingsControlView.xaml.cs
@@ -0,0 +1,12 @@
+using System.Windows.Controls;
+
+namespace AdamStudio.Modules.SettingsRegion.Views
+{
+ public partial class SettingsControlView : UserControl
+ {
+ public SettingsControlView()
+ {
+ InitializeComponent();
+ }
+ }
+}
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..8ae4a42 100644
--- a/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs
+++ b/Modules/AdamStudio.Modules.StatusBar/ViewModels/StatusBarViewModel.cs
@@ -4,6 +4,8 @@
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;
using System;
@@ -26,6 +28,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
@@ -43,19 +47,19 @@ public class StatusBarViewModel : RegionViewModelBase
#region ~
- public StatusBarViewModel(IRegionManager regionManager, IFlyoutManager flyoutManager, IFlyoutStateChecker flyoutState, ICommunicationProviderService communicationProviderService,
- IStatusBarNotificationDeliveryService statusBarNotification, ICultureProvider cultureProvider, IControlHelper controlHelper) : base(regionManager)
+ public StatusBarViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
{
- mFlyoutManager = flyoutManager;
- mCommunicationProviderService = communicationProviderService;
- mStatusBarNotificationDelivery = statusBarNotification;
- mFlyoutState = flyoutState;
- mCultureProvider = cultureProvider;
- mControlHelper = controlHelper;
-
+ 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();
}
@@ -76,7 +80,7 @@ private void OpenNotificationPanel()
private bool OpenNotificationPanelCanExecute()
{
- return !mFlyoutState.IsNotificationFlyoutOpened;
+ return !mFlyoutState.IsFlyoutsOpened;
}
#endregion
@@ -214,6 +218,7 @@ private void LoadResource()
mCompileLogStatusBar = mCultureProvider.FindResource("StatusBarViewModel.CompileLogStatusBar");
mAppLogStatusBar = mCultureProvider.FindResource("StatusBarViewModel.AppLogStatusBar");
+
mChangAppLanguageLogMessage = mCultureProvider.FindResource("StatusBarViewModel.ChangAppLanguage.LogMessage");
}
@@ -231,7 +236,7 @@ private void UpdateStatusConnectToolbar()
ConnectIcon = PackIconModernKind.Connect;
}
- AppLogStatusBar = mChangAppLanguageLogMessage;
+ mLogger.LogInformation(mChangAppLanguageLogMessage);
}
#endregion
@@ -246,14 +251,16 @@ private void Subscribe()
mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent += RaiseChangeProgressRingStateEvent;
mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent += RaiseNewCompileLogMessageEvent;
- mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent += RaiseNewAppLogMessageEvent;
mStatusBarNotificationDelivery.RaiseUpdateNotificationCounterEvent += RaiseUpdateNotificationCounterEvent;
- mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent += IsOpenedStateChangeEvent;
+ mFlyoutState.IsFlyoutsOpenedStateChangeEvent += IsOpenedStateChangeEvent;
mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent;
+ mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent;
}
+
+
private void Unsubscribe()
{
mCommunicationProviderService.RaiseTcpServiceCientConnectedEvent -= RaiseAdamTcpCientConnectedEvent;
@@ -262,11 +269,11 @@ private void Unsubscribe()
mStatusBarNotificationDelivery.RaiseChangeProgressRingStateEvent -= RaiseChangeProgressRingStateEvent;
mStatusBarNotificationDelivery.RaiseNewCompileLogMessageEvent -= RaiseNewCompileLogMessageEvent;
- mStatusBarNotificationDelivery.RaiseNewAppLogMessageEvent -= RaiseNewAppLogMessageEvent;
- mFlyoutState.IsNotificationFlyoutOpenedStateChangeEvent -= IsOpenedStateChangeEvent;
+ mFlyoutState.IsFlyoutsOpenedStateChangeEvent -= IsOpenedStateChangeEvent;
mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent -= RaiseCurrentAppCultureLoadOrChangeEvent;
+ mLogWriteEventAwareService.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent;
}
#endregion
@@ -325,8 +332,13 @@ private void RaiseCurrentAppCultureLoadOrChangeEvent(object sender)
UpdateStatusConnectToolbar();
}
+ private void RaiseNewLogMessageWriteEvent(object sender, string message)
+ {
+ AppLogStatusBar = message;
+ }
+
#endregion
-
+
}
}
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 @@
-
-
+ Background="Transparent"
+ Padding="10 0 10 0"
+ Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}"
+ Style="{StaticResource MahApps.Styles.Button.ToolBar}">
-
-
+ BadgeBorderThickness="3"
+ BadgePlacementMode="TopRight"
+ Badge="{Binding NotificationBadge}">
-
-
-
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..cc91303
--- /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..295d590
--- /dev/null
+++ b/Modules/AdamStudio.Modules.ToolBarRegion/ViewModels/ToolBarViewModel.cs
@@ -0,0 +1,361 @@
+using AdamController.WebApi.Client.v1.ResponseModel;
+using AdamStudio.Controls.CustomControls.Services;
+using AdamStudio.Core.Mvvm;
+using AdamStudio.Services.Interfaces;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Prism.Commands;
+using Prism.Regions;
+using System;
+using System.Windows;
+using System.Windows.Threading;
+
+namespace AdamStudio.Modules.ToolBarRegion.ViewModels
+{
+ public class ToolBarViewModel : RegionViewModelBase
+ {
+ #region DelegateCommands
+
+ public DelegateCommand CleanExecuteEditorDelegateCommand { get; }
+
+ #endregion
+
+ #region Services
+
+ private readonly ILogger mLogger;
+ private readonly ILogWriteEventAwareService mLogWriteEventAware;
+ private readonly IPythonRemoteRunnerService mPythonRemoteRunner;
+ private readonly ICultureProvider mCultureProvider;
+ private readonly ITcpClientService mTcpClientService;
+ private readonly IWebApiService mWebApiService;
+ private readonly IFlyoutStateChecker mFlyoutStateChecker;
+
+ #endregion
+
+ #region Var
+
+ private bool mIsWarningStackOwerflowAlreadyShow;
+ private string mFinishAppExecute;
+ private string mWarningStackOwerflow1;
+ private string mWarningStackOwerflow2;
+ private string mWarningStackOwerflow3;
+
+ #endregion
+
+ #region ~
+
+ public ToolBarViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
+ {
+ mLogger = serviceProvider.GetService>();
+ mLogWriteEventAware = serviceProvider.GetService();
+ mPythonRemoteRunner = serviceProvider.GetService();
+ mCultureProvider = serviceProvider.GetService();
+ mTcpClientService = serviceProvider.GetService();
+ mWebApiService = serviceProvider.GetService();
+ mFlyoutStateChecker = serviceProvider.GetService();
+
+ CleanExecuteEditorDelegateCommand = new DelegateCommand(CleanExecuteEditor, CleanExecuteEditorCanExecute);
+ mLogger.LogTrace("Load ~");
+ }
+
+ #endregion
+
+ #region Commands method
+
+ private void CleanExecuteEditor()
+ {
+ ResultText = string.Empty;
+ ResultExecutionTime = null;
+ }
+
+ private bool CleanExecuteEditorCanExecute()
+ {
+ bool isResultNotEmpty = ResultText?.Length > 0;
+ return isResultNotEmpty;
+ }
+
+ #endregion
+
+ #region Navigation
+
+ public override void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback)
+ {
+ base.ConfirmNavigationRequest(navigationContext, continuationCallback);
+ }
+
+ public override void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ Subscribe();
+
+ 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 bool isPythonCodeExecute;
+ public bool IsPythonCodeExecute
+ {
+ get => isPythonCodeExecute;
+ set
+ {
+ 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
+
+ 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;
+ }));
+ }
+
+ private void ClearResults()
+ {
+ ResultText = string.Empty;
+ 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)
+ {
+ PythonVersion = pythonVersion;
+ PythonBinPath = pythonBinPath;
+ PythonWorkDir = pythonWorkDir;
+ }
+
+ 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");
+ }
+
+ private void RaiseDelegateCommandsCanExecuteChanged()
+ {
+ CleanExecuteEditorDelegateCommand.RaiseCanExecuteChanged();
+ }
+
+ #endregion
+
+ #region Events
+
+ private void RaiseNewLogMessageWriteEvent(object sender, string message)
+ {
+ ApplicationLogs += $"{message}\n";
+ }
+
+ private void OnRaisePythonScriptExecuteStart(object sender)
+ {
+ IsPythonCodeExecute = true;
+ mIsWarningStackOwerflowAlreadyShow = false;
+ ClearResults();
+ }
+
+ private void OnRaisePythonScriptExecuteFinish(object sender, ExtendedCommandExecuteResult remoteCommandExecuteResult)
+ {
+ if (remoteCommandExecuteResult == null)
+ return;
+
+ UpdateResultText("", true);
+ UpdateResultExecutionTimeText(remoteCommandExecuteResult);
+ IsPythonCodeExecute = false;
+ }
+
+ private void OnRaisePythonStandartOutput(object sender, string message)
+ {
+ UpdateResultText(message);
+ }
+
+ 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)
+ {
+
+ }
+
+ private void IsNotificationFlyoutOpenedStateChangeEvent(object sender)
+ {
+ if (mFlyoutStateChecker.IsFlyoutsOpened)
+ {
+ LogsButtonIsChecked = false;
+ ResultButtonIsChecked = false;
+ }
+ }
+
+ #endregion
+
+ #region Subscribes
+ private void Subscribe()
+ {
+ mTcpClientService.RaiseTcpCientConnectedEvent += RaiseTcpCientConnectedEvent;
+ mTcpClientService.RaiseTcpClientDisconnectedEvent += RaiseTcpClientDisconnectedEvent;
+
+ mLogWriteEventAware.RaiseNewLogMessageWriteEvent += RaiseNewLogMessageWriteEvent;
+
+ mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent += OnRaisePythonScriptExecuteStart;
+ mPythonRemoteRunner.RaisePythonStandartOutputEvent += OnRaisePythonStandartOutput;
+ mPythonRemoteRunner.RaisePythonScriptExecuteFinishEvent += OnRaisePythonScriptExecuteFinish;
+
+ mCultureProvider.RaiseCurrentAppCultureLoadOrChangeEvent += RaiseCurrentAppCultureLoadOrChangeEvent;
+
+ mFlyoutStateChecker.IsFlyoutsOpenedStateChangeEvent += IsNotificationFlyoutOpenedStateChangeEvent;
+ }
+
+ private void Unsubscribe()
+ {
+ mTcpClientService.RaiseTcpCientConnectedEvent -= RaiseTcpCientConnectedEvent;
+ mTcpClientService.RaiseTcpClientDisconnectedEvent -= RaiseTcpClientDisconnectedEvent;
+
+ mLogWriteEventAware.RaiseNewLogMessageWriteEvent -= RaiseNewLogMessageWriteEvent;
+
+ mPythonRemoteRunner.RaisePythonScriptExecuteStartEvent -= OnRaisePythonScriptExecuteStart;
+ mPythonRemoteRunner.RaisePythonStandartOutputEvent -= OnRaisePythonStandartOutput;
+ 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
new file mode 100644
index 0000000..5cf37bf
--- /dev/null
+++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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..4cbf5ab
--- /dev/null
+++ b/Modules/AdamStudio.Modules.ToolBarRegion/Views/ToolBarView.xaml.cs
@@ -0,0 +1,13 @@
+using System.Windows.Controls;
+
+
+namespace AdamStudio.Modules.ToolBarRegion.Views
+{
+ public partial class ToolBarView : UserControl
+ {
+ public ToolBarView()
+ {
+ InitializeComponent();
+ }
+ }
+}