diff --git a/4x/Libraries/Windows.winmd b/4x/Libraries/Windows.winmd
new file mode 100644
index 0000000..0f90a14
Binary files /dev/null and b/4x/Libraries/Windows.winmd differ
diff --git a/4x/Move Mouse/App.config b/4x/Move Mouse/App.config
index 6bf4a8c..0e5f521 100644
--- a/4x/Move Mouse/App.config
+++ b/4x/Move Mouse/App.config
@@ -27,7 +27,7 @@
-
+
diff --git a/4x/Move Mouse/App.xaml.cs b/4x/Move Mouse/App.xaml.cs
index 71f15a6..358571f 100644
--- a/4x/Move Mouse/App.xaml.cs
+++ b/4x/Move Mouse/App.xaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
diff --git a/4x/Move Mouse/Classes/Settings.cs b/4x/Move Mouse/Classes/Settings.cs
index bfb49fb..1fc160a 100644
--- a/4x/Move Mouse/Classes/Settings.cs
+++ b/4x/Move Mouse/Classes/Settings.cs
@@ -1,6 +1,7 @@
using ellabi.Actions;
using ellabi.Annotations;
using ellabi.Schedules;
+using Serilog.Events;
using System;
using System.ComponentModel;
using System.Linq;
@@ -48,6 +49,9 @@ public class Settings : INotifyPropertyChanged
//private bool? _hookKeyEnabled;
//private Key _hookKey;
private bool? _standWithUkraine;
+ private bool? _pauseOnBattery;
+ private LogEventLevel? _logLevel;
+ private bool? _hideSystemTrayNotifications;
public int LowerInterval
{
@@ -419,7 +423,7 @@ public bool MinimiseOnStop
}
}
- public bool? PreventScreenBurn
+ public bool PreventScreenBurn
{
get
{
@@ -433,7 +437,7 @@ public bool? PreventScreenBurn
}
}
- public bool? ActiveWhenLocked
+ public bool ActiveWhenLocked
{
get
{
@@ -447,7 +451,7 @@ public bool? ActiveWhenLocked
}
}
- public bool? ShowMoveMouseStatus
+ public bool ShowMoveMouseStatus
{
get
{
@@ -479,7 +483,7 @@ public bool StandWithUkraine
{
get
{
- if (_standWithUkraine == null) _standWithUkraine = true;
+ if (_standWithUkraine == null) _standWithUkraine = false;
return _standWithUkraine.Value;
}
set
@@ -489,6 +493,48 @@ public bool StandWithUkraine
}
}
+ public bool PauseOnBattery
+ {
+ get
+ {
+ if (_pauseOnBattery == null) _pauseOnBattery = false;
+ return _pauseOnBattery.Value;
+ }
+ set
+ {
+ _pauseOnBattery = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public LogEventLevel LogLevel
+ {
+ get
+ {
+ if (_logLevel == null) _logLevel = LogEventLevel.Verbose;
+ return _logLevel.Value;
+ }
+ set
+ {
+ _logLevel = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public bool HideSystemTrayNotifications
+ {
+ get
+ {
+ if (_hideSystemTrayNotifications == null) _hideSystemTrayNotifications = false;
+ return _hideSystemTrayNotifications.Value;
+ }
+ set
+ {
+ _hideSystemTrayNotifications = value;
+ OnPropertyChanged();
+ }
+ }
+
[XmlArrayItem(Type = typeof(ActionBase)),
XmlArrayItem(Type = typeof(MoveMouseCursorAction)),
XmlArrayItem(Type = typeof(ClickMouseAction)),
diff --git a/4x/Move Mouse/Converters/MouseStateIsSleepingConverter.cs b/4x/Move Mouse/Converters/MouseStateIsSleepingConverter.cs
index 757444d..b0707bc 100644
--- a/4x/Move Mouse/Converters/MouseStateIsSleepingConverter.cs
+++ b/4x/Move Mouse/Converters/MouseStateIsSleepingConverter.cs
@@ -1,6 +1,5 @@
using ellabi.ViewModels;
using System;
-using System.Diagnostics;
using System.Globalization;
using System.Windows.Data;
diff --git a/4x/Move Mouse/Move Mouse.csproj b/4x/Move Mouse/Move Mouse.csproj
index 195638f..6daa463 100644
--- a/4x/Move Mouse/Move Mouse.csproj
+++ b/4x/Move Mouse/Move Mouse.csproj
@@ -83,15 +83,15 @@
..\packages\Microsoft.Expression.Drawing.3.0.0\lib\net45\Microsoft.Expression.Drawing.dll
-
- ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.1\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll
+
+ ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.2\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll
-
- ..\packages\Quartz.3.4.0\lib\net472\Quartz.dll
+
+ ..\packages\Quartz.3.5.0\lib\net472\Quartz.dll
- ..\packages\Serilog.2.11.0\lib\net46\Serilog.dll
+ ..\packages\Serilog.2.12.0\lib\net47\Serilog.dll
..\packages\Serilog.Sinks.File.5.0.0\lib\net45\Serilog.Sinks.File.dll
@@ -233,20 +233,20 @@
-
- ..\packages\Extended.Wpf.Toolkit.4.3.0\lib\net40\Xceed.Wpf.AvalonDock.dll
+
+ ..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.dll
-
- ..\packages\Extended.Wpf.Toolkit.4.3.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll
+
+ ..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll
-
- ..\packages\Extended.Wpf.Toolkit.4.3.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll
+
+ ..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll
-
- ..\packages\Extended.Wpf.Toolkit.4.3.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll
+
+ ..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll
-
- ..\packages\Extended.Wpf.Toolkit.4.3.0\lib\net40\Xceed.Wpf.Toolkit.dll
+
+ ..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.Toolkit.dll
@@ -591,6 +591,9 @@
+
+
+
+
+
+ ..\UWP Package\Source\
+
+
+
+
+
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
+
+
-
-
+
+
\ No newline at end of file
diff --git a/4x/Move Mouse/Move Mouse.csproj.user b/4x/Move Mouse/Move Mouse.csproj.user
index 154adcb..479cda8 100644
--- a/4x/Move Mouse/Move Mouse.csproj.user
+++ b/4x/Move Mouse/Move Mouse.csproj.user
@@ -1,7 +1,8 @@
- /WorkingDirectory:"C:\Temp"
+
+
publish\
diff --git a/4x/Move Mouse/Properties/AssemblyInfo.cs b/4x/Move Mouse/Properties/AssemblyInfo.cs
index 452af4f..77586da 100644
--- a/4x/Move Mouse/Properties/AssemblyInfo.cs
+++ b/4x/Move Mouse/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@
// 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("4.14.0.0")]
-[assembly: AssemblyFileVersion("4.14.0.0")]
+[assembly: AssemblyVersion("4.15.0.0")]
+[assembly: AssemblyFileVersion("4.15.0.0")]
diff --git a/4x/Move Mouse/Properties/Resources.Designer.cs b/4x/Move Mouse/Properties/Resources.Designer.cs
index 3790f79..a9b8496 100644
--- a/4x/Move Mouse/Properties/Resources.Designer.cs
+++ b/4x/Move Mouse/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace ellabi.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", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -440,6 +440,16 @@ internal static System.Drawing.Icon Mouse_SystemTray_Active {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ ///
+ internal static System.Drawing.Icon Mouse_SystemTray_Battery {
+ get {
+ object obj = ResourceManager.GetObject("Mouse_SystemTray_Battery", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
///
diff --git a/4x/Move Mouse/Properties/Resources.resx b/4x/Move Mouse/Properties/Resources.resx
index 0b36b6b..1623482 100644
--- a/4x/Move Mouse/Properties/Resources.resx
+++ b/4x/Move Mouse/Properties/Resources.resx
@@ -235,6 +235,9 @@
..\Resources\Mouse-SystemTray-Active.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\Mouse-SystemTray-Battery.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
..\Resources\Mouse-SystemTray-Execute.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/4x/Move Mouse/Resources/Mouse-SystemTray-Battery.ico b/4x/Move Mouse/Resources/Mouse-SystemTray-Battery.ico
new file mode 100644
index 0000000..6fcc7a7
Binary files /dev/null and b/4x/Move Mouse/Resources/Mouse-SystemTray-Battery.ico differ
diff --git a/4x/Move Mouse/StaticCode.cs b/4x/Move Mouse/StaticCode.cs
index 3fabbbb..d41690a 100644
--- a/4x/Move Mouse/StaticCode.cs
+++ b/4x/Move Mouse/StaticCode.cs
@@ -86,11 +86,11 @@ public static void CreateLog()
}
}
- public static void EnableLog()
+ public static void EnableLog(LogEventLevel minimumLevel)
{
try
{
- _loggingLevelSwitch.MinimumLevel = (int)LogEventLevel.Verbose;
+ _loggingLevelSwitch.MinimumLevel = minimumLevel;
Logger?.Here().Debug(LogPath);
}
catch (Exception ex)
diff --git a/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs b/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs
index d1c2cb0..79fef1c 100644
--- a/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs
+++ b/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs
@@ -10,7 +10,6 @@
using Quartz.Impl.Triggers;
using System;
using System.ComponentModel;
-using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
@@ -27,6 +26,8 @@ internal class MouseWindowViewModel : INotifyPropertyChanged, IDisposable
public delegate void RequestMinimiseHandler(object sender);
+ public delegate void RequestNotificationHandler(object sender, string title, string message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon symbol);
+
//public delegate void HookKeyEnabledChangedHandler(object sender, bool enabled, Key key);
public event PropertyChangedEventHandler PropertyChanged;
@@ -34,6 +35,7 @@ internal class MouseWindowViewModel : INotifyPropertyChanged, IDisposable
public event AltTabVisibilityChangedHandler AltTabVisibilityChanged;
public event RequestActivateHandler RequestActivate;
public event RequestMinimiseHandler RequestMinimise;
+ public event RequestNotificationHandler RequestNotification;
//public event HookKeyEnabledChangedHandler HookKeyEnabledChanged;
private MouseState _currentState;
@@ -67,7 +69,8 @@ public enum MouseState
Paused,
Executing,
Sleeping,
- OnBattery
+ OnBattery,
+ Locked
}
public SettingsWindowViewModel SettingsVm => _settingsVm ?? (_settingsVm = new SettingsWindowViewModel());
@@ -141,6 +144,7 @@ public MouseWindowViewModel()
//StaticCode.ThemeUpdated += StaticCode_ThemeUpdated;
if (StaticCode.DownloadSource == StaticCode.MoveMouseSource.GitHub) StaticCode.UpdateAvailablityChanged += StaticCode_UpdateAvailablityChanged;
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
+ SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
ThreadPool.QueueUserWorkItem(ForceSystrayIconVisibilityAtLaunch);
ScheduleJobs();
//Debug.WriteLine(SystemInformation.PowerStatus.BatteryChargeStatus);
@@ -177,6 +181,12 @@ private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
case SessionSwitchReason.SessionUnlock:
_workstationLocked = false;
+
+ if ((CurrentState.Equals(MouseState.Locked) || CurrentState.Equals(MouseState.Running)) && !SettingsVm.Settings.ActiveWhenLocked)
+ {
+ ShowNotification("Automatically resuming now workstation has been unlocked.");
+ }
+
break;
case SessionSwitchReason.SessionLock:
_workstationLocked = true;
@@ -189,6 +199,33 @@ private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
}
}
+ private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
+ {
+ try
+ {
+ StaticCode.Logger?.Here().Debug(e.Mode.ToString());
+
+ if (SettingsVm.Settings.PauseOnBattery && e.Mode.Equals(PowerModes.StatusChange))
+ {
+ //todo Check what happens if state is Executing
+ if (CurrentState.Equals(MouseState.Running) && RunningOnBattery())
+ {
+ Stop(MouseState.OnBattery);
+ ShowNotification("Pausing now running on battery.");
+ }
+ else if (CurrentState.Equals(MouseState.OnBattery) && !RunningOnBattery())
+ {
+ Start();
+ ShowNotification("Resuming now running on mains power.");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ StaticCode.Logger?.Here().Error(ex.Message);
+ }
+ }
+
//private void StaticCode_ThemeUpdated(Theme theme)
//{
// try
@@ -214,9 +251,11 @@ private void StaticCode_ScheduleArrived(ScheduleBase.ScheduleAction action)
{
case ScheduleBase.ScheduleAction.Start:
Start();
+ ShowNotification("Scheduled start.");
break;
case ScheduleBase.ScheduleAction.Stop:
Stop(MouseState.Idle);
+ ShowNotification("Scheduled stop.");
break;
}
}
@@ -357,6 +396,7 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
StopAutoResumeTimer();
}
}
+
break;
}
case "Schedules":
@@ -369,6 +409,22 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
OnAltTabVisibilityChanged(this, !SettingsVm.Settings.HideFromAltTab);
break;
}
+ case "PauseOnBattery":
+ {
+ if (!SettingsVm.Settings.PauseOnBattery && CurrentState.Equals(MouseState.OnBattery))
+ {
+ Start();
+ ShowNotification("Resuming now running on mains power.");
+ }
+ //todo Check what happens if state is Executing
+ else if (SettingsVm.Settings.PauseOnBattery && CurrentState.Equals(MouseState.Running) && RunningOnBattery())
+ {
+ Stop(MouseState.OnBattery);
+ ShowNotification("Pausing now running on battery.");
+ }
+
+ break;
+ }
//case "HookKeyEnabled":
//{
// //OnHookKeyEnabledChanged(this, SettingsVm.Settings.HookKeyEnabled, SettingsVm.Settings.HookKey);
@@ -423,26 +479,33 @@ public void Start()
if (CurrentState != MouseState.Running)
{
- if (!BlackoutIsActive())
+ if (SettingsVm.Settings.PauseOnBattery && RunningOnBattery())
{
- StopAutoResumeTimer();
- _activeExecutionId = Guid.NewGuid();
- _lastStopStartToggleTime = DateTime.Now;
- PerformActions(ActionBase.EventTrigger.Start);
- double interval = SettingsVm.Settings.RandomInterval ? new Random().Next((SettingsVm.Settings.LowerInterval * 1000), (SettingsVm.Settings.UpperInterval * 1000)) : (SettingsVm.Settings.LowerInterval * 1000);
- interval = interval > 0 ? interval : 1;
- ExecutionTime = DateTime.Now.AddMilliseconds(interval);
- CurrentState = MouseState.Running;
- _actionTimer = new Timer(param => { PerformActions(ActionBase.EventTrigger.Interval); }, null, TimeSpan.FromMilliseconds(interval), Timeout.InfiniteTimeSpan);
- StopBlackoutTimer();
- AdjustVolume();
- if (_settingsVm.Settings.TopmostWhenRunning) OnRequestActivate(this);
- StartAutoPauseTimer();
+ CurrentState = MouseState.OnBattery;
}
else
{
- CurrentState = MouseState.Sleeping;
- StartBlackoutTimer();
+ if (!BlackoutIsActive())
+ {
+ StopAutoResumeTimer();
+ _activeExecutionId = Guid.NewGuid();
+ _lastStopStartToggleTime = DateTime.Now;
+ PerformActions(ActionBase.EventTrigger.Start);
+ double interval = SettingsVm.Settings.RandomInterval ? new Random().Next((SettingsVm.Settings.LowerInterval * 1000), (SettingsVm.Settings.UpperInterval * 1000)) : (SettingsVm.Settings.LowerInterval * 1000);
+ interval = interval > 0 ? interval : 1;
+ ExecutionTime = DateTime.Now.AddMilliseconds(interval);
+ CurrentState = MouseState.Running;
+ _actionTimer = new Timer(param => { PerformActions(ActionBase.EventTrigger.Interval); }, null, TimeSpan.FromMilliseconds(interval), Timeout.InfiniteTimeSpan);
+ StopBlackoutTimer();
+ AdjustVolume();
+ if (_settingsVm.Settings.TopmostWhenRunning) OnRequestActivate(this);
+ StartAutoPauseTimer();
+ }
+ else
+ {
+ CurrentState = MouseState.Sleeping;
+ StartBlackoutTimer();
+ }
}
}
}
@@ -571,38 +634,51 @@ private void PerformActions(ActionBase.EventTrigger trigger)
break;
case ActionBase.EventTrigger.Interval:
- if (((SettingsVm.Settings.ActiveWhenLocked.HasValue && SettingsVm.Settings.ActiveWhenLocked.Value) || !_workstationLocked) && !BlackoutIsActive())
+ if (SettingsVm.Settings.ActiveWhenLocked || !_workstationLocked)
{
- CurrentState = MouseState.Executing;
- StopAutoPauseTimer();
-
- if (SettingsVm.Settings.Actions.Any(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger)))
+ if (!BlackoutIsActive())
{
- var actions = _firstPass ? SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger)) : SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat);
+ CurrentState = MouseState.Executing;
+ StopAutoPauseTimer();
- foreach (var action in actions)
+ if (SettingsVm.Settings.Actions.Any(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger)))
{
- if (_activeExecutionId.Equals(executionId))
+ var actions = _firstPass ? SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger)) : SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat);
+
+ foreach (var action in actions)
{
- action.Execute();
+ if (_activeExecutionId.Equals(executionId))
+ {
+ action.Execute();
+ }
}
}
- }
- _firstPass = false;
+ _firstPass = false;
+ }
+ else
+ {
+ CurrentState = MouseState.Sleeping;
+ }
}
else
{
- CurrentState = MouseState.Sleeping;
+ CurrentState = MouseState.Locked;
}
if (_activeExecutionId.Equals(executionId) && (CurrentState.Equals(MouseState.Sleeping) || (!_firstPass && SettingsVm.Settings.Actions.Any(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat))))
{
Start();
+
+ if (CurrentState.Equals(MouseState.Sleeping))
+ {
+ ShowNotification("Automatically resuming after blackout expired.");
+ }
}
else
{
Stop(MouseState.Idle);
+ ShowNotification("Automatically stopping as there are no actions that are configured to repeat at each interval.");
}
break;
@@ -729,6 +805,7 @@ private void _autoResumeTimer_Elapsed(object sender, System.Timers.ElapsedEventA
if (StaticCode.GetLastInputTime().TotalSeconds > SettingsVm.Settings.AutoResumeSeconds)
{
Start();
+ ShowNotification($"Automatically resuming after {SettingsVm.Settings.AutoResumeSeconds} seconds of inactivity.");
}
}
catch (Exception ex)
@@ -785,6 +862,7 @@ private void _blackoutTimer_Elapsed(object sender, System.Timers.ElapsedEventArg
if (!BlackoutIsActive())
{
Start();
+ ShowNotification("Resuming now blackout is over.");
}
}
catch (Exception ex)
@@ -795,20 +873,51 @@ private void _blackoutTimer_Elapsed(object sender, System.Timers.ElapsedEventArg
private bool BlackoutIsActive()
{
- bool _blackoutIsActive;
+ bool blackoutIsActive;
try
{
- _blackoutIsActive = (SettingsVm.Settings.Blackouts != null) && SettingsVm.Settings.Blackouts.Any(blackout => (blackout.EnabledDays.Any(day => day.Equals(DateTime.Now.AddDays(-1).DayOfWeek)) && (new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, blackout.Time.Hours, blackout.Time.Minutes, blackout.Time.Seconds).Add(blackout.Duration) > DateTime.Now)) || (blackout.EnabledDays.Any(day => day.Equals(DateTime.Now.DayOfWeek)) && (blackout.Time < DateTime.Now.TimeOfDay) && (blackout.Time.Add(blackout.Duration) > DateTime.Now.TimeOfDay)));
+ blackoutIsActive = (SettingsVm.Settings.Blackouts != null) && SettingsVm.Settings.Blackouts.Any(blackout => (blackout.EnabledDays.Any(day => day.Equals(DateTime.Now.AddDays(-1).DayOfWeek)) && (new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, blackout.Time.Hours, blackout.Time.Minutes, blackout.Time.Seconds).Add(blackout.Duration) > DateTime.Now)) || (blackout.EnabledDays.Any(day => day.Equals(DateTime.Now.DayOfWeek)) && (blackout.Time < DateTime.Now.TimeOfDay) && (blackout.Time.Add(blackout.Duration) > DateTime.Now.TimeOfDay)));
}
catch (Exception ex)
{
- _blackoutIsActive = false;
+ blackoutIsActive = false;
StaticCode.Logger?.Here().Error(ex.Message);
}
- StaticCode.Logger?.Here().Debug(_blackoutIsActive.ToString());
- return _blackoutIsActive;
+ StaticCode.Logger?.Here().Debug(blackoutIsActive.ToString());
+ return blackoutIsActive;
+ }
+
+ private bool RunningOnBattery()
+ {
+ bool runningOnBattery;
+
+ try
+ {
+ runningOnBattery = System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus.Equals(System.Windows.Forms.PowerLineStatus.Offline);
+ }
+ catch (Exception ex)
+ {
+ runningOnBattery = false;
+ StaticCode.Logger?.Here().Error(ex.Message);
+ }
+
+ StaticCode.Logger?.Here().Debug(runningOnBattery.ToString());
+ return runningOnBattery;
+ }
+
+ public void ShowNotification(string message)
+ {
+ ShowNotification(null, message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.None);
+ }
+
+ public void ShowNotification(string title, string message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon symbol)
+ {
+ if (!SettingsVm.Settings.HideSystemTrayIcon && !SettingsVm.Settings.HideSystemTrayNotifications)
+ {
+ OnRequestNotification(this, title, message, symbol);
+ }
}
protected void OnMouseStateChanged(object sender, MouseState state)
@@ -858,6 +967,20 @@ protected void OnRequestActivate(object sender)
}
}
+ protected void OnRequestNotification(object sender, string title, string message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon symbol)
+ {
+ StaticCode.Logger?.Here().Debug($"{title}\t{message}\t{symbol}");
+
+ try
+ {
+ RequestNotification?.Invoke(sender, title, message, symbol);
+ }
+ catch (Exception ex)
+ {
+ StaticCode.Logger?.Here().Error(ex.Message);
+ }
+ }
+
protected void OnRequestMinimise(object sender)
{
StaticCode.Logger?.Here().Debug(String.Empty);
@@ -895,6 +1018,7 @@ public void Dispose()
//StaticCode.ThemeUpdated -= StaticCode_ThemeUpdated;
StaticCode.UpdateAvailablityChanged -= StaticCode_UpdateAvailablityChanged;
SystemEvents.SessionSwitch -= SystemEvents_SessionSwitch;
+ SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
}
catch (Exception ex)
{
diff --git a/4x/Move Mouse/ViewModels/SettingsWindowViewModel.cs b/4x/Move Mouse/ViewModels/SettingsWindowViewModel.cs
index fdbec13..c9aa509 100644
--- a/4x/Move Mouse/ViewModels/SettingsWindowViewModel.cs
+++ b/4x/Move Mouse/ViewModels/SettingsWindowViewModel.cs
@@ -3,6 +3,7 @@
using ellabi.Classes;
using ellabi.Schedules;
using ellabi.Utilities;
+using Serilog.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -121,11 +122,14 @@ public StartupTaskState LaunchAtStartup
public string Copyright => ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright;
+ public IEnumerable LogEventLevels => Enum.GetValues(typeof(LogEventLevel)).Cast();
+
+
public SettingsWindowViewModel()
{
if (Settings.EnableLogging)
{
- StaticCode.EnableLog();
+ StaticCode.EnableLog(Settings.LogLevel);
}
StaticCode.Logger?.Here().Information($"WorkingDirectory = {StaticCode.WorkingDirectory}");
@@ -235,13 +239,22 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (Settings.EnableLogging)
{
- StaticCode.EnableLog();
+ StaticCode.EnableLog(Settings.LogLevel);
}
else
{
StaticCode.DisableLog();
}
+ break;
+ }
+ case "LogLevel":
+ {
+ if (Settings.EnableLogging)
+ {
+ StaticCode.EnableLog(Settings.LogLevel);
+ }
+
break;
}
}
diff --git a/4x/Move Mouse/Views/MouseWindow.xaml b/4x/Move Mouse/Views/MouseWindow.xaml
index b9c5d9e..96c05d6 100644
--- a/4x/Move Mouse/Views/MouseWindow.xaml
+++ b/4x/Move Mouse/Views/MouseWindow.xaml
@@ -193,6 +193,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -275,39 +285,6 @@
-
-
-
@@ -320,24 +297,16 @@
diff --git a/4x/Move Mouse/Views/MouseWindow.xaml.cs b/4x/Move Mouse/Views/MouseWindow.xaml.cs
index da8e0d6..5289334 100644
--- a/4x/Move Mouse/Views/MouseWindow.xaml.cs
+++ b/4x/Move Mouse/Views/MouseWindow.xaml.cs
@@ -11,6 +11,7 @@
using System.Windows.Interop;
using System.Windows.Media.Animation;
using System.Windows.Shell;
+using static System.Windows.Forms.AxHost;
namespace ellabi.Views
{
@@ -50,6 +51,7 @@ private void MouseWindow_Loaded(object sender, RoutedEventArgs e)
_vm.AltTabVisibilityChanged += _vm_AltTabVisibilityChanged;
_vm.RequestActivate += _vm_RequestActivate;
_vm.RequestMinimise += _vm_RequestMinimise;
+ _vm.RequestNotification += _vm_RequestNotification;
//_vm.HookKeyEnabledChanged += _vm_HookKeyEnabledChanged;
if (_vm.SettingsVm.Settings.HideFromAltTab)
@@ -60,6 +62,7 @@ private void MouseWindow_Loaded(object sender, RoutedEventArgs e)
if (_vm.SettingsVm.Settings.StartAtLaunch)
{
_vm.Start();
+ _vm.ShowNotification("Automatically started at launch.");
}
else if (_vm.SettingsVm.Settings.MinimiseOnStop)
{
@@ -67,6 +70,21 @@ private void MouseWindow_Loaded(object sender, RoutedEventArgs e)
}
}
+ private void _vm_RequestNotification(object sender, string title, string message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon symbol)
+ {
+ try
+ {
+ Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
+ {
+ MouseTaskbarIcon.ShowBalloonTip(title, message, symbol);
+ }));
+ }
+ catch (Exception ex)
+ {
+ StaticCode.Logger?.Here().Error(ex.Message);
+ }
+ }
+
private void _vm_RequestMinimise(object sender)
{
StaticCode.Logger?.Here().Debug(String.Empty);
@@ -154,12 +172,12 @@ private void _vm_MouseStateChanged(object sender, MouseWindowViewModel.MouseStat
if (TaskbarItemInfo != null)
{
TaskbarItemInfo.ProgressState =
- state.Equals(MouseWindowViewModel.MouseState.Running) ? TaskbarItemProgressState.Normal :
- state.Equals(MouseWindowViewModel.MouseState.Executing) ? TaskbarItemProgressState.Error :
- state.Equals(MouseWindowViewModel.MouseState.Paused) ? TaskbarItemProgressState.Paused :
- state.Equals(MouseWindowViewModel.MouseState.Sleeping) ? TaskbarItemProgressState.Paused :
- state.Equals(MouseWindowViewModel.MouseState.OnBattery) ? TaskbarItemProgressState.Paused :
- TaskbarItemProgressState.None;
+ state.Equals(MouseWindowViewModel.MouseState.Running) ? TaskbarItemProgressState.Normal :
+ state.Equals(MouseWindowViewModel.MouseState.Executing) ? TaskbarItemProgressState.Error :
+ state.Equals(MouseWindowViewModel.MouseState.Paused) ? TaskbarItemProgressState.Paused :
+ state.Equals(MouseWindowViewModel.MouseState.Sleeping) ? TaskbarItemProgressState.Paused :
+ state.Equals(MouseWindowViewModel.MouseState.OnBattery) ? TaskbarItemProgressState.Paused :
+ TaskbarItemProgressState.None;
}
}));
}
diff --git a/4x/Move Mouse/Views/SettingsWindow.xaml b/4x/Move Mouse/Views/SettingsWindow.xaml
index 51e3736..090485b 100644
--- a/4x/Move Mouse/Views/SettingsWindow.xaml
+++ b/4x/Move Mouse/Views/SettingsWindow.xaml
@@ -12,7 +12,7 @@
xmlns:classes="clr-namespace:ellabi.Classes"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
mc:Ignorable="d"
- Title="Move Mouse Settings" Height="412" Width="640" Icon="/Resources/Mouse.ico" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" WindowStyle="None" MouseDown="SettingsWindow_OnMouseDown" ShowActivated="True" Loaded="SettingsWindow_OnLoaded">
+ Title="Move Mouse Settings" Height="442" Width="640" Icon="/Resources/Mouse.ico" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" WindowStyle="None" MouseDown="SettingsWindow_OnMouseDown" ShowActivated="True" Loaded="SettingsWindow_OnLoaded">
@@ -1175,7 +1175,7 @@
-
+
@@ -1682,9 +1682,13 @@
+
+
+
+
-
+
+
+
+
+