Exemplo n.º 1
0
        private void AppCommandTheme_Executed(object sender, EventArgs e)
        {
            ICommandSource source = sender as ICommandSource;

            if (source.CommandParameter is string)
            {
                eStyle style = (eStyle)Enum.Parse(typeof(eStyle), source.CommandParameter.ToString());
                // Using StyleManager change the style and color tinting
                if (StyleManager.IsMetro(style))
                {
                    ribbonControl1.RibbonStripFont = new System.Drawing.Font("Segoe UI", 9.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    if (style == eStyle.Metro)
                    {
                        StyleManager.MetroColorGeneratorParameters = DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters.DarkBlue;
                    }

                    // Adjust size of switch button to match Metro styling
                    switchButtonItem1.SwitchWidth  = 12;
                    switchButtonItem1.ButtonWidth  = 42;
                    switchButtonItem1.ButtonHeight = 19;

                    // Adjust tab strip style
                    tabStrip1.Style = eTabStripStyle.Metro;

                    StyleManager.Style = style; // BOOM
                }
                else
                {
                    // If previous style was Metro we need to update other properties as well
                    if (StyleManager.IsMetro(StyleManager.Style))
                    {
                        ribbonControl1.RibbonStripFont = null;

                        // Adjust size of switch button to match Office styling
                        switchButtonItem1.SwitchWidth  = 28;
                        switchButtonItem1.ButtonWidth  = 62;
                        switchButtonItem1.ButtonHeight = 20;
                    }
                    // Adjust tab strip style
                    tabStrip1.Style = eTabStripStyle.Office2007Document;
                    StyleManager.ChangeStyle(style, Color.Empty);
                }
            }
            else if (source.CommandParameter is Color)
            {
                if (StyleManager.IsMetro(StyleManager.Style))
                {
                    StyleManager.MetroColorGeneratorParameters = new DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters(Color.White, (Color)source.CommandParameter);
                }
                else
                {
                    StyleManager.ColorTint = (Color)source.CommandParameter;
                }
            }
        }
Exemplo n.º 2
0
 public BaseForm()
 {
     if (!this.DesignMode)
     {
         //必须放在初始化组件之前
         this.GetIcon();
     }
     InitializeComponent();
     StyleManager.ChangeStyle((eStyle)Enum.Parse(typeof(eStyle), SystemInfo.CurrentStyle), string.IsNullOrEmpty(SystemInfo.CurrentThemeColor)
             ? Color.Empty
             : ColorTranslator.FromHtml(SystemInfo.CurrentThemeColor));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 改变UI风格。
 /// </summary>
 /// <param name="uiStyle"></param>
 protected virtual void ChangeUIStyle(eStyle uiStyle)
 {
     PrepareBeforeChangeUIStyle(uiStyle);
     if (StyleManager.IsMetro(uiStyle))
     {
         StyleManager.Style = uiStyle;
     }
     else
     {
         StyleManager.ChangeStyle(uiStyle, Color.Empty);
     }
 }
 private void buttonStyleCustom_ExpandChange(object sender, EventArgs e)
 {
     if (buttonStyleCustom.Expanded)
     {
         // Remember the starting color scheme to apply if no color is selected during live-preview
         m_ColorSelected = false;
         m_BaseStyle     = StyleManager.Style;
     }
     else
     {
         if (!m_ColorSelected)
         {
             StyleManager.ChangeStyle(m_BaseStyle, Color.Empty);
         }
     }
 }
        private void AppCommandTheme_Executed(object sender, EventArgs e)
        {
            var source = sender as ICommandSource;

            if (source.CommandParameter is string)
            {
                SystemInfo.CurrentStyle = source.CommandParameter.ToString();
                var style = (eStyle)Enum.Parse(typeof(eStyle), SystemInfo.CurrentStyle);
                StyleManager.ChangeStyle(style, Color.Empty);
                UserConfigHelper.SaveConfig();
            }
            else if (source.CommandParameter is Color)
            {
                StyleManager.ColorTint = (Color)source.CommandParameter;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method that is called when the properties should be saved
        /// </summary>
        /// <param name="sender">The object that called this method</param>
        /// <param name="e">The RoutedEventArgs</param>
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Properties.Settings.Default.Save();

                LoadSettings();

                _mainWindow.LoadProperties();

                StyleManager.ChangeStyle(_mainWindow);
                StyleManager.ChangeStyle(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "DeadPix", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new AboutWindow object
        /// </summary>
        public AboutWindow()
        {
            InitializeComponent();
            StyleManager.ChangeStyle(this);

            // Enable window dragging, if the setting is enabled
            try
            {
                if (Properties.Settings.Default.WindowDraggable)
                {
                    MouseDown += OnMouseDown;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Advanced PortChecker", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Method that is called when the Save Button is clicked
        /// </summary>
        /// <param name="sender">The object that called this method</param>
        /// <param name="e">The RoutedEventArgs</param>
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Properties.Settings.Default.TimeOutType = CboTimeOut.SelectedIndex;
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (CboTimeOut.SelectedIndex)
                {
                case 0:
                    if (IntTimeOut.Value != null)
                    {
                        Properties.Settings.Default.TimeOut = (int)IntTimeOut.Value;
                    }
                    break;

                case 1:
                    if (IntTimeOut.Value != null)
                    {
                        Properties.Settings.Default.TimeOut = (int)IntTimeOut.Value * 1000;
                    }
                    break;

                case 2:
                    if (IntTimeOut.Value != null)
                    {
                        Properties.Settings.Default.TimeOut = (int)IntTimeOut.Value * 60 * 1000;
                    }
                    break;
                }

                Properties.Settings.Default.Save();

                LoadSettings();

                _mw.WindowDraggable();

                StyleManager.ChangeStyle(_mw);
                StyleManager.ChangeStyle(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Advanced PortChecker", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Method that is called when all settings should be reset to their default values
        /// </summary>
        /// <param name="sender">The object that called this method</param>
        /// <param name="e">The RoutedEventArgs</param>
        private void BtnReset_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to reset all settings?", "DeadPix", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            try
            {
                Properties.Settings.Default.Reset();
                Properties.Settings.Default.Save();

                _mainWindow.LoadProperties();
                StyleManager.ChangeStyle(_mainWindow);
                StyleManager.ChangeStyle(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "DeadPix", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 10
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new MainWindow object
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            StringVariables stringVariables = new StringVariables
            {
                CancelButtonText      = "Cancel",
                DownloadButtonText    = "Download",
                InformationButtonText = "Information",
                NoNewVersionText      = "You are running the latest version!",
                TitleText             = "Advanced PortChecker",
                UpdateNowText         = "Would you like to update the application now?"
            };

            _updateManager = new UpdateManager(Assembly.GetExecutingAssembly().GetName().Version, "https://codedead.com/Software/Advanced%20PortChecker/update.xml", stringVariables);

            WindowDraggable();
            // Change the theme
            StyleManager.ChangeStyle(this);
            LoadSettings();
        }
        private void AppCommandTheme_Executed(object sender, EventArgs e)
        {
            ICommandSource source = sender as ICommandSource;

            if (source.CommandParameter is string)
            {
                SystemInfo.CurrentStyle = source.CommandParameter.ToString();
                eStyle style = (eStyle)Enum.Parse(typeof(eStyle), SystemInfo.CurrentStyle);
                // Using StyleManager change the style and color tinting
                StyleManager.ChangeStyle(style, Color.Empty);
                //if (style == eStyle.Office2007Black || style == eStyle.Office2007Blue || style == eStyle.Office2007Silver || style == eStyle.Office2007VistaGlass)
                //    buttonFile.BackstageTabEnabled = false;
                //else
                //    buttonFile.BackstageTabEnabled = true;
                UserConfigHelper.SaveConfig();
            }
            else if (source.CommandParameter is Color)
            {
                StyleManager.ColorTint = (Color)source.CommandParameter;
            }
        }
Exemplo n.º 12
0
        private void ThemeChanged(string param)
        {
            switch (param)
            {
            case "Metro":
                StyleManager.MetroColorGeneratorParameters = DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters.DarkBlue;
                StyleManager.Style = eStyle.Metro;     // BOOM
                break;

            case "Office2007Blue":
            case "Office2007Silver":
            case "Office2007Black":
            case "Office2007VistaGlass":
            case "Office2010Silver":
            case "Office2010Blue":
            case "Office2010Black":
            case "Windows7Blue":
            case "VisualStudio2010Blue":
                eStyle style = (eStyle)Enum.Parse(typeof(eStyle), param);
                StyleManager.ChangeStyle(style, Color.Empty);
                break;

            default:
                if (param.StartsWith("#"))
                {
                    string colorstr            = param.TrimStart('#');
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(Convert.ToInt32(colorstr, 16));
                    if (StyleManager.Style == eStyle.Metro)
                    {
                        StyleManager.MetroColorGeneratorParameters = new DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters(Color.White, color);
                    }
                    else
                    {
                        StyleManager.ColorTint = color;
                    }
                }
                break;
            }
        }
Exemplo n.º 13
0
 private void buttonStyleCustom_ExpandChange(object sender, System.EventArgs e)
 {
     if (buttonStyleCustom.Expanded)
     {
         // Remember the starting color scheme to apply if no color is selected during live-preview
         m_ColorSelected = false;
         m_BaseStyle     = StyleManager.Style;
     }
     else
     {
         if (!m_ColorSelected)
         {
             if (StyleManager.IsMetro(StyleManager.Style))
             {
                 StyleManager.MetroColorGeneratorParameters = DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters.Default;
             }
             else
             {
                 StyleManager.ChangeStyle(m_BaseStyle, Color.Empty);
             }
         }
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Method that is called when the Reset Button is clicked
        /// </summary>
        /// <param name="sender">The object that called this method</param>
        /// <param name="e">The RoutedEventArgs</param>
        private void BtnReset_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("Are you sure you want to reset all settings?", "Advanced PortChecker", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return;
                }

                Properties.Settings.Default.Reset();
                Properties.Settings.Default.Save();

                LoadSettings();

                _mw.WindowDraggable();

                StyleManager.ChangeStyle(_mw);
                StyleManager.ChangeStyle(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Advanced PortChecker", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Change the visual style of the controls, depending on the settings
 /// </summary>
 private void ChangeVisualStyle()
 {
     StyleManager.ChangeStyle(this);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Change the visual style of an object, depending on the settings.
 /// </summary>
 internal void ChangeVisualStyle()
 {
     StyleManager.ChangeStyle(this);
 }
Exemplo n.º 17
0
        private void AppCommandTheme_Executed(object sender, EventArgs e)
        {
            ICommandSource source = sender as ICommandSource;

            if (source.CommandParameter is string)
            {
                eStyle style = (eStyle)Enum.Parse(typeof(eStyle), source.CommandParameter.ToString());
                // Using StyleManager change the style and color tinting
                if (StyleManager.IsMetro(style))
                {
                    // More customization is needed for Metro
                    // Capitalize App Button and tab
                    buttonFile.Text = buttonFile.Text.ToUpper();
                    foreach (BaseItem item in RibbonControl.Items)
                    {
                        // Ribbon Control may contain items other than tabs so that needs to be taken in account
                        RibbonTabItem tab = item as RibbonTabItem;
                        if (tab != null)
                        {
                            tab.Text = tab.Text.ToUpper();
                        }
                    }

                    buttonFile.BackstageTabEnabled = true; // Use Backstage for Metro

                    ribbonControl1.RibbonStripFont = new System.Drawing.Font("Segoe UI", 9.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    if (style == eStyle.Metro)
                    {
                        StyleManager.MetroColorGeneratorParameters = DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters.DarkBlue;
                    }

                    // Adjust size of switch button to match Metro styling
                    switchButtonItem1.SwitchWidth  = 16;
                    switchButtonItem1.ButtonWidth  = 48;
                    switchButtonItem1.ButtonHeight = 19;

                    // Adjust tab strip style
                    //tabStrip1.Style = eTabStripStyle.Metro;

                    StyleManager.Style = style; // BOOM
                }
                else
                {
                    // If previous style was Metro we need to update other properties as well
                    if (StyleManager.IsMetro(StyleManager.Style))
                    {
                        ribbonControl1.RibbonStripFont = null;
                        // Fix capitalization App Button and tab
                        buttonFile.Text = ToTitleCase(buttonFile.Text);
                        foreach (BaseItem item in RibbonControl.Items)
                        {
                            // Ribbon Control may contain items other than tabs so that needs to be taken in account
                            RibbonTabItem tab = item as RibbonTabItem;
                            if (tab != null)
                            {
                                tab.Text = ToTitleCase(tab.Text);
                            }
                        }
                        // Adjust size of switch button to match Office styling
                        switchButtonItem1.SwitchWidth  = 28;
                        switchButtonItem1.ButtonWidth  = 62;
                        switchButtonItem1.ButtonHeight = 20;
                    }
                    // Adjust tab strip style
                    // tabStrip1.Style = eTabStripStyle.Office2007Document;
                    StyleManager.ChangeStyle(style, Color.Empty);
                    if (style == eStyle.Office2007Black || style == eStyle.Office2007Blue || style == eStyle.Office2007Silver || style == eStyle.Office2007VistaGlass)
                    {
                        buttonFile.BackstageTabEnabled = false;
                    }
                    else
                    {
                        buttonFile.BackstageTabEnabled = true;
                    }
                }
            }
            else if (source.CommandParameter is Color)
            {
                if (StyleManager.IsMetro(StyleManager.Style))
                {
                    StyleManager.MetroColorGeneratorParameters = new DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters(Color.White, (Color)source.CommandParameter);
                }
                else
                {
                    StyleManager.ColorTint = (Color)source.CommandParameter;
                }
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Method that is called when the style has changed
 /// </summary>
 /// <param name="sender">The object that called this method</param>
 /// <param name="e">The SelectionChangedEventArgs</param>
 private void ChbStyle_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     StyleManager.ChangeStyle(this);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Change the visual style of the controls, depending on the settings
 /// </summary>
 internal void LoadTheme()
 {
     _applicationModule?.AddData("DeviceLog is currently changing the theme...");
     StyleManager.ChangeStyle(this);
     _applicationModule?.AddData("DeviceLog is done changing the theme.");
 }
Exemplo n.º 20
0
 /// <summary>
 /// Change the visual style of the controls, depending on the settings.
 /// </summary>
 private void ChangeVisualStyle()
 {
     _logController.AddLog(new ApplicationLog("Changing AboutWindow theme style"));
     StyleManager.ChangeStyle(this);
     _logController.AddLog(new ApplicationLog("Done changing AboutWindow theme style"));
 }
        /// <summary>
        /// Method that is called when the Save Button is clicked
        /// </summary>
        /// <param name="sender">The object that called this method</param>
        /// <param name="e">The RoutedEventArgs</param>
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Properties.Settings.Default.TimeOutType = CboTimeOut.SelectedIndex;
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (CboTimeOut.SelectedIndex)
                {
                case 0:
                    if (IntTimeOut.Value != null)
                    {
                        Properties.Settings.Default.TimeOut = (int)IntTimeOut.Value;
                    }
                    break;

                case 1:
                    if (IntTimeOut.Value != null)
                    {
                        Properties.Settings.Default.TimeOut = (int)IntTimeOut.Value * 1000;
                    }
                    break;

                case 2:
                    if (IntTimeOut.Value != null)
                    {
                        Properties.Settings.Default.TimeOut = ((int)IntTimeOut.Value * 60) * 1000;
                    }
                    break;
                }
                if (ChbAutoUpdate.IsChecked != null)
                {
                    Properties.Settings.Default.AutoUpdate = ChbAutoUpdate.IsChecked.Value;
                }
                if (ChbWindowDraggable.IsChecked != null)
                {
                    Properties.Settings.Default.WindowDraggable = ChbWindowDraggable.IsChecked.Value;
                }
                if (IntScanThreads.Value != null)
                {
                    Properties.Settings.Default.ScanThreads = (int)IntScanThreads.Value;
                }
                Properties.Settings.Default.VisualStyle = ChbStyle.Text;

                Properties.Settings.Default.MetroColor = CpMetroBrush.Color;
                if (IntBorderThickness.Value != null)
                {
                    Properties.Settings.Default.BorderThickness = (int)IntBorderThickness.Value;
                }
                Properties.Settings.Default.WindowOpacity      = SldOpacity.Value / 100;
                Properties.Settings.Default.WindowResizeBorder = SldWindowResize.Value;

                Properties.Settings.Default.Save();

                LoadSettings();

                _mw.WindowDraggable();

                StyleManager.ChangeStyle(_mw);
                StyleManager.ChangeStyle(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Advanced PortChecker", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }