private void HandleColorsDrawItem(object sender, DrawItemEventArgs e)
        {
            Debug.Assert(ReferenceEquals(sender, m_cbColors));

            ComboBox cb = ((ComboBox)sender);

            if (0 > e.Index || e.Index > cb.Items.Count)
            {
                return;
            }

            // Draw a combo box item using the color as a background.
            Graphics  g    = e.Graphics;
            Rectangle rect = e.Bounds;

            // Get the color proxy object.
            GoogleColor item = (GoogleColor)cb.Items[e.Index];

            // Background fill color painting.
            Brush brush = new SolidBrush(item.Color);

            g.FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);

            // Foreground is the color name in black.
            g.DrawString(item.ToString(), cb.Font,
                         Brushes.Black, rect.X, rect.Top);
        }
        private void HandleColorsSelectedIndexChanged(object sender,
                                                      EventArgs e)
        {
            GoogleColor item = m_cbColors.Items
                               .Cast <GoogleColor>()
                               .ElementAt(m_cbColors.SelectedIndex);

            m_cbColors.BackColor         = item.Color;
            m_data.DefaultAppFolderColor = item == m_nullColor ? null : item;
        }
示例#3
0
 PluginConfig(PluginConfig c)
 {
     m_autoSync            = c.m_autoSync;
     m_enabledCmds         = c.m_enabledCmds;
     m_defaultFolder       = c.m_defaultFolder;
     m_defaultFolderColor  = c.m_defaultFolderColor;
     m_defaultDriveScope   = c.m_defaultDriveScope;
     m_defaultClientId     = c.m_defaultClientId;
     m_defaultClientSecret = c.m_defaultClientSecret;
     m_useLegacyCreds      = c.m_useLegacyCreds;
     m_dontSaveAuthToken   = c.m_dontSaveAuthToken;
     m_warnSavedAuthToken  = c.m_warnSavedAuthToken;
     m_isDirty             = c.m_isDirty;
     m_ver            = c.m_ver;
     m_autoResumeSave = c.m_autoResumeSave;
 }
示例#4
0
 PluginConfig()
 {
     m_autoSync            = AutoSyncMode.DISABLED;
     m_enabledCmds         = SyncCommands.All;
     m_defaultFolder       = null;
     m_defaultFolderColor  = null;
     m_defaultDriveScope   = null;
     m_defaultClientId     = string.Empty;
     m_defaultClientSecret = GdsDefs.PsEmptyEx;
     m_useLegacyCreds      = false;
     m_dontSaveAuthToken   = false;
     m_warnSavedAuthToken  = false;
     m_isDirty             = true;
     m_ver            = null;
     m_autoResumeSave = false;
 }
        public ConfigurationForm(ConfigurationFormData data)
        {
            InitializeComponent();

            EnsureCheckEnabledGroupBox(m_chkDefaultUseLegacyCreds,
                                       m_grpDriveAuthDefaults);
            EnsureCheckEnabledGroupBox(m_chkUseLegacyCreds, m_grpDriveAuth);

            Text                = GdsDefs.ProductName;
            DatabaseFilePath    = string.Empty;
            m_lblAboutVer.Text  = GdsDefs.Version;
            m_lblAboutProd.Text = GdsDefs.ProductAttributedTitle;
            m_lblCopyright.Text = Assembly
                                  .GetAssembly(typeof(ConfigurationForm))
                                  .GetCustomAttribute <AssemblyCopyrightAttribute>()
                                  .Copyright;

            // Localize the form
            Control[] textCx = new Control[]
            {
                m_lnkGoogle,
                m_lnkHelp,
                m_lnkHome,
                m_lnkPrivacy,
                m_lnkGoogle2,
                m_lnkHelp2,
                m_tabGSignIn,
                m_tabOptions,
                m_tabAbout,
                m_grpEntry,
                m_grpDriveAuth,
                m_lblAccount,
                m_lblClientId,
                m_lblClientSecret,
                m_chkDriveScope,
                m_chkLegacyClientId,
                m_grpDriveOptions,
                m_lblHintFolder,
                m_lblFolder,
                m_btnCancel,
                m_btnOK,
                m_grpCmdEnabled,
                m_chkSyncEnabled,
                m_chkUploadEnabled,
                m_chkDownloadEnabled,
                m_grpAutoSync,
                m_chkSyncOnOpen,
                m_chkSyncOnSave,
                m_lblDefaultClientId,
                m_lblDefaultClientSecret,
                m_chkDefaultDriveScope,
                m_chkDefaultLegacyClientId,
                m_grpFolderDefaults,
                m_lblHintDefaultFolder,
                m_lblDefaultFolderLabel,
                m_lblDefFolderColor,
                m_btnGetColors,
                m_lblAttribution,
                m_chkDefaultUseLegacyCreds,
                m_chkUseLegacyCreds,
                m_grpAuthTokenSecurityDefaults,
                m_chkDontSaveAuthDefault,
                m_chkWarnAuthToken,
                m_lnkAuthTokenDefaultsHelp,
                m_grpAuthTokenSecurity,
                m_chkDontSaveAuthToken,
                m_lnkAuthTokenHelp,
                m_chkSyncOnReopen,
            };
            foreach (Control c in textCx)
            {
                c.Text = Resources.GetString(c.Text);
            }

            m_data = data;

            // Wire events and such for the folder color picker.
            m_nullColor = new GoogleColor(m_cbColors.BackColor,
                                          GoogleColor.Default.Name);
            m_cbColors.DrawMode              = DrawMode.OwnerDrawVariable;
            m_cbColors.DrawItem             += HandleColorsDrawItem;
            m_btnGetColors.Click            += HandleColorsComboLazyLoad;
            m_cbColors.SelectedIndexChanged += HandleColorsSelectedIndexChanged;
            if (m_data.DefaultAppFolderColor == null ||
                m_data.DefaultAppFolderColor == GoogleColor.Default)
            {
                m_cbColors.Items.Add(m_nullColor);
                m_cbColors.SelectedIndex = 0;
                m_cbColors.Enabled       = false;
            }
            else
            {
                GoogleColor[] userColors = new[]
                {
                    m_nullColor,
                    new GoogleColor(m_data.DefaultAppFolderColor.Color,
                                    m_data.DefaultAppFolderColor.Name)
                };
                m_cbColors.Items.Clear();
                m_cbColors.Items.AddRange(userColors);
                m_cbColors.SelectedItem = userColors[1];
                m_cbColors.Enabled      = string.IsNullOrWhiteSpace(m_txtFolderDefault.Text);
            }
            m_btnGetColors.Enabled = string.IsNullOrWhiteSpace(m_txtFolderDefault.Text);
            m_bColorsQueried       = false;
        }