示例#1
0
        private void Rename()
        {
            if (_accountsList != null &&
                _accountsList.Accounts != null)
            {
                string beforeName = GetSelectedItem();
                string theName    = beforeName;

                AccountConfigValues theAccount = _accountsList.GetAccountByName(theName);

                if (theAccount != null)
                {
                    Image  accountImage      = imageListIcons.Images[0];
                    string emailProviderType = !string.IsNullOrEmpty(theAccount.EmailProvider) ? theAccount.EmailProvider.ToLower() : string.Empty;

                    if (imageListIcons.Images.IndexOfKey(emailProviderType) >= 0)
                    {
                        accountImage = imageListIcons.Images[emailProviderType];
                    }

                    DialogResult dialogResult = InputBox.Show(theAccount.Name, Translator.Translate(AccountPromptTextKey), ref theName, accountImage);

                    if (!dialogResult.Equals(DialogResult.Cancel) &&
                        !string.IsNullOrEmpty(theName) &&
                        !beforeName.Equals(theName))
                    {
                        if (!_accountsList.CheckAccountExistsByName(theName))
                        {
                            if (theAccount.Equals(_accountsList.ActiveAccount))
                            {
                                _accountsList.ActiveAccountName = theName;
                            }
                            if (theAccount.Equals(_accountsList.StartUpAccount))
                            {
                                _accountsList.StartUpAccountName = theName;
                            }
                            theAccount.Name = theName;

                            Populate();
                            Raise_Config_Changed();
                        }
                        else
                        {
                            MessageBox.Show(Translator.Translate(AccountDuplicateTextKey), Translator.Translate(AccountsTextKey), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
示例#2
0
        private ListViewItem CreateListItem(AccountConfigValues account)
        {
            ListViewItem item = new ListViewItem();

            ListViewItem.ListViewSubItem startUpItem = new ListViewItem.ListViewSubItem();

            item.Text = account.Name;
            item.SubItems.Add(new ListViewItem.ListViewSubItem(item, account.SmtpConfig.EmailAddress));
            item.SubItems.Add(startUpItem);
            startUpItem.Text = account.Equals(_accountsList.StartUpAccount) ? Translator.Translate(AccountStartUpTextKey) : string.Empty;

            if (account.Equals(_accountsList.ActiveAccount))
            {
                item.Font = ActiveFont;
            }
            else
            {
                item.ForeColor = Color.Gray;
                item.Font      = NormalFont;
            }

            item.Tag = account.Name;

            int imageIndex = 0;

            if (account.SmtpConfig != null &&
                !string.IsNullOrEmpty(account.SmtpConfig.EmailAddress))
            {
                string emailProviderType = !string.IsNullOrEmpty(account.EmailProvider) ? account.EmailProvider.ToLower() : string.Empty;
                if (!string.IsNullOrEmpty(emailProviderType))
                {
                    imageIndex = imageListIcons.Images.IndexOfKey(emailProviderType);
                }
            }

            item.ImageIndex = imageIndex >= 0 ? imageIndex : 0;

            return(item);
        }
示例#3
0
        private void Remove()
        {
            if (_accountsList != null &&
                _accountsList.Accounts != null)
            {
                if (!_accountsList.Accounts.Count.Equals(1))
                {
                    string theName = GetSelectedItem();

                    AccountConfigValues theAccount = _accountsList.GetAccountByName(theName);

                    if (theAccount != null)
                    {
                        if (MessageBox.Show(Translator.Translate(AccountDeletePromptTextKey, theAccount.Name), Translator.Translate(AccountsTextKey), MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                        {
                            if (theAccount.Equals(_accountsList.StartUpAccount))
                            {
                                _accountsList.StartUpAccountName = !theAccount.Equals(_accountsList.ActiveAccount) ? _accountsList.ActiveAccount.Name : _accountsList.Accounts[0].Name;
                            }
                            if (theAccount.Equals(_accountsList.ActiveAccount))
                            {
                                _accountsList.Accounts.Remove(theAccount);
                                Raise_Account_Activated(_accountsList.StartUpAccount);
                            }
                            else
                            {
                                _accountsList.Accounts.Remove(theAccount);
                            }

                            Populate();
                            Raise_Config_Changed();
                        }
                    }
                }
            }
        }