From e774f9a90fd812a9de8c3efe966a759bee8be703 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 11 Mar 2020 03:41:20 +0200 Subject: Working on FSE/PPC performance provider. Implemented resolution service. a lot of work! --- .../Console/DefaultConsoleEngineService.cs | 22 +- .../Performance/DefaultPerformanceService.cs | 227 +++++++++++++++++++++ .../Performance/IPerformanceService.cs | 14 ++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 4 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 3 + 5 files changed, 264 insertions(+), 6 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/IPerformanceService.cs (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs index 42228614e..02d510a93 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Console; +using Tango.Console.Network; using Tango.Core.DI; using Tango.Integration.ExternalBridge; using Tango.PPC.Common.ExternalBridge; @@ -21,16 +22,27 @@ namespace Tango.PPC.Common.Console externalBridge.RegisterRequestHandler(this); } - [ExternalBridgeRequestHandlerMethod(typeof(ConsoleCommandDTO))] - public async void OnConsoleCommandReceived(ConsoleCommandDTO command, String token, ITransporter transporter) + [ExternalBridgeRequestHandlerMethod(typeof(GetCurrentDirectoryRequest))] + public async void OnGetCurrentDirectoryRequest(GetCurrentDirectoryRequest request, String token, ITransporter transporter) + { + await transporter.SendGenericResponse(new GetCurrentDirectoryResponse() { CurrentDirectory = Environment.CurrentDirectory }, token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(ConsoleCommandRequest))] + public async void OnConsoleCommandRequest(ConsoleCommandRequest request, String token, ITransporter transporter) { if (Enabled) { try { ConsoleExecutionEngine engine = new ConsoleExecutionEngine(); - var result = await engine.Execute(command); - await transporter.SendGenericResponse(result, token, new TransportResponseConfig() + var result = await engine.Execute(request); + await transporter.SendGenericResponse(new ConsoleCommandResponse() + { + Output = result.Output, + Suggestions = result.Suggestions, + WorkingFolder = result.WorkingFolder + }, token, new TransportResponseConfig() { Immediate = true, }); @@ -44,7 +56,7 @@ namespace Tango.PPC.Common.Console public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) { - + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs new file mode 100644 index 000000000..700cc0d47 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs @@ -0,0 +1,227 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.DI; +using Tango.Integration.ExternalBridge; +using Tango.Integration.ExternalBridge.Network.Performance; +using Tango.PPC.Common.ExternalBridge; + +namespace Tango.PPC.Common.Performance +{ + [TangoCreateWhenRegistered] + public class DefaultPerformanceService : ExtendedObject, IPerformanceService + { + #region Nested Classes + + public static class PerformanceInfo + { + [DllImport("psapi.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size); + + [StructLayout(LayoutKind.Sequential)] + public struct PerformanceInformation + { + public int Size; + public IntPtr CommitTotal; + public IntPtr CommitLimit; + public IntPtr CommitPeak; + public IntPtr PhysicalTotal; + public IntPtr PhysicalAvailable; + public IntPtr SystemCache; + public IntPtr KernelTotal; + public IntPtr KernelPaged; + public IntPtr KernelNonPaged; + public IntPtr PageSize; + public int HandlesCount; + public int ProcessCount; + public int ThreadCount; + } + + public static Int64 GetPhysicalAvailableMemoryInMiB() + { + PerformanceInformation pi = new PerformanceInformation(); + if (GetPerformanceInfo(out pi, Marshal.SizeOf(pi))) + { + return Convert.ToInt64((pi.PhysicalAvailable.ToInt64() * pi.PageSize.ToInt64() / 1048576)); + } + else + { + return -1; + } + + } + + public static Int64 GetTotalMemoryInMiB() + { + PerformanceInformation pi = new PerformanceInformation(); + if (GetPerformanceInfo(out pi, Marshal.SizeOf(pi))) + { + return Convert.ToInt64((pi.PhysicalTotal.ToInt64() * pi.PageSize.ToInt64() / 1048576)); + } + else + { + return -1; + } + + } + } + + #endregion + + private class PerformanceClient + { + public ExternalBridgeReceiver Receiver { get; set; } + public String Token { get; set; } + } + + private List _clients; + private PerformancePackage _package; + private bool _isStarted; + private Thread _performanceThread; + + public bool Enabled { get; set; } = true; + + public DefaultPerformanceService(IPPCExternalBridgeService externalBridge) + { + _package = new PerformancePackage(); + _clients = new List(); + externalBridge.RegisterRequestHandler(this); + } + + [ExternalBridgeRequestHandlerMethod(typeof(StartPerformanceUpdatesRequest))] + public async void OnStartPerformanceUpdatesRequest(StartPerformanceUpdatesRequest request, String token, ExternalBridgeReceiver receiver) + { + if (Enabled) + { + try + { + if (!_clients.Exists(x => x.Receiver == receiver)) + { + _clients.Add(new PerformanceClient() { Receiver = receiver, Token = token }); + OnReceiversChanged(); + } + + await receiver.SendGenericResponse(new StartPerformanceUpdatesResponse() { Package = _package }, token); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error sending performance package."); + } + } + } + + public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) + { + _clients.RemoveAll(x => x.Receiver == receiver); + OnReceiversChanged(); + } + + private void OnReceiversChanged() + { + if (_clients.Count > 0 && !_isStarted) + { + _isStarted = true; + _performanceThread = new Thread(PerformanceThreadMethod); + _performanceThread.IsBackground = true; + _performanceThread.Start(); + } + else if (_clients.Count == 0 && _isStarted) + { + _isStarted = false; + } + } + + private async void PerformanceThreadMethod() + { + while (_isStarted) + { + try + { + _package.ApplicationCPU = (int)GetAppCPU(); + _package.CPU = (int)GetTotalCPU(); + _package.ApplicationRAM = (int)BytesToMegaBytes(GetAppRam()); + _package.RAM = (int)PerformanceInfo.GetTotalMemoryInMiB(); + _package.MaxRAM = (int)PerformanceInfo.GetPhysicalAvailableMemoryInMiB(); + + DriveInfo info = new DriveInfo("C"); + _package.DiskCapacity = (int)BytesToMegaBytes(info.TotalSize); + _package.AvailableDiskSpace = (int)BytesToMegaBytes(info.AvailableFreeSpace); + _package.DateTime = DateTime.Now; + + foreach (var client in _clients.ToList()) + { + try + { + await client.Receiver.SendGenericResponse(new StartPerformanceUpdatesResponse() { Package = _package }, client.Token); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error sending performance package."); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error creating performance package."); + } + + Thread.Sleep(2000); + } + } + + #region Helpers + + private float BytesToMegaBytes(long bytes) + { + return bytes / 1024f / 1024f; + } + + public float GetAppCPU() + { + PerformanceCounter cpuCounter = new PerformanceCounter(); + cpuCounter.CategoryName = "Process"; + cpuCounter.CounterName = "% Processor Time"; + cpuCounter.InstanceName = Process.GetCurrentProcess().ProcessName; + + // will always start at 0 + float firstValue = cpuCounter.NextValue(); + System.Threading.Thread.Sleep(1000); + // now matches task manager reading + float secondValue = cpuCounter.NextValue(); + + return secondValue / Environment.ProcessorCount; + } + + public float GetTotalCPU() + { + PerformanceCounter cpuCounter = new PerformanceCounter(); + cpuCounter.CategoryName = "Processor"; + cpuCounter.CounterName = "% Processor Time"; + cpuCounter.InstanceName = "_Total"; + + // will always start at 0 + float firstValue = cpuCounter.NextValue(); + System.Threading.Thread.Sleep(1000); + // now matches task manager reading + float secondValue = cpuCounter.NextValue(); + + return secondValue; + } + + public long GetAppRam() + { + Process proc = Process.GetCurrentProcess(); + return proc.PrivateMemorySize64; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/IPerformanceService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/IPerformanceService.cs new file mode 100644 index 000000000..c3bfd1543 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/IPerformanceService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.ExternalBridge; + +namespace Tango.PPC.Common.Performance +{ + public interface IPerformanceService : IExternalBridgeRequestHandler + { + bool Enabled { get; set; } + } +} 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 f7b3f9e4c..df6b881a0 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 @@ -159,6 +159,8 @@ + + @@ -437,7 +439,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index a8cbcfe2d..da6c630d4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -20,6 +20,7 @@ using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.OS; +using Tango.PPC.Common.Performance; using Tango.PPC.Common.Printing; using Tango.PPC.Common.RemoteAssistance; using Tango.PPC.Common.RemoteDesktop; @@ -82,6 +83,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); if (App.StartupArgs.Contains("-webDebug")) { @@ -117,6 +119,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); -- cgit v1.3.1 From 755f37e3e3e553a91dd2c5a7f0ddad8359287a3b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 12 Mar 2020 17:15:11 +0200 Subject: Working on FSE/PPC monitoring/system info. --- .../FSE/Modules/Tango.FSE.PPCConsole/App.xaml | 1 + .../Converters/DoubleToChartValuesConverter.cs | 23 + .../Tango.FSE.PPCConsole.csproj | 27 + .../Tango.FSE.PPCConsole/ViewModelLocator.cs | 9 + .../Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs | 2 +- .../ViewModels/MonitoringViewVM.cs | 182 +++ .../Tango.FSE.PPCConsole/Views/MainView.xaml | 2 +- .../Tango.FSE.PPCConsole/Views/MonitoringView.xaml | 184 +++ .../Views/MonitoringView.xaml.cs | 33 + .../Modules/Tango.FSE.PPCConsole/packages.config | 2 + .../FSE/Tango.FSE.Common/Controls/FSEPanel.cs | 49 + .../FSE/Tango.FSE.Common/Controls/FSEPanel.xaml | 36 + .../FSE/Tango.FSE.Common/FSEViewModel.cs | 7 + .../FSE/Tango.FSE.Common/Graphs/GraphHelper.cs | 37 + .../FSE/Tango.FSE.Common/Graphs/RealTimeGraph.cs | 101 ++ .../FSE/Tango.FSE.Common/Graphs/RealTimeGraph.xaml | 62 + .../FSE/Tango.FSE.Common/Images/screw.png | Bin 0 -> 937 bytes .../FSE/Tango.FSE.Common/Resources/Colors.xaml | 43 +- .../FSE/Tango.FSE.Common/Resources/Controls.xaml | 1 + .../FSE/Tango.FSE.Common/Resources/Graphs.xaml | 9 + .../FSE/Tango.FSE.Common/Resources/Images.xaml | 1 + .../SystemInfo/ISystemInfoProvider.cs | 14 + .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 28 +- Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml | 1 + .../SystemInfo/DefaultSystemInfoProvider.cs | 39 + .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 1 + .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 4 + .../Performance/DefaultPerformanceService.cs | 6 +- .../SystemInfo/DefaultSystemInfoService.cs | 55 + .../SystemInfo/ISystemInfoService.cs | 13 + .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 9 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 3 + .../RealTimeGraphX.WPF/Themes/Generic.xaml | 2 +- .../RealTimeGraphX.WPF/WpfGraphAxisControl.cs | 38 +- .../RealTimeGraphX.WPF/WpfGraphAxisPanel.cs | 2 +- .../RealTimeGraphX.WPF/WpfGraphDataSeries.cs | 10 + .../RealTimeGraphX.WPF/WpfGraphSurface.cs | 21 +- .../RealTimeGraphX/DataPoints/DateTimeDataPoint.cs | 178 +++ .../RealTimeGraphX/DataPoints/Int32DataPoint.cs | 13 +- .../RealTimeGraphX/GraphController.cs | 114 +- .../RealTimeGraphX/IGraphDataSeries.cs | 5 + .../RealTimeGraphX/IGraphSurface.cs | 10 + .../Renderers/ScrollingLineRenderer.cs | 2 +- .../Information/GetMachineInformationResponse.cs | 1 + .../Network/Information/InformationPackage.cs | 5 +- .../Network/Information/MachineProperty.cs | 14 - .../Tango.Integration/Tango.Integration.csproj | 7 +- .../Visual_Studio/Tango.SystemInfo/Connection.cs | 83 ++ Software/Visual_Studio/Tango.SystemInfo/IWMI.cs | 11 + .../Tango.SystemInfo/Properties/AssemblyInfo.cs | 36 + .../Visual_Studio/Tango.SystemInfo/SystemObject.cs | 31 + .../Tango.SystemInfo/SystemObjectProperty.cs | 12 + .../Tango.SystemInfo/SystemObjectsCollection.cs | 111 ++ .../Tango.SystemInfo/Tango.SystemInfo.csproj | 102 ++ .../Visual_Studio/Tango.SystemInfo/WMIReader.cs | 60 + .../Visual_Studio/Tango.SystemInfo/Win32_BIOS.cs | 25 + .../Tango.SystemInfo/Win32_BaseBoard.cs | 27 + .../Tango.SystemInfo/Win32_Battery.cs | 25 + .../Visual_Studio/Tango.SystemInfo/Win32_Bus.cs | 25 + .../Tango.SystemInfo/Win32_CDROMDrive.cs | 25 + .../Tango.SystemInfo/Win32_DMAChannel.cs | 25 + .../Tango.SystemInfo/Win32_DiskDrive.cs | 25 + .../Visual_Studio/Tango.SystemInfo/Win32_Fan.cs | 25 + .../Tango.SystemInfo/Win32_FloppyController.cs | 25 + .../Tango.SystemInfo/Win32_FloppyDrive.cs | 25 + .../Tango.SystemInfo/Win32_IDEController.cs | 25 + .../Tango.SystemInfo/Win32_IRQResource.cs | 25 + .../Tango.SystemInfo/Win32_Keyboard.cs | 25 + .../Tango.SystemInfo/Win32_MemoryDevice.cs | 25 + .../Tango.SystemInfo/Win32_NetworkAdapter.cs | 25 + .../Win32_NetworkAdapterConfiguration.cs | 25 + .../Tango.SystemInfo/Win32_OnBoardDevice.cs | 25 + .../Tango.SystemInfo/Win32_OperatingSystem.cs | 21 + .../Tango.SystemInfo/Win32_PCMCIController.cs | 25 + .../Tango.SystemInfo/Win32_POTSModem.cs | 25 + .../Tango.SystemInfo/Win32_ParallelPort.cs | 25 + .../Tango.SystemInfo/Win32_PhysicalMedia.cs | 25 + .../Tango.SystemInfo/Win32_PhysicalMemory.cs | 25 + .../Tango.SystemInfo/Win32_PortConnector.cs | 25 + .../Tango.SystemInfo/Win32_PortResource.cs | 25 + .../Tango.SystemInfo/Win32_Processor.cs | 25 + .../Tango.SystemInfo/Win32_SCSIController.cs | 25 + .../Tango.SystemInfo/Win32_SerialPort.cs | 25 + .../Win32_SerialPortConfiguration.cs | 25 + .../Tango.SystemInfo/Win32_SoundDevice.cs | 25 + .../Tango.SystemInfo/Win32_SystemEnclosure.cs | 25 + .../Tango.SystemInfo/Win32_TapeDrive.cs | 25 + .../Tango.SystemInfo/Win32_TemperatureProbe.cs | 25 + .../Tango.SystemInfo/Win32_USBController.cs | 25 + .../Visual_Studio/Tango.SystemInfo/Win32_USBHub.cs | 25 + .../Win32_UninterruptiblePowerSupply.cs | 25 + .../Tango.SystemInfo/Win32_VideoController.cs | 25 + .../Tango.SystemInfo/Win32_VoltageProbe.cs | 25 + .../Visual_Studio/Tango.SystemInfo/XMLConfig.cs | 29 + .../Visual_Studio/Tango.SystemInfo/settings.xml | 1347 ++++++++++++++++++++ Software/Visual_Studio/Tango.sln | 54 +- 96 files changed, 4166 insertions(+), 64 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Converters/DoubleToChartValuesConverter.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/GraphHelper.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Images/screw.png create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Graphs.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs create mode 100644 Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/DateTimeDataPoint.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/MachineProperty.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Connection.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/IWMI.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/SystemObject.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/SystemObjectProperty.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/SystemObjectsCollection.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Tango.SystemInfo.csproj create mode 100644 Software/Visual_Studio/Tango.SystemInfo/WMIReader.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_BIOS.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_BaseBoard.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_Battery.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_Bus.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_CDROMDrive.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_DMAChannel.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_DiskDrive.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_Fan.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyController.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyDrive.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_IDEController.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_IRQResource.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_Keyboard.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_MemoryDevice.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapter.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapterConfiguration.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_OnBoardDevice.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_OperatingSystem.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_PCMCIController.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_POTSModem.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_ParallelPort.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMedia.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMemory.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_PortConnector.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_PortResource.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_Processor.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_SCSIController.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPort.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPortConfiguration.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_SoundDevice.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_SystemEnclosure.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_TapeDrive.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_TemperatureProbe.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_USBController.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_USBHub.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_UninterruptiblePowerSupply.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_VideoController.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/Win32_VoltageProbe.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/XMLConfig.cs create mode 100644 Software/Visual_Studio/Tango.SystemInfo/settings.xml (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/App.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/App.xaml index cfb949890..cf17cb88e 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/App.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/App.xaml @@ -39,6 +39,7 @@ + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Converters/DoubleToChartValuesConverter.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Converters/DoubleToChartValuesConverter.cs new file mode 100644 index 000000000..1ac86b849 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Converters/DoubleToChartValuesConverter.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.FSE.PPCConsole.Converters +{ + public class DoubleToChartValuesConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return new LiveCharts.ChartValues() { (double)value }; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj index 0948b8f5c..dd869dcfe 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj @@ -49,6 +49,12 @@ ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + ..\..\..\packages\LiveCharts.0.9.7\lib\net45\LiveCharts.dll + + + ..\..\..\packages\LiveCharts.Wpf.0.9.7\lib\net45\LiveCharts.Wpf.dll + ..\..\..\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll @@ -98,10 +104,12 @@ + + ConsoleView.xaml @@ -109,6 +117,9 @@ MainView.xaml + + MonitoringView.xaml + RemoteDesktopView.xaml @@ -143,6 +154,14 @@ + + {6b9774f7-960d-438e-ad81-c6b9be328d50} + RealTimeGraphX.WPF + + + {f13a489c-80ee-4cd0-bdd4-92d959215646} + RealTimeGraphX + {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete @@ -183,6 +202,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {997a961c-beda-4b56-aa0f-c39e532f7ffa} + Tango.SystemInfo + {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport @@ -213,6 +236,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs index 1d07a1684..88b16a04f 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs @@ -15,6 +15,7 @@ namespace Tango.FSE.PPCConsole TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } public static MainViewVM MainViewVM @@ -40,5 +41,13 @@ namespace Tango.FSE.PPCConsole return TangoIOC.Default.GetInstance(); } } + + public static MonitoringViewVM MonitoringViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs index 8b9c4169a..1dbb37fdc 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs @@ -17,6 +17,7 @@ namespace Tango.FSE.PPCConsole.ViewModels { ConsoleView, RemoteDesktopView, + MonitoringView, } private NavigationView _selectedView; @@ -36,7 +37,6 @@ namespace Tango.FSE.PPCConsole.ViewModels SelectedView = NavigationView.RemoteDesktopView; } - public override void OnApplicationReady() { base.OnApplicationReady(); diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs new file mode 100644 index 000000000..4562cab75 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs @@ -0,0 +1,182 @@ +using LiveCharts; +using RealTimeGraphX.DataPoints; +using RealTimeGraphX.WPF; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; +using Tango.FSE.Common; +using Tango.FSE.Common.Graphs; +using Tango.FSE.Common.Performance; +using Tango.Integration.ExternalBridge.Network.Information; +using Tango.SystemInfo; +using static Tango.SharedUI.Controls.NavigationControl; + +namespace Tango.FSE.PPCConsole.ViewModels +{ + public class MonitoringViewVM : FSEViewModel, INavigationViewModel + { + public WpfGraphController CPUController { get; set; } + + public WpfGraphController RAMController { get; set; } + + public Func DiskSpacePointLabel { get; set; } + + private InformationPackage _systemInfo; + public InformationPackage SystemInfo + { + get { return _systemInfo; } + set { _systemInfo = value; RaisePropertyChangedAuto(); } + } + + private SystemObjectsCollection _selectedSystemObjectCollection; + public SystemObjectsCollection SelectedSystemObjectCollection + { + get { return _selectedSystemObjectCollection; } + set { _selectedSystemObjectCollection = value; RaisePropertyChangedAuto(); } + } + + private bool _fetchingSystemInfo; + public bool FetchingSystemInfo + { + get { return _fetchingSystemInfo; } + set { _fetchingSystemInfo = value; RaisePropertyChangedAuto(); } + } + + private double _usedDiskSpace; + public double UsedDiskSpace + { + get { return _usedDiskSpace; } + set + { + if (_usedDiskSpace != value) + { + _usedDiskSpace = value; + RaisePropertyChangedAuto(); + } + } + } + + private double _availableDiskSpace; + public double AvailableDiskSpace + { + get { return _availableDiskSpace; } + set + { + if (_availableDiskSpace != value) + { + _availableDiskSpace = value; + RaisePropertyChangedAuto(); + } + } + } + + public MonitoringViewVM() + { + CPUController = CreateController(CreateSeries("Total", GraphHelper.GraphColor.White), CreateSeries("Application", GraphHelper.GraphColor.Red)); + RAMController = CreateController(CreateSeries("Total", GraphHelper.GraphColor.White), CreateSeries("Application", GraphHelper.GraphColor.Yellow)); + UsedDiskSpace = 1000 * 40; + AvailableDiskSpace = 1000 * 60; + DiskSpacePointLabel = (point) => + { + return $"{(point.Y / 1000d).ToString("0.0")} GB"; + }; + } + + private WpfGraphController CreateController(params WpfGraphDataSeries[] seriesCollection) + { + var controller = new WpfGraphController(); + + foreach (var series in seriesCollection) + { + controller.DataSeriesCollection.Add(series); + } + + controller.Range.AutoY = false; + controller.Range.MaximumY = 100; + controller.Range.MinimumY = 0; + controller.Range.MaximumX = new DateTime(0).AddMinutes(1); + + controller.RefreshRate = TimeSpan.FromMilliseconds(100); + + return controller; + } + + private WpfGraphDataSeries CreateSeries(String name, GraphHelper.GraphColor fill) + { + WpfGraphDataSeries series = new WpfGraphDataSeries(); + series.Name = name; + series.Fill = GraphHelper.GetGraphBrush(fill); + series.StrokeThickness = 1; + series.Stroke = GraphHelper.GetGraphStrokeColor(); + return series; + } + + public override void OnApplicationStarted() + { + base.OnApplicationStarted(); + PerformanceProvider.PerformancePackageAvailable += PerformanceProvider_PerformancePackageAvailable; + MachineProvider.MachineDisconnected += MachineProvider_MachineDisconnected; + } + + private void MachineProvider_MachineDisconnected(object sender, Common.Connection.MachineDisconnectedEventArgs e) + { + SystemInfo = null; + } + + private void PerformanceProvider_PerformancePackageAvailable(object sender, PerformancePackageEventArgs e) + { + List xx = new List() + { + DateTime.Now, + DateTime.Now + }; + + //CPU + CPUController.PushData(xx, new List() + { + e.Package.CPU, + e.Package.ApplicationCPU + }); + + //App RAM + RAMController.Range.MaximumY = e.Package.MaxRAM; + RAMController.PushData(xx, new List() + { + e.Package.RAM, + e.Package.ApplicationRAM + }); + + UsedDiskSpace = e.Package.DiskCapacity - e.Package.AvailableDiskSpace; + AvailableDiskSpace = e.Package.AvailableDiskSpace; + } + + public override async void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (SystemInfo == null) + { + try + { + FetchingSystemInfo = true; + SystemInfo = await SystemInfoProvider.GetSystemInformationPackage(); + SelectedSystemObjectCollection = SystemInfo.System.FirstOrDefault(); + } + catch (Exception ex) + { + FetchingSystemInfo = false; + LogManager.Log(ex, "Error retrieving system information from remote machine."); + await NotificationProvider.ShowWarning("Error retrieving the remote machine tablet system information."); + } + finally + { + FetchingSystemInfo = false; + } + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml index 1b7a6ceea..e94c05041 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml @@ -33,7 +33,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml new file mode 100644 index 000000000..fbe53327f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CPU + + + + + + + + + + + + + + + + + + + + RAM + + + + + + + + + + + + AVAILABLE DISK SPACE + + + + + + + + + + + + + SYSTEM INFORMATION + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml.cs new file mode 100644 index 000000000..84672dd50 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MonitoringView.xaml.cs @@ -0,0 +1,33 @@ +using LiveCharts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.PPCConsole.Views +{ + /// + /// Interaction logic for MonitoringView.xaml + /// + public partial class MonitoringView : UserControl + { + public Func PointLabel { get; set; } + + public MonitoringView() + { + PointLabel = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation); + + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config index c795da787..626240206 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config @@ -4,6 +4,8 @@ + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.cs new file mode 100644 index 000000000..3eaabb595 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.Common.Controls +{ + public class FSEPanel : ContentControl + { + public CornerRadius CornerRadius + { + get { return (CornerRadius)GetValue(CornerRadiusProperty); } + set { SetValue(CornerRadiusProperty, value); } + } + public static readonly DependencyProperty CornerRadiusProperty = + DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(FSEPanel), new PropertyMetadata(default(CornerRadius))); + + public double ScrewSize + { + get { return (double)GetValue(ScrewSizeProperty); } + set { SetValue(ScrewSizeProperty, value); } + } + public static readonly DependencyProperty ScrewSizeProperty = + DependencyProperty.Register("ScrewSize", typeof(double), typeof(FSEPanel), new PropertyMetadata(10.0)); + + public Thickness ScrewMargin + { + get { return (Thickness)GetValue(ScrewMarginProperty); } + set { SetValue(ScrewMarginProperty, value); } + } + public static readonly DependencyProperty ScrewMarginProperty = + DependencyProperty.Register("ScrewMargin", typeof(Thickness), typeof(FSEPanel), new PropertyMetadata(default(Thickness))); + + static FSEPanel() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(FSEPanel), new FrameworkPropertyMetadata(typeof(FSEPanel))); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.xaml new file mode 100644 index 000000000..986899490 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSEPanel.xaml @@ -0,0 +1,36 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs index 75d9e593c..5d560d754 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs @@ -24,6 +24,7 @@ using Tango.FSE.Common.Notifications; using Tango.FSE.Common.Performance; using Tango.FSE.Common.RemoteDesktop; using Tango.FSE.Common.Resolution; +using Tango.FSE.Common.SystemInfo; using Tango.Settings; using Tango.SharedUI; using static Tango.SharedUI.Controls.NavigationControl; @@ -98,6 +99,12 @@ namespace Tango.FSE.Common [TangoInject] public IPerformanceProvider PerformanceProvider { get; set; } + /// + /// Gets or sets the system information provider. + /// + [TangoInject] + public ISystemInfoProvider SystemInfoProvider { get; set; } + /// /// Gets or sets the resolution service. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/GraphHelper.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/GraphHelper.cs new file mode 100644 index 000000000..7227f5f0d --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/GraphHelper.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; + +namespace Tango.FSE.Common.Graphs +{ + public static class GraphHelper + { + public enum GraphColor + { + White, + Red, + Yellow, + Green, + Orange + } + + public static Color GetGraphColor(GraphColor graphColor) + { + return (Color)Application.Current.Resources[$"FSE_RealTimeGraph_{graphColor.ToString()}"]; + } + + public static Brush GetGraphBrush(GraphColor graphColor) + { + return new SolidColorBrush(GetGraphColor(graphColor)); + } + + public static Color GetGraphStrokeColor() + { + return (Color)Application.Current.Resources["FSE_RealTimeGraph_ForegroundColor"]; + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.cs new file mode 100644 index 000000000..5a2dd3eed --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.cs @@ -0,0 +1,101 @@ +using RealTimeGraphX; +using System; +using System.Windows; +using System.Windows.Controls; + +namespace Tango.FSE.Common.Graphs +{ + public class RealTimeGraph : Control + { + /// + /// Gets or sets the graph controller. + /// + public IGraphController Controller + { + get { return (IGraphController)GetValue(ControllerProperty); } + set { SetValue(ControllerProperty, value); } + } + public static readonly DependencyProperty ControllerProperty = + DependencyProperty.Register("Controller", typeof(IGraphController), typeof(RealTimeGraph), new PropertyMetadata(null)); + + + /// + /// Gets or sets the string format of the y-axis. + /// + public String StringFormat + { + get { return (String)GetValue(StringFormatProperty); } + set { SetValue(StringFormatProperty, value); } + } + public static readonly DependencyProperty StringFormatProperty = + DependencyProperty.Register("StringFormat", typeof(String), typeof(RealTimeGraph), new PropertyMetadata("0.0")); + + + /// + /// Gets or sets the display name. + /// + public String DisplayName + { + get { return (String)GetValue(DisplayNameProperty); } + set { SetValue(DisplayNameProperty, value); } + } + public static readonly DependencyProperty DisplayNameProperty = + DependencyProperty.Register("DisplayName", typeof(String), typeof(RealTimeGraph), new PropertyMetadata(null)); + + + /// + /// Gets or sets the display units. + /// + public String DisplayUnits + { + get { return (String)GetValue(DisplayUnitsProperty); } + set { SetValue(DisplayUnitsProperty, value); } + } + public static readonly DependencyProperty DisplayUnitsProperty = + DependencyProperty.Register("DisplayUnits", typeof(String), typeof(RealTimeGraph), new PropertyMetadata(null)); + + /// + /// Gets or sets the graph label visibility. + /// + public Visibility GraphLabelVisibility + { + get { return (Visibility)GetValue(GraphLabelVisibilityProperty); } + set { SetValue(GraphLabelVisibilityProperty, value); } + } + public static readonly DependencyProperty GraphLabelVisibilityProperty = + DependencyProperty.Register("GraphLabelVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible)); + + + /// + /// Gets or sets the vertical ticks. + /// + public int VerticalTicks + { + get { return (int)GetValue(VerticalTicksProperty); } + set { SetValue(VerticalTicksProperty, value); } + } + public static readonly DependencyProperty VerticalTicksProperty = + DependencyProperty.Register("VerticalTicks", typeof(int), typeof(RealTimeGraph), new PropertyMetadata(10)); + + + /// + /// Gets or sets the horizontal ticks. + /// + public int HorizontalTicks + { + get { return (int)GetValue(HorizontalTicksProperty); } + set { SetValue(HorizontalTicksProperty, value); } + } + public static readonly DependencyProperty HorizontalTicksProperty = + DependencyProperty.Register("HorizontalTicks", typeof(int), typeof(RealTimeGraph), new PropertyMetadata(10)); + + + /// + /// Initializes the class. + /// + static RealTimeGraph() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(RealTimeGraph), new FrameworkPropertyMetadata(typeof(RealTimeGraph))); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.xaml new file mode 100644 index 000000000..64f7e300e --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Graphs/RealTimeGraph.xaml @@ -0,0 +1,62 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Images/screw.png b/Software/Visual_Studio/FSE/Tango.FSE.Common/Images/screw.png new file mode 100644 index 000000000..46a8134fe Binary files /dev/null and b/Software/Visual_Studio/FSE/Tango.FSE.Common/Images/screw.png differ diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Colors.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Colors.xaml index 27ba83315..1a355ebf0 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Colors.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Colors.xaml @@ -13,7 +13,7 @@ #707070 #03A9F4 #009FE7 - + #FF4C4C #FF914C #6DFF72 @@ -27,6 +27,21 @@ #FF6F6F #8EFF6F #FA9252 + #FFB84B + + #18FFFFFF + #B6FF6F6F + #BBFFB84B + #B958C13B + #BBFA9252 + + #7C98B3 + #202020 + #505050 + #303030 + + #202020 + #252525 @@ -39,7 +54,7 @@ - + @@ -54,7 +69,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -69,7 +104,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml index bc2425b0e..b4afcd7f2 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml @@ -6,6 +6,7 @@ + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Graphs.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Graphs.xaml new file mode 100644 index 000000000..813fb9841 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Graphs.xaml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Images.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Images.xaml index cad9b5f0d..c0ce6434d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Images.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Images.xaml @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs new file mode 100644 index 000000000..d21224c4d --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.ExternalBridge.Network.Information; + +namespace Tango.FSE.Common.SystemInfo +{ + public interface ISystemInfoProvider + { + Task GetSystemInformationPackage(); + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index 119ab74d4..58b12d625 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -91,6 +91,7 @@ ConnectedMachineIcon.xaml + @@ -107,6 +108,8 @@ + + @@ -128,6 +131,7 @@ + @@ -139,6 +143,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -151,6 +159,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -167,6 +179,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -236,6 +252,14 @@ + + {6b9774f7-960d-438e-ad81-c6b9be328d50} + RealTimeGraphX.WPF + + + {f13a489c-80ee-4cd0-bdd4-92d959215646} + RealTimeGraphX + {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete @@ -311,7 +335,9 @@ - + + + REM nswag run "$(SolutionDir)Web\Tango.MachineService.Gateway\Nswag\GatewayClient.nswag" /variables:assembly="$(SolutionDir)Web\Tango.MachineService.Gateway\bin\Tango.MachineService.Gateway.dll",output="$(ProjectDir)Gateway\GatewayClient.cs" diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml index de6694069..7b311a10a 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml @@ -57,6 +57,7 @@ + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs new file mode 100644 index 000000000..cfa840793 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.DI; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.SystemInfo; +using Tango.Integration.ExternalBridge.Network.Information; + +namespace Tango.FSE.UI.SystemInfo +{ + public class DefaultSystemInfoProvider : ExtendedObject, ISystemInfoProvider + { + private InformationPackage _package; + + [TangoInject] + private IMachineProvider MachineProvider { get; set; } + + public async Task GetSystemInformationPackage() + { + if (_package == null) + { + var response = await MachineProvider.MachineOperator.SendGenericRequest(new GetMachineInformationRequest(), new Transport.TransportRequestConfig() + { + Timeout = TimeSpan.FromSeconds(30) + }); + + _package = response.Package; + return _package; + } + else + { + return _package; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index eb59d67d0..ab7fe2cb7 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -153,6 +153,7 @@ + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs index 52be9581c..dab997c58 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs @@ -18,6 +18,7 @@ using Tango.FSE.Common.Notifications; using Tango.FSE.Common.Performance; using Tango.FSE.Common.RemoteDesktop; using Tango.FSE.Common.Resolution; +using Tango.FSE.Common.SystemInfo; using Tango.FSE.Common.Threading; using Tango.FSE.Common.Web; using Tango.FSE.UI.Authentication; @@ -32,6 +33,7 @@ using Tango.FSE.UI.Notifications; using Tango.FSE.UI.Performance; using Tango.FSE.UI.RemoteDesktop; using Tango.FSE.UI.Resolution; +using Tango.FSE.UI.SystemInfo; using Tango.FSE.UI.Threading; using Tango.FSE.UI.ViewModels; @@ -55,6 +57,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); @@ -77,6 +80,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs index 700cc0d47..2279d204c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs @@ -148,8 +148,8 @@ namespace Tango.PPC.Common.Performance _package.ApplicationCPU = (int)GetAppCPU(); _package.CPU = (int)GetTotalCPU(); _package.ApplicationRAM = (int)BytesToMegaBytes(GetAppRam()); - _package.RAM = (int)PerformanceInfo.GetTotalMemoryInMiB(); - _package.MaxRAM = (int)PerformanceInfo.GetPhysicalAvailableMemoryInMiB(); + _package.MaxRAM = (int)BytesToMegaBytes((long)new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory); + _package.RAM = _package.MaxRAM - (int)PerformanceInfo.GetPhysicalAvailableMemoryInMiB(); DriveInfo info = new DriveInfo("C"); _package.DiskCapacity = (int)BytesToMegaBytes(info.TotalSize); @@ -173,7 +173,7 @@ namespace Tango.PPC.Common.Performance LogManager.Log(ex, "Error creating performance package."); } - Thread.Sleep(2000); + Thread.Sleep(200); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs new file mode 100644 index 000000000..0f1c81416 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.DI; +using Tango.Integration.ExternalBridge; +using Tango.Integration.ExternalBridge.Network.Information; +using Tango.PPC.Common.ExternalBridge; + +namespace Tango.PPC.Common.SystemInfo +{ + [TangoCreateWhenRegistered] + public class DefaultSystemInfoService : ExtendedObject, ISystemInfoService, IExternalBridgeRequestHandler + { + public bool Enabled { get; set; } = true; + + private GetMachineInformationResponse response; + + public DefaultSystemInfoService(IPPCExternalBridgeService externalBridge) + { + externalBridge.RegisterRequestHandler(this); + } + + [ExternalBridgeRequestHandlerMethod(typeof(GetMachineInformationRequest))] + public async void OnGetMachineInformationRequest(GetMachineInformationRequest request, String token, ExternalBridgeReceiver receiver) + { + try + { + if (response == null) + { + response = new GetMachineInformationResponse() + { + Package = new InformationPackage() + { + System = Tango.SystemInfo.SystemObjectsCollection.Create(), + } + }; + } + + await receiver.SendGenericResponse(response, token); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error sending system information."); + } + } + + public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs new file mode 100644 index 000000000..0cc493891 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.SystemInfo +{ + public interface ISystemInfoService + { + bool Enabled { get; set; } + } +} 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 df6b881a0..4551fe427 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 @@ -72,6 +72,7 @@ + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll @@ -169,6 +170,8 @@ + + @@ -393,6 +396,10 @@ {e1e66ed9-597d-45fa-8048-de90a6930484} Tango.SQLExaminer + + {997a961c-beda-4b56-aa0f-c39e532f7ffa} + Tango.SystemInfo + {fd86424c-6e84-491b-8df9-3d0f5c236a2a} Tango.Touch @@ -439,7 +446,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index da6c630d4..9e150221d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -26,6 +26,7 @@ using Tango.PPC.Common.RemoteAssistance; using Tango.PPC.Common.RemoteDesktop; using Tango.PPC.Common.Storage; using Tango.PPC.Common.Synchronization; +using Tango.PPC.Common.SystemInfo; using Tango.PPC.Common.Threading; using Tango.PPC.Common.UpdatePackages; using Tango.PPC.Common.UWF; @@ -84,6 +85,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); if (App.StartupArgs.Contains("-webDebug")) { @@ -120,6 +122,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/Themes/Generic.xaml b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/Themes/Generic.xaml index 1070736ef..64145bcfa 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/Themes/Generic.xaml +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/Themes/Generic.xaml @@ -34,7 +34,7 @@ - + diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisControl.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisControl.cs index 23b831abe..aa738b203 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisControl.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisControl.cs @@ -25,6 +25,7 @@ namespace RealTimeGraphX.WPF public class WpfGraphAxisControl : WpfGraphComponentBase { private ItemsControl _items_control; + private WpfGraphAxisPanel _axisPanel; /// /// Initializes the class. @@ -97,9 +98,37 @@ namespace RealTimeGraphX.WPF base.OnApplyTemplate(); _items_control = GetTemplateChild("PART_ItemsControl") as ItemsControl; + + _items_control.Loaded += (x, e) => + { + ItemsPresenter itemsPresenter = GetVisualChild(_items_control); + _axisPanel = VisualTreeHelper.GetChild(itemsPresenter, 0) as WpfGraphAxisPanel; + }; + OnTicksChanged(); } + private static T GetVisualChild(DependencyObject parent) where T : Visual + { + T child = default(T); + + int numVisuals = VisualTreeHelper.GetChildrenCount(parent); + for (int i = 0; i < numVisuals; i++) + { + Visual v = (Visual)VisualTreeHelper.GetChild(parent, i); + child = v as T; + if (child == null) + { + child = GetVisualChild(v); + } + if (child != null) + { + break; + } + } + return child; + } + /// /// Called when the property has changed. /// @@ -107,16 +136,15 @@ namespace RealTimeGraphX.WPF { Items = new ObservableCollection(Enumerable.Range(0, Ticks).Select(x => new WpfGraphAxisTickData())); - if (Controller != null) - { - Controller.RequestVirtualRangeChange(); - } + Controller?.RequestVirtualRangeChange(); + + _axisPanel?.UpdatePanel(); } protected override void OnControllerChanged(IGraphController oldController, IGraphController newController) { base.OnControllerChanged(oldController, newController); - + if (newController != null) { newController.RequestVirtualRangeChange(); diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisPanel.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisPanel.cs index f10b583f4..4fb6d94bc 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisPanel.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphAxisPanel.cs @@ -46,7 +46,7 @@ namespace RealTimeGraphX.WPF /// /// Updates the panel. /// - private void UpdatePanel() + public void UpdatePanel() { RowDefinitions.Clear(); ColumnDefinitions.Clear(); diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphDataSeries.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphDataSeries.cs index 15a99ab54..8eab3eabe 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphDataSeries.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphDataSeries.cs @@ -135,5 +135,15 @@ namespace RealTimeGraphX.WPF { get { return Fill != null; } } + + private object _currentValue; + /// + /// Gets the current value. + /// + public object CurrentValue + { + get { return _currentValue; } + set { _currentValue = value; RaisePropertyChangedAuto(); } + } } } diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphSurface.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphSurface.cs index ebcff3472..1a3015728 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphSurface.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX.WPF/WpfGraphSurface.cs @@ -40,6 +40,20 @@ namespace RealTimeGraphX.WPF private Point _last_mouse_position; private Grid _grid; + #region Events + + /// + /// Occurs when the surface size has changed. + /// + public event EventHandler SurfaceSizeChanged; + + /// + /// Occurs when the surface zoom rectangle has changed. + /// + public event EventHandler ZoomRectChanged; + + #endregion + #region Properties /// @@ -177,6 +191,8 @@ namespace RealTimeGraphX.WPF } _zoom_rect = new System.Drawing.RectangleF((float)x, (float)y, _zoom_rect.Width, _zoom_rect.Height); + + ZoomRectChanged?.Invoke(this, new EventArgs()); } _last_mouse_position = _current_mouse_position; @@ -202,6 +218,7 @@ namespace RealTimeGraphX.WPF _zoom_rect = new System.Drawing.RectangleF((float)Canvas.GetLeft(_selection_rectangle), (float)Canvas.GetTop(_selection_rectangle), (float)_selection_rectangle.Width, (float)_selection_rectangle.Height); _selection_rectangle.Visibility = Visibility.Hidden; _is_scaled = true; + ZoomRectChanged?.Invoke(this, new EventArgs()); } } @@ -222,6 +239,7 @@ namespace RealTimeGraphX.WPF { _zoom_rect = new System.Drawing.RectangleF(); _is_scaled = false; + ZoomRectChanged?.Invoke(this, new EventArgs()); } else if (Keyboard.IsKeyDown(Key.LeftCtrl)) { @@ -301,7 +319,7 @@ namespace RealTimeGraphX.WPF /// The points. public void DrawSeries(WpfGraphDataSeries dataSeries, IEnumerable points) { - _g.DrawCurve(dataSeries.GdiPen, points.ToArray()); + _g.DrawPolygon(dataSeries.GdiPen, points.ToArray()); } /// @@ -373,6 +391,7 @@ namespace RealTimeGraphX.WPF { _size = new System.Drawing.SizeF((float)e.NewSize.Width, (float)e.NewSize.Height); _size_changed = true; + SurfaceSizeChanged?.Invoke(this, new EventArgs()); } #endregion diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/DateTimeDataPoint.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/DateTimeDataPoint.cs new file mode 100644 index 000000000..9ec750af9 --- /dev/null +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/DateTimeDataPoint.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RealTimeGraphX.DataPoints +{ + public class DateTimeDataPoint : GraphDataPoint + { + /// + /// Initializes a new instance of the class. + /// + public DateTimeDataPoint() : base() + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + public DateTimeDataPoint(DateTime value) : base(value) + { + + } + + /// + /// Performs an implicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static implicit operator DateTimeDataPoint(DateTime value) + { + return new DateTimeDataPoint(value); + } + + /// + /// Implements the operator -. + /// + /// a. + /// The b. + /// + /// The result of the operator. + /// + public static DateTimeDataPoint operator -(DateTimeDataPoint a, DateTimeDataPoint b) + { + return new DateTimeDataPoint(new DateTime(a.Value.Ticks - b.Value.Ticks)); + } + + /// + /// Implements the operator +. + /// + /// a. + /// The b. + /// + /// The result of the operator. + /// + public static DateTimeDataPoint operator +(DateTimeDataPoint a, DateTimeDataPoint b) + { + return new DateTimeDataPoint(new DateTime(a.Value.Ticks + b.Value.Ticks)); + } + + /// + /// Sums the value of this instance with another instance value and returns the result. + /// + /// The other instance. + /// + public override IGraphDataPoint Add(IGraphDataPoint other) + { + return new DateTimeDataPoint(new DateTime(this.Value.Ticks + (other as DateTimeDataPoint).Value.Ticks)); + } + + /// + /// Subtract the value of another instance from this instance and returns the result. + /// + /// The other instance. + /// + public override IGraphDataPoint Subtract(IGraphDataPoint other) + { + return new DateTimeDataPoint(new DateTime(this.Value.Ticks - (other as DateTimeDataPoint).Value.Ticks)); + } + + /// + /// Multiplies the value of this instance with another instance value and returns the result. + /// + /// The other instance. + /// + public override IGraphDataPoint Multiply(IGraphDataPoint other) + { + return new DateTimeDataPoint(new DateTime(this.Value.Ticks * (other as DateTimeDataPoint).Value.Ticks)); + } + + /// + /// Divides the value of this instance with another instance value and returns the result. + /// + /// The other instance. + /// + public override IGraphDataPoint Divide(IGraphDataPoint other) + { + return new DateTimeDataPoint(new DateTime(this.Value.Ticks / (other as DateTimeDataPoint).Value.Ticks)); + } + + /// + /// Returns the percentage value of this instance between the specified minimum and maximum values. + /// + /// The minimum. + /// The maximum. + /// + public override double ComputeRelativePosition(IGraphDataPoint min, IGraphDataPoint max) + { + DateTime dMin = min as DateTimeDataPoint; + DateTime dMax = max as DateTimeDataPoint; + + if (dMax.Ticks - dMin.Ticks == 0) //Prevent divide by zero + { + return dMin.Ticks; + } + + var result = ((Value.Ticks - dMin.Ticks) * 100) / (dMax.Ticks - dMin.Ticks); + + return double.IsNaN(result) ? dMin.Ticks : result; + } + + /// + /// Returns the absolute value of the specified percentage value between the specified minimum and maximum values. + /// + /// The minimum. + /// The maximum. + /// The percentage. + /// + public override IGraphDataPoint ComputeAbsolutePosition(IGraphDataPoint min, IGraphDataPoint max, double percentage) + { + double minimum = ((DateTime)min.GetValue()).Ticks; + double maximum = ((DateTime)max.GetValue()).Ticks; + + return new DateTimeDataPoint(new DateTime((long)(minimum + (maximum - minimum) * percentage))); + } + + /// + /// Creates a range of values from the specified minimum and maximum. + /// + /// The minimum. + /// The maximum. + /// The count. + /// + public override IEnumerable CreateRange(IGraphDataPoint min, IGraphDataPoint max, int count) + { + double minimum = ((DateTime)min.GetValue()).Ticks; + double maximum = ((DateTime)max.GetValue()).Ticks; + + return Enumerable.Range(0, count). + Select(i => minimum + (maximum - minimum) * ((double)i / (count - 1))). + Select(x => new DateTimeDataPoint(new DateTime((long)x))); + } + + /// + /// Returns a formated string of this data point. + /// + /// The format. + /// + public override string ToString(string format) + { + return Value.ToString(format); + } + + /// + /// Parses the specified value and returns a new instance of data point. + /// + /// The value. + /// + public override IGraphDataPoint Parse(string value) + { + return new DateTimeDataPoint(DateTime.Parse(value)); + } + } +} diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/Int32DataPoint.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/Int32DataPoint.cs index 4bccdcb74..787e59aae 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/Int32DataPoint.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/DataPoints/Int32DataPoint.cs @@ -118,6 +118,11 @@ namespace RealTimeGraphX.DataPoints Int32DataPoint dMin = min as Int32DataPoint; Int32DataPoint dMax = max as Int32DataPoint; + if (dMax - dMin == 0) //Prevent divide by zero + { + return dMin; + } + var result = ((Value - dMin) * 100) / (dMax - dMin); return result; @@ -147,12 +152,12 @@ namespace RealTimeGraphX.DataPoints /// public override IEnumerable CreateRange(IGraphDataPoint min, IGraphDataPoint max, int count) { - int minimum = (int)min.GetValue(); - int maximum = (int)max.GetValue(); + double minimum = (int)min.GetValue(); + double maximum = (int)max.GetValue(); return Enumerable.Range(0, count). - Select(i => minimum + (maximum - minimum) * ((int)i / (count - 1))). - Select(x => new Int32DataPoint(x)); + Select(i => minimum + (maximum - minimum) * ((double)i / (count - 1))). + Select(x => new Int32DataPoint((int)x)); } /// diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs index 328f0736e..1b452df57 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs @@ -47,6 +47,8 @@ namespace RealTimeGraphX public int RenderedItems { get; set; } public bool IsClearSeries { get; set; } + + public bool IsUpdateSeries { get; set; } } #endregion @@ -113,8 +115,10 @@ namespace RealTimeGraphX get { return _surface; } set { + var previous = _surface; _surface = value; RequestVirtualRangeChange(); + OnSurfaceChanged(previous, _surface); } } @@ -227,11 +231,8 @@ namespace RealTimeGraphX { List> pending_lists = new List>(); - if (_pending_series_collection.Count == 0) - { - Thread.Sleep(TimeSpan.FromSeconds(1)); - continue; - } + var pending_list_first = _pending_series_collection.BlockDequeue(); + pending_lists.Add(pending_list_first); while (_pending_series_collection.Count > 0) { @@ -247,24 +248,24 @@ namespace RealTimeGraphX { _pending_series_collection = new GraphDataQueue>(); _to_render.Clear(); - break; } - - if (_to_render.ContainsKey(pending_series.Series)) + else if (!pending_series.IsUpdateSeries) { - var s = _to_render[pending_series.Series]; - s.XX.AddRange(pending_series.XX); - s.YY.AddRange(pending_series.YY); - } - else - { - _to_render[pending_series.Series] = pending_series; + if (_to_render.ContainsKey(pending_series.Series)) + { + var s = _to_render[pending_series.Series]; + s.XX.AddRange(pending_series.XX); + s.YY.AddRange(pending_series.YY); + } + else + { + _to_render[pending_series.Series] = pending_series; + } } } } if (_to_render.Count > 0) - //if (DateTime.Now > _last_render_time.AddMilliseconds(RefreshRate.TotalMilliseconds) && _to_render.Count > 0) { GraphDataPoint min_x = _range.MaximumX - _range.MaximumX; GraphDataPoint max_x = _range.MaximumX; @@ -346,6 +347,11 @@ namespace RealTimeGraphX foreach (var item in to_render) { + if (item.YY.Count > 0) + { + item.Series.CurrentValue = item.YY.Last().GetValue(); + } + var points = Renderer.Render(Surface, item.Series, _range, item.XX, item.YY, min_x, max_x, min_y, max_y); to_draw.Add(new Tuple>(item.Series, points)); } @@ -384,6 +390,26 @@ namespace RealTimeGraphX #region Protected Methods + /// + /// Called when the surface has changed. + /// + /// The previous. + /// The surface. + protected virtual void OnSurfaceChanged(IGraphSurface previous, IGraphSurface surface) + { + if (previous != null) + { + previous.SurfaceSizeChanged += Surface_SurfaceSizeChanged; + previous.ZoomRectChanged += Surface_ZoomRectChanged; + } + + if (surface != null) + { + surface.SurfaceSizeChanged += Surface_SurfaceSizeChanged; + surface.ZoomRectChanged += Surface_ZoomRectChanged; + } + } + /// /// Raises the event. /// @@ -431,6 +457,62 @@ namespace RealTimeGraphX #endregion + #region Surface Event Handlers + + /// + /// Handles the ZoomRectChanged event of the Surface control. + /// + /// The source of the event. + /// The instance containing the event data. + private void Surface_ZoomRectChanged(object sender, EventArgs e) + { + if (!_pending_series_collection.ToList().SelectMany(x => x).ToList().Exists(x => x.IsUpdateSeries)) + { + List updateSeries = new List(); + + foreach (var pending_Series in _to_render) + { + updateSeries.Add(new PendingSeries() + { + IsUpdateSeries = true, + Series = pending_Series.Value.Series, + XX = new List(), + YY = new List(), + }); + } + + _pending_series_collection.BlockEnqueue(updateSeries); + } + } + + /// + /// Handles the SurfaceSizeChanged event of the Surface control. + /// + /// The source of the event. + /// The instance containing the event data. + private void Surface_SurfaceSizeChanged(object sender, EventArgs e) + { + if (!_pending_series_collection.ToList().SelectMany(x => x).ToList().Exists(x => x.IsUpdateSeries)) + { + List updateSeries = new List(); + + foreach (var pending_Series in _to_render) + { + updateSeries.Add(new PendingSeries() + { + IsUpdateSeries = true, + Series = pending_Series.Value.Series, + XX = new List(), + YY = new List(), + }); + } + + _pending_series_collection.BlockEnqueue(updateSeries); + } + } + + #endregion + #region Public Methods /// diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphDataSeries.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphDataSeries.cs index dd05da92b..03640e44a 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphDataSeries.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphDataSeries.cs @@ -27,5 +27,10 @@ namespace RealTimeGraphX /// Gets or sets a value indicating whether this series should be visible. /// bool IsVisible { get; set; } + + /// + /// Gets the current value. + /// + Object CurrentValue { get; set; } } } diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphSurface.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphSurface.cs index 310bc7c3d..a3aeb90d9 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphSurface.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/IGraphSurface.cs @@ -11,6 +11,16 @@ namespace RealTimeGraphX /// public interface IGraphSurface : IGraphComponent { + /// + /// Occurs when the surface size has changed. + /// + event EventHandler SurfaceSizeChanged; + + /// + /// Occurs when the surface zoom rectangle has changed. + /// + event EventHandler ZoomRectChanged; + /// /// Returns the actual size of the surface. /// diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/Renderers/ScrollingLineRenderer.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/Renderers/ScrollingLineRenderer.cs index 82e80aa0f..0a4ac8368 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/Renderers/ScrollingLineRenderer.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/Renderers/ScrollingLineRenderer.cs @@ -78,7 +78,7 @@ namespace RealTimeGraphX.Renderers surface.FillSeries(series, GetFillPoints(surface, points)); } - surface.DrawSeries(series, points); + surface.DrawSeries(series, GetFillPoints(surface, points)); } } } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs index d44382b2e..5ae1aa440 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs @@ -8,5 +8,6 @@ namespace Tango.Integration.ExternalBridge.Network.Information { public class GetMachineInformationResponse { + public InformationPackage Package { get; set; } } } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs index 3e004d4f5..afa23492e 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs @@ -3,16 +3,17 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.SystemInfo; namespace Tango.Integration.ExternalBridge.Network.Information { public class InformationPackage { - public List Properties { get; set; } + public List System { get; set; } public InformationPackage() { - Properties = new List(); + System = new List(); } } } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/MachineProperty.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/MachineProperty.cs deleted file mode 100644 index 99232d624..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/MachineProperty.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Integration.ExternalBridge.Network.Information -{ - public class MachineProperty - { - public String Name { get; set; } - public String Value { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index b439fc211..1356c115c 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -109,7 +109,6 @@ - @@ -205,6 +204,10 @@ {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} Tango.Settings + + {997a961c-beda-4b56-aa0f-c39e532f7ffa} + Tango.SystemInfo + {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport @@ -218,7 +221,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SystemInfo/Connection.cs b/Software/Visual_Studio/Tango.SystemInfo/Connection.cs new file mode 100644 index 000000000..3e4e1e73d --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Connection.cs @@ -0,0 +1,83 @@ +using System; +using System.Management; +using System.Collections.Generic; +using System.Text; + +//Tango.SystemInfo +namespace Tango.SystemInfo +{ + class Connection + { + ManagementScope connectionScope; + ConnectionOptions options; + + #region "properties" + public ManagementScope GetConnectionScope + { + get { return connectionScope; } + } + public ConnectionOptions GetOptions + { + get { return options; } + } + #endregion + + #region "static helpers" + public static ConnectionOptions SetConnectionOptions() + { + ConnectionOptions options = new ConnectionOptions(); + options.Impersonation = ImpersonationLevel.Impersonate; + options.Authentication = AuthenticationLevel.Default; + options.EnablePrivileges = true; + return options; + } + + public static ManagementScope SetConnectionScope(string machineName, + ConnectionOptions options) + { + ManagementScope connectScope = new ManagementScope(); + connectScope.Path = new ManagementPath(@"\\" + machineName + @"\root\CIMV2"); + connectScope.Options = options; + + try + { + connectScope.Connect(); + } + catch (ManagementException e) + { + Console.WriteLine("An Error Occurred: " + e.Message.ToString()); + } + return connectScope; + } + #endregion + + #region "constructors" + public Connection() + { + EstablishConnection(null, null, null, Environment.MachineName); + } + + public Connection(string userName, + string password, + string domain, + string machineName) + { + EstablishConnection(userName, password, domain, machineName); + } + #endregion + + #region "private helpers" + private void EstablishConnection(string userName, string password, string domain, string machineName) + { + options = Connection.SetConnectionOptions(); + if (domain != null || userName != null) + { + options.Username = domain + "\\" + userName; + options.Password = password; + } + connectionScope = Connection.SetConnectionScope(machineName, options); + } + #endregion + + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/IWMI.cs b/Software/Visual_Studio/Tango.SystemInfo/IWMI.cs new file mode 100644 index 000000000..06252731f --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/IWMI.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + interface IWMI + { + IList GetHardwareInfoList(); + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.SystemInfo/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..1ff929bce --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.SystemInfo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.SystemInfo")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("997a961c-beda-4b56-aa0f-c39e532f7ffa")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Tango.SystemInfo/SystemObject.cs b/Software/Visual_Studio/Tango.SystemInfo/SystemObject.cs new file mode 100644 index 000000000..be1c74fe5 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/SystemObject.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + public class SystemObject + { + public String Name { get; set; } + public List Properties { get; set; } + + public SystemObject() + { + Properties = new List(); + } + + public override string ToString() + { + String msg = String.Empty; + + msg = $"Name: {Name}\n"; + + foreach (var prop in Properties) + { + msg += $"{prop.Name}: {prop.Value}\n"; + } + + return msg; + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/SystemObjectProperty.cs b/Software/Visual_Studio/Tango.SystemInfo/SystemObjectProperty.cs new file mode 100644 index 000000000..c2d04e2a5 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/SystemObjectProperty.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + public class SystemObjectProperty + { + public String Name { get; set; } + public String Value { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/SystemObjectsCollection.cs b/Software/Visual_Studio/Tango.SystemInfo/SystemObjectsCollection.cs new file mode 100644 index 000000000..ec191750c --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/SystemObjectsCollection.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.SystemInfo +{ + public class SystemObjectsCollection + { + public String Name { get; set; } + + public List Objects { get; set; } + + public SystemObjectsCollection() + { + Objects = new List(); + } + + public override string ToString() + { + String str = String.Empty; + + str += Name + "\n\n"; + + foreach (var obj in Objects) + { + str += obj.ToString(); + str += "\n"; + } + + str += "\n"; + + return str; + } + + public static List Create() + { + List list = new List(); + + Connection wmiConnection = new Connection(); + + SystemObjectsCollection board = new SystemObjectsCollection() { Name = "Board" }; + Win32_BaseBoard boardConnection = new Win32_BaseBoard(wmiConnection); + board.Objects = boardConnection.GetHardwareInfoList().ToList(); + list.Add(board); + + SystemObjectsCollection bios = new SystemObjectsCollection() { Name = "BIOS" }; + Win32_BIOS biosConnection = new Win32_BIOS(wmiConnection); + bios.Objects = biosConnection.GetHardwareInfoList().ToList(); + list.Add(bios); + + SystemObjectsCollection disk = new SystemObjectsCollection() { Name = "Disk Drives" }; + Win32_DiskDrive diskConnection = new Win32_DiskDrive(wmiConnection); + disk.Objects = diskConnection.GetHardwareInfoList().ToList(); + list.Add(disk); + + SystemObjectsCollection fan = new SystemObjectsCollection() { Name = "Fan" }; + Win32_Fan fanConnection = new Win32_Fan(wmiConnection); + fan.Objects = fanConnection.GetHardwareInfoList().ToList(); + list.Add(fan); + + SystemObjectsCollection network = new SystemObjectsCollection() { Name = "Network" }; + Win32_NetworkAdapter networkConnection = new Win32_NetworkAdapter(wmiConnection); + network.Objects = networkConnection.GetHardwareInfoList().ToList(); + list.Add(network); + + SystemObjectsCollection memory = new SystemObjectsCollection() { Name = "Memory" }; + Win32_PhysicalMemory memoryConnection = new Win32_PhysicalMemory(wmiConnection); + memory.Objects = memoryConnection.GetHardwareInfoList().ToList(); + list.Add(memory); + + SystemObjectsCollection processor = new SystemObjectsCollection() { Name = "Processor" }; + Win32_Processor processorConnection = new Win32_Processor(wmiConnection); + processor.Objects = processorConnection.GetHardwareInfoList().ToList(); + list.Add(processor); + + SystemObjectsCollection serial = new SystemObjectsCollection() { Name = "Serial Ports" }; + Win32_SerialPort serialConnection = new Win32_SerialPort(wmiConnection); + serial.Objects = serialConnection.GetHardwareInfoList().ToList(); + list.Add(serial); + + SystemObjectsCollection sound = new SystemObjectsCollection() { Name = "Sound" }; + Win32_SoundDevice soundConnection = new Win32_SoundDevice(wmiConnection); + sound.Objects = soundConnection.GetHardwareInfoList().ToList(); + list.Add(sound); + + SystemObjectsCollection temp = new SystemObjectsCollection() { Name = "Temperature" }; + Win32_TemperatureProbe tempConnection = new Win32_TemperatureProbe(wmiConnection); + temp.Objects = tempConnection.GetHardwareInfoList().ToList(); + list.Add(temp); + + SystemObjectsCollection power = new SystemObjectsCollection() { Name = "Power Supply" }; + Win32_UninterruptiblePowerSupply powerConnection = new Win32_UninterruptiblePowerSupply(wmiConnection); + power.Objects = powerConnection.GetHardwareInfoList().ToList(); + list.Add(power); + + SystemObjectsCollection video = new SystemObjectsCollection() { Name = "Video Controller" }; + Win32_VideoController videoConnection = new Win32_VideoController(wmiConnection); + video.Objects = videoConnection.GetHardwareInfoList().ToList(); + list.Add(video); + + SystemObjectsCollection voltage = new SystemObjectsCollection() { Name = "Voltage" }; + Win32_VoltageProbe voltageConnection = new Win32_VoltageProbe(wmiConnection); + voltage.Objects = voltageConnection.GetHardwareInfoList().ToList(); + list.Add(voltage); + + return list; + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Tango.SystemInfo.csproj b/Software/Visual_Studio/Tango.SystemInfo/Tango.SystemInfo.csproj new file mode 100644 index 000000000..90cf14c29 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Tango.SystemInfo.csproj @@ -0,0 +1,102 @@ + + + + + Debug + AnyCPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA} + Library + Properties + Tango.SystemInfo + Tango.SystemInfo + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SystemInfo/WMIReader.cs b/Software/Visual_Studio/Tango.SystemInfo/WMIReader.cs new file mode 100644 index 000000000..d7d909089 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/WMIReader.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Management; + +namespace Tango.SystemInfo +{ + class WMIReader + { + public static IList GetPropertyValues(Connection WMIConnection, + string SelectQuery, + string className) + { + List hardwareList = new List(); + + ManagementScope connectionScope = WMIConnection.GetConnectionScope; + List alProperties = new List(); + SelectQuery msQuery = new SelectQuery(SelectQuery); + ManagementObjectSearcher searchProcedure = new ManagementObjectSearcher(connectionScope, msQuery); + + try + { + foreach (ManagementObject item in searchProcedure.Get()) + { + SystemObject hardware = new SystemObject(); + + try + { + hardware.Name = item["Name"].ToString(); + } + catch + { + hardware.Name = item.ToString(); + } + + hardwareList.Add(hardware); + + foreach (string property in XMLConfig.GetSettings(className)) + { + try + { + hardware.Properties.Add(new SystemObjectProperty() + { + Name = property, + Value = item[property].ToString() + }); + } + catch (SystemException) { /* ignore error */ } + } + } + } + catch (ManagementException e) + { + /* Do Nothing */ + } + + return hardwareList; + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_BIOS.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_BIOS.cs new file mode 100644 index 000000000..f86c0d5ca --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_BIOS.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_BIOS : IWMI + { + Connection WMIConnection; + + public Win32_BIOS(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_BaseBoard.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_BaseBoard.cs new file mode 100644 index 000000000..f9030ff54 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_BaseBoard.cs @@ -0,0 +1,27 @@ +using System; +using System.Management; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_BaseBoard: IWMI + { + Connection WMIConnection; + + public Win32_BaseBoard(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_Battery.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_Battery.cs new file mode 100644 index 000000000..91700d678 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_Battery.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_Battery : IWMI + { + Connection WMIConnection; + + public Win32_Battery(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_Bus.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_Bus.cs new file mode 100644 index 000000000..8aba00430 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_Bus.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_Bus : IWMI + { + Connection WMIConnection; + + public Win32_Bus(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_CDROMDrive.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_CDROMDrive.cs new file mode 100644 index 000000000..e6eaa08a9 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_CDROMDrive.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_CDROMDrive : IWMI + { + Connection WMIConnection; + + public Win32_CDROMDrive(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_DMAChannel.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_DMAChannel.cs new file mode 100644 index 000000000..12e0228fb --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_DMAChannel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_DMAChannel : IWMI + { + Connection WMIConnection; + + public Win32_DMAChannel(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_DiskDrive.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_DiskDrive.cs new file mode 100644 index 000000000..8600a663d --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_DiskDrive.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_DiskDrive : IWMI + { + Connection WMIConnection; + + public Win32_DiskDrive(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_Fan.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_Fan.cs new file mode 100644 index 000000000..afc241c37 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_Fan.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_Fan : IWMI + { + Connection WMIConnection; + + public Win32_Fan(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyController.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyController.cs new file mode 100644 index 000000000..5ac1f9d8f --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_FloppyController : IWMI + { + Connection WMIConnection; + + public Win32_FloppyController(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyDrive.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyDrive.cs new file mode 100644 index 000000000..10b1b8fde --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_FloppyDrive.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_FloppyDrive : IWMI + { + Connection WMIConnection; + + public Win32_FloppyDrive(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_IDEController.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_IDEController.cs new file mode 100644 index 000000000..899a4ad5e --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_IDEController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_IDEController : IWMI + { + Connection WMIConnection; + + public Win32_IDEController(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_IRQResource.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_IRQResource.cs new file mode 100644 index 000000000..ff39c68fd --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_IRQResource.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_IRQResource : IWMI + { + Connection WMIConnection; + + public Win32_IRQResource(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_Keyboard.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_Keyboard.cs new file mode 100644 index 000000000..2657b5954 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_Keyboard.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_Keyboard : IWMI + { + Connection WMIConnection; + + public Win32_Keyboard(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_MemoryDevice.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_MemoryDevice.cs new file mode 100644 index 000000000..8ed21c13d --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_MemoryDevice.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_MemoryDevice : IWMI + { + Connection WMIConnection; + + public Win32_MemoryDevice(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapter.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapter.cs new file mode 100644 index 000000000..561919a2d --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_NetworkAdapter : IWMI + { + Connection WMIConnection; + + public Win32_NetworkAdapter(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapterConfiguration.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapterConfiguration.cs new file mode 100644 index 000000000..ba22e1d01 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_NetworkAdapterConfiguration.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_NetworkAdapterConfiguration : IWMI + { + Connection WMIConnection; + + public Win32_NetworkAdapterConfiguration(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_OnBoardDevice.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_OnBoardDevice.cs new file mode 100644 index 000000000..7c4bea2a3 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_OnBoardDevice.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_OnBoardDevice : IWMI + { + Connection WMIConnection; + + public Win32_OnBoardDevice(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_OperatingSystem.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_OperatingSystem.cs new file mode 100644 index 000000000..24b93d92c --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_OperatingSystem.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_OperatingSystem : IWMI + { + Connection WMIConnection; + + public Win32_OperatingSystem(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + + public IList GetHardwareInfoList() + { + return WMIReader.GetPropertyValues(WMIConnection, "select * from Win32_OperatingSystem", "Win32_OperatingSystem"); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_PCMCIController.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_PCMCIController.cs new file mode 100644 index 000000000..772af0a28 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_PCMCIController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_PCMCIController : IWMI + { + Connection WMIConnection; + + public Win32_PCMCIController(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_POTSModem.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_POTSModem.cs new file mode 100644 index 000000000..29f9549ca --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_POTSModem.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_POTSModem : IWMI + { + Connection WMIConnection; + + public Win32_POTSModem(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_ParallelPort.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_ParallelPort.cs new file mode 100644 index 000000000..81244c588 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_ParallelPort.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_ParallelPort : IWMI + { + Connection WMIConnection; + + public Win32_ParallelPort(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMedia.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMedia.cs new file mode 100644 index 000000000..816944da4 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMedia.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_PhysicalMedia : IWMI + { + Connection WMIConnection; + + public Win32_PhysicalMedia(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMemory.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMemory.cs new file mode 100644 index 000000000..d319a3fa7 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_PhysicalMemory.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_PhysicalMemory : IWMI + { + Connection WMIConnection; + + public Win32_PhysicalMemory(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_PortConnector.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_PortConnector.cs new file mode 100644 index 000000000..20288cec7 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_PortConnector.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_PortConnector : IWMI + { + Connection WMIConnection; + + public Win32_PortConnector(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_PortResource.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_PortResource.cs new file mode 100644 index 000000000..8a8da41e7 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_PortResource.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_PortResource : IWMI + { + Connection WMIConnection; + + public Win32_PortResource(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_Processor.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_Processor.cs new file mode 100644 index 000000000..e8387c2bd --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_Processor.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_Processor : IWMI + { + Connection WMIConnection; + + public Win32_Processor(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_SCSIController.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_SCSIController.cs new file mode 100644 index 000000000..dfe689951 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_SCSIController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_SCSIController : IWMI + { + Connection WMIConnection; + + public Win32_SCSIController(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPort.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPort.cs new file mode 100644 index 000000000..6b20763f9 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPort.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_SerialPort : IWMI + { + Connection WMIConnection; + + public Win32_SerialPort(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPortConfiguration.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPortConfiguration.cs new file mode 100644 index 000000000..d1efe826b --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_SerialPortConfiguration.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_SerialPortConfiguration : IWMI + { + Connection WMIConnection; + + public Win32_SerialPortConfiguration(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_SoundDevice.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_SoundDevice.cs new file mode 100644 index 000000000..bece1f169 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_SoundDevice.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_SoundDevice : IWMI + { + Connection WMIConnection; + + public Win32_SoundDevice(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_SystemEnclosure.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_SystemEnclosure.cs new file mode 100644 index 000000000..184ee3b99 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_SystemEnclosure.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_SystemEnclosure : IWMI + { + Connection WMIConnection; + + public Win32_SystemEnclosure(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_TapeDrive.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_TapeDrive.cs new file mode 100644 index 000000000..94600d518 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_TapeDrive.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_TapeDrive : IWMI + { + Connection WMIConnection; + + public Win32_TapeDrive(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_TemperatureProbe.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_TemperatureProbe.cs new file mode 100644 index 000000000..579203237 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_TemperatureProbe.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_TemperatureProbe : IWMI + { + Connection WMIConnection; + + public Win32_TemperatureProbe(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_USBController.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_USBController.cs new file mode 100644 index 000000000..6df7b4799 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_USBController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_USBController : IWMI + { + Connection WMIConnection; + + public Win32_USBController(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_USBHub.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_USBHub.cs new file mode 100644 index 000000000..b0f812ebe --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_USBHub.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_USBHub : IWMI + { + Connection WMIConnection; + + public Win32_USBHub(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_UninterruptiblePowerSupply.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_UninterruptiblePowerSupply.cs new file mode 100644 index 000000000..d8dc7bacd --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_UninterruptiblePowerSupply.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_UninterruptiblePowerSupply : IWMI + { + Connection WMIConnection; + + public Win32_UninterruptiblePowerSupply(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_VideoController.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_VideoController.cs new file mode 100644 index 000000000..973303b98 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_VideoController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_VideoController : IWMI + { + Connection WMIConnection; + + public Win32_VideoController(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/Win32_VoltageProbe.cs b/Software/Visual_Studio/Tango.SystemInfo/Win32_VoltageProbe.cs new file mode 100644 index 000000000..818898aa8 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/Win32_VoltageProbe.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.SystemInfo +{ + class Win32_VoltageProbe : IWMI + { + Connection WMIConnection; + + public Win32_VoltageProbe(Connection WMIConnection) + { + this.WMIConnection = WMIConnection; + } + public IList GetHardwareInfoList() + { + string className = System.Text.RegularExpressions.Regex.Match( + this.GetType().ToString(), "Win32_.*").Value; + + return WMIReader.GetPropertyValues(WMIConnection, + "SELECT * FROM " + className, + className); + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/XMLConfig.cs b/Software/Visual_Studio/Tango.SystemInfo/XMLConfig.cs new file mode 100644 index 000000000..a6113a0cb --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/XMLConfig.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace Tango.SystemInfo +{ + class XMLConfig + { + private static List propNames; + + public static List GetSettings(string WMIClassName) + { + if (propNames == null) + { + propNames = new List(); + System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument(); + xmldoc.Load(Tango.Core.Helpers.EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.SystemInfo.settings.xml")); + System.Xml.XmlNode properties = xmldoc.SelectSingleNode("//" + WMIClassName); + + for (int i = 0; i < properties.ChildNodes.Count; i++) + propNames.Add(properties.ChildNodes[i].InnerText); + + } + + return propNames; + } + } +} diff --git a/Software/Visual_Studio/Tango.SystemInfo/settings.xml b/Software/Visual_Studio/Tango.SystemInfo/settings.xml new file mode 100644 index 000000000..ae3059407 --- /dev/null +++ b/Software/Visual_Studio/Tango.SystemInfo/settings.xml @@ -0,0 +1,1347 @@ + + + + + BootDevice + BuildNumber + BuildType + Caption + CodeSet + CountryCode + CreationClassName + CSCreationClassName + CSDVersion + CSName + CurrentTimeZone + DataExecutionPrevention_Available + DataExecutionPrevention_32BitApplications + DataExecutionPrevention_Drivers + DataExecutionPrevention_SupportPolicy + Debug + Description + Distributed + EncryptionLevel + FreePhysicalMemory + FreeSpaceInPagingFiles + FreeVirtualMemory + InstallDate + LargeSystemCache + LastBootUpTime + LocalDateTime + Locale + Manufacturer + MaxNumberOfProcesses + MaxProcessMemorySize + Name + NumberOfLicensedUsers + NumberOfProcesses + NumberOfUsers + OperatingSystemSKU + Organization + OSArchitecture + OSLanguage + OSProductSuite + OSType + OtherTypeDescription + PAEEnabled + PlusProductID + PlusVersionNumber + PortableOperatingSystem + Primary + ProductType + RegisteredUser + SerialNumber + ServicePackMajorVersion + ServicePackMinorVersion + SizeStoredInPagingFiles + Status + SuiteMask + SystemDevice + SystemDirectory + SystemDrive + TotalSwapSpaceSize + TotalVirtualMemorySize + TotalVisibleMemorySize + Version + WindowsDirectory + QuantumLength + QuantumType + + + Caption + CreationClassName + Depth + Description + Height + HostingBoard + HotSwappable + InstallDate + Manufacturer + Model + Name + OtherIdentifyingInfo + PartNumber + PoweredOn + Product + Removable + Replaceable + RequirementsDescription + RequiresDaughterBoard + SerialNumber + SKU + SlotLayout + SpecialRequirements + Status + Tag + Version + Weight + Width + + + Availability + BatteryRechargeTime + BatteryStatus + Caption + Chemistry + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DesignCapacity + DesignVoltage + DeviceID + ErrorCleared + ErrorDescription + EstimatedChargeRemaining + EstimatedRunTime + ExpectedBatteryLife + ExpectedLife + FullChargeCapacity + InstallDate + LastErrorCode + MaxRechargeTime + Name + PNPDeviceID + PowerManagementSupported + SmartBatteryVersion + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOnBattery + TimeToFullCharge + + + BuildNumber + Caption + CodeSet + CurrentLanguage + Description + IdentificationCode + InstallableLanguages + InstallDate + LanguageEdition + Manufacturer + Name + OtherTargetOS + PrimaryBIOS + ReleaseDate + SerialNumber + SMBIOSBIOSVersion + SMBIOSMajorVersion + SMBIOSMinorVersion + SMBIOSPresent + SoftwareElementID + SoftwareElementState + Status + TargetOperatingSystem + Version + + + Availability + BusNum + BusType + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Name + PNPDeviceID + PowerManagementSupported + Status + StatusInfo + SystemCreationClassName + SystemName + + + Availability + Caption + CompressionMethod + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + DefaultBlockSize + Description + DeviceID + Drive + DriveIntegrity + ErrorCleared + ErrorDescription + ErrorMethodology + FileSystemFlags + FileSystemFlagsEx + InstallDate + LastErrorCode + Manufacturer + MaxBlockSize + MaximumComponentLength + MaxMediaSize + MediaLoaded + MediaType + MfrAssignedRevisionLevel + MinBlockSize + Name + NeedsCleaning + NumberOfMediaSupported + PNPDeviceID + PowerManagementSupported + RevisionLevel + SCSIBus + SCSILogicalUnit + SCSIPort + SCSITargetId + SerialNumber + Size + Status + StatusInfo + SystemCreationClassName + SystemName + TransferRate + VolumeName + VolumeSerialNumber + + + Availability + BytesPerSector + Capabilities[] + CapabilityDescriptions[] + Caption + CompressionMethod + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + DefaultBlockSize + Description + DeviceID + ErrorCleared + ErrorDescription + ErrorMethodology + FirmwareRevision + Index + InstallDate + InterfaceType + LastErrorCode + Manufacturer + MaxBlockSize + MaxMediaSize + MediaLoaded + MediaType + MinBlockSize + Model + Name + NeedsCleaning + NumberOfMediaSupported + Partitions + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + SCSIBus + SCSILogicalUnit + SCSIPort + SCSITargetId + SectorsPerTrack + SerialNumber + Signature + Size + Status + StatusInfo + SystemCreationClassName + SystemName + TotalCylinders + TotalHeads + TotalSectors + TotalTracks + TracksPerCylinder + + + 16AddressSize + 16Availability + BurstMode + 16ByteMode + Caption + 16ChannelTiming + CreationClassName + CSCreationClassName + CSName + Description + 32DMAChannel + InstallDate + 32MaxTransferSize + Name + 32Port + Status + 16TransferWidths[] + 16TypeCTiming + 16WordMode + + + ActiveCooling + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DesiredSpeed + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Name + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + Status + StatusInfo + SystemCreationClassName + SystemName + VariableSpeed + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Manufacturer + MaxNumberControlled + Name + PNPDeviceID + PowerManagementSupported + ProtocolSupported + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + Availability + Caption + CompressionMethod + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + DefaultBlockSize + Description + DeviceID + ErrorCleared + ErrorDescription + ErrorMethodology + InstallDate + LastErrorCode + Manufacturer + MaxBlockSize + MaxMediaSize + MinBlockSize + Name + NeedsCleaning + NumberOfMediaSupported + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + Status + StatusInfo + SystemCreationClassName + SystemName + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Manufacturer + MaxNumberControlled + Name + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolSupported + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + Availability + Caption + CreationClassName + CSCreationClassName + CSName + Description + Hardware + InstallDate + IRQNumber + Name + Shareable + Status + TriggerLevel + TriggerType + Vector + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + IsLocked + LastErrorCode + Layout + Name + NumberOfFunctionKeys + Password + PNPDeviceID + PowerManagementSupported + Status + StatusInfo + SystemCreationClassName + SystemName + + + Access + AdditionalErrorData[] + Availability + BlockSize + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CorrectableError + CreationClassName + Description + DeviceID + EndingAddress + ErrorAccess + ErrorAddress + ErrorCleared + ErrorDataOrder + ErrorDescription + ErrorGranularity + ErrorInfo + ErrorMethodology + ErrorResolution + ErrorTime + ErrorTransferSize + InstallDate + LastErrorCode + Name + NumberOfBlocks + OtherErrorDescription + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + Purpose + StartingAddress + Status + StatusInfo + SystemCreationClassName + SystemLevelAddress + SystemName + + + AdapterType + AdapterTypeID + AutoSense + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + GUID + Index + InstallDate + Installed + InterfaceIndex + LastErrorCode + MACAddress + Manufacturer + MaxNumberControlled + MaxSpeed + Name + NetConnectionID + NetConnectionStatus + NetEnabled + NetworkAddresses[] + PermanentAddress + PhysicalAdapter + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProductName + ServiceName + Speed + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + ArpAlwaysSourceRoute + ArpUseEtherSNAP + Caption + DatabasePath + DeadGWDetectEnabled + DefaultIPGateway[] + DefaultTOS + DefaultTTL + Description + DHCPEnabled + DHCPLeaseExpires + DHCPLeaseObtained + DHCPServer + DNSDomain + DNSDomainSuffixSearchOrder[] + DNSEnabledForWINSResolution + DNSHostName + DNSServerSearchOrder[] + DomainDNSRegistrationEnabled + ForwardBufferMemory + FullDNSRegistrationEnabled + GatewayCostMetric[] + IGMPLevel + Index + InterfaceIndex + IPAddress[] + IPConnectionMetric + IPEnabled + IPFilterSecurityEnabled + IPPortSecurityEnabled + IPSecPermitIPProtocols[] + IPSecPermitTCPPorts[] + IPSecPermitUDPPorts[] + IPSubnet[] + IPUseZeroBroadcast + IPXAddress + IPXEnabled + IPXFrameType[] + IPXMediaType + IPXNetworkNumber[] + IPXVirtualNetNumber + KeepAliveInterval + KeepAliveTime + MACAddress + MTU + NumForwardPackets + PMTUBHDetectEnabled + PMTUDiscoveryEnabled + ServiceName + SettingID + TcpipNetbiosOptions + TcpMaxConnectRetransmissions + TcpMaxDataRetransmissions + TcpNumConnections + TcpUseRFC1122UrgentPointer + TcpWindowSize + WINSEnableLMHostsLookup + WINSHostLookupFile + WINSPrimaryServer + WINSScopeID + WINSSecondaryServer + + + Caption + CreationClassName + Description + DeviceType + Enabled + HotSwappable + InstallDate + Manufacturer + Model + Name + OtherIdentifyingInfo + PartNumber + PoweredOn + Removable + Replaceable + SerialNumber + SKU + Status + Tag + Version + + + Availability + Capabilities[] + CapabilityDescriptions[] + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + DMASupport + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + MaxNumberControlled + Name + OSAutoDiscovered + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolSupported + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Manufacturer + MaxNumberControlled + Name + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolSupported + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + Caption + Description + InstallDate + Name + Status + CreationClassName + Manufacturer + Model + SKU + SerialNumber + Tag + Version + PartNumber + OtherIdentifyingInfo + PoweredOn + Removable + Replaceable + HotSwappable + Capacity + MediaType + MediaDescription + WriteProtectOn + CleanerMedia + + + BankLabel + Capacity + Caption + CreationClassName + DataWidth + Description + DeviceLocator + FormFactor + HotSwappable + InstallDate + InterleaveDataDepth + InterleavePosition + Manufacturer + MemoryType + Model + Name + OtherIdentifyingInfo + PartNumber + PositionInRow + PoweredOn + Removable + Replaceable + SerialNumber + SKU + Speed + Status + Tag + TotalWidth + TypeDetail + Version + + + Caption + ConnectorPinout + ConnectorType[] + CreationClassName + Description + ExternalReferenceDesignator + InstallDate + InternalReferenceDesignator + Manufacturer + Model + Name + OtherIdentifyingInfo + PartNumber + PortType + PoweredOn + SerialNumber + SKU + Status + Tag + Version + + + Alias + Caption + CreationClassName + CSCreationClassName + CSName + Description + EndingAddress + InstallDate + Name + StartingAddress + Status + + + AnswerMode + AttachedTo + Availability + BlindOff + BlindOn + Caption + CompatibilityFlags + CompressionInfo + CompressionOff + CompressionOn + ConfigManagerErrorCode + ConfigManagerUserConfig + ConfigurationDialog + CountriesSupported[] + CountrySelected + CreationClassName + CurrentPasswords[] + DCB[] + Default[] + Description + DeviceID + DeviceLoader + DeviceType + DialType + DriverDate + ErrorCleared + ErrorControlForced + ErrorControlInfo + ErrorControlOff + ErrorControlOn + ErrorDescription + FlowControlHard + FlowControlOff + FlowControlSoft + InactivityScale + InactivityTimeout + Index + InstallDate + LastErrorCode + MaxBaudRateToPhone + MaxBaudRateToSerialPort + MaxNumberOfPasswords + Model + ModemInfPath + ModemInfSection + ModulationBell + ModulationCCITT + ModulationScheme + Name + PNPDeviceID + PortSubClass + PowerManagementCapabilities[] + PowerManagementSupported + Prefix + Properties[] + ProviderName + Pulse + Reset + ResponsesKeyName + RingsBeforeAnswer + SpeakerModeDial + SpeakerModeOff + SpeakerModeOn + SpeakerModeSetup + SpeakerVolumeHigh + SpeakerVolumeInfo + SpeakerVolumeLow + SpeakerVolumeMed + Status + StatusInfo + StringFormat + SupportsCallback + SupportsSynchronousConnect + SystemCreationClassName + SystemName + Terminator + TimeOfLastReset + Tone + VoiceSwitchFeature + + + AddressWidth + Architecture + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CpuStatus + CreationClassName + CurrentClockSpeed + CurrentVoltage + DataWidth + Description + DeviceID + ErrorCleared + ErrorDescription + ExtClock + Family + InstallDate + L2CacheSize + L2CacheSpeed + L3CacheSize + L3CacheSpeed + LastErrorCode + Level + LoadPercentage + Manufacturer + MaxClockSpeed + Name + NumberOfCores + NumberOfLogicalProcessors + OtherFamilyDescription + PNPDeviceID + PowerManagementSupported + ProcessorId + ProcessorType + Revision + Role + SocketDesignation + Status + StatusInfo + Stepping + SystemCreationClassName + SystemName + UniqueId + UpgradeMethod + Version + VoltageCaps + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + ControllerTimeouts + CreationClassName + Description + DeviceID + DeviceMap + DriverName + ErrorCleared + ErrorDescription + HardwareVersion + Index + InstallDate + LastErrorCode + Manufacturer + MaxDataWidth + MaxNumberControlled + MaxTransferRate + Name + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtectionManagement + ProtocolSupported + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + Availability + Binary + Capabilities[] + CapabilityDescriptions[] + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + MaxBaudRate + MaximumInputBufferSize + MaximumOutputBufferSize + MaxNumberControlled + Name + OSAutoDiscovered + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolSupported + ProviderType + SettableBaudRate + SettableDataBits + SettableFlowControl + SettableParity + SettableParityCheck + SettableRLSD + SettableStopBits + Status + StatusInfo + Supports16BitMode + SupportsDTRDSR + SupportsElapsedTimeouts + SupportsIntTimeouts + SupportsParityCheck + SupportsRLSD + SupportsRTSCTS + SupportsSpecialCharacters + SupportsXOnXOff + SupportsXOnXOffSet + SystemCreationClassName + SystemName + TimeOfLastReset + + + AbortReadWriteOnError + BaudRate + BinaryModeEnabled + BitsPerByte + Caption + ContinueXMitOnXOff + CTSOutflowControl + Description + DiscardNULLBytes + DSROutflowControl + DSRSensitivity + DTRFlowControlType + EOFCharacter + ErrorReplaceCharacter + ErrorReplacementEnabled + EventCharacter + IsBusy + Name + Parity + ParityCheckEnabled + RTSFlowControlType + SettingID + StopBits + XOffCharacter + XOffXMitThreshold + XOnCharacter + XOnXMitThreshold + XOnXOffInFlowControl + XOnXOffOutFlowControl + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + DMABufferSize + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Manufacturer + MPU401Address + Name + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProductName + Status + StatusInfo + SystemCreationClassName + SystemName + + + AudibleAlarm + BreachDescription + CableManagementStrategy + Caption + ChassisTypes[] + CreationClassName + CurrentRequiredOrProduced + Depth + Description + HeatGeneration + Height + HotSwappable + InstallDate + LockPresent + Manufacturer + Model + Name + NumberOfPowerCords + OtherIdentifyingInfo + PartNumber + PoweredOn + Removable + Replaceable + SecurityBreach + SecurityStatus + SerialNumber + ServiceDescriptions[] + ServicePhilosophy[] + SKU + SMBIOSAssetTag + Status + Tag + TypeDescriptions[] + Version + VisibleAlarm + Weight + Width + + + Availability + Capabilities[] + CapabilityDescriptions[] + Caption + Compression + CompressionMethod + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + DefaultBlockSize + Description + DeviceID + ECC + EOTWarningZoneSize + ErrorCleared + ErrorDescription + ErrorMethodology + FeaturesHigh + FeaturesLow + Id + InstallDate + LastErrorCode + Manufacturer + MaxBlockSize + MaxMediaSize + MaxPartitionCount + MediaType + MinBlockSize + Name + NeedsCleaning + NumberOfMediaSupported + Padding + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ReportSetMarks + Status + StatusInfo + SystemCreationClassName + SystemName + + + Accuracy + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + CurrentReading + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + IsLinear + LastErrorCode + LowerThresholdCritical + LowerThresholdFatal + LowerThresholdNonCritical + MaxReadable + MinReadable + Name + NominalReading + NormalMax + NormalMin + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + Resolution + Status + StatusInfo + SystemCreationClassName + SystemName + Tolerance + UpperThresholdCritical + UpperThresholdFatal + UpperThresholdNonCritical + + + ActiveInputVoltage + Availability + BatteryInstalled + CanTurnOffRemotely + Caption + CommandFile + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + EstimatedChargeRemaining + EstimatedRunTime + FirstMessageDelay + InstallDate + IsSwitchingSupply + LastErrorCode + LowBatterySignal + MessageInterval + Name + PNPDeviceID + PowerFailSignal + PowerManagementCapabilities[] + PowerManagementSupported + Range1InputFrequencyHigh + Range1InputFrequencyLow + Range1InputVoltageHigh + Range1InputVoltageLow + Range2InputFrequencyHigh + Range2InputFrequencyLow + Range2InputVoltageHigh + Range2InputVoltageLow + RemainingCapacityStatus + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOnBackup + TotalOutputPower + TypeOfRangeSwitching + UPSPort + + + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + LastErrorCode + Manufacturer + MaxNumberControlled + Name + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolSupported + Status + StatusInfo + SystemCreationClassName + SystemName + TimeOfLastReset + + + Availability + Caption + ClassCode + ConfigManagerErrorCode + ConfigManagerUserCode + CreationClassName + CurrentAlternativeSettings + CurrentConfigValue + Description + DeviceID + ErrorCleared + ErrorDescription + GangSwitched + InstallDate + LastErrorCode + Name + NumberOfConfigs + NumberOfPorts + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolCode + Status + StatusInfo + SubclassCode + SystemCreationClassName + SystemName + USBVersion + + + AcceleratorCapabilities[] + AdapterCompatibility + AdapterDACType + AdapterRAM + Availability + CapabilityDescriptions[] + Caption + ColorTableEntries + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + CurrentBitsPerPixel + CurrentHorizontalResolution + CurrentNumberOfColors + CurrentNumberOfColumns + CurrentNumberOfRows + CurrentRefreshRate + CurrentScanMode + CurrentVerticalResolution + Description + DeviceID + DeviceSpecificPens + DitherType + DriverDate + DriverVersion + ErrorCleared + ErrorDescription + ICMIntent + ICMMethod + InfFilename + InfSection + InstallDate + InstalledDisplayDrivers + LastErrorCode + MaxMemorySupported + MaxNumberControlled + MaxRefreshRate + MinRefreshRate + Monochrome + Name + NumberOfColorPlanes + NumberOfVideoPages + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + ProtocolSupported + ReservedSystemPaletteEntries + SpecificationVersion + Status + StatusInfo + SystemCreationClassName + SystemName + SystemPaletteEntries + TimeOfLastReset + VideoArchitecture + VideoMemoryType + VideoMode + VideoModeDescription + VideoProcessor + + + Accuracy + Availability + Caption + ConfigManagerErrorCode + ConfigManagerUserConfig + CreationClassName + CurrentReading + Description + DeviceID + ErrorCleared + ErrorDescription + InstallDate + IsLinear + LastErrorCode + LowerThresholdCritical + LowerThresholdFatal + LowerThresholdNonCritical + MaxReadable + MinReadable + Name + NominalReading + NormalMax + NormalMin + PNPDeviceID + PowerManagementCapabilities[] + PowerManagementSupported + Resolution + Status + StatusInfo + SystemCreationClassName + SystemName + Tolerance + UpperThresholdCritical + UpperThresholdFatal + UpperThresholdNonCritical + + + + + + diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index f29a631e2..d1ef102ad 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -365,6 +365,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebRtc.NET", "SideChains\We EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.WebRTC", "Tango.WebRTC\Tango.WebRTC.csproj", "{09F81A12-0F77-4336-854D-9E0A74A17F9E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.SystemInfo", "Tango.SystemInfo\Tango.SystemInfo.csproj", "{997A961C-BEDA-4B56-AA0F-C39E532F7FFA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -6491,6 +6493,46 @@ Global {09F81A12-0F77-4336-854D-9E0A74A17F9E}.Release|x64.Build.0 = Release|Any CPU {09F81A12-0F77-4336-854D-9E0A74A17F9E}.Release|x86.ActiveCfg = Release|Any CPU {09F81A12-0F77-4336-854D-9E0A74A17F9E}.Release|x86.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|ARM.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|x64.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.AppVeyor|x86.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|ARM.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|ARM.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|ARM64.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|x64.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|x64.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|x86.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Debug|x86.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|Any CPU.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|ARM.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|ARM.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|ARM64.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|ARM64.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x64.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x64.Build.0 = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x86.ActiveCfg = Release|Any CPU + {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -6615,12 +6657,12 @@ Global {A07E6CB4-0132-4EB1-9A38-C8C057884DC2} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_UpdateFileVersion = False - BuildVersion_StartDate = 2000/1/1 - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs BuildVersion_UseGlobalSettings = False + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_StartDate = 2000/1/1 + BuildVersion_UpdateFileVersion = False + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} EndGlobalSection EndGlobal -- cgit v1.3.1 From 96fe20a20e7c107473cefeda3b06950955952bec Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 15 Mar 2020 01:55:42 +0200 Subject: Improved Console. Increased SignalR adapter connect timeout. Implemented Tango.FileSystem !!! --- .../ViewModels/ConsoleViewVM.cs | 7 +- .../Tango.FSE.Common/Console/IConsoleService.cs | 2 +- .../Tango.FSE.UI/Console/DefaultConsoleService.cs | 6 +- .../FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs | 53 ++ .../FSE/Tango.FSE.UI/Views/LayoutView.xaml | 71 +- .../Console/DefaultConsoleEngineService.cs | 6 +- .../Tango.Console/ConsoleControlVM.cs | 7 +- .../Tango.Console/ConsoleDictionary.cs | 2 +- .../Tango.Console/ConsoleExecutionEngine.cs | 26 +- .../Visual_Studio/Tango.Console/ConsoleTextBox.cs | 28 +- .../Network/GetCurrentDirectoryResponse.cs | 6 + .../Tango.Console/Themes/Generic.xaml | 72 +- .../Visual_Studio/Tango.FileSystem/DragItem.cs | 14 + .../Visual_Studio/Tango.FileSystem/DriveItem.cs | 38 + .../Tango.FileSystem/FileExplorerControl.cs | 423 +++++++++ .../Tango.FileSystem/FileExplorerControlMode.cs | 14 + .../Visual_Studio/Tango.FileSystem/FileItem.cs | 132 +++ .../Tango.FileSystem/FileSystemItem.cs | 78 ++ .../Tango.FileSystem/FileSystemItemType.cs | 15 + .../Tango.FileSystem/FileSystemManager.cs | 89 ++ .../Visual_Studio/Tango.FileSystem/FolderItem.cs | 34 + .../Tango.FileSystem/IFileSystemContainer.cs | 14 + .../Tango.FileSystem/Images/drive.png | Bin 0 -> 2166 bytes .../Tango.FileSystem/Images/folder.png | Bin 0 -> 317 bytes .../Tango.FileSystem/Network/FileSystemItemDTO.cs | 33 + .../Tango.FileSystem/Network/FileUploadRequest.cs | 14 + .../Tango.FileSystem/Network/FileUploadResponse.cs | 13 + .../Network/GetFileSystemItemRequest.cs | 13 + .../Network/GetFileSystemItemResponse.cs | 13 + .../Network/StartFileDownloadRequest.cs | 13 + .../Network/StartFileDownloadResponse.cs | 15 + .../Network/StartFolderDownloadRequest.cs | 13 + .../Network/StartFolderDownloadResponse.cs | 15 + .../Tango.FileSystem/Properties/AssemblyInfo.cs | 55 ++ .../Properties/Resources.Designer.cs | 62 ++ .../Tango.FileSystem/Properties/Resources.resx | 117 +++ .../Properties/Settings.Designer.cs | 30 + .../Tango.FileSystem/Properties/Settings.settings | 7 + .../Tango.FileSystem/Tango.FileSystem.csproj | 122 +++ .../Tango.FileSystem/Themes/Generic.xaml | 211 +++++ .../Tango.FileSystem/VirtualFileDataObject.cs | 983 +++++++++++++++++++++ .../Converters/DateTimeUtcToLocalDateTime.cs | 30 + .../Tango.SharedUI/Tango.SharedUI.csproj | 3 +- .../Adapters/SignalRTransportAdapter.cs | 10 +- .../Tango.Transport/ITransportAdapter.cs | 3 +- Software/Visual_Studio/Tango.sln | 54 +- 46 files changed, 2881 insertions(+), 85 deletions(-) create mode 100644 Software/Visual_Studio/Tango.FileSystem/DragItem.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/DriveItem.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FileExplorerControlMode.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FileItem.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FileSystemItem.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FileSystemItemType.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/FolderItem.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/IFileSystemContainer.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Images/drive.png create mode 100644 Software/Visual_Studio/Tango.FileSystem/Images/folder.png create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/FileSystemItemDTO.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/FileUploadRequest.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/FileUploadResponse.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemResponse.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadRequest.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadResponse.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadRequest.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadResponse.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Properties/Resources.resx create mode 100644 Software/Visual_Studio/Tango.FileSystem/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Properties/Settings.settings create mode 100644 Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj create mode 100644 Software/Visual_Studio/Tango.FileSystem/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/Tango.FileSystem/VirtualFileDataObject.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs index 3ccab26da..4c6eb9958 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs @@ -35,13 +35,14 @@ namespace Tango.FSE.PPCConsole.ViewModels public override void OnApplicationStarted() { - ConsoleService.Initialized += ConsoleService_Initialized; + ConsoleService.Initialized += ConsoleService_Initialized1; } - private void ConsoleService_Initialized(object sender, EventArgs e) + private void ConsoleService_Initialized1(object sender, GetCurrentDirectoryResponse e) { ConsoleVM.Clear(); - ConsoleVM.CurrentCommand.WorkingFolder = ConsoleService.CurrentDirectory; + ConsoleVM.CurrentCommand.WorkingFolder = e.CurrentDirectory; + ConsoleVM.AppendSuggestions(e.Suggestions); } private async void ConsoleVM_CommandExecuting(object sender, ConsoleCommandExecutingEventArgs e) diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Console/IConsoleService.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Console/IConsoleService.cs index dd32b9b93..321b183d8 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Console/IConsoleService.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Console/IConsoleService.cs @@ -9,7 +9,7 @@ namespace Tango.FSE.Common.Console { public interface IConsoleService { - event EventHandler Initialized; + event EventHandler Initialized; String CurrentDirectory { get; } Task ExecuteCommand(ConsoleCommandRequest request, TimeSpan? timeout = null); } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs index a13adc6d1..640b547a9 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs @@ -14,7 +14,7 @@ namespace Tango.FSE.UI.Console [TangoCreateWhenRegistered] public class DefaultConsoleService : ExtendedObject, IConsoleService { - public event EventHandler Initialized; + public event EventHandler Initialized; public string CurrentDirectory { get; private set; } @@ -30,8 +30,8 @@ namespace Tango.FSE.UI.Console { try { - CurrentDirectory = (await MachineProvider.MachineOperator.SendGenericRequest(new GetCurrentDirectoryRequest())).CurrentDirectory; - Initialized?.Invoke(this, new EventArgs()); + var response = await MachineProvider.MachineOperator.SendGenericRequest(new GetCurrentDirectoryRequest(), new Transport.TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(10) }); + Initialized?.Invoke(this, response); } catch (Exception ex) { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs index 29d7e1394..4e6621b9e 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs @@ -5,17 +5,22 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.Core.Threading; using Tango.FSE.Common; using Tango.FSE.Common.Navigation; using Tango.FSE.Common.Notifications; using Tango.FSE.UI.Panes; using Tango.Integration.ExternalBridge; using Tango.SharedUI.Helpers; +using Tango.Transport; namespace Tango.FSE.UI.ViewModels { public class LayoutViewVM : FSEViewModel { + private ActionTimer _transportOutActionTimer; + private ActionTimer _transportInActionTimer; + private bool _isConnectionPaneOpened; public bool IsConnectionPaneOpened { @@ -58,6 +63,20 @@ namespace Tango.FSE.UI.ViewModels set { _isLogsOpened = value; RaisePropertyChangedAuto(); } } + private bool _transportOut; + public bool TransportOut + { + get { return _transportOut; } + set { _transportOut = value; RaisePropertyChanged(nameof(TransportOut)); } + } + + private bool _transportIn; + public bool TransportIn + { + get { return _transportIn; } + set { _transportIn = value; RaisePropertyChanged(nameof(TransportIn)); } + } + public RelayCommand ToggleConnectionPaneCommand { get; set; } public RelayCommand LogoutCommand { get; set; } @@ -74,6 +93,37 @@ namespace Tango.FSE.UI.ViewModels LogViewerPaneVM = new LogViewerPaneVM(); LogoutCommand = new RelayCommand(Logout); + + _transportOutActionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + _transportInActionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + } + + private void MachineProvider_MachineDisconnected(object sender, Common.Connection.MachineDisconnectedEventArgs e) + { + if (e.MachineOperator.Adapter != null) + { + e.MachineOperator.Adapter.PropertyChanged -= Adapter_PropertyChanged; + } + } + + private void MachineProvider_MachineConnected(object sender, Common.Connection.MachineConnectedEventArgs e) + { + e.MachineOperator.Adapter.PropertyChanged -= Adapter_PropertyChanged; + e.MachineOperator.Adapter.PropertyChanged += Adapter_PropertyChanged; + } + + private void Adapter_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(ITransportAdapter.TotalBytesSent)) + { + TransportOut = true; + _transportOutActionTimer.ResetReplace(() => TransportOut = false); + } + else if (e.PropertyName == nameof(ITransportAdapter.TotalBytesReceived)) + { + TransportIn = true; + _transportInActionTimer.ResetReplace(() => TransportIn = false); + } } private async void ConnectedMachinePaneVM_DisconnectedFromMachine(object sender, EventArgs e) @@ -115,6 +165,9 @@ namespace Tango.FSE.UI.ViewModels public override void OnApplicationStarted() { DiagnosticsProvider.FrameReceived += DiagnosticsProvider_FrameReceived; + + MachineProvider.MachineDisconnected += MachineProvider_MachineDisconnected; + MachineProvider.MachineConnected += MachineProvider_MachineConnected; } private void DiagnosticsProvider_FrameReceived(object sender, Common.Diagnostics.DiagnosticsFrameReceivedEventArgs e) diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml index eaf49c51a..cbe57e8dc 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml @@ -26,7 +26,8 @@ - + + @@ -42,10 +43,62 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -55,7 +108,7 @@ - + @@ -495,7 +548,7 @@ - + @@ -539,7 +592,7 @@ - + @@ -550,7 +603,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs index 02d510a93..4a9ee468a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs @@ -25,7 +25,11 @@ namespace Tango.PPC.Common.Console [ExternalBridgeRequestHandlerMethod(typeof(GetCurrentDirectoryRequest))] public async void OnGetCurrentDirectoryRequest(GetCurrentDirectoryRequest request, String token, ITransporter transporter) { - await transporter.SendGenericResponse(new GetCurrentDirectoryResponse() { CurrentDirectory = Environment.CurrentDirectory }, token); + await transporter.SendGenericResponse(new GetCurrentDirectoryResponse() + { + CurrentDirectory = Environment.CurrentDirectory, + Suggestions = ConsoleExecutionEngine.GetSuggestions(Environment.CurrentDirectory) + }, token); } [ExternalBridgeRequestHandlerMethod(typeof(ConsoleCommandRequest))] diff --git a/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs b/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs index ed32bd321..1cb4118b9 100644 --- a/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs +++ b/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs @@ -106,13 +106,18 @@ namespace Tango.Console CreateNew(result.WorkingFolder, true); - Suggestions = _knownSuggestions.Concat(result.Suggestions).OrderBy(x => x.Name).ToList(); + AppendSuggestions(result.Suggestions); }); CommandExecuting?.Invoke(this, args); } } + public void AppendSuggestions(List suggestions) + { + Suggestions = _knownSuggestions.Concat(suggestions).OrderBy(x => x.Name).ToList(); + } + public void Clear() { Commands.Clear(); diff --git a/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs b/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs index f0e1ab3f6..00e4a865d 100644 --- a/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs +++ b/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs @@ -25,7 +25,7 @@ namespace Tango.Console { ConsoleKnownCommand command = new ConsoleKnownCommand(); String[] args = line.Split('\t'); - command.Name = args[0]; + command.Name = args[0].ToLower(); command.Description = args[1].Replace("\"", ""); _knownCommands.Add(command); } diff --git a/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs b/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs index 42bc2ac00..02b58a658 100644 --- a/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs +++ b/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs @@ -61,7 +61,7 @@ namespace Tango.Console } //process.StartInfo.Verb = "runas"; - if (ConsoleDictionary.GetKnownCommands().Exists(x => x.Name.ToLower() == parsedCommand.Command)) + if (ConsoleDictionary.GetKnownCommands().Exists(x => x.Name.ToLower() == parsedCommand.Command.ToLower())) { process.StartInfo.FileName = "cmd.exe"; process.StartInfo.Arguments = "/C " + request.Command; @@ -93,30 +93,38 @@ namespace Tango.Console }); } - private ConsoleCommandExecutionResult CreateResult(String workingFolder, String output) + public static List GetSuggestions(String folder) { - ConsoleCommandExecutionResult result = new ConsoleCommandExecutionResult(); - result.WorkingFolder = workingFolder; - result.Output = output; + List suggestions = new List(); - foreach (var dir in Directory.GetDirectories(Path.GetFullPath(workingFolder))) + foreach (var dir in Directory.GetDirectories(Path.GetFullPath(folder))) { - result.Suggestions.Add(new ConsoleSuggestion() + suggestions.Add(new ConsoleSuggestion() { Type = ConsoleSuggestionType.Folder, Name = Path.GetFileName(dir) }); } - foreach (var file in Directory.GetFiles(Path.GetFullPath(workingFolder))) + foreach (var file in Directory.GetFiles(Path.GetFullPath(folder))) { - result.Suggestions.Add(new ConsoleSuggestion() + suggestions.Add(new ConsoleSuggestion() { Type = ConsoleSuggestionType.File, Name = Path.GetFileName(file), }); } + return suggestions; + } + + private ConsoleCommandExecutionResult CreateResult(String workingFolder, String output) + { + ConsoleCommandExecutionResult result = new ConsoleCommandExecutionResult(); + result.WorkingFolder = workingFolder; + result.Output = output; + result.Suggestions.AddRange(GetSuggestions(workingFolder)); + return result; } } diff --git a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs index 2802c0fe6..d2d20b629 100644 --- a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs +++ b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs @@ -22,6 +22,7 @@ namespace Tango.Console private Border _caret; private ListBox _listSuggestions; private Popup _popup; + private Popup _suggestionsPopup; static ConsoleTextBox() { @@ -44,13 +45,13 @@ namespace Tango.Console public static readonly DependencyProperty CaretPositionProperty = DependencyProperty.Register("CaretPosition", typeof(double), typeof(ConsoleTextBox), new PropertyMetadata(0.0)); - public Visibility SuggestionsVisibility + public bool IsSuggestionsOpened { - get { return (Visibility)GetValue(SuggestionsVisibilityProperty); } - set { SetValue(SuggestionsVisibilityProperty, value); } + get { return (bool)GetValue(IsSuggestionsOpenedProperty); } + set { SetValue(IsSuggestionsOpenedProperty, value); } } - public static readonly DependencyProperty SuggestionsVisibilityProperty = - DependencyProperty.Register("SuggestionsVisibility", typeof(Visibility), typeof(ConsoleTextBox), new PropertyMetadata(Visibility.Collapsed)); + public static readonly DependencyProperty IsSuggestionsOpenedProperty = + DependencyProperty.Register("IsSuggestionsOpened", typeof(bool), typeof(ConsoleTextBox), new PropertyMetadata(false)); public List FilteredSuggestions { @@ -125,7 +126,7 @@ namespace Tango.Console protected override void OnPreviewKeyDown(KeyEventArgs e) { - if (SuggestionsVisibility == Visibility.Visible) + if (IsSuggestionsOpened) { if (e.Key == Key.Down) { @@ -179,13 +180,13 @@ namespace Tango.Console Text = selectedItem.Name; } - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; CaretIndex = Text.Length; e.Handled = true; return; } - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; } } @@ -203,21 +204,21 @@ namespace Tango.Console if (Suggestions != null) { - FilteredSuggestions = Suggestions.Where(x => lastWord.IsNotNullOrEmpty() && x.Name.ToLower().StartsWith(lastWord.ToLower())).OrderBy(x => x.Name).Take(MaxSuggestions).ToList(); + FilteredSuggestions = Suggestions.Where(x => (lastWord.IsNotNullOrEmpty() && x.Name.ToLower().StartsWith(lastWord.ToLower())) || Text.EndsWith(" ")).OrderBy(x => x.Name).Take(MaxSuggestions).ToList(); if (Text.Contains(" ")) { FilteredSuggestions = FilteredSuggestions.Where(x => x.Type != ConsoleSuggestionType.Command).ToList(); } - SuggestionsVisibility = FilteredSuggestions.Count > 0 ? Visibility.Visible : Visibility.Collapsed; + IsSuggestionsOpened = FilteredSuggestions.Count > 0; _popup.IsOpen = false; _popup.IsOpen = FilteredSuggestions.Count > 0 && SelectedSuggestion != null; } } else { - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; _popup.IsOpen = false; } } @@ -228,7 +229,7 @@ namespace Tango.Console if (CaretIndex < Text.Length) { - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; _popup.IsOpen = false; } } @@ -240,6 +241,7 @@ namespace Tango.Console _caret = GetTemplateChild("PART_Caret") as Border; _listSuggestions = GetTemplateChild("PART_listSuggestions") as ListBox; _popup = GetTemplateChild("PART_popup") as Popup; + _suggestionsPopup = GetTemplateChild("PART_SuggestionsPopup") as Popup; } private void MoveCustomCaret() @@ -250,6 +252,8 @@ namespace Tango.Console { Canvas.SetLeft(_caret, caretLocation.X); CaretPosition = caretLocation.X; + + _suggestionsPopup.PlacementRectangle = new Rect(CaretPosition + 10, 20, 0, 0); } } } diff --git a/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs b/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs index 30a24e461..7b6eedda0 100644 --- a/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs +++ b/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs @@ -9,5 +9,11 @@ namespace Tango.Console.Network public class GetCurrentDirectoryResponse { public String CurrentDirectory { get; set; } + public List Suggestions { get; set; } + + public GetCurrentDirectoryResponse() + { + Suggestions = new List(); + } } } diff --git a/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml index e2a9e2b8f..cc62cbbf5 100644 --- a/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml @@ -47,41 +47,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.FileSystem/DragItem.cs b/Software/Visual_Studio/Tango.FileSystem/DragItem.cs new file mode 100644 index 000000000..e71b095e1 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/DragItem.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem +{ + public class DragItem + { + public FileSystemItem FileSystemItem { get; set; } + public String Destination { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/DriveItem.cs b/Software/Visual_Studio/Tango.FileSystem/DriveItem.cs new file mode 100644 index 000000000..9c4494fec --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/DriveItem.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem +{ + public class DriveItem : FileSystemItem, IFileSystemContainer + { + public ObservableCollection Items { get; set; } + + public String Label { get; set; } + + public DriveType DriveType { get; set; } + + public DriveItem() + { + Type = FileSystemItemType.Drive; + Items = new ObservableCollection(); + } + + protected override string OnGetName() + { + return Label; + } + + public override string Description + { + get + { + return DriveType.ToString().ToTitle(); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs new file mode 100644 index 000000000..23cac7733 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs @@ -0,0 +1,423 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Core.IO; + +namespace Tango.FileSystem +{ + public class FileExplorerControl : Control + { + private ListBox _listBox; + private DataGrid _datagrid; + private bool _preventSynchronization; + private Point _dragOutStartPoint; + private bool _isMouseDown; + private List _selectedItemsBeforeDrag; + + public IFileSystemContainer CurrentItem + { + get { return (IFileSystemContainer)GetValue(CurrentItemProperty); } + set { SetValue(CurrentItemProperty, value); } + } + public static readonly DependencyProperty CurrentItemProperty = + DependencyProperty.Register("CurrentItem", typeof(IFileSystemContainer), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public FileSystemItem SelectedItem + { + get { return (FileSystemItem)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + public static readonly DependencyProperty SelectedItemProperty = + DependencyProperty.Register("SelectedItem", typeof(FileSystemItem), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ICommand ItemDoubleClickedCommand + { + get { return (ICommand)GetValue(ItemDoubleClickedCommandProperty); } + set { SetValue(ItemDoubleClickedCommandProperty, value); } + } + public static readonly DependencyProperty ItemDoubleClickedCommandProperty = + DependencyProperty.Register("ItemDoubleClickedCommand", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ICommand DeleteCommand + { + get { return (ICommand)GetValue(DeleteCommandProperty); } + set { SetValue(DeleteCommandProperty, value); } + } + public static readonly DependencyProperty DeleteCommandProperty = + DependencyProperty.Register("DeleteCommand", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ICommand DropCommand + { + get { return (ICommand)GetValue(DropCommandProperty); } + set { SetValue(DropCommandProperty, value); } + } + public static readonly DependencyProperty DropCommandProperty = + DependencyProperty.Register("DropCommand", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ICommand DragCommand + { + get { return (ICommand)GetValue(DragCommandProperty); } + set { SetValue(DragCommandProperty, value); } + } + public static readonly DependencyProperty DragCommandProperty = + DependencyProperty.Register("DragCommand", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ImageSource DriveIcon + { + get { return (ImageSource)GetValue(DriveIconProperty); } + set { SetValue(DriveIconProperty, value); } + } + public static readonly DependencyProperty DriveIconProperty = + DependencyProperty.Register("DriveIcon", typeof(ImageSource), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ImageSource FolderIcon + { + get { return (ImageSource)GetValue(FolderIconProperty); } + set { SetValue(FolderIconProperty, value); } + } + public static readonly DependencyProperty FolderIconProperty = + DependencyProperty.Register("FolderIcon", typeof(ImageSource), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public FileExplorerControlMode Mode + { + get { return (FileExplorerControlMode)GetValue(ModeProperty); } + set { SetValue(ModeProperty, value); } + } + public static readonly DependencyProperty ModeProperty = + DependencyProperty.Register("Mode", typeof(FileExplorerControlMode), typeof(FileExplorerControl), new PropertyMetadata(FileExplorerControlMode.Large)); + + public ObservableCollection SelectedItems + { + get { return (ObservableCollection)GetValue(SelectedItemsProperty); } + set { SetValue(SelectedItemsProperty, value); } + } + public static readonly DependencyProperty SelectedItemsProperty = + DependencyProperty.Register("SelectedItems", typeof(ObservableCollection), typeof(FileExplorerControl), new PropertyMetadata(null, (d, e) => (d as FileExplorerControl).OnSelectedItemsChanged())); + + public bool AllowDrag + { + get { return (bool)GetValue(AllowDragProperty); } + set { SetValue(AllowDragProperty, value); } + } + public static readonly DependencyProperty AllowDragProperty = + DependencyProperty.Register("AllowDrag", typeof(bool), typeof(FileExplorerControl), new PropertyMetadata(null)); + + static FileExplorerControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(FileExplorerControl), new FrameworkPropertyMetadata(typeof(FileExplorerControl))); + } + + public FileExplorerControl() + { + _selectedItemsBeforeDrag = new List(); + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _listBox = GetTemplateChild("PART_listbox") as ListBox; + _datagrid = GetTemplateChild("PART_datagrid") as DataGrid; + + _listBox.SelectionChanged += _listBox_SelectionChanged; + _datagrid.SelectionChanged += _datagrid_SelectionChanged; + } + + protected override void OnPreviewKeyUp(KeyEventArgs e) + { + base.OnPreviewKeyUp(e); + + if (e.Key == Key.Delete) + { + if (SelectedItems != null && SelectedItems.Count > 0) + { + DeleteCommand?.Execute(SelectedItems); + } + } + } + + private void _datagrid_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!_preventSynchronization) + { + _preventSynchronization = true; + + _listBox.SelectedItems.Clear(); + + foreach (var item in _datagrid.SelectedItems) + { + _listBox.SelectedItems.Add(item); + } + + SynchronizeSelectedItems(_listBox.SelectedItems); + + _preventSynchronization = false; + } + } + + private void _listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!_preventSynchronization) + { + _preventSynchronization = true; + + _datagrid.SelectedItems.Clear(); + + foreach (var item in _listBox.SelectedItems) + { + _datagrid.SelectedItems.Add(item); + } + + SynchronizeSelectedItems(_listBox.SelectedItems); + + _preventSynchronization = false; + } + } + + private void SynchronizeSelectedItems(IList items) + { + if (SelectedItems == null) + { + SelectedItems = items.Cast().ToObservableCollection(); + } + else + { + SelectedItems.Clear(); + + foreach (var item in items.Cast().ToList()) + { + SelectedItems.Add(item); + } + } + } + + private void OnSelectedItemsChanged() + { + if (SelectedItems != null) + { + SelectedItems.CollectionChanged -= SelectedItems_CollectionChanged; + SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; + SynchronizeControls(); + } + } + + private void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + SynchronizeControls(); + } + + private void SynchronizeControls() + { + if (_listBox == null) return; + + if (!_preventSynchronization) + { + _preventSynchronization = true; + + _listBox.SelectedItems.Clear(); + _datagrid.SelectedItems.Clear(); + + foreach (var item in SelectedItems) + { + _listBox.SelectedItems.Add(item); + _datagrid.SelectedItems.Add(item); + } + + _preventSynchronization = false; + } + } + + protected override void OnDrop(DragEventArgs e) + { + base.OnDrop(e); + + try + { + string[] items = (string[])e.Data.GetData(DataFormats.FileDrop, false); + + if (items != null && items.Length > 0) + { + List fItems = new List(); + + foreach (var item in items) + { + if (Directory.Exists(item)) + { + fItems.Add(new FolderItem() { Path = item }); + } + else if (File.Exists(item)) + { + fItems.Add(new FileItem() { Path = item }); + } + } + + if (fItems.Count > 0) + { + DropCommand?.Execute(fItems); + } + } + } + catch { } //Ignore + } + + protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) + { + base.OnPreviewMouseLeftButtonDown(e); + + if (!AllowDrag) return; + + if (e.OriginalSource is FrameworkElement) + { + var listBoxItem = (e.OriginalSource as FrameworkElement).FindAncestor(); + var dataGridRow = (e.OriginalSource as FrameworkElement).FindAncestor(); + if (listBoxItem == null && dataGridRow == null) + { + return; + } + } + + _selectedItemsBeforeDrag.Clear(); + _selectedItemsBeforeDrag.AddRange(SelectedItems); + _isMouseDown = true; + AllowDrop = false; + _dragOutStartPoint = e.GetPosition(null); + } + + protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) + { + base.OnPreviewMouseLeftButtonUp(e); + AllowDrop = true; + _isMouseDown = false; + } + + protected async override void OnPreviewMouseMove(MouseEventArgs e) + { + base.OnPreviewMouseMove(e); + + if (_isMouseDown) + { + Point mpos = e.GetPosition(null); + Vector diff = this._dragOutStartPoint - mpos; + + if (e.LeftButton == MouseButtonState.Pressed && + Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || + Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance) + { + if (SelectedItems.Count == 0) + { + return; + } + + + SelectedItems.Clear(); + + foreach (var item in _selectedItemsBeforeDrag) + { + SelectedItems.Add(item); + } + + List> dropItems = new List>(); + + foreach (var item in SelectedItems) + { + var tempFile = TemporaryManager.Default.CreateFile(".remote"); + dropItems.Add(new Tuple(item, tempFile)); + } + + List notifyItems = new List(); + + List watchers = new List(); + + FileSystemEventHandler handler = (x, args) => + { + var detectedDropItem = dropItems.SingleOrDefault(y => y.Item2.FileName == System.IO.Path.GetFileName(args.FullPath)); + + Debug.WriteLine($"File Created: {args.FullPath}"); + + if (detectedDropItem != null) + { + try + { + detectedDropItem.Item2.Delete(); //Delete temp file. + + if (File.Exists(args.FullPath)) + { + File.Delete(args.FullPath); //Delete dropped fake file. + + dropItems.Remove(detectedDropItem); + + notifyItems.Add(new DragItem() + { + FileSystemItem = detectedDropItem.Item1, + Destination = System.IO.Path.GetDirectoryName(args.FullPath), + }); + + if (dropItems.Count == 0) + { + foreach (var watcher in watchers) + { + watcher.Dispose(); + } + + //Notify to user with all items! + Dispatcher.BeginInvoke(new Action(() => + { + DragCommand?.Execute(notifyItems); + })); + } + } + } + catch { } + } + else + { + Debug.WriteLine($"Not Found: {args.FullPath}"); + } + }; + + foreach (var drive in DriveInfo.GetDrives().Where(x => x.IsReady && (x.DriveType == DriveType.Fixed || x.DriveType == DriveType.Removable))) + { + FileSystemWatcher watcher = new FileSystemWatcher(drive.RootDirectory.FullName, "*.remote"); + watcher.IncludeSubdirectories = true; + watcher.EnableRaisingEvents = true; + watcher.Created += handler; + watchers.Add(watcher); + } + + string[] files = dropItems.Select(x => x.Item2.Path).ToArray(); + var ef = DragDrop.DoDragDrop(this, new DataObject(DataFormats.FileDrop, files, false), DragDropEffects.Copy); + + await Task.Delay(3000); + + foreach (var watcher in watchers) + { + watcher.Dispose(); + } + + if (dropItems.Count > 0) + { + //Notify about problem! + } + + _isMouseDown = false; + AllowDrop = true; + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControlMode.cs b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControlMode.cs new file mode 100644 index 000000000..b11c93845 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControlMode.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem +{ + public enum FileExplorerControlMode + { + Large, + Details + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FileItem.cs b/Software/Visual_Studio/Tango.FileSystem/FileItem.cs new file mode 100644 index 000000000..cbc90ce06 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FileItem.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Tango.Core.IO; + +namespace Tango.FileSystem +{ + public class FileItem : FileSystemItem + { + private static Dictionary iconCache; + private static Dictionary smallIconCache; + private static Dictionary typeDescriptionCache; + + static FileItem() + { + iconCache = new Dictionary(); + smallIconCache = new Dictionary(); + typeDescriptionCache = new Dictionary(); + } + + public FileItem() + { + Type = FileSystemItemType.File; + } + + public String Extension + { + get { return System.IO.Path.GetExtension(Path); } + } + + private BitmapSource _icon; + public BitmapSource Icon + { + get + { + if (_icon == null) + { + _icon = GetFileIcon(); + } + + return _icon; + } + } + + private BitmapSource _smallIcon; + public BitmapSource SmallIcon + { + get + { + if (_smallIcon == null) + { + _smallIcon = GetSmallFileIcon(); + } + + return _smallIcon; + } + } + + public override string Description + { + get + { + if (typeDescriptionCache.ContainsKey(Extension)) + { + return typeDescriptionCache[Extension]; + } + else + { + var tempFile = TemporaryManager.Default.CreateFile(Extension); + var shellFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(tempFile); + var text = shellFile.Properties.System.ItemTypeText.Value.ToStringSafe(); + shellFile.Dispose(); + tempFile.Delete(); + typeDescriptionCache.Add(Extension, text); + return text; + } + } + } + + protected BitmapSource GetFileIcon() + { + if (iconCache.ContainsKey(Extension)) + { + return iconCache[Extension]; + } + else + { + var tempFile = TemporaryManager.Default.CreateFile(Extension); + var shellFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(tempFile); + var source = shellFile.Thumbnail.MediumBitmapSource; + shellFile.Dispose(); + tempFile.Delete(); + iconCache.Add(Extension, source); + return source; + } + } + + private BitmapSource GetSmallFileIcon() + { + if (smallIconCache.ContainsKey(Extension)) + { + return smallIconCache[Extension]; + } + else + { + var tempFile = TemporaryManager.Default.CreateFile(Extension); + var shellFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(tempFile); + var source = shellFile.Thumbnail.SmallBitmapSource; + shellFile.Dispose(); + tempFile.Delete(); + smallIconCache.Add(Extension, source); + return source; + } + } + + private BitmapSource IconToBitmapSource(Icon icon) + { + var imageSource = Imaging.CreateBitmapSourceFromHIcon( + icon.Handle, + Int32Rect.Empty, + BitmapSizeOptions.FromEmptyOptions()); + return imageSource; + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemItem.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemItem.cs new file mode 100644 index 000000000..6f8190f6c --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemItem.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.FileSystem.Network; + +namespace Tango.FileSystem +{ + public abstract class FileSystemItem + { + public String Path { get; set; } + + public FileSystemItemType Type { get; protected set; } + + public abstract String Description { get; } + + public DateTime DateModified { get; set; } + + public long Size { get; set; } + + public String Name + { + get { return OnGetName(); } + } + + public FileSystemItem() + { + DateModified = DateTime.Now; + Size = 1000 * 1000; + } + + protected virtual String OnGetName() + { + return System.IO.Path.GetFileName(Path); + } + + public override string ToString() + { + return Name; + } + + public static FileSystemItem FromDTO(FileSystemItemDTO dto) + { + FileSystemItem item = null; + + if (dto.Type == FileSystemItemType.Drive) + { + item = new DriveItem() + { + DriveType = dto.DriveType, + Label = dto.DriveLabel, + Items = dto.Items.Select(x => FromDTO(x)).ToObservableCollection() + }; + } + else if (dto.Type == FileSystemItemType.Folder) + { + item = new FolderItem() + { + Items = dto.Items.Select(x => FromDTO(x)).ToObservableCollection() + }; + } + else if (dto.Type == FileSystemItemType.File) + { + item = new FileItem(); + } + + item.DateModified = dto.DateModified; + item.Path = dto.Path; + item.Size = dto.Size; + item.Type = dto.Type; + + return item; + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemItemType.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemItemType.cs new file mode 100644 index 000000000..5af1858a9 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemItemType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem +{ + public enum FileSystemItemType + { + Drive, + Folder, + File, + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs new file mode 100644 index 000000000..9a051793d --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FileSystem.Network; + +namespace Tango.FileSystem +{ + public class FileSystemManager + { + public FileSystemItemDTO GetRoot() + { + FileSystemItemDTO folder = new FileSystemItemDTO(); + folder.Path = "This PC"; + folder.IsRoot = true; + folder.Type = FileSystemItemType.Folder; + folder.Items = DriveInfo.GetDrives().Select(x => new FileSystemItemDTO() + { + Path = x.RootDirectory.FullName, + DriveType = x.DriveType, + DriveLabel = x.Name, + Type = FileSystemItemType.Drive, + }).Cast().ToList(); + + return folder; + } + + public FileSystemItemDTO GetFolder(String path) + { + List items = new List(); + + if (String.IsNullOrWhiteSpace(path)) + { + return GetRoot(); + } + + if (!Directory.Exists(path)) + { + throw new DirectoryNotFoundException("The specified directory could not be located."); + } + + foreach (var directory in Directory.GetDirectories(path)) + { + items.Add(new FileSystemItemDTO() + { + Path = directory, + Type = FileSystemItemType.Folder, + DateModified = Directory.GetLastWriteTimeUtc(directory), + }); + } + + foreach (var file in Directory.GetFiles(path)) + { + items.Add(new FileSystemItemDTO() + { + Path = file, + Type = FileSystemItemType.File, + DateModified = File.GetLastWriteTimeUtc(file), + Size = new FileInfo(file).Length + }); + } + + return new FileSystemItemDTO() + { + Path = path, + Type = path.Length == 3 ? FileSystemItemType.Drive : FileSystemItemType.Folder, + Items = items + }; + } + + public void Delete(String path) + { + if (Directory.Exists(path)) + { + Directory.Delete(path); + } + else if (File.Exists(path)) + { + File.Delete(path); + } + else + { + throw new FileNotFoundException("Could not locate the specified file or directory."); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/FolderItem.cs b/Software/Visual_Studio/Tango.FileSystem/FolderItem.cs new file mode 100644 index 000000000..95b065a2d --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/FolderItem.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem +{ + public class FolderItem : FileSystemItem, IFileSystemContainer + { + public ObservableCollection Items { get; set; } + + public bool IsRoot { get; set; } + + public object Icon { get; set; } //Fake for binding error. + + public object SmallIcon { get; set; } //Fake for binding error. + + public FolderItem() + { + Type = FileSystemItemType.Folder; + Items = new ObservableCollection(); + } + + public override string Description + { + get + { + return "Folder"; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/IFileSystemContainer.cs b/Software/Visual_Studio/Tango.FileSystem/IFileSystemContainer.cs new file mode 100644 index 000000000..a75764a14 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/IFileSystemContainer.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem +{ + public interface IFileSystemContainer + { + ObservableCollection Items { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Images/drive.png b/Software/Visual_Studio/Tango.FileSystem/Images/drive.png new file mode 100644 index 000000000..b0cda6195 Binary files /dev/null and b/Software/Visual_Studio/Tango.FileSystem/Images/drive.png differ diff --git a/Software/Visual_Studio/Tango.FileSystem/Images/folder.png b/Software/Visual_Studio/Tango.FileSystem/Images/folder.png new file mode 100644 index 000000000..800af7186 Binary files /dev/null and b/Software/Visual_Studio/Tango.FileSystem/Images/folder.png differ diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/FileSystemItemDTO.cs b/Software/Visual_Studio/Tango.FileSystem/Network/FileSystemItemDTO.cs new file mode 100644 index 000000000..900ba0628 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/FileSystemItemDTO.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class FileSystemItemDTO + { + public String Path { get; set; } + + public String DriveLabel { get; set; } + + public FileSystemItemType Type { get; set; } + + public DriveType DriveType { get; set; } + + public DateTime DateModified { get; set; } + + public long Size { get; set; } + + public bool IsRoot { get; set; } + + public List Items { get; set; } + + public FileSystemItemDTO() + { + Items = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/FileUploadRequest.cs b/Software/Visual_Studio/Tango.FileSystem/Network/FileUploadRequest.cs new file mode 100644 index 000000000..50c35c584 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/FileUploadRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class FileUploadRequest + { + public String Path { get; set; } + public byte[] Data { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/FileUploadResponse.cs b/Software/Visual_Studio/Tango.FileSystem/Network/FileUploadResponse.cs new file mode 100644 index 000000000..4f4bc0d52 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/FileUploadResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class FileUploadResponse + { + + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs b/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs new file mode 100644 index 000000000..f69c7bd98 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class GetFileSystemItemRequest + { + public String Path { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemResponse.cs b/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemResponse.cs new file mode 100644 index 000000000..8b82e41fc --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class GetFileSystemItemResponse + { + public FileSystemItemDTO FileSystemItem { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadRequest.cs b/Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadRequest.cs new file mode 100644 index 000000000..aac03af38 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class StartFileDownloadRequest + { + public String Path { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadResponse.cs b/Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadResponse.cs new file mode 100644 index 000000000..187d15254 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/StartFileDownloadResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class StartFileDownloadResponse + { + public byte[] Data { get; set; } + public long Position { get; set; } + public long Length { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadRequest.cs b/Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadRequest.cs new file mode 100644 index 000000000..e7989bd98 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class StartFolderDownloadRequest + { + public String Path { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadResponse.cs b/Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadResponse.cs new file mode 100644 index 000000000..c48d4c04c --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/StartFolderDownloadResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class StartFolderDownloadResponse + { + public byte[] ZipData { get; set; } + public long Position { get; set; } + public long Length { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.FileSystem/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..6daf8a3bd --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.FileSystem")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.FileSystem")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Tango.FileSystem/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.FileSystem/Properties/Resources.Designer.cs new file mode 100644 index 000000000..10db63263 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.FileSystem.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.FileSystem.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Properties/Resources.resx b/Software/Visual_Studio/Tango.FileSystem/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.FileSystem/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.FileSystem/Properties/Settings.Designer.cs new file mode 100644 index 000000000..ddac2a111 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.FileSystem.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Properties/Settings.settings b/Software/Visual_Studio/Tango.FileSystem/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj b/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj new file mode 100644 index 000000000..90dfd78d2 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj @@ -0,0 +1,122 @@ + + + + + Debug + AnyCPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0} + library + Tango.FileSystem + Tango.FileSystem + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + 4.0 + + + + + + + + + + MSBuild:Compile + Designer + + + + Code + + + + + + + + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + 1.1.1 + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.FileSystem/Themes/Generic.xaml b/Software/Visual_Studio/Tango.FileSystem/Themes/Generic.xaml new file mode 100644 index 000000000..c9e561e29 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Themes/Generic.xaml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.FileSystem/VirtualFileDataObject.cs b/Software/Visual_Studio/Tango.FileSystem/VirtualFileDataObject.cs new file mode 100644 index 000000000..a4a065792 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/VirtualFileDataObject.cs @@ -0,0 +1,983 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; +using System.Windows; + +namespace Tango.FileSystem +{ + /// + /// Class implementing drag/drop and clipboard support for virtual files. + /// Also offers an alternate interface to the IDataObject interface. + /// + public sealed class VirtualFileDataObject : System.Runtime.InteropServices.ComTypes.IDataObject, IAsyncOperation + { + /// + /// Gets or sets a value indicating whether the data object can be used asynchronously. + /// + public bool IsAsynchronous { get; set; } + + /// + /// Identifier for CFSTR_FILECONTENTS. + /// + private static short FILECONTENTS = (short)(DataFormats.GetDataFormat(NativeMethods.CFSTR_FILECONTENTS).Id); + + /// + /// Identifier for CFSTR_FILEDESCRIPTORW. + /// + private static short FILEDESCRIPTORW = (short)(DataFormats.GetDataFormat(NativeMethods.CFSTR_FILEDESCRIPTORW).Id); + + /// + /// Identifier for CFSTR_PASTESUCCEEDED. + /// + private static short PASTESUCCEEDED = (short)(DataFormats.GetDataFormat(NativeMethods.CFSTR_PASTESUCCEEDED).Id); + + /// + /// Identifier for CFSTR_PERFORMEDDROPEFFECT. + /// + private static short PERFORMEDDROPEFFECT = (short)(DataFormats.GetDataFormat(NativeMethods.CFSTR_PERFORMEDDROPEFFECT).Id); + + /// + /// Identifier for CFSTR_PREFERREDDROPEFFECT. + /// + private static short PREFERREDDROPEFFECT = (short)(DataFormats.GetDataFormat(NativeMethods.CFSTR_PREFERREDDROPEFFECT).Id); + + /// + /// In-order list of registered data objects. + /// + private List _dataObjects = new List(); + + /// + /// Tracks whether an asynchronous operation is ongoing. + /// + private bool _inOperation; + + /// + /// Stores the user-specified start action. + /// + private Action _startAction; + + /// + /// Stores the user-specified end action. + /// + private Action _endAction; + + /// + /// Initializes a new instance of the VirtualFileDataObject class. + /// + public VirtualFileDataObject() + { + IsAsynchronous = true; + } + + /// + /// Initializes a new instance of the VirtualFileDataObject class. + /// + /// Optional action to run at the start of the data transfer. + /// Optional action to run at the end of the data transfer. + public VirtualFileDataObject(Action startAction, Action endAction) + : this() + { + _startAction = startAction; + _endAction = endAction; + } + + #region IDataObject Members + // Explicit interface implementation hides the technical details from users of VirtualFileDataObject. + + /// + /// Creates a connection between a data object and an advisory sink. + /// + /// A FORMATETC structure that defines the format, target device, aspect, and medium that will be used for future notifications. + /// One of the ADVF values that specifies a group of flags for controlling the advisory connection. + /// A pointer to the IAdviseSink interface on the advisory sink that will receive the change notification. + /// When this method returns, contains a pointer to a DWORD token that identifies this connection. + /// HRESULT success code. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + int System.Runtime.InteropServices.ComTypes.IDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) + { + Marshal.ThrowExceptionForHR(NativeMethods.OLE_E_ADVISENOTSUPPORTED); + throw new NotImplementedException(); + } + + /// + /// Destroys a notification connection that had been previously established. + /// + /// A DWORD token that specifies the connection to remove. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + void System.Runtime.InteropServices.ComTypes.IDataObject.DUnadvise(int connection) + { + Marshal.ThrowExceptionForHR(NativeMethods.OLE_E_ADVISENOTSUPPORTED); + throw new NotImplementedException(); + } + + /// + /// Creates an object that can be used to enumerate the current advisory connections. + /// + /// When this method returns, contains an IEnumSTATDATA that receives the interface pointer to the new enumerator object. + /// HRESULT success code. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + int System.Runtime.InteropServices.ComTypes.IDataObject.EnumDAdvise(out IEnumSTATDATA enumAdvise) + { + Marshal.ThrowExceptionForHR(NativeMethods.OLE_E_ADVISENOTSUPPORTED); + throw new NotImplementedException(); + } + + /// + /// Creates an object for enumerating the FORMATETC structures for a data object. + /// + /// One of the DATADIR values that specifies the direction of the data. + /// IEnumFORMATETC interface. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + IEnumFORMATETC System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc(DATADIR direction) + { + if (direction == DATADIR.DATADIR_GET) + { + if (0 == _dataObjects.Count) + { + // Note: SHCreateStdEnumFmtEtc fails for a count of 0; throw helpful exception + throw new InvalidOperationException("VirtualFileDataObject requires at least one data object to enumerate."); + } + + // Create enumerator and return it + IEnumFORMATETC enumerator; + if (NativeMethods.SUCCEEDED(NativeMethods.SHCreateStdEnumFmtEtc((uint)(_dataObjects.Count), _dataObjects.Select(d => d.FORMATETC).ToArray(), out enumerator))) + { + return enumerator; + } + + // Returning null here can cause an AV in the caller; throw instead + Marshal.ThrowExceptionForHR(NativeMethods.E_FAIL); + } + throw new NotImplementedException(); + } + + /// + /// Provides a standard FORMATETC structure that is logically equivalent to a more complex structure. + /// + /// A pointer to a FORMATETC structure that defines the format, medium, and target device that the caller would like to use to retrieve data in a subsequent call such as GetData. + /// When this method returns, contains a pointer to a FORMATETC structure that contains the most general information possible for a specific rendering, making it canonically equivalent to formatetIn. + /// HRESULT success code. + int System.Runtime.InteropServices.ComTypes.IDataObject.GetCanonicalFormatEtc(ref FORMATETC formatIn, out FORMATETC formatOut) + { + throw new NotImplementedException(); + } + + /// + /// Obtains data from a source data object. + /// + /// A pointer to a FORMATETC structure that defines the format, medium, and target device to use when passing the data. + /// When this method returns, contains a pointer to the STGMEDIUM structure that indicates the storage medium containing the returned data through its tymed member, and the responsibility for releasing the medium through the value of its pUnkForRelease member. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + void System.Runtime.InteropServices.ComTypes.IDataObject.GetData(ref FORMATETC format, out STGMEDIUM medium) + { + medium = new STGMEDIUM(); + var hr = ((System.Runtime.InteropServices.ComTypes.IDataObject)this).QueryGetData(ref format); + if (NativeMethods.SUCCEEDED(hr)) + { + // Find the best match + var formatCopy = format; // Cannot use ref or out parameter inside an anonymous method, lambda expression, or query expression + var dataObject = _dataObjects + .Where(d => + (d.FORMATETC.cfFormat == formatCopy.cfFormat) && + (d.FORMATETC.dwAspect == formatCopy.dwAspect) && + (0 != (d.FORMATETC.tymed & formatCopy.tymed) && + (d.FORMATETC.lindex == formatCopy.lindex))) + .FirstOrDefault(); + if (dataObject != null) + { + if (!IsAsynchronous && (FILEDESCRIPTORW == dataObject.FORMATETC.cfFormat) && !_inOperation) + { + // Enter the operation and call the start action + _inOperation = true; + if (null != _startAction) + { + _startAction(this); + } + } + + // Populate the STGMEDIUM + medium.tymed = dataObject.FORMATETC.tymed; + var result = dataObject.GetData(); // Possible call to user code + hr = result.Item2; + if (NativeMethods.SUCCEEDED(hr)) + { + medium.unionmember = result.Item1; + } + } + else + { + // Couldn't find a match + hr = NativeMethods.DV_E_FORMATETC; + } + } + if (!NativeMethods.SUCCEEDED(hr)) // Not redundant; hr gets updated in the block above + { + Marshal.ThrowExceptionForHR(hr); + } + } + + /// + /// Obtains data from a source data object. + /// + /// A pointer to a FORMATETC structure that defines the format, medium, and target device to use when passing the data. + /// A STGMEDIUM that defines the storage medium containing the data being transferred. + void System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere(ref FORMATETC format, ref STGMEDIUM medium) + { + throw new NotImplementedException(); + } + + /// + /// Determines whether the data object is capable of rendering the data described in the FORMATETC structure. + /// + /// A pointer to a FORMATETC structure that defines the format, medium, and target device to use for the query. + /// HRESULT success code. + int System.Runtime.InteropServices.ComTypes.IDataObject.QueryGetData(ref FORMATETC format) + { + var formatCopy = format; // Cannot use ref or out parameter inside an anonymous method, lambda expression, or query expression + var formatMatches = _dataObjects.Where(d => d.FORMATETC.cfFormat == formatCopy.cfFormat); + if (!formatMatches.Any()) + { + return NativeMethods.DV_E_FORMATETC; + } + var tymedMatches = formatMatches.Where(d => 0 != (d.FORMATETC.tymed & formatCopy.tymed)); + if (!tymedMatches.Any()) + { + return NativeMethods.DV_E_TYMED; + } + var aspectMatches = tymedMatches.Where(d => d.FORMATETC.dwAspect == formatCopy.dwAspect); + if (!aspectMatches.Any()) + { + return NativeMethods.DV_E_DVASPECT; + } + return NativeMethods.S_OK; + } + + /// + /// Transfers data to the object that implements this method. + /// + /// A FORMATETC structure that defines the format used by the data object when interpreting the data contained in the storage medium. + /// A STGMEDIUM structure that defines the storage medium in which the data is being passed. + /// true to specify that the data object called, which implements SetData, owns the storage medium after the call returns. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + void System.Runtime.InteropServices.ComTypes.IDataObject.SetData(ref FORMATETC formatIn, ref STGMEDIUM medium, bool release) + { + var handled = false; + if ((formatIn.dwAspect == DVASPECT.DVASPECT_CONTENT) && + (formatIn.tymed == TYMED.TYMED_HGLOBAL) && + (medium.tymed == formatIn.tymed)) + { + // Supported format; capture the data + var ptr = NativeMethods.GlobalLock(medium.unionmember); + if (IntPtr.Zero != ptr) + { + try + { + var length = NativeMethods.GlobalSize(ptr).ToInt32(); + var data = new byte[length]; + Marshal.Copy(ptr, data, 0, length); + // Store it in our own format + SetData(formatIn.cfFormat, data); + handled = true; + } + finally + { + NativeMethods.GlobalUnlock(medium.unionmember); + } + } + + // Release memory if we now own it + if (release) + { + Marshal.FreeHGlobal(medium.unionmember); + } + } + + // Handle synchronous mode + if (!IsAsynchronous && (PERFORMEDDROPEFFECT == formatIn.cfFormat) && _inOperation) + { + // Call the end action and exit the operation + if (null != _endAction) + { + _endAction(this); + } + _inOperation = false; + } + + // Throw if unhandled + if (!handled) + { + throw new NotImplementedException(); + } + } + + #endregion + + /// + /// Provides data for the specified data format (HGLOBAL). + /// + /// Data format. + /// Sequence of data. + public void SetData(short dataFormat, IEnumerable data) + { + _dataObjects.Add( + new DataObject + { + FORMATETC = new FORMATETC + { + cfFormat = dataFormat, + ptd = IntPtr.Zero, + dwAspect = DVASPECT.DVASPECT_CONTENT, + lindex = -1, + tymed = TYMED.TYMED_HGLOBAL + }, + GetData = () => + { + var dataArray = data.ToArray(); + var ptr = Marshal.AllocHGlobal(dataArray.Length); + Marshal.Copy(dataArray, 0, ptr, dataArray.Length); + return new Tuple(ptr, NativeMethods.S_OK); + }, + }); + } + + /// + /// Provides data for the specified data format and index (ISTREAM). + /// + /// Data format. + /// Index of data. + /// Action generating the data. + /// + /// Uses Stream instead of IEnumerable(T) because Stream is more likely + /// to be natural for the expected scenarios. + /// + public void SetData(short dataFormat, int index, Action streamData) + { + _dataObjects.Add( + new DataObject + { + FORMATETC = new FORMATETC + { + cfFormat = dataFormat, + ptd = IntPtr.Zero, + dwAspect = DVASPECT.DVASPECT_CONTENT, + lindex = index, + tymed = TYMED.TYMED_ISTREAM + }, + GetData = () => + { + // Create IStream for data + var ptr = IntPtr.Zero; + var iStream = NativeMethods.CreateStreamOnHGlobal(IntPtr.Zero, true); + if (streamData != null) + { + // Wrap in a .NET-friendly Stream and call provided code to fill it + using (var stream = new IStreamWrapper(iStream)) + { + streamData(stream); + } + } + // Return an IntPtr for the IStream + ptr = Marshal.GetComInterfaceForObject(iStream, typeof(IStream)); + Marshal.ReleaseComObject(iStream); + return new Tuple(ptr, NativeMethods.S_OK); + }, + }); + } + + /// + /// Provides data for the specified data format (FILEGROUPDESCRIPTOR/FILEDESCRIPTOR) + /// + /// Collection of virtual files. + public void SetData(IEnumerable fileDescriptors) + { + // Prepare buffer + var bytes = new List(); + // Add FILEGROUPDESCRIPTOR header + bytes.AddRange(StructureBytes(new NativeMethods.FILEGROUPDESCRIPTOR { cItems = (uint)(fileDescriptors.Count()) })); + // Add n FILEDESCRIPTORs + foreach (var fileDescriptor in fileDescriptors) + { + // Set required fields + var FILEDESCRIPTOR = new NativeMethods.FILEDESCRIPTOR + { + cFileName = fileDescriptor.Name, + }; + // Set optional timestamp + if (fileDescriptor.ChangeTimeUtc.HasValue) + { + FILEDESCRIPTOR.dwFlags |= NativeMethods.FD_CREATETIME | NativeMethods.FD_WRITESTIME; + var changeTime = fileDescriptor.ChangeTimeUtc.Value.ToLocalTime().ToFileTime(); + var changeTimeFileTime = new System.Runtime.InteropServices.ComTypes.FILETIME + { + dwLowDateTime = (int)(changeTime & 0xffffffff), + dwHighDateTime = (int)(changeTime >> 32), + }; + FILEDESCRIPTOR.ftLastWriteTime = changeTimeFileTime; + FILEDESCRIPTOR.ftCreationTime = changeTimeFileTime; + } + // Set optional length + if (fileDescriptor.Length.HasValue) + { + FILEDESCRIPTOR.dwFlags |= NativeMethods.FD_FILESIZE; + FILEDESCRIPTOR.nFileSizeLow = (uint)(fileDescriptor.Length & 0xffffffff); + FILEDESCRIPTOR.nFileSizeHigh = (uint)(fileDescriptor.Length >> 32); + } + // Add structure to buffer + bytes.AddRange(StructureBytes(FILEDESCRIPTOR)); + } + + // Set CFSTR_FILEDESCRIPTORW + SetData(FILEDESCRIPTORW, bytes); + // Set n CFSTR_FILECONTENTS + var index = 0; + foreach (var fileDescriptor in fileDescriptors) + { + SetData(FILECONTENTS, index, fileDescriptor.StreamContents); + index++; + } + } + + /// + /// Gets or sets the CFSTR_PASTESUCCEEDED value for the object. + /// + public DragDropEffects? PasteSucceeded + { + get { return GetDropEffect(PASTESUCCEEDED); } + set { SetData(PASTESUCCEEDED, BitConverter.GetBytes((UInt32)value)); } + } + + /// + /// Gets or sets the CFSTR_PERFORMEDDROPEFFECT value for the object. + /// + public DragDropEffects? PerformedDropEffect + { + get { return GetDropEffect(PERFORMEDDROPEFFECT); } + set { SetData(PERFORMEDDROPEFFECT, BitConverter.GetBytes((UInt32)value)); } + } + + /// + /// Gets or sets the CFSTR_PREFERREDDROPEFFECT value for the object. + /// + public DragDropEffects? PreferredDropEffect + { + get { return GetDropEffect(PREFERREDDROPEFFECT); } + set { SetData(PREFERREDDROPEFFECT, BitConverter.GetBytes((UInt32)value)); } + } + + /// + /// Gets the DragDropEffects value (if any) previously set on the object. + /// + /// Clipboard format. + /// DragDropEffects value or null. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + private DragDropEffects? GetDropEffect(short format) + { + // Get the most recent setting + var dataObject = _dataObjects + .Where(d => + (format == d.FORMATETC.cfFormat) && + (DVASPECT.DVASPECT_CONTENT == d.FORMATETC.dwAspect) && + (TYMED.TYMED_HGLOBAL == d.FORMATETC.tymed)) + .LastOrDefault(); + if (null != dataObject) + { + // Read the value and return it + var result = dataObject.GetData(); + if (NativeMethods.SUCCEEDED(result.Item2)) + { + var ptr = NativeMethods.GlobalLock(result.Item1); + if (IntPtr.Zero != ptr) + { + try + { + var length = NativeMethods.GlobalSize(ptr).ToInt32(); + if (4 == length) + { + var data = new byte[length]; + Marshal.Copy(ptr, data, 0, length); + return (DragDropEffects)(BitConverter.ToUInt32(data, 0)); + } + } + finally + { + NativeMethods.GlobalUnlock(result.Item1); + } + } + } + } + return null; + } + + #region IAsyncOperation Members + // Explicit interface implementation hides the technical details from users of VirtualFileDataObject. + + /// + /// Called by a drop source to specify whether the data object supports asynchronous data extraction. + /// + /// A Boolean value that is set to VARIANT_TRUE to indicate that an asynchronous operation is supported, or VARIANT_FALSE otherwise. + void IAsyncOperation.SetAsyncMode(int fDoOpAsync) + { + IsAsynchronous = !(NativeMethods.VARIANT_FALSE == fDoOpAsync); + } + + /// + /// Called by a drop target to determine whether the data object supports asynchronous data extraction. + /// + /// A Boolean value that is set to VARIANT_TRUE to indicate that an asynchronous operation is supported, or VARIANT_FALSE otherwise. + void IAsyncOperation.GetAsyncMode(out int pfIsOpAsync) + { + pfIsOpAsync = IsAsynchronous ? NativeMethods.VARIANT_TRUE : NativeMethods.VARIANT_FALSE; + } + + /// + /// Called by a drop target to indicate that asynchronous data extraction is starting. + /// + /// Reserved. Set this value to NULL. + void IAsyncOperation.StartOperation(IBindCtx pbcReserved) + { + _inOperation = true; + if (null != _startAction) + { + _startAction(this); + } + } + + /// + /// Called by the drop source to determine whether the target is extracting data asynchronously. + /// + /// Set to VARIANT_TRUE if data extraction is being handled asynchronously, or VARIANT_FALSE otherwise. + void IAsyncOperation.InOperation(out int pfInAsyncOp) + { + pfInAsyncOp = _inOperation ? NativeMethods.VARIANT_TRUE : NativeMethods.VARIANT_FALSE; + } + + /// + /// Notifies the data object that that asynchronous data extraction has ended. + /// + /// An HRESULT value that indicates the outcome of the data extraction. Set to S_OK if successful, or a COM error code otherwise. + /// Reserved. Set to NULL. + /// A DROPEFFECT value that indicates the result of an optimized move. This should be the same value that would be passed to the data object as a CFSTR_PERFORMEDDROPEFFECT format with a normal data extraction operation. + void IAsyncOperation.EndOperation(int hResult, IBindCtx pbcReserved, uint dwEffects) + { + if (null != _endAction) + { + _endAction(this); + } + _inOperation = false; + } + + #endregion + + /// + /// Returns the in-memory representation of an interop structure. + /// + /// Structure to return. + /// In-memory representation of structure. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Method doesn't decrease security.")] + private static IEnumerable StructureBytes(object source) + { + // Set up for call to StructureToPtr + var size = Marshal.SizeOf(source.GetType()); + var ptr = Marshal.AllocHGlobal(size); + var bytes = new byte[size]; + try + { + Marshal.StructureToPtr(source, ptr, false); + // Copy marshalled bytes to buffer + Marshal.Copy(ptr, bytes, 0, size); + } + finally + { + Marshal.FreeHGlobal(ptr); + } + return bytes; + } + + /// + /// Class representing a virtual file for use by drag/drop or the clipboard. + /// + [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Deliberate to provide obvious coupling.")] + public class FileDescriptor + { + /// + /// Gets or sets the name of the file. + /// + public string Name { get; set; } + + /// + /// Gets or sets the (optional) length of the file. + /// + public Int64? Length { get; set; } + + /// + /// Gets or sets the (optional) change time of the file. + /// + public DateTime? ChangeTimeUtc { get; set; } + + /// + /// Gets or sets an Action that returns the contents of the file. + /// + public Action StreamContents { get; set; } + } + + /// + /// Class representing the result of a SetData call. + /// + private class DataObject + { + /// + /// FORMATETC structure for the data. + /// + public FORMATETC FORMATETC { get; set; } + + /// + /// Func returning the data as an IntPtr and an HRESULT success code. + /// + public Func> GetData { get; set; } + } + + /// + /// Represents a 2-tuple, or pair. + /// + /// + /// Minimal implementation of the .NET 4 Tuple class; remove if running on .NET 4. + /// + /// The type of the tuple's first component. + /// The type of the tuple's second component. + private class Tuple + { + /// + /// Gets the value of the current Tuple(T1, T2) object's first component. + /// + public T1 Item1 { get; private set; } + + /// + /// Gets the value of the current Tuple(T1, T2) object's second component. + /// + public T2 Item2 { get; private set; } + + /// + /// Initializes a new instance of the Tuple(T1, T2) class. + /// + /// The value of the tuple's first component. + /// The value of the tuple's second component. + public Tuple(T1 item1, T2 item2) + { + Item1 = item1; + Item2 = item2; + } + } + + /// + /// Simple class that exposes a write-only IStream as a Stream. + /// + private class IStreamWrapper : Stream + { + /// + /// IStream instance being wrapped. + /// + private IStream _iStream; + + /// + /// Initializes a new instance of the IStreamWrapper class. + /// + /// IStream instance to wrap. + public IStreamWrapper(IStream iStream) + { + _iStream = iStream; + } + + /// + /// Gets a value indicating whether the current stream supports reading. + /// + public override bool CanRead + { + get { return false; } + } + + /// + /// Gets a value indicating whether the current stream supports seeking. + /// + public override bool CanSeek + { + get { return false; } + } + + /// + /// Gets a value indicating whether the current stream supports writing. + /// + public override bool CanWrite + { + get { return true; } + } + + /// + /// Clears all buffers for this stream and causes any buffered data to be written to the underlying device. + /// + public override void Flush() + { + throw new NotImplementedException(); + } + + /// + /// Gets the length in bytes of the stream. + /// + public override long Length + { + get { throw new NotImplementedException(); } + } + + /// + /// Gets or sets the position within the current stream. + /// + public override long Position + { + get { throw new NotImplementedException(); } + set { throw new NotImplementedException(); } + } + + /// + /// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. + /// + /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. + /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream. + /// The maximum number of bytes to be read from the current stream. + /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. + public override int Read(byte[] buffer, int offset, int count) + { + throw new NotImplementedException(); + } + + /// + /// Sets the position within the current stream. + /// + /// A byte offset relative to the origin parameter. + /// A value of type SeekOrigin indicating the reference point used to obtain the new position. + /// The new position within the current stream. + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotImplementedException(); + } + + /// + /// Sets the length of the current stream. + /// + /// The desired length of the current stream in bytes. + public override void SetLength(long value) + { + throw new NotImplementedException(); + } + + /// + /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. + /// + /// An array of bytes. This method copies count bytes from buffer to the current stream. + /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream. + /// The number of bytes to be written to the current stream. + public override void Write(byte[] buffer, int offset, int count) + { + if (offset == 0) + { + // Optimize common case to avoid creating extra buffers + _iStream.Write(buffer, count, IntPtr.Zero); + } + else + { + // Easy way to provide the relevant byte[] + _iStream.Write(buffer.Skip(offset).ToArray(), count, IntPtr.Zero); + } + } + } + + /// + /// Initiates a drag-and-drop operation. + /// + /// A reference to the dependency object that is the source of the data being dragged. + /// A data object that contains the data being dragged. + /// One of the DragDropEffects values that specifies permitted effects of the drag-and-drop operation. + /// One of the DragDropEffects values that specifies the final effect that was performed during the drag-and-drop operation. + /// + /// Call this method instead of System.Windows.DragDrop.DoDragDrop because this method handles IDataObject better. + /// + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "dragSource", Justification = "Parameter is present so the signature matches that of System.Windows.DragDrop.DoDragDrop.")] + public static DragDropEffects DoDragDrop(DependencyObject dragSource, System.Runtime.InteropServices.ComTypes.IDataObject dataObject, DragDropEffects allowedEffects) + { + int[] finalEffect = new int[1]; + try + { + NativeMethods.DoDragDrop(dataObject, new DropSource(), (int)allowedEffects, finalEffect); + } + finally + { + var virtualFileDataObject = dataObject as VirtualFileDataObject; + if ((null != virtualFileDataObject) && !virtualFileDataObject.IsAsynchronous && virtualFileDataObject._inOperation) + { + // Call the end action and exit the operation + if (null != virtualFileDataObject._endAction) + { + virtualFileDataObject._endAction(virtualFileDataObject); + } + virtualFileDataObject._inOperation = false; + } + } + return (DragDropEffects)(finalEffect[0]); + } + + /// + /// Contains the methods for generating visual feedback to the end user and for canceling or completing the drag-and-drop operation. + /// + private class DropSource : NativeMethods.IDropSource + { + /// + /// Determines whether a drag-and-drop operation should continue. + /// + /// Indicates whether the Esc key has been pressed since the previous call to QueryContinueDrag or to DoDragDrop if this is the first call to QueryContinueDrag. A TRUE value indicates the end user has pressed the escape key; a FALSE value indicates it has not been pressed. + /// The current state of the keyboard modifier keys on the keyboard. Possible values can be a combination of any of the flags MK_CONTROL, MK_SHIFT, MK_ALT, MK_BUTTON, MK_LBUTTON, MK_MBUTTON, and MK_RBUTTON. + /// This method returns S_OK/DRAGDROP_S_DROP/DRAGDROP_S_CANCEL on success. + public int QueryContinueDrag(int fEscapePressed, uint grfKeyState) + { + var escapePressed = (0 != fEscapePressed); + var keyStates = (DragDropKeyStates)grfKeyState; + if (escapePressed) + { + return NativeMethods.DRAGDROP_S_CANCEL; + } + else if (DragDropKeyStates.None == (keyStates & DragDropKeyStates.LeftMouseButton)) + { + return NativeMethods.DRAGDROP_S_DROP; + } + return NativeMethods.S_OK; + } + + /// + /// Gives visual feedback to an end user during a drag-and-drop operation. + /// + /// The DROPEFFECT value returned by the most recent call to IDropTarget::DragEnter, IDropTarget::DragOver, or IDropTarget::DragLeave. + /// This method returns S_OK on success. + public int GiveFeedback(uint dwEffect) + { + return NativeMethods.DRAGDROP_S_USEDEFAULTCURSORS; + } + } + + /// + /// Provides access to Win32-level constants, structures, and functions. + /// + private static class NativeMethods + { + public const int DRAGDROP_S_DROP = 0x00040100; + public const int DRAGDROP_S_CANCEL = 0x00040101; + public const int DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102; + public const int DV_E_DVASPECT = -2147221397; + public const int DV_E_FORMATETC = -2147221404; + public const int DV_E_TYMED = -2147221399; + public const int E_FAIL = -2147467259; + public const uint FD_CREATETIME = 0x00000008; + public const uint FD_WRITESTIME = 0x00000020; + public const uint FD_FILESIZE = 0x00000040; + public const int OLE_E_ADVISENOTSUPPORTED = -2147221501; + public const int S_OK = 0; + public const int S_FALSE = 1; + public const int VARIANT_FALSE = 0; + public const int VARIANT_TRUE = -1; + + public const string CFSTR_FILECONTENTS = "FileContents"; + public const string CFSTR_FILEDESCRIPTORW = "FileGroupDescriptorW"; + public const string CFSTR_PASTESUCCEEDED = "Paste Succeeded"; + public const string CFSTR_PERFORMEDDROPEFFECT = "Performed DropEffect"; + public const string CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect"; + + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "Structure exists for interop.")] + [StructLayout(LayoutKind.Sequential)] + public struct FILEGROUPDESCRIPTOR + { + public UInt32 cItems; + // Followed by 0 or more FILEDESCRIPTORs + } + + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "Structure exists for interop.")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct FILEDESCRIPTOR + { + public UInt32 dwFlags; + public Guid clsid; + public Int32 sizelcx; + public Int32 sizelcy; + public Int32 pointlx; + public Int32 pointly; + public UInt32 dwFileAttributes; + public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime; + public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime; + public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime; + public UInt32 nFileSizeHigh; + public UInt32 nFileSizeLow; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] + public string cFileName; + } + + [ComImport] + [Guid("00000121-0000-0000-C000-000000000046")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IDropSource + { + [PreserveSig] + int QueryContinueDrag(int fEscapePressed, uint grfKeyState); + [PreserveSig] + int GiveFeedback(uint dwEffect); + } + + [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Justification = "Win32 API.")] + [DllImport("shell32.dll")] + public static extern int SHCreateStdEnumFmtEtc(uint cfmt, FORMATETC[] afmt, out IEnumFORMATETC ppenumFormatEtc); + + [return: MarshalAs(UnmanagedType.Interface)] + [DllImport("ole32.dll", PreserveSig = false)] + public static extern IStream CreateStreamOnHGlobal(IntPtr hGlobal, [MarshalAs(UnmanagedType.Bool)] bool fDeleteOnRelease); + + [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true, PreserveSig = false)] + public static extern void DoDragDrop(System.Runtime.InteropServices.ComTypes.IDataObject dataObject, IDropSource dropSource, int allowedEffects, int[] finalEffect); + + [DllImport("kernel32.dll")] + public static extern IntPtr GlobalLock(IntPtr hMem); + + [return: MarshalAs(UnmanagedType.Bool)] + [DllImport("kernel32.dll")] + public static extern bool GlobalUnlock(IntPtr hMem); + + [DllImport("kernel32.dll")] + public static extern IntPtr GlobalSize(IntPtr handle); + + /// + /// Returns true iff the HRESULT is a success code. + /// + /// HRESULT to check. + /// True iff a success code. + public static bool SUCCEEDED(int hr) + { + return (0 <= hr); + } + } + } + + /// + /// Definition of the IAsyncOperation COM interface. + /// + /// + /// Pseudo-public because VirtualFileDataObject implements it. + /// + [ComImport] + [Guid("3D8B0590-F691-11d2-8EA9-006097DF5BD4")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal interface IAsyncOperation + { + void SetAsyncMode([In] Int32 fDoOpAsync); + void GetAsyncMode([Out] out Int32 pfIsOpAsync); + void StartOperation([In] IBindCtx pbcReserved); + void InOperation([Out] out Int32 pfInAsyncOp); + void EndOperation([In] Int32 hResult, [In] IBindCtx pbcReserved, [In] UInt32 dwEffects); + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs new file mode 100644 index 000000000..7ce4a6532 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class DateTimeUtcToLocalDateTime : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + try + { + return ((DateTime)value).ToLocalTime(); + } + catch + { + return value; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index 834e9e1fe..4764d0eac 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -99,6 +99,7 @@ + @@ -253,7 +254,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs b/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs index c1d3d4967..a8f272292 100644 --- a/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs +++ b/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs @@ -55,11 +55,17 @@ namespace Tango.Transport.Adapters /// public bool EnableCompression { get; set; } + /// + /// Gets or sets the adapter connection timeout. + /// + public TimeSpan ConnectionTimeout { get; set; } + /// /// Initializes a new instance of the class. /// public SignalRTransportAdapter() : base() { + ConnectionTimeout = TimeSpan.FromSeconds(30); WriteInterval = TimeSpan.FromMilliseconds(10); ComponentName = $"SignalR Adapter {_component_counter++}"; } @@ -137,10 +143,10 @@ namespace Tango.Transport.Adapters if (!completed) { completed = true; - completionSource.SetException(new TimeoutException("Could not connect the SignalR adapter.")); + completionSource.SetException(new TimeoutException("Could not reach the remote machine after the given timeout.")); } - }, TimeSpan.FromSeconds(5)); + }, ConnectionTimeout); if (Mode == SignalRTransportAdapterMode.CreateSession) { diff --git a/Software/Visual_Studio/Tango.Transport/ITransportAdapter.cs b/Software/Visual_Studio/Tango.Transport/ITransportAdapter.cs index 3cfd1ca48..d77ad1ed4 100644 --- a/Software/Visual_Studio/Tango.Transport/ITransportAdapter.cs +++ b/Software/Visual_Studio/Tango.Transport/ITransportAdapter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Reactive; using System.Reactive.Linq; @@ -12,7 +13,7 @@ namespace Tango.Transport /// Represents a transport adapter capable of connecting, writing and receiving data from a stream. /// /// - public interface ITransportAdapter : ITransportComponent + public interface ITransportAdapter : ITransportComponent, INotifyPropertyChanged { /// /// Gets the total bytes received. diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index d1ef102ad..921301cc0 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -367,6 +367,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.WebRTC", "Tango.WebRT EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.SystemInfo", "Tango.SystemInfo\Tango.SystemInfo.csproj", "{997A961C-BEDA-4B56-AA0F-C39E532F7FFA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FileSystem", "Tango.FileSystem\Tango.FileSystem.csproj", "{C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -6533,6 +6535,46 @@ Global {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x64.Build.0 = Release|Any CPU {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x86.ActiveCfg = Release|Any CPU {997A961C-BEDA-4B56-AA0F-C39E532F7FFA}.Release|x86.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|ARM.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|x64.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.AppVeyor|x86.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|ARM.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|ARM64.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|x64.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|x64.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|x86.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Debug|x86.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|Any CPU.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|ARM.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|ARM.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|ARM64.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|ARM64.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x64.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x64.Build.0 = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x86.ActiveCfg = Release|Any CPU + {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -6657,12 +6699,12 @@ Global {A07E6CB4-0132-4EB1-9A38-C8C057884DC2} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal -- cgit v1.3.1