Beispiel #1
0
        protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            string oldTheme = Enum.GetName(typeof(Theme), currentComponentTheme);

            try
            {
                if (Settings.Component.Mode == Mode.DarkOnly)
                {
                    RegistryHandler.SetAppsTheme((int)Theme.Dark);
                    currentComponentTheme = Theme.Dark;
                }
                else if (Settings.Component.Mode == Mode.LightOnly)
                {
                    RegistryHandler.SetAppsTheme((int)Theme.Light);
                    currentComponentTheme = Theme.Light;
                }
                else
                {
                    RegistryHandler.SetAppsTheme((int)newTheme);
                    currentComponentTheme = newTheme;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "could not set apps theme");
            }
            Logger.Info($"update info - previous: {oldTheme}, now: {Enum.GetName(typeof(Theme), currentComponentTheme)}, mode: {Enum.GetName(typeof(Mode), Settings.Component.Mode)}");
        }
        protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            // todo change behavior for win11 22H2, write and apply custom theme file. Use Winforms Screens to assing correct monitors.
            string oldIndividual = Enum.GetName(typeof(Theme), currentIndividualTheme);
            string oldGlobal     = Enum.GetName(typeof(Theme), currentGlobalTheme);
            string oldSolid      = Enum.GetName(typeof(Theme), currentSolidColorTheme);

            string oldPos = Enum.GetName(typeof(WallpaperPosition), currentWallpaperPosition);

            try
            {
                if (newTheme == Theme.Dark)
                {
                    HandleSwitchByType(Settings.Component.TypeDark, Theme.Dark);
                }
                else if (newTheme == Theme.Light)
                {
                    HandleSwitchByType(Settings.Component.TypeLight, Theme.Light);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "could not set wallpapers");
            }

            if (newTheme == Theme.Dark)
            {
                LogHandleSwitch(Settings.Component.TypeDark, oldGlobal, oldIndividual, oldSolid, oldPos);
            }
            else if (newTheme == Theme.Light)
            {
                LogHandleSwitch(Settings.Component.TypeLight, oldGlobal, oldIndividual, oldSolid, oldPos);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Diese Methode informiert alle registrierten Eventhandler über den Zustandswechsel 
 /// (ein-/ausgeschaltet) des Schalters.
 /// </summary>
 public void OnSwitchStateChanged(SwitchEventArgs e)
 {
     if (SwitchStateChanged != null)
     {
         SwitchStateChanged(this, e);
     }
 }
        protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            string oldIndividual = Enum.GetName(typeof(Theme), currentIndividualTheme);
            string oldGlobal     = Enum.GetName(typeof(Theme), currentGlobalTheme);
            string oldSolid      = Enum.GetName(typeof(Theme), currentSolidColorTheme);

            string oldPos = Enum.GetName(typeof(WallpaperPosition), currentWallpaperPosition);

            try
            {
                if (newTheme == Theme.Dark)
                {
                    HandleSwitchByType(Settings.Component.TypeDark, Theme.Dark);
                }
                else if (newTheme == Theme.Light)
                {
                    HandleSwitchByType(Settings.Component.TypeLight, Theme.Light);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "could not set wallpapers");
            }

            if (newTheme == Theme.Dark)
            {
                LogHandleSwitch(Settings.Component.TypeDark, oldGlobal, oldIndividual, oldSolid, oldPos);
            }
            else if (newTheme == Theme.Light)
            {
                LogHandleSwitch(Settings.Component.TypeLight, oldGlobal, oldIndividual, oldSolid, oldPos);
            }
        }
        protected override async void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            string oldTheme   = Enum.GetName(typeof(Theme), currentComponentTheme);
            Task   switchTask = Task.Run(() =>
            {
                if (newTheme == Theme.Light)
                {
                    Settings.Component.Scripts.ForEach(s =>
                    {
                        if (s.AllowedSources.Contains(SwitchSource.Any) || s.AllowedSources.Contains(e.Source))
                        {
                            ScriptHandler.Launch(s.Name, s.Command, s.ArgsLight, s.TimeoutMillis, s.WorkingDirectory);
                        }
                    });
                    currentComponentTheme = Theme.Light;
                }
                else
                {
                    Settings.Component.Scripts.ForEach(s =>
                    {
                        if (s.AllowedSources.Contains(SwitchSource.Any) || s.AllowedSources.Contains(e.Source))
                        {
                            ScriptHandler.Launch(s.Name, s.Command, s.ArgsDark, s.TimeoutMillis, s.WorkingDirectory);
                        }
                    });
                    currentComponentTheme = Theme.Dark;
                }
            });
            await switchTask;

            Logger.Info($"update info - previous: {oldTheme}, now: {Enum.GetName(typeof(Theme), currentComponentTheme)}");
        }
Beispiel #6
0
        private void OnSwitchStateChanged(object sender, SwitchEventArgs switchEventArgs)
        {
            if (commonRunParameters1.InvokeRequired)
            {
                commonRunParameters1.Invoke(new Action(() => OnSwitchStateChanged(sender, switchEventArgs)));
            }

            if (switchEventArgs.SwitchEnabled)
            {
                if (_actualPattern == null)
                {
                    World.Robot.RobotConsole[Leds.Led1].LedEnabled = switchEventArgs.SwitchEnabled;
                    _actualPattern = new FindSpaceAndParkPattern((float)commonRunParameters1.UPSpeed.Value / 1000f, (float)commonRunParameters1.UPAcceleration.Value / 1000f);
                    _actualPattern.PatternFinished += ActualPatternOnPatternFinished;
                    _actualPattern.Start();
                }
                else
                {
                    _actualPattern.Restart();
                }
            }
            else
            {
                if (_actualPattern != null)
                {
                    _actualPattern.Halt();
                }
            }
        }
Beispiel #7
0
 private void StartTestatRun(object sender, SwitchEventArgs e)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new RunDelegate(Run));
     }
 }
Beispiel #8
0
 /// <summary>
 /// Update switch state if sender is own set
 /// switch.
 /// </summary>
 /// <param name="sender">The switch from where the change is from</param>
 /// <param name="e">Event</param>
 private void SwitchCtrl_SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     if (sender == switchCtrl)
     {
         this.state = e.SwitchEnabled;
         updateView();
     }
 }
Beispiel #9
0
 private void SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke(new EventHandler <SwitchEventArgs>(SwitchStateChanged), sender, e);
     }
     else
     {
         State = e.SwitchEnabled;
     }
 }
Beispiel #10
0
 void MakeImageSwitchStateChanged(object sender, SwitchEventArgs e)
 {
     if (!Constants.IsWinCE)
     {
         fww.worldView1.GetWorldAsImage().Save(DateTime.Now.ToString("ddMMyyyyHHmmssffff") + ".jpg", ImageFormat.Jpeg);
     }
     else
     {
         fww.worldView1.GetWorldAsImage().Save("\\CompactFlash\\FTPRoot\\x86\\" + DateTime.Now.ToString("ddMMyyyyHHmmssffff") + ".bmp", ImageFormat.Bmp);
     }
 }
Beispiel #11
0
 private void Testat1_Form1_SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     if (e.SwitchEnabled == true)
     {
         par.driveParcour(R);
         changeLabel(par.numberOfObjects);
     }
     else
     {
         // ev stop.
     }
 }
Beispiel #12
0
 private void OnSwitchStateChangedEvent(object sender, SwitchEventArgs args)
 {
     if (InvokeRequired)             // Prüft ob Thread != GUI-Thread
     {
         // Synchronisierung notwendig
         Invoke(new EventHandler <SwitchEventArgs>(OnSwitchStateChangedEvent), sender, args);
     }
     else
     {
         // Synchronisierung nicht notwendig
         State = args.SwitchEnabled;
     }
 }
        public static void RequestSwitch(AdmConfigBuilder builder, SwitchEventArgs e)
        {
            if (state.ForcedTheme == Theme.Dark)
            {
                UpdateTheme(builder.Config, Theme.Dark, e);
                return;
            }
            else if (state.ForcedTheme == Theme.Light)
            {
                UpdateTheme(builder.Config, Theme.Light, e);
                return;
            }

            if (builder.Config.Events.DarkThemeOnBattery)
            {
                if (PowerManager.BatteryStatus == BatteryStatus.Discharging)
                {
                    UpdateTheme(builder.Config, Theme.Dark, e);
                    return;
                }
                if (!builder.Config.AutoThemeSwitchingEnabled)
                {
                    UpdateTheme(builder.Config, Theme.Light, e);
                    return;
                }
            }

            if (builder.Config.AutoThemeSwitchingEnabled)
            {
                DateTime sunrise = builder.Config.Sunrise;
                DateTime sunset  = builder.Config.Sunset;
                if (builder.Config.Location.Enabled)
                {
                    LocationHandler.GetSunTimes(builder, out sunrise, out sunset);
                }
                //the time bewteen sunrise and sunset, aka "day"
                if (Extensions.NowIsBetweenTimes(sunrise.TimeOfDay, sunset.TimeOfDay))
                {
                    UpdateTheme(builder.Config, Theme.Light, e, sunrise);
                }
                else
                {
                    UpdateTheme(builder.Config, Theme.Dark, e, sunset);
                }
            }
            else
            {
                UpdateTheme(builder.Config, state.LastRequestedTheme, e);
            }
        }
Beispiel #14
0
 //Eventhandler für eine Änderung des Status der LED
 private void SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     //Invoke Required ist nötig, da nur der Thread der hier die SwitchView erzeugt hat, etwas am
     //GUI ändern darf. Wenn dieser Thread aktiv ist, ist InvokeRequired = false und das GUI wird aktualisiert
     //Ansonsten wenn ein anderer Thread zugreifen will, ist das InvokeRequired = true und die
     //SwitchStateChanged Methode muss nochmals aufgerufen werden vom richtigen Thread. Das geschieht im
     //Code unten nach der If-Anweisung Invoke(new.....)
     if (InvokeRequired)
     {
         Invoke(new EventHandler <SwitchEventArgs>(SwitchStateChanged), sender, e);
     }
     else
     {
         State = e.SwitchEnabled;
     }
 }
        protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            string oldTheme = Enum.GetName(typeof(Theme), currentComponentTheme);

            try
            {
                if (Settings.Component.Mode == Mode.DarkOnly)
                {
                    OfficeTheme(Settings.Component.DarkTheme);
                    currentComponentTheme = Theme.Dark;
                }
                else if (Settings.Component.Mode == Mode.LightOnly)
                {
                    OfficeTheme(Settings.Component.LightTheme);
                    currentComponentTheme = Theme.Light;
                    ChoosenLightTheme     = Settings.Component.LightTheme;
                }
                else if (Settings.Component.Mode == Mode.FollowSystemTheme)
                {
                    OfficeTheme(6);
                    currentComponentTheme = Theme.Automatic;
                    ChoosenLightTheme     = 6;
                }
                else
                {
                    if (newTheme == Theme.Dark)
                    {
                        OfficeTheme(Settings.Component.DarkTheme);
                    }
                    else
                    {
                        OfficeTheme(Settings.Component.LightTheme);
                    }
                    currentComponentTheme = newTheme;
                    ChoosenLightTheme     = Settings.Component.LightTheme;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "could not set office theme");
            }
            Logger.Info($"update info - previous: {oldTheme}, now: {Enum.GetName(typeof(Theme), currentComponentTheme)}, mode: {Enum.GetName(typeof(Mode), Settings.Component.Mode)}");
        }
 public void Switch(Theme newTheme, SwitchEventArgs e)
 {
     Logger.Debug($"switch invoked for {GetType().Name}");
     ForceSwitch = false;
     if (Enabled)
     {
         if (!Initialized)
         {
             try
             {
                 EnableHook();
             }
             catch (Exception ex)
             {
                 Logger.Error(ex, $"error while running enable hook for {GetType().Name}");
             }
         }
         if (ComponentNeedsUpdate(newTheme))
         {
             try
             {
                 HandleSwitch(newTheme, e);
             }
             catch (Exception ex)
             {
                 Logger.Error(ex, $"uncaught exception in component {GetType().Name}, source: {ex.Source}, message: ");
             }
         }
     }
     else if (Initialized)
     {
         try
         {
             DisableHook();
         }
         catch (Exception ex)
         {
             Logger.Error(ex, $"error while running disable hook for {GetType().Name}");
         }
     }
 }
        protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            bool oldTheme = currentColorFilterActive;

            try
            {
                RegistryHandler.ColorFilterSetup();
                if (newTheme == Theme.Dark)
                {
                    RegistryHandler.ColorFilterKeySender(true);
                    currentColorFilterActive = true;
                }
                else
                {
                    RegistryHandler.ColorFilterKeySender(false);
                    currentColorFilterActive = false;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "could not enable color filter:");
            }
            Logger.Info($"update info - previous: {oldTheme}, now: {currentColorFilterActive}, enabled: {Settings.Enabled}");
        }
Beispiel #18
0
        protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
        {
            string oldTheme = Enum.GetName(typeof(Theme), currentComponentTheme);

            newTheme = newTheme == Theme.Dark ? Theme.Dark : Theme.Light;
            ThemeFile themeFile = GlobalState.ManagedThemeFile;

            if (Settings.Component.Mode == Mode.DarkOnly)
            {
                themeFile.VisualStyles.AppMode = (nameof(Theme.Dark), themeFile.VisualStyles.AppMode.Item2);
                currentComponentTheme          = Theme.Dark;
            }
            else if (Settings.Component.Mode == Mode.LightOnly)
            {
                themeFile.VisualStyles.AppMode = (nameof(Theme.Light), themeFile.VisualStyles.AppMode.Item2);
                currentComponentTheme          = Theme.Light;
            }
            else
            {
                themeFile.VisualStyles.AppMode = (Enum.GetName(typeof(Theme), newTheme), themeFile.VisualStyles.AppMode.Item2);
                currentComponentTheme          = newTheme;
            }
            Logger.Info($"update info - previous: {oldTheme}, now: {Enum.GetName(typeof(Theme), currentComponentTheme)}, mode: {Enum.GetName(typeof(Mode), Settings.Component.Mode)}");
        }
Beispiel #19
0
        void switchStateChanged(object sender, SwitchEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new EventHandler <SwitchEventArgs>(switchStateChanged), sender, e);
            }
            else
            {
                robotConsole[(Leds)(int)e.Swi].LedEnabled = e.SwitchEnabled;

                if ((int)e.Swi == 1 && e.SwitchEnabled)
                {
                    runLine1.Start();
                }
                else if ((int)e.Swi == 2 && e.SwitchEnabled)
                {
                    runArc1.Start();
                }
                else if ((int)e.Swi == 3 && e.SwitchEnabled)
                {
                    runTurn1.Start();
                }
            }
        }
Beispiel #20
0
 public void Run(List <ISwitchComponent> components, Theme newTheme, SwitchEventArgs e)
 {
     if (newTheme == Theme.Dark && lastSorting != Theme.Dark)
     {
         components.Sort((x, y) => x.PriorityToDark.CompareTo(y.PriorityToDark));
         lastSorting = Theme.Dark;
     }
     else if (newTheme == Theme.Light && lastSorting != Theme.Light)
     {
         components.Sort((x, y) => x.PriorityToLight.CompareTo(y.PriorityToLight));
         lastSorting = Theme.Light;
     }
     components.ForEach(c =>
     {
         if (Builder.Config.WindowsThemeMode.Enabled && c.ThemeHandlerCompatibility)
         {
             c.Switch(newTheme, e);
         }
         else if (!Builder.Config.WindowsThemeMode.Enabled)
         {
             c.Switch(newTheme, e);
         }
     });
 }
Beispiel #21
0
 //Wenn Schalter 1 betätigt wurde, soll der Vorgang gestartet werden
 private void Switch1_SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     //Invoke Required ist nötig, da nur der Thread der hier die SwitchView erzeugt hat, etwas am
     //GUI ändern darf. Wenn dieser Thread aktiv ist, ist InvokeRequired = false und das GUI wird aktualisiert
     //Ansonsten wenn ein anderer Thread zugreifen will, ist das InvokeRequired = true und die
     //SwitchStateChanged Methode muss nochmals aufgerufen werden vom richtigen Thread. Das geschieht im
     //Code unten nach der If-Anweisung Invoke(new.....)
     if (InvokeRequired)
     {
         Invoke(new EventHandler <SwitchEventArgs>(Switch1_SwitchStateChanged), sender, e);
     }
     else
     {
         //Wenn bool Variable noch nicht gesetzt und Schalter betätigt wurde --> Variable setzen
         //und Vorgänge starten
         if (e.SwitchEnabled && !switch1enabled)
         {
             //Textbox
             textBoxLänge.Text  = "Messung läuft...";
             textBoxBreite.Text = "Messung läuft...";
             switch1enabled     = true;
         }
     }
 }
Beispiel #22
0
 private void SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     On = e.SwitchEnabled;
 }
 /// <summary>
 /// Entrypoint, called when a component needs to be updated
 /// </summary>
 /// <param name="newTheme">the new theme to apply</param>
 /// <param name="e">the switch event args</param>
 protected abstract void HandleSwitch(Theme newTheme, SwitchEventArgs e);
 public void SwitchEventHandler(object sender, SwitchEventArgs e)
 {
     _status = e.Status;
     Debug.Print($"{_name}: {Bounds} {((Form)sender).Bounds} {_status}");
 }
Beispiel #25
0
 void MakeImageSwitchStateChanged(object sender, SwitchEventArgs e)
 {
     if (!Constants.IsWinCE)
     fww.worldView1.GetWorldAsImage().Save(DateTime.Now.ToString("ddMMyyyyHHmmssffff")+".jpg", ImageFormat.Jpeg);
       else {
      fww.worldView1.GetWorldAsImage().Save("\\CompactFlash\\FTPRoot\\x86\\" + DateTime.Now.ToString("ddMMyyyyHHmmssffff") + ".bmp", ImageFormat.Bmp);
       }
 }
Beispiel #26
0
 private void ResetSwitchStateChanged(object sender, SwitchEventArgs switchEventArgs)
 {
     ButtonResetOnClick(null, null);
       World.Robot.Drive.Position = new PositionInfo(0, 0, 90);
 }
Beispiel #27
0
        private void OnSwitchStateChanged(object sender, SwitchEventArgs switchEventArgs)
        {
            if (commonRunParameters1.InvokeRequired) {
            commonRunParameters1.Invoke(new Action(() => OnSwitchStateChanged(sender, switchEventArgs)));
              }

              if (switchEventArgs.SwitchEnabled)
              {
            if (_actualPattern == null)
            {
              World.Robot.RobotConsole[Leds.Led1].LedEnabled = switchEventArgs.SwitchEnabled;
              _actualPattern = new FindSpaceAndParkPattern((float)commonRunParameters1.UPSpeed.Value / 1000f, (float)commonRunParameters1.UPAcceleration.Value / 1000f);
              _actualPattern.PatternFinished += ActualPatternOnPatternFinished;
              _actualPattern.Start();
            }
            else
            {
              _actualPattern.Restart();
            }
              }
              else
              {
            if (_actualPattern != null)
            {
              _actualPattern.Halt();
            }
              }
        }
 public static void UpdateTheme(AdmConfig config, Theme newTheme, SwitchEventArgs e, DateTime switchTime = new())
Beispiel #29
0
 private void SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     On = e.SwitchEnabled;
 }
Beispiel #30
0
 private void OnSwitchStateChanged(object sender, SwitchEventArgs e)
 {
     this.State = e.SwitchEnabled;
 }
Beispiel #31
0
 void switchStateChanged(object sender, SwitchEventArgs e)
 {
     robotConsole[(Leds)(int)e.Swi].LedEnabled = e.SwitchEnabled;
 }
Beispiel #32
0
 protected override void HandleSwitch(Theme newTheme, SwitchEventArgs e)
 {
     Task.Run(async() => { await SwitchSystemTheme(newTheme); }).Wait();
 }
Beispiel #33
0
 private void SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     _robotConsole[(Leds)e.Swi].LedEnabled = e.SwitchEnabled;
 }
Beispiel #34
0
 private void ResetSwitchStateChanged(object sender, SwitchEventArgs switchEventArgs)
 {
     ButtonResetOnClick(null, null);
     World.Robot.Drive.Position = new PositionInfo(0, 0, 90);
 }
Beispiel #35
0
 void SwitchStateChanged(object sender, SwitchEventArgs e)
 {
     rc[(Leds)(int)e.Swi].LedEnabled = e.SwitchEnabled;
 }
Beispiel #36
0
 private void Switch4StateChanged(object sender, SwitchEventArgs e)
 {
     rc[Leds.Led4].LedEnabled = e.SwitchEnabled;
 }