Exemplo n.º 1
0
 /// <summary>
 /// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
 /// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
 /// occurring rather than two
 /// </summary>
 public static void SwitchToPrinterTheme(bool doReloadEvent)
 {
     if (ActiveSliceSettings.Instance != null)
     {
         if (ActiveSliceSettings.Instance.PrinterSelected)
         {
             //Attempt to load userSetting theme as default
             string activeThemeName = UserSettings.Instance.get(UserSettingsKey.ActiveThemeName);
             if (string.IsNullOrEmpty(activeThemeName))
             {
                 activeThemeName = "Blue - Light";
             }
             if (ActiveSliceSettings.Instance.Contains(SettingsKey.active_theme_name))
             {
                 activeThemeName = ActiveSliceSettings.Instance.GetValue(SettingsKey.active_theme_name);
                 if (string.IsNullOrEmpty(activeThemeName))
                 {
                     activeThemeName = "Blue - Light";
                 }
                 if (!doReloadEvent)
                 {
                     ActiveTheme.SuspendEvents();
                 }
             }
             else
             {
                 //If the active printer has no theme we set it to the default so that it does not suddenly change colors later when another printer's color is changed
                 ActiveSliceSettings.Instance.SetValue(SettingsKey.active_theme_name, activeThemeName);
             }
             ActiveTheme.Instance = ActiveTheme.GetThemeColors(activeThemeName);
             ActiveTheme.ResumeEvents();
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
        /// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
        /// occurring rather than two
        /// </summary>
        public static void SwitchToPrinterTheme(bool doReloadEvent)
        {
            if (ActiveSliceSettings.Instance != null)
            {
                if (ActiveSliceSettings.Instance.PrinterSelected)
                {
                    string activeThemeName = "Blue - Light";
                    if (ActiveSliceSettings.Instance.Contains(SettingsKey.active_theme_name))
                    {
                        activeThemeName = ActiveSliceSettings.Instance.GetValue(SettingsKey.active_theme_name);
                        if (string.IsNullOrEmpty(activeThemeName))
                        {
                            activeThemeName = "Blue - Light";
                        }
                        if (!doReloadEvent)
                        {
                            ActiveTheme.SuspendEvents();
                        }
                    }

                    ActiveTheme.Instance = ActiveTheme.GetThemeColors(activeThemeName);
                    ActiveTheme.ResumeEvents();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
        /// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
        /// occurring rather than two
        /// </summary>
        public static void SwitchToPrinterTheme(bool doReloadEvent)
        {
            if (ActiveSliceSettings.Instance.PrinterSelected)
            {
                //Attempt to load userSetting theme as default
                string activeThemeName = ActiveSliceSettings.Instance.GetValue(SettingsKey.active_theme_name);
                if (!string.IsNullOrEmpty(activeThemeName))
                {
                    if (!doReloadEvent)
                    {
                        ActiveTheme.SuspendEvents();
                    }

                    ActiveTheme.Instance = ActiveTheme.GetThemeColors(activeThemeName);

                    ActiveTheme.ResumeEvents();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
        /// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
        /// occurring rather than two
        /// </summary>
        public static void SwitchToPrinterTheme(bool doReloadEvent)
        {
            int defaultThemeIndex = 1;

            int themeIndex;

            if (ActiveSliceSettings.Instance != null)
            {
                string activeThemeIndex = ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex");
                if (string.IsNullOrEmpty(activeThemeIndex) || !int.TryParse(activeThemeIndex, out themeIndex))
                {
                    themeIndex = defaultThemeIndex;
                }

                if (!doReloadEvent)
                {
                    ActiveTheme.SuspendEvents();
                }
                ActiveTheme.Instance = ActiveTheme.AvailableThemes[themeIndex];
                ActiveTheme.ResumeEvents();
            }
        }