private void _ButtonNewAccount_Click(object sender, EventArgs e)
        {
            // create a new account for the user to edit. this is how it's done on the mac, and requires less clicks.
            String  accountName = "[New Account]";
            Account account     = new Account(accountName, String.Empty);

            if (_ButtonAccounts.ButtonItems.Count == 0)
            {
                account.Default = true;
            }

            PreferencesButtonItem item = new PreferencesButtonItem()
            {
                ButtonText      = accountName,
                AssociatedPanel = new AccountPanel()
                {
                    NewAccount       = true,
                    Account          = account,
                    ControlBackColor = _PanelAccounts.ControlBackColor
                }
            };

            _PanelParent.Controls.Add(item.AssociatedPanel);

            //InitPanelShapes(item.AssociatedPanel);

            item.AssociatedPanel.BringToFront();

            _ButtonAccounts.ButtonItems.Add(item);

            item.Activate();

            _PanelNewAccount.Hide();
        }
        private void InitAccounts()
        {
            foreach (Account account in Config.Current.Accounts)
            {
                PreferencesButtonItem item = new PreferencesButtonItem()
                {
                    ButtonText      = account.FullAddress,
                    AssociatedPanel = new AccountPanel()
                    {
                        Account          = account,
                        Dock             = DockStyle.Fill,
                        ControlBackColor = _PanelAccounts.ControlBackColor
                    }
                };

                //InitPanelShapes(item.AssociatedPanel);
                item.AssociatedPanel.Hide();
                _PanelParent.Controls.Add(item.AssociatedPanel);
                item.AssociatedPanel.BringToFront();

                if (account.Default)
                {
                    item.Font = new Font(item.Font, FontStyle.Bold);
                }

                _ButtonAccounts.ButtonItems.Add(item);
            }
        }
Beispiel #3
0
        private void _ButtonDefault_Click(object sender, EventArgs e)
        {
            _ButtonDefault.Enabled = false;

            var accountPanels = this.Parent.Controls.All().Where(o => o is AccountPanel);

            Account      defaultAccount      = Config.Current.Accounts.Where(o => o.Default).FirstOrDefault();
            AccountPanel defaultAccountPanel = accountPanels.Where(o => (o as AccountPanel).Account.Default).FirstOrDefault() as AccountPanel;

            Forms.Preferences form = this.ParentForm as Forms.Preferences;

            PreferencesButton buttonAccounts = form._ButtonGroup.Controls.Find("_ButtonAccounts", true)[0] as PreferencesButton;

            PreferencesButtonItem thisItem    = buttonAccounts.ButtonItems.All().Where(o => o.AssociatedPanel == this).FirstOrDefault();
            PreferencesButtonItem defaultItem = buttonAccounts.ButtonItems.All().Where(o => o.ButtonText == defaultAccount.FullAddress).FirstOrDefault();

            defaultAccount.Default = false;
            Account.Default        = true;

            _ButtonDefault.Enabled = false;
            defaultAccountPanel.DefaultButton.Enabled = true;

            thisItem.Font    = new Font(thisItem.Font, FontStyle.Bold);
            defaultItem.Font = new Font(defaultItem.Font, FontStyle.Regular);
        }
Beispiel #4
0
        private PreferencesButtonItem GetButtonItem()
        {
            Forms.Preferences form = this.ParentForm as Forms.Preferences;

            PreferencesButton     buttonAccounts = form._ButtonGroup.Controls.Find("_ButtonAccounts", true)[0] as PreferencesButton;
            PreferencesButtonItem thisItem       = buttonAccounts.ButtonItems.All().Where(o => o.AssociatedPanel == this).FirstOrDefault();

            return(thisItem);
        }
Beispiel #5
0
        private void _Credentials_Changed(object sender, EventArgs e)
        {
            if (AccountExists())               // aww, you're naughty.
            {
                return;
            }

            _PictureExclamation.Visible = _LabelError.Visible = false;

            Boolean somethingChanged = false;

            if ((_TextUsername.Text != this.Account.Login) || (_TextUsername.Text.Length > 0))              // dude, change something already.
            {
                if (!NewAccount)
                {
                    somethingChanged = true;
                }
            }

            if ((_TextPassword.Text != _filler) && (_TextPassword.Text.Length > 0))
            {
                somethingChanged = true;
            }

            if (somethingChanged && !Config.Current.Accounts.Contains(Account))
            {
                Config.Current.Accounts.Add(Account);
                somethingChanged = true;
                NewAccount       = false;
            }

            if (somethingChanged)
            {
                Account.Login    = _TextUsername.Text;
                Account.Password = _TextPassword.Text;

                PreferencesButtonItem item = GetButtonItem();

                item.ButtonText = this.HeaderText = Account.FullAddress;

                Config.Current.Save();
            }
        }
Beispiel #6
0
        private void _TaskButtonYes_Click(object sender, EventArgs e)
        {
            TaskDialogButton button = (TaskDialogButton)sender;

            Forms.Preferences form = this.ParentForm as Forms.Preferences;

            PreferencesButton     buttonAccounts = form._ButtonGroup.Controls.Find("_ButtonAccounts", true)[0] as PreferencesButton;
            PreferencesButtonItem thisItem       = buttonAccounts.ButtonItems.All().Where(o => o.AssociatedPanel == this).FirstOrDefault();

            ((TaskDialog)button.HostingDialog).Close();

            buttonAccounts.ButtonItems.Remove(thisItem);

            this.Parent.Controls.Remove(this);

            buttonAccounts.AssociatedPanel.Show();

            Config.Current.Accounts.Remove(this.Account);
            Config.Current.Save();
        }