diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-03-19 02:13:01 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-03-19 02:13:01 +0200 |
| commit | fb8342a8ec237f5646a4807b63c12f6afe3ba290 (patch) | |
| tree | efce179c712ea20d2b8f3d90f39c8d1765d33ea2 | |
| parent | 7320824d1fc827b25327a2aaa3d571480b40975c (diff) | |
| download | Tango-fb8342a8ec237f5646a4807b63c12f6afe3ba290.tar.gz Tango-fb8342a8ec237f5646a4807b63c12f6afe3ba290.zip | |
Improved monitoring.
Implemented RDP keyboard/double click.
8 files changed, 127 insertions, 34 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs index 3bcb2adbd..7ccb40c3f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs @@ -276,10 +276,7 @@ namespace Tango.PPC.Common.RemoteDesktop } else if (request.EventType == MouseEventType.DoubleClick) { - MouseController.MouseEvent(MouseEventFlags.LeftDown); - MouseController.MouseEvent(MouseEventFlags.LeftUp); - MouseController.MouseEvent(MouseEventFlags.LeftDown); - MouseController.MouseEvent(MouseEventFlags.LeftUp); + MouseController.DoubleClick(); } if (receiver != null) @@ -291,6 +288,8 @@ namespace Tango.PPC.Common.RemoteDesktop [ExternalBridgeRequestHandlerMethod(typeof(KeyboardStateRequest))] public async void OnKeyboardStateRequestReceived(KeyboardStateRequest request, String token, ExternalBridgeReceiver receiver) { + Debug.WriteLine($"{request.EventType}, {request.Key}, {request.IsShiftDown}"); + if (request.EventType == KeyboardEventType.Down) { KeyboardController.KeyDown(request.Key, request.IsCtrlDown, request.IsShiftDown, request.IsAltDown); @@ -300,7 +299,10 @@ namespace Tango.PPC.Common.RemoteDesktop KeyboardController.KeyUp(request.Key, request.IsCtrlDown, request.IsShiftDown, request.IsAltDown); } - await receiver.SendGenericResponse(new KeyboardStateResponse(), token); + if (receiver != null) + { + await receiver.SendGenericResponse(new KeyboardStateResponse(), token); + } } private async void _engine_FrameReceived(object sender, ScreenCaptureFrameReceivedEventArgs<RasterFrame> e) @@ -419,6 +421,10 @@ namespace Tango.PPC.Common.RemoteDesktop { OnMouseStateRequestReceived(request as MouseStateRequest, null, null); } + else if (request.GetType() == typeof(KeyboardStateRequest)) + { + OnKeyboardStateRequestReceived(request as KeyboardStateRequest, null, null); + } } catch (Exception ex) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs index 0f1c81416..205013e0c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.WindowsAPICodePack.Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -7,7 +8,11 @@ using Tango.Core; using Tango.Core.DI; using Tango.Integration.ExternalBridge; using Tango.Integration.ExternalBridge.Network.Information; +using Tango.PPC.Common.Application; +using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.ExternalBridge; +using Tango.Settings; +using Tango.SystemInfo; namespace Tango.PPC.Common.SystemInfo { @@ -17,9 +22,13 @@ namespace Tango.PPC.Common.SystemInfo public bool Enabled { get; set; } = true; private GetMachineInformationResponse response; + private IPPCApplicationManager _applicationManager; + private IConnectivityProvider _connectivityProvider; - public DefaultSystemInfoService(IPPCExternalBridgeService externalBridge) + public DefaultSystemInfoService(IPPCExternalBridgeService externalBridge, IPPCApplicationManager applicationManager, IConnectivityProvider connectivityProvider) { + _applicationManager = applicationManager; + _connectivityProvider = connectivityProvider; externalBridge.RegisterRequestHandler(this); } @@ -30,11 +39,80 @@ namespace Tango.PPC.Common.SystemInfo { if (response == null) { + //Get the networks that are currently connected to + var connectedNetwork = NetworkListManager.GetNetworks(NetworkConnectivityLevels.Connected).FirstOrDefault(); + + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + + var system = SystemObjectsCollection.Create(); + + //Add custom information.. + system.Insert(0, new SystemObjectsCollection() + { + Name = "Application", + Objects = new List<SystemObject>() + { + new SystemObject() + { + Name = "Tango PPC", + Properties = new List<SystemObjectProperty>() + { + new SystemObjectProperty() { Name = "Version", Value = _applicationManager.Version.ToString(3) }, + new SystemObjectProperty() { Name = "Build Date", Value = _applicationManager.BuildDate.ToString() }, + new SystemObjectProperty() { Name = "Previous Version", Value = settings.PreviousApplicationVersion.ToString() }, + new SystemObjectProperty() { Name = "Firmware Version", Value = _applicationManager.FirmwareVersion.ToString() }, + new SystemObjectProperty() { Name = "Technician Mode", Value = _applicationManager.IsInTechnicianMode.ToStringYesNo() }, + new SystemObjectProperty() { Name = "After Update", Value = _applicationManager.IsAfterUpdate.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Startup Date", Value = _applicationManager.StartUpDate.ToString() }, + }, + }, + new SystemObject() + { + Name = "Network", + Properties = new List<SystemObjectProperty>() + { + new SystemObjectProperty() { Name = "Network Name", Value = connectedNetwork.Name }, + new SystemObjectProperty() { Name = "Category", Value = connectedNetwork.Category.ToString() }, + new SystemObjectProperty() { Name = "Type", Value = connectedNetwork.Connectivity.ToString() }, + new SystemObjectProperty() { Name = "Domain", Value = connectedNetwork.DomainType.ToString() }, + new SystemObjectProperty() { Name = "Connected Time", Value = connectedNetwork.ConnectedTime.ToString() }, + new SystemObjectProperty() { Name = "Internet Connection", Value = connectedNetwork.IsConnectedToInternet.ToStringYesNo() }, + }, + }, + new SystemObject() + { + Name = "Settings", + Properties = new List<SystemObjectProperty>() + { + new SystemObjectProperty() { Name = "Application State", Value = settings.ApplicationState.ToString() }, + new SystemObjectProperty() { Name = "Auto Update Check", Value = settings.AutoCheckForUpdates.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Auto Update Interval", Value = settings.AutoUpdateCheckInterval.ToString() }, + new SystemObjectProperty() { Name = "Automatic Thread Loading", Value = settings.EnableAutomaticThreadLoading.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Firmware Logs Enabled", Value = settings.EnableEmbeddedDebugLogs.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Emergency Switch Enabled", Value = settings.EnableEmergencyNotifications.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Liquid Quantity Validation Enabled", Value = settings.EnableJobLiquidQuantityValidation.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Remote Assistance Enabled", Value = settings.EnableRemoteAssistance.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Remote Desktop Enabled", Value = settings.EnableRemoteDesktop.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Start in Technician Mode", Value = settings.EnableTechnicianModeByDefault.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Watchdog Enabled", Value = settings.EnableWatchDog.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Job Units Method", Value = settings.JobUnitsMethod.ToString() }, + new SystemObjectProperty() { Name = "PowerUp Screen Enabled", Value = settings.DisplayPowerUpScreen.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Firmware COM Port", Value = settings.EmbeddedComPort.ToString() }, + new SystemObjectProperty() { Name = "Emergency COM Port", Value = settings.EmergencyComPort.ToString() }, + new SystemObjectProperty() { Name = "Job Upload Method", Value = settings.JobUploadStrategy.ToString() }, + new SystemObjectProperty() { Name = "Diagnostics Synchronization", Value = settings.SynchronizeDiagnostics.ToStringYesNo() }, + new SystemObjectProperty() { Name = "Jobs Synchronization", Value = settings.SynchronizeJobs.ToStringYesNo() }, + new SystemObjectProperty() { Name = "TCP Write Mode", Value = settings.TcpTransportAdapterWriteMode.ToString() }, + }.OrderBy(x => x.Name).ToList(), + }, + }, + }); + response = new GetMachineInformationResponse() { Package = new InformationPackage() { - System = Tango.SystemInfo.SystemObjectsCollection.Create(), + System = system, } }; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 664e9e228..ad197f47b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -73,6 +73,9 @@ <Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Microsoft.SqlServer.AzureStorageEnum, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" /> <Reference Include="Microsoft.VisualBasic" /> + <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath> + </Reference> <Reference Include="Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> @@ -452,7 +455,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config index 50785f217..adc33d349 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config @@ -6,6 +6,7 @@ <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" /> <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" /> <package id="Ionic.Zip" version="1.9.1.8" targetFramework="net461" /> + <package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.0" targetFramework="net461" /> <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> <package id="System.Data.SQLite" version="1.0.108.0" targetFramework="net46" /> <package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" /> diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/BooleanExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/BooleanExtensions.cs new file mode 100644 index 000000000..02464dc8e --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/BooleanExtensions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +public static class BooleanExtensions +{ + public static String ToStringYesNo(this Boolean value) + { + return value ? "Yes" : "No"; + } +} + diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 605ba53dc..b4496a368 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -93,6 +93,7 @@ <Compile Include="Components\CmdCommand.cs" /> <Compile Include="CustomAttributes\PropertyIndexAttribute.cs" /> <Compile Include="CustomAttributes\StringFormatAttribute.cs" /> + <Compile Include="ExtensionMethods\BooleanExtensions.cs" /> <Compile Include="ExtensionMethods\ByteArrayExtensions.cs" /> <Compile Include="ExtensionMethods\ZipArchiveExtensions.cs" /> <Compile Include="IO\KnownFolders.cs" /> @@ -206,7 +207,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> <Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs index 832018dac..0c077f1d3 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/Input/KeyboardController.cs @@ -50,30 +50,7 @@ namespace Tango.RemoteDesktop.Input public static void KeyUp(Key key, bool ctrlDown, bool shitDown, bool altDown) { VirtualKeyCode virtualKey = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(key); - - if (ctrlDown || shitDown || altDown) - { - List<VirtualKeyCode> modifierKeys = new List<VirtualKeyCode>(); - - if (ctrlDown) - { - modifierKeys.Add(VirtualKeyCode.LCONTROL); - } - if (shitDown) - { - modifierKeys.Add(VirtualKeyCode.LSHIFT); - } - if (altDown) - { - modifierKeys.Add(VirtualKeyCode.MENU); - } - - simulator.Keyboard.ModifiedKeyStroke(modifierKeys, virtualKey); - } - else - { - simulator.Keyboard.KeyUp(virtualKey); - } + simulator.Keyboard.KeyUp(virtualKey); } } } diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs index ec556f88c..ce3a3eb09 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/Input/MouseController.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; +using WindowsInput; namespace Tango.RemoteDesktop.Input { @@ -33,6 +34,13 @@ namespace Tango.RemoteDesktop.Input [DllImport("user32.dll")] private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); + private static InputSimulator simulator; + + static MouseController() + { + simulator = new InputSimulator(); + } + public static void SetCursorPosition(int x, int y) { SetCursorPos(x, y); @@ -64,6 +72,11 @@ namespace Tango.RemoteDesktop.Input ; } + public static void DoubleClick() + { + simulator.Mouse.LeftButtonDoubleClick(); + } + [StructLayout(LayoutKind.Sequential)] public struct MousePoint { |
