diff --git a/.idea/.idea.WMR USB Controller/.idea/.name b/.idea/.idea.WMR USB Controller/.idea/.name new file mode 100644 index 0000000..319180c --- /dev/null +++ b/.idea/.idea.WMR USB Controller/.idea/.name @@ -0,0 +1 @@ +WMR USB Controller \ No newline at end of file diff --git a/WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/codeStyles/codeStyleConfig.xml b/.idea/.idea.WMR USB Controller/.idea/codeStyles/codeStyleConfig.xml similarity index 100% rename from WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/codeStyles/codeStyleConfig.xml rename to .idea/.idea.WMR USB Controller/.idea/codeStyles/codeStyleConfig.xml diff --git a/WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/encodings.xml b/.idea/.idea.WMR USB Controller/.idea/encodings.xml similarity index 100% rename from WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/encodings.xml rename to .idea/.idea.WMR USB Controller/.idea/encodings.xml diff --git a/WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/indexLayout.xml b/.idea/.idea.WMR USB Controller/.idea/indexLayout.xml similarity index 100% rename from WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/indexLayout.xml rename to .idea/.idea.WMR USB Controller/.idea/indexLayout.xml diff --git a/WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/projectSettingsUpdater.xml b/.idea/.idea.WMR USB Controller/.idea/projectSettingsUpdater.xml similarity index 100% rename from WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/projectSettingsUpdater.xml rename to .idea/.idea.WMR USB Controller/.idea/projectSettingsUpdater.xml diff --git a/WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/vcs.xml b/.idea/.idea.WMR USB Controller/.idea/vcs.xml similarity index 69% rename from WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/vcs.xml rename to .idea/.idea.WMR USB Controller/.idea/vcs.xml index 6c0b863..94a25f7 100644 --- a/WMR-USB-Controller/.idea/.idea.WMR-USB-Controller/.idea/vcs.xml +++ b/.idea/.idea.WMR USB Controller/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/App.config b/App.config similarity index 100% rename from WMR-USB-Controller/WMR-USB-Controller/App.config rename to App.config diff --git a/WMR-USB-Controller/WMR-USB-Controller/App.xaml b/App.xaml similarity index 100% rename from WMR-USB-Controller/WMR-USB-Controller/App.xaml rename to App.xaml diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..5267e39 --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace WMR_USB_Controller +{ + /// + /// Логика взаимодействия для App.xaml + /// + public partial class App : Application + { + } +} diff --git a/WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml b/MainWindow.xaml similarity index 86% rename from WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml rename to MainWindow.xaml index aa83127..6ed68ae 100644 --- a/WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml +++ b/MainWindow.xaml @@ -5,9 +5,11 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WMR_USB_Controller" mc:Ignorable="d" - Title="WMR USB Controller" Height="512" Width="512" - Background="Gray" - Icon="Main.ico"> + Title="WMR USB Controller" + Height="512" + Width="512" + Icon="WMR USB Controller Main Icon.ico" + Background="#FF5B5B5B"> diff --git a/WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml.cs b/MainWindow.xaml.cs similarity index 98% rename from WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml.cs rename to MainWindow.xaml.cs index be5fac7..8c226cb 100644 --- a/WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -15,7 +15,7 @@ public partial class MainWindow private AutostartManager _autostartManager; private TrayIconManager _trayIconManager; - + public MainWindow() { InitializeComponent(); @@ -50,13 +50,13 @@ protected override void OnStateChanged(EventArgs e) if (WindowState == WindowState.Minimized) { Hide(); - + _trayIconManager.ShowIcon(); } base.OnStateChanged(e); } - + private void DisableWmrDeviceAction(object sender, RoutedEventArgs e) { ChangeWmrDeviceState(false); @@ -82,4 +82,4 @@ private void SwitchAutostartStatus(object sender, RoutedEventArgs e) _autostartManager.SetToAutostart(); } } -} \ No newline at end of file +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2794ad5 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Общие сведения об этой сборке предоставляются следующим набором +// набор атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("WMR USB Controller")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WMR USB Controller")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// из модели COM, установите атрибут ComVisible для этого типа в значение true. +[assembly: ComVisible(false)] + +//Чтобы начать создание локализуемых приложений, задайте +//CultureYouAreCodingWith в файле .csproj +//в . Например, при использовании английского (США) +//в своих исходных файлах установите в en-US. Затем отмените преобразование в комментарий +//атрибута NeutralResourceLanguage ниже. Обновите "en-US" в +//строка внизу для обеспечения соответствия настройки UICulture в файле проекта. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам + //(используется, если ресурс не найден на странице, + // или в словарях ресурсов приложения) + ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов + //(используется, если ресурс не найден на странице, + // в приложении или в каких-либо словарях ресурсов для конкретной темы) +)] + + +// Сведения о версии для сборки включают четыре следующих значения: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Номер редакции +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..56ebab5 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// Этот код был создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + + +namespace WMR_USB_Controller.Properties +{ + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [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() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [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("WMR_USB_Controller.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Переопределяет свойство CurrentUICulture текущего потока для всех + /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// + [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/WMR-USB-Controller/WMR-USB-Controller/Properties/Resources.resx b/Properties/Resources.resx similarity index 100% rename from WMR-USB-Controller/WMR-USB-Controller/Properties/Resources.resx rename to Properties/Resources.resx diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..7f237be --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// 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 WMR_USB_Controller.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/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/WMR USB Controller Main Icon.ico b/WMR USB Controller Main Icon.ico new file mode 100644 index 0000000..89cc951 Binary files /dev/null and b/WMR USB Controller Main Icon.ico differ diff --git a/WMR USB Controller.csproj b/WMR USB Controller.csproj new file mode 100644 index 0000000..55ffc87 --- /dev/null +++ b/WMR USB Controller.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {39E03BA3-7D0D-43A5-8CA0-FAB9E213BF66} + WinExe + WMR_USB_Controller + WMR USB Controller + v4.8 + 8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x64 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + WMR USB Controller Main Icon.ico + + + app.manifest + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + \ No newline at end of file diff --git a/WMR USB Controller.sln b/WMR USB Controller.sln new file mode 100644 index 0000000..032f6d3 --- /dev/null +++ b/WMR USB Controller.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WMR USB Controller", "WMR USB Controller.csproj", "{39E03BA3-7D0D-43A5-8CA0-FAB9E213BF66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {39E03BA3-7D0D-43A5-8CA0-FAB9E213BF66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39E03BA3-7D0D-43A5-8CA0-FAB9E213BF66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39E03BA3-7D0D-43A5-8CA0-FAB9E213BF66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39E03BA3-7D0D-43A5-8CA0-FAB9E213BF66}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F5BBEFB4-CE7C-445F-8A78-3A46CBFEA52D} + EndGlobalSection +EndGlobal diff --git a/WMR-USB-Controller/WMR-USB-Controller.sln b/WMR-USB-Controller/WMR-USB-Controller.sln deleted file mode 100644 index 7a31e93..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WMR-USB-Controller", "WMR-USB-Controller\WMR-USB-Controller.csproj", "{F1129B7A-04E8-452A-ADA2-FF85C65D55E5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F1129B7A-04E8-452A-ADA2-FF85C65D55E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F1129B7A-04E8-452A-ADA2-FF85C65D55E5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F1129B7A-04E8-452A-ADA2-FF85C65D55E5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F1129B7A-04E8-452A-ADA2-FF85C65D55E5}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/WMR-USB-Controller/WMR-USB-Controller/App.xaml.cs b/WMR-USB-Controller/WMR-USB-Controller/App.xaml.cs deleted file mode 100644 index 243429a..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller/App.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace WMR_USB_Controller -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App - { - } -} \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/Main.ico b/WMR-USB-Controller/WMR-USB-Controller/Main.ico deleted file mode 100644 index 191cdef..0000000 Binary files a/WMR-USB-Controller/WMR-USB-Controller/Main.ico and /dev/null differ diff --git a/WMR-USB-Controller/WMR-USB-Controller/Properties/AssemblyInfo.cs b/WMR-USB-Controller/WMR-USB-Controller/Properties/AssemblyInfo.cs deleted file mode 100644 index 9a57305..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -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("WMR_USB_Controller")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("WMR_USB_Controller")] -[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")] \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/Properties/Resources.Designer.cs b/WMR-USB-Controller/WMR-USB-Controller/Properties/Resources.Designer.cs deleted file mode 100644 index d9d53d2..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller/Properties/Resources.Designer.cs +++ /dev/null @@ -1,69 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 WMR_USB_Controller.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("WMR_USB_Controller.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; } - } - } -} \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/WMR-USB-Controller.csproj b/WMR-USB-Controller/WMR-USB-Controller/WMR-USB-Controller.csproj deleted file mode 100644 index 6ef131a..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller/WMR-USB-Controller.csproj +++ /dev/null @@ -1,93 +0,0 @@ - - - - - Debug - AnyCPU - {F1129B7A-04E8-452A-ADA2-FF85C65D55E5} - WinExe - WMR_USB_Controller - WMR_USB_Controller - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - latest - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - - - \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/YUART/USB/USBDevicesManager.cs b/WMR-USB-Controller/WMR-USB-Controller/YUART/USB/USBDevicesManager.cs deleted file mode 100644 index d8f0e88..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller/YUART/USB/USBDevicesManager.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Diagnostics; -using System.Management; -using System.Linq; - -namespace WMR_USB_Controller.YUART.USB -{ - /// - /// Class, that handles data about connected USB devices. - /// - public sealed class UsbDevicesManager - { - private const string UsbSeekerQueryString = @"SELECT * FROM Win32_PnPEntity where DeviceID Like ""USB%"""; - private const string UsbDescriptionParameterName = "Name"; - private const string PathToDevManViewTool = @"DevManView.exe"; - private const string EnableWmrCommand = "/enable"; - private const string DisableWmrCommand = "/disable"; - - private readonly string[] _wmrNames = { - "Windows Mixed Reality", - "WMR" - }; - - private Process _wmrOnProcess; - private Process _wmrOffProcess; - private string _wmrDeviceName; - - /// - /// Initialize UsbDevicesManager class. - /// - public void Initialize() - { - GetWmrDevice(); - PrepareControlProcesses(); - } - - private void GetWmrDevice() - { - using var usbSearcher = new ManagementObjectSearcher(UsbSeekerQueryString); - - using var collectionUsbObjects = usbSearcher.Get(); - - foreach (var deviceObject in collectionUsbObjects) - { - var deviceDescription = (string) deviceObject.GetPropertyValue(UsbDescriptionParameterName); - - if (!_wmrNames.Any(deviceDescription.Contains)) continue; - - _wmrDeviceName = deviceDescription; - - break; - } - } - - private void PrepareControlProcesses() - { - _wmrOnProcess = new Process - { - StartInfo = - { - FileName = PathToDevManViewTool, - Arguments = $"{EnableWmrCommand} \"{_wmrDeviceName}\"" - } - }; - - _wmrOffProcess = new Process - { - StartInfo = - { - FileName = PathToDevManViewTool, - Arguments = $"{DisableWmrCommand} \"{_wmrDeviceName}\"" - } - }; - } - - /// - /// Activate or disable WMR device. - /// - /// Activate WMR device? - public void ActivateWmrDevice(bool newStatus) - { - var action = newStatus ? _wmrOnProcess : _wmrOffProcess; - - action.Start(); - action.WaitForExit(); - } - } -} \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/packages.config b/WMR-USB-Controller/WMR-USB-Controller/packages.config deleted file mode 100644 index f1efb7a..0000000 --- a/WMR-USB-Controller/WMR-USB-Controller/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/WMR-USB-Controller/WMR-USB-Controller/YUART/Autostart/AutostartManager.cs b/YUART/Autostart/AutostartManager.cs similarity index 96% rename from WMR-USB-Controller/WMR-USB-Controller/YUART/Autostart/AutostartManager.cs rename to YUART/Autostart/AutostartManager.cs index f11c154..45d5dea 100644 --- a/WMR-USB-Controller/WMR-USB-Controller/YUART/Autostart/AutostartManager.cs +++ b/YUART/Autostart/AutostartManager.cs @@ -10,7 +10,7 @@ namespace WMR_USB_Controller.YUART.Autostart public sealed class AutostartManager { private const string PathToAutostartRegKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; - + private readonly RegistryKey _autostartRegKey = Registry.CurrentUser.OpenSubKey(PathToAutostartRegKey, true); private readonly string _appExecutionPath = System.Reflection.Assembly.GetExecutingAssembly().Location; private readonly CheckBox _autostartCheckbox; @@ -28,31 +28,31 @@ public AutostartManager(CheckBox autostartCheckbox) public void Initialize() { SetApplicationName(); - + SetAutostartCheckboxValue(); } - + private void SetApplicationName() { _appName = Application.Current.MainWindow?.Title; } - + private void SetAutostartCheckboxValue() { if (_autostartCheckbox.IsChecked == null) return; var startupAutostartValue = _autostartRegKey.GetValue(_appName); - + _autostartCheckbox.IsChecked = startupAutostartValue != null; } - + /// /// Sets/removes app from autostart (depends from the value of autostart checkbox). /// public void SetToAutostart() { if (_autostartCheckbox.IsChecked == null || _autostartRegKey == null) return; - + if (_autostartCheckbox.IsChecked.Value) { _autostartRegKey.SetValue(_appName, _appExecutionPath); diff --git a/WMR-USB-Controller/WMR-USB-Controller/YUART/Tray Icon/TrayIconManager.cs b/YUART/Tray Icon/TrayIconManager.cs similarity index 95% rename from WMR-USB-Controller/WMR-USB-Controller/YUART/Tray Icon/TrayIconManager.cs rename to YUART/Tray Icon/TrayIconManager.cs index 7d167a9..bcfc67e 100644 --- a/WMR-USB-Controller/WMR-USB-Controller/YUART/Tray Icon/TrayIconManager.cs +++ b/YUART/Tray Icon/TrayIconManager.cs @@ -9,7 +9,7 @@ namespace WMR_USB_Controller.YUART.Tray_Icon /// public sealed class TrayIconManager { - private const string PathToTrayIcon = "Main.ico"; + private const string PathToTrayIcon = "WMR USB Controller Main Icon.ico"; private const string ToolTipText = "WMR USB Controller"; private const string DisableWmrMenuItemText = "Disable WMR Device"; private const string EnableWmrMenuItemText = "Enable WMR Device"; @@ -20,9 +20,9 @@ public sealed class TrayIconManager Visible = false, Text = ToolTipText }; - + private readonly MainWindow _mainWindow; - + private ContextMenu _disableWmrMenu; private ContextMenu _enableWmrMenu; @@ -37,7 +37,7 @@ public TrayIconManager(MainWindow mainWindow) public void Initialize() { InitializeTrayOptions(); - + _trayIcon.ContextMenu = _enableWmrMenu; _trayIcon.DoubleClick += ShowMainWindow; @@ -71,9 +71,9 @@ private void ActivateWmr(object _, EventArgs eventArgs) private void ShowMainWindow(object _, EventArgs eventArgs) { HideIcon(); - + _mainWindow.Show(); - + _mainWindow.WindowState = WindowState.Normal; } diff --git a/YUART/USB/UsbDevicesManager.cs b/YUART/USB/UsbDevicesManager.cs new file mode 100644 index 0000000..ab92a7a --- /dev/null +++ b/YUART/USB/UsbDevicesManager.cs @@ -0,0 +1,76 @@ +using System; +using System.Management; +using System.Windows; + +namespace WMR_USB_Controller.YUART.USB +{ + /// + /// Class, that handles data about connected USB devices. + /// + public sealed class UsbDevicesManager + { + private const string UsbSeekerQueryString = @"SELECT * FROM Win32_PnPEntity WHERE PNPClass LIKE 'Holographic'"; + private const string PnpRootPath = "root\\CIMV2"; + private const string CantFoundWmrDeviceMessage = "Can't find WMR device!"; + + private ManagementObject _wmrDevice; + + /// + /// Initialize UsbDevicesManager class. + /// + public void Initialize() + { + GetWmrDevice(); + } + + private void GetWmrDevice() + { + using var usbSearcher = new ManagementObjectSearcher(PnpRootPath, UsbSeekerQueryString); + + using var collectionUsbObjects = usbSearcher.Get(); + + if (collectionUsbObjects.Count == 0) + { + MessageBox.Show(CantFoundWmrDeviceMessage); + return; + } + + GetFirstFoundedDevice(collectionUsbObjects); + } + + private void GetFirstFoundedDevice(ManagementObjectCollection collectionUsbObjects) + { + foreach (ManagementObject device in collectionUsbObjects) + { + _wmrDevice = device; + break; + } + } + + /// + /// Activate or disable WMR device. + /// + /// Activate WMR device? + public void ActivateWmrDevice(bool newStatus) + { + if (newStatus) + { + EnableWmrDevice(); + } + else + { + DisableWmrDevice(); + } + } + + private void EnableWmrDevice() + { + _wmrDevice.InvokeMethod("Enable", null, null); + } + + private void DisableWmrDevice() + { + _wmrDevice.InvokeMethod("Disable", null, null); + } + } +} \ No newline at end of file diff --git a/app.manifest b/app.manifest new file mode 100644 index 0000000..8184cd9 --- /dev/null +++ b/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +