diff --git a/Petrroll.Helpers/Petrroll.Helpers.csproj b/Petrroll.Helpers/Petrroll.Helpers.csproj
index 70cb018..003c9db 100644
--- a/Petrroll.Helpers/Petrroll.Helpers.csproj
+++ b/Petrroll.Helpers/Petrroll.Helpers.csproj
@@ -9,8 +9,9 @@
Properties
Petrroll.Helpers
Petrroll.Helpers
- v4.5
+ v4.6.1
512
+
true
diff --git a/PowerSwitcher.TrayApp/App.config b/PowerSwitcher.TrayApp/App.config
index 8e15646..bae5d6d 100644
--- a/PowerSwitcher.TrayApp/App.config
+++ b/PowerSwitcher.TrayApp/App.config
@@ -1,6 +1,6 @@
-
+
-
+
-
\ No newline at end of file
+
diff --git a/PowerSwitcher.TrayApp/Configuration/PowerSwitcherConfiguration.cs b/PowerSwitcher.TrayApp/Configuration/PowerSwitcherConfiguration.cs
index ce3ca81..ae6efff 100644
--- a/PowerSwitcher.TrayApp/Configuration/PowerSwitcherConfiguration.cs
+++ b/PowerSwitcher.TrayApp/Configuration/PowerSwitcherConfiguration.cs
@@ -14,6 +14,10 @@ public class PowerSwitcherSettings : ObservableObject
public bool AutomaticOnACSwitch { get; set; } = false;
public Guid AutomaticPlanGuidOnAC { get; set; } = new Guid("8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c");
public Guid AutomaticPlanGuidOffAC { get; set; } = new Guid("a1841308-3541-4fab-bc81-f71556f20b4a");
+ public Guid AutomaticPlanGuidOnApp { get; set; } = new Guid("8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c");
+ public Guid AutomaticPlanGuidOffApp { get; set; } = new Guid("a1841308-3541-4fab-bc81-f71556f20b4a");
+
+ public string AutomaticAppSwitchApp { get; set; } = "";
//TODO: Fix so that it can be changed during runtime
public Key ShowOnShortcutKey { get; set; } = Key.L;
diff --git a/PowerSwitcher.TrayApp/PowerSwitcher.TrayApp.csproj b/PowerSwitcher.TrayApp/PowerSwitcher.TrayApp.csproj
index 1361514..042cb65 100644
--- a/PowerSwitcher.TrayApp/PowerSwitcher.TrayApp.csproj
+++ b/PowerSwitcher.TrayApp/PowerSwitcher.TrayApp.csproj
@@ -9,7 +9,7 @@
Properties
PowerSwitcher.TrayApp
PowerSwitcher.TrayApp
- v4.5
+ v4.6.1
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
@@ -28,6 +28,7 @@
false
false
true
+
AnyCPU
@@ -65,9 +66,11 @@
app.manifest
+
+
diff --git a/PowerSwitcher.TrayApp/Properties/Resources.Designer.cs b/PowerSwitcher.TrayApp/Properties/Resources.Designer.cs
index 4a93aec..1a7ae7d 100644
--- a/PowerSwitcher.TrayApp/Properties/Resources.Designer.cs
+++ b/PowerSwitcher.TrayApp/Properties/Resources.Designer.cs
@@ -8,10 +8,10 @@
//
//------------------------------------------------------------------------------
-namespace PowerSwitcher.TrayApp.Properties
-{
-
-
+namespace PowerSwitcher.TrayApp.Properties {
+ using System;
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -19,51 +19,43 @@ namespace PowerSwitcher.TrayApp.Properties
// 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ 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()
- {
+ 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))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PowerSwitcher.TrayApp.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
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
diff --git a/PowerSwitcher.TrayApp/Properties/Settings.Designer.cs b/PowerSwitcher.TrayApp/Properties/Settings.Designer.cs
index d0f8aa6..05888d2 100644
--- a/PowerSwitcher.TrayApp/Properties/Settings.Designer.cs
+++ b/PowerSwitcher.TrayApp/Properties/Settings.Designer.cs
@@ -8,21 +8,17 @@
//
//------------------------------------------------------------------------------
-namespace PowerSwitcher.TrayApp.Properties
-{
-
-
+namespace PowerSwitcher.TrayApp.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
- {
-
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.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
- {
+
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
diff --git a/PowerSwitcher.TrayApp/Resources/AppStrings.Designer.cs b/PowerSwitcher.TrayApp/Resources/AppStrings.Designer.cs
index a02314a..8c328ad 100644
--- a/PowerSwitcher.TrayApp/Resources/AppStrings.Designer.cs
+++ b/PowerSwitcher.TrayApp/Resources/AppStrings.Designer.cs
@@ -19,7 +19,7 @@ namespace PowerSwitcher.TrayApp.Resources {
// 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class AppStrings {
@@ -78,6 +78,15 @@ internal static string AboutAppURL {
}
}
+ ///
+ /// Looks up a localized string similar to Application trigger.
+ ///
+ internal static string ApplicationName {
+ get {
+ return ResourceManager.GetString("ApplicationName", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to PowerPlanSwitcher.
///
@@ -141,6 +150,15 @@ internal static string SchemaToSwitchOffAc {
}
}
+ ///
+ /// Looks up a localized string similar to Schema to switch to when application exits.
+ ///
+ internal static string SchemaToSwitchOffApp {
+ get {
+ return ResourceManager.GetString("SchemaToSwitchOffApp", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Schema to switch to on AC.
///
@@ -150,6 +168,15 @@ internal static string SchemaToSwitchOnAc {
}
}
+ ///
+ /// Looks up a localized string similar to Schema to switch to when application starts.
+ ///
+ internal static string SchemaToSwitchOnApp {
+ get {
+ return ResourceManager.GetString("SchemaToSwitchOnApp", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Settings.
///
diff --git a/PowerSwitcher.TrayApp/Resources/AppStrings.resx b/PowerSwitcher.TrayApp/Resources/AppStrings.resx
index 3e25f52..0d08650 100644
--- a/PowerSwitcher.TrayApp/Resources/AppStrings.resx
+++ b/PowerSwitcher.TrayApp/Resources/AppStrings.resx
@@ -123,6 +123,9 @@
http://github.com/Petrroll/PowerSwitcher
+
+ Application trigger
+
PowerPlanSwitcher
@@ -144,9 +147,15 @@
Schema to switch to off AC
+
+ Schema to switch to when application exits
+
Schema to switch to on AC
+
+ Schema to switch to when application starts
+
Settings
diff --git a/PowerSwitcher.TrayApp/TrayApp.cs b/PowerSwitcher.TrayApp/TrayApp.cs
index 0bca37c..563755c 100644
--- a/PowerSwitcher.TrayApp/TrayApp.cs
+++ b/PowerSwitcher.TrayApp/TrayApp.cs
@@ -7,6 +7,8 @@
using System.Reflection;
using System.Windows;
using WF = System.Windows.Forms;
+using System.Management;
+using Microsoft.VisualBasic;
namespace PowerSwitcher.TrayApp
@@ -20,6 +22,8 @@ public class TrayApp
public event Action ShowFlyout;
IPowerManager pwrManager;
ConfigurationInstance configuration;
+ ManagementEventWatcher startWatcher;
+ ManagementEventWatcher stopWatcher;
#endregion
#region Contructor
@@ -30,6 +34,13 @@ public TrayApp(IPowerManager powerManager, ConfigurationInstance sch.Guid == schemaGuidToSwitch);
+ if (schemaToSwitchTo == null) { return; }
+ pwrManager.SetPowerSchema(schemaToSwitchTo);
+ }
+ #endregion
+
#region ContextMenuItemRelatedStuff
private void ContextMenu_Popup(object sender, EventArgs e)
@@ -215,6 +300,21 @@ private void updateTrayMenuWithPowerSchema(IPowerSchema powerSchema)
);
_trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOnAC"].MenuItems.Add(0, newItemSettingsOnAC);
+
+ var newItemSettingsOffApp = getNewPowerSchemaItem(
+ powerSchema,
+ (s, ea) => setPowerSchemaAsOffApp(powerSchema),
+ (powerSchema.Guid == configuration.Data.AutomaticPlanGuidOffApp)
+ );
+ _trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOffApp"].MenuItems.Add(0, newItemSettingsOffApp);
+
+ var newItemSettingsOnApp = getNewPowerSchemaItem(
+ powerSchema,
+ (s, ea) => setPowerSchemaAsOnApp(powerSchema),
+ (powerSchema.Guid == configuration.Data.AutomaticPlanGuidOnApp)
+ );
+
+ _trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOnApp"].MenuItems.Add(0, newItemSettingsOnApp);
}
private void clearPowerSchemasInTray()
@@ -230,6 +330,8 @@ private void clearPowerSchemasInTray()
_trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOffAC"].MenuItems.Clear();
_trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOnAC"].MenuItems.Clear();
+ _trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOffApp"].MenuItems.Clear();
+ _trayIcon.ContextMenu.MenuItems["settings"].MenuItems["settingsOnApp"].MenuItems.Clear();
}
private WF.MenuItem getNewPowerSchemaItem(IPowerSchema powerSchema, EventHandler clickedHandler, bool isChecked)
@@ -256,6 +358,17 @@ private void setPowerSchemaAsOnAC(IPowerSchema powerSchema)
configuration.Data.AutomaticPlanGuidOnAC = powerSchema.Guid;
configuration.Save();
}
+ private void setPowerSchemaAsOffApp(IPowerSchema powerSchema)
+ {
+ configuration.Data.AutomaticPlanGuidOffApp = powerSchema.Guid;
+ configuration.Save();
+ }
+
+ private void setPowerSchemaAsOnApp(IPowerSchema powerSchema)
+ {
+ configuration.Data.AutomaticPlanGuidOnApp = powerSchema.Guid;
+ configuration.Save();
+ }
private void switchToPowerSchema(IPowerSchema powerSchema)
{
@@ -281,6 +394,11 @@ void Exit_Click(object sender, EventArgs e)
_trayIcon.Visible = false;
_trayIcon.Dispose();
+ startWatcher.Stop();
+ stopWatcher.Stop();
+ startWatcher.Dispose();
+ stopWatcher.Dispose();
+
pwrManager.Dispose();
Application.Current.Shutdown();
diff --git a/PowerSwitcher.TrayApp/app.manifest b/PowerSwitcher.TrayApp/app.manifest
index b9577f3..547e232 100644
--- a/PowerSwitcher.TrayApp/app.manifest
+++ b/PowerSwitcher.TrayApp/app.manifest
@@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
-
+
diff --git a/PowerSwitcher/PowerSwitcher.csproj b/PowerSwitcher/PowerSwitcher.csproj
index 2e12b24..b14280c 100644
--- a/PowerSwitcher/PowerSwitcher.csproj
+++ b/PowerSwitcher/PowerSwitcher.csproj
@@ -9,8 +9,9 @@
Properties
PowerSwitcher
PowerSwitcher
- v4.5
+ v4.6.1
512
+
true