From c5f72d4ee2b7048cb3f0612b044c41652cc79e75 Mon Sep 17 00:00:00 2001 From: TonCunha Date: Tue, 26 May 2020 11:56:30 -0300 Subject: [PATCH] Add auto start option to open all profiles when Windows starts --- README.md | 11 +-- src/MMT.Core/MMT.Core.csproj | 4 + src/MMT.Core/ProfileManager.cs | 2 +- src/MMT.Core/RegistryMananger.cs | 30 ++++++++ src/MMT.Core/StaticResources.cs | 16 ++++ src/MMT.UI/MMT.UI.csproj | 22 +++++- src/MMT.UI/MainWindow.xaml | 11 ++- src/MMT.UI/MainWindow.xaml.cs | 78 +++++++++++++++++-- src/MMT.UI/Resource.Designer.cs | 73 ++++++++++++++++++ src/MMT.UI/Resource.resx | 124 +++++++++++++++++++++++++++++++ 10 files changed, 350 insertions(+), 21 deletions(-) create mode 100644 src/MMT.Core/RegistryMananger.cs create mode 100644 src/MMT.UI/Resource.Designer.cs create mode 100644 src/MMT.UI/Resource.resx diff --git a/README.md b/README.md index ad5142c..a8b23be 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,16 @@ Launcher to manage profiles and open multiple instances of Microsoft Teams deskt * .NET Core * WPF * [MahApps](https://mahapps.com/) +* [WPF NotifyIcon](https://github.com/hardcodet/wpf-notifyicon) ## Prerequisites * Microsoft Teams * .NET Core +## Releases +You can download the latest version in [Releases](https://github.com/TonCunha/multi-microsoft-teams/releases) + ## Deployment 1. Open project in Visual Studio @@ -31,12 +35,9 @@ Launcher to manage profiles and open multiple instances of Microsoft Teams deskt ### Configure Multi Teams 1. Open Multi Microsoft Teams 2. Create all the profiles you need by clicking the New profile button -3. Select a profile or check All profiles and Launch Teams +3. Select a profile and Launch Teams 4. Uncheck the options auto-start application in all Microsoft Teams - -## After initial configurations -1. Open Multi Microsoft Teams -2. Select a profile or check All profiles and Launch Teams +5. You can check Auto Start option to launch all profiles when Windows starts ## Authors diff --git a/src/MMT.Core/MMT.Core.csproj b/src/MMT.Core/MMT.Core.csproj index cb63190..52ceb1d 100644 --- a/src/MMT.Core/MMT.Core.csproj +++ b/src/MMT.Core/MMT.Core.csproj @@ -4,4 +4,8 @@ netcoreapp3.1 + + + + diff --git a/src/MMT.Core/ProfileManager.cs b/src/MMT.Core/ProfileManager.cs index 26691b2..5a8e515 100644 --- a/src/MMT.Core/ProfileManager.cs +++ b/src/MMT.Core/ProfileManager.cs @@ -40,7 +40,7 @@ public void Delete(string profileName) string path = Path.Combine(_customProfilesPath, profileName); if (Directory.Exists(path)) - Directory.Delete(path); + Directory.Delete(path, true); } } } diff --git a/src/MMT.Core/RegistryMananger.cs b/src/MMT.Core/RegistryMananger.cs new file mode 100644 index 0000000..5cdfd12 --- /dev/null +++ b/src/MMT.Core/RegistryMananger.cs @@ -0,0 +1,30 @@ +using Microsoft.Win32; +using System.Diagnostics; + +namespace MMT.Core +{ + public class RegistryManager + { + private readonly RegistryKey _registryKey; + + public RegistryManager() + { + _registryKey = Registry.CurrentUser.OpenSubKey(StaticResources.StartupApplications, true); + } + + public bool IsApplicationInStartup(string name) + { + return _registryKey.GetValue(name) != null; + } + + public void AddApplicationInStartup(string name) + { + _registryKey.SetValue(name, Process.GetCurrentProcess().MainModule.FileName); //AppDomain.CurrentDomain.BaseDirectory); + } + + public void RemoveApplicationFromStartup(string appName) + { + _registryKey.DeleteValue(appName, false); + } + } +} diff --git a/src/MMT.Core/StaticResources.cs b/src/MMT.Core/StaticResources.cs index 674cdab..aea3da9 100644 --- a/src/MMT.Core/StaticResources.cs +++ b/src/MMT.Core/StaticResources.cs @@ -43,5 +43,21 @@ public static string UpdateExe return @"AppData\Local\Microsoft\Teams\Update.exe"; } } + + public static string StartupApplications + { + get + { + return @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; + } + } + + public static string AppName + { + get + { + return "Multi MS Teams"; + } + } } } diff --git a/src/MMT.UI/MMT.UI.csproj b/src/MMT.UI/MMT.UI.csproj index 335a519..b6e9cec 100644 --- a/src/MMT.UI/MMT.UI.csproj +++ b/src/MMT.UI/MMT.UI.csproj @@ -12,10 +12,15 @@ https://github.com/TonCunha/multi-microsoft-teams Cleriton Cunha Launcher to manage profiles and open multiple instances of Microsoft Teams - LICENSE + LICENSE + 1.0.0.1 + 1.0.0.1 + 1.0.0.1 + + @@ -30,4 +35,19 @@ + + + True + True + Resource.resx + + + + + + ResXFileCodeGenerator + Resource.Designer.cs + + + \ No newline at end of file diff --git a/src/MMT.UI/MainWindow.xaml b/src/MMT.UI/MainWindow.xaml index 880c3cb..9ed4be6 100644 --- a/src/MMT.UI/MainWindow.xaml +++ b/src/MMT.UI/MainWindow.xaml @@ -3,23 +3,22 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" + xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:local="clr-namespace:MMT.UI" mc:Ignorable="d" - Title="Multi Microsoft Teams" Height="250" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize"> + Title="Multi Microsoft Teams" Height="250" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" StateChanged="MetroWindow_StateChanged"> - - + Github - + @@ -32,7 +31,7 @@