Ejemplo n.º 1
0
        void CheckBox_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chk = sender as CheckBox;

            if (chk != null)
            {
                ShortcutControlInfo sci = chk.Tag as ShortcutControlInfo;
                if (sci != null)
                {
                    sci.CheckBox.ForeColor = sci.CheckBox.Checked ? SystemColors.WindowText : SystemColors.GrayText;
                }
            }
        }
Ejemplo n.º 2
0
        public SettingForm()
        {
            InitializeComponent();

            InitCulture();

            int r = 0;

            foreach (ShortcutAction action in ShortcutActionManager.Instance.Actions.Values)
            {
                if (action.HideInList)
                {
                    continue;
                }

                ShortcutControlInfo sci = new ShortcutControlInfo
                {
                    Action = action,
                };

                sci.CheckBox = new CheckBox()
                {
                    Text = action.Name, Dock = DockStyle.Fill, Tag = sci
                };
                sci.CheckBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged);

                unvell.JustCapture.XML.ActionInfo ai = (ConfigurationManager.Instance.GetCurrentUserConfiguration().GetAction(action.Id));

                if (ai != null)
                {
                    sci.CheckBox.Checked = ai.activated;
                }
                sci.KeyField = new ShortcutTextbox()
                {
                    ShortcutKeys = ai == null? Keys.None  :ShortcutKeyToolkit.StringToKeys(ai.shortcutKeys),
                    Dock         = DockStyle.Fill,
                    Tag          = sci
                };

                table.Controls.Add(sci.CheckBox, 0, r);
                table.Controls.Add(sci.KeyField, 1, r);

                scis.Add(sci);
                r++;
            }

            if (RegistryToolkit.PermissionToWriteSystemStartup())
            {
                chkStartup.Enabled = true;
            }
            else
            {
                chkStartup.Enabled      = false;
                imgNoPermission.Visible = true;
                labNoPermission.Visible = true;
            }

            chkStartup.Checked = RegistryToolkit.IsStartupProcessExists(ProductInfo.ProductName);

            chkStartup.CheckedChanged += (s, e) =>
            {
                if (chkStartup.Checked)
                {
                    RegistryToolkit.SetStartupProcess(ProductInfo.ProductName, Application.ExecutablePath);
                }
                else
                {
                    // try delete value of registry
                    if (!RegistryToolkit.RemoveStartupProcess(ProductInfo.ProductName))
                    {
                        // if deleting is failed, try write a non-existed value to start up registry
                        if (!RegistryToolkit.SetStartupProcess(ProductInfo.ProductName, string.Empty))
                        {
                            // if value cannot be replaced with an invalid application path,
                            // check on and tell user the startup item cannot be removed
                            imgNoPermission.Visible = labNoPermission.Visible = true;
                            chkStartup.Checked      = true;
                        }
                    }
                }
            };

            // show toolbar
            chkShowToolboxInCapturer.Checked = ConfigurationManager.Instance.IsCurrentUserSetting(
                UserConfigKey.CF_Toolstrip, true);

            // restore last selected region
            chkRestorePreviousRegion.Checked = ConfigurationManager.Instance.IsCurrentUserSetting(
                UserConfigKey.User_RestoreLastSelectRegion, true);

            // check for updates
            chkCheckForUpdates.Checked = ConfigurationManager.Instance.IsCurrentUserSetting(
                UserConfigKey.User_EnableCheckForUpdates, true);

            outerLineColorComboBox.CurrentColor = FileToolkit.DecodeColor(ConfigurationManager.Instance.GetCurrentUserSetting(
                                                                              UserConfigKey.CF_Selection_OuterColor, Color.Black.Name));
            innerLineColorComboBox.CurrentColor = FileToolkit.DecodeColor(ConfigurationManager.Instance.GetCurrentUserSetting(
                                                                              UserConfigKey.CF_Selection_InnerColor, Color.Gold.Name));
            thumbColorComboBox.CurrentColor = FileToolkit.DecodeColor(ConfigurationManager.Instance.GetCurrentUserSetting(
                                                                          UserConfigKey.CF_Selection_ThumbColor, Color.SkyBlue.Name));

            // show coordinate info
            chkShowCoordinateInfo.Checked = ConfigurationManager.Instance.IsCurrentUserSetting(UserConfigKey.CF_Show_Coordinate_Info, true);

            // magnifier scale
            string magnifierScaleStr = ConfigurationManager.Instance.GetCurrentUserSetting(UserConfigKey.CF_Magnifier_Scale, "2");
            int    magnifierScale    = 2;

            int.TryParse(magnifierScaleStr, out magnifierScale);
            trkMagnifierScale.ValueChanged += (s, e) => UpdateMagnifierValue();
            trkMagnifierScale.Value         = magnifierScale;

            regionSelectionSamplePanel.Paint += (s, e) =>
            {
                Graphics g = e.Graphics;

                Rectangle rect = regionSelectionSamplePanel.ClientRectangle;

                rect.Inflate(-10, -10);
                RangeHandlerEdit.UpdateRangeHandlers(rect, thumbs);

                rect.Inflate(3, 3);
                GraphicsToolkit.DrawDoubleLineRectangle(g, rect, outerLineColorComboBox.CurrentColor,
                                                        innerLineColorComboBox.CurrentColor);

                RangeHandlerEdit.DrawRangeHandlerPos(g, thumbs, thumbColorComboBox.CurrentColor);
            };

            outerLineColorComboBox.ColorSelected += (s, e) => regionSelectionSamplePanel.Invalidate();
            innerLineColorComboBox.ColorSelected += (s, e) => regionSelectionSamplePanel.Invalidate();
            thumbColorComboBox.ColorSelected     += (s, e) => regionSelectionSamplePanel.Invalidate();

            languageCombo.SelectedValueChanged += (s, e) =>
            {
                CultureInfo selectedCulture = MainForm.SupportedCultures[languageCombo.SelectedIndex];

                if (LangResource.Culture != selectedCulture)
                {
                    LangResource.Culture = selectedCulture;
                    InitCulture();
                }
            };

            ReloadSupportedLanguageList();

            chkShowCoordinateInfo.Checked = ConfigurationManager.Instance.IsCurrentUserSetting(
                UserConfigKey.CF_Show_Coordinate_Info, true);
        }