예제 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            AccountInfo ai = comboBox1.SelectedItem as AccountInfo;

            if (ai != null)
            {
                ai.RestoreSettings(_core);
            }
        }
예제 #2
0
        public override bool Action(string action)
        {
            bool result = base.Action(action);

            if (result)
            {
                if (action == ACTION_SHOW)
                {
                    List <AccountInfo> ail = AccountInfo.GetAccountInfos();
                    using (AccountsForm dlg = new AccountsForm(Core, AccountInfo.GetAccountInfos()))
                    {
                        if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault();
                            foreach (AccountInfo ai in ail)
                            {
                                RemoveAction(string.Format("Account switcher|{0}", ai.Name));
                                main.RemoveAction(this, "Account switcher", ai.Name);
                            }
                            AccountInfo.SetAccountInfos(dlg.AccountInfoSettings);
                            AddAccountsToMenu(dlg.AccountInfoSettings);
                        }
                    }
                }
                else
                {
                    string[] parts = action.Split(new char[] { '|' }, 2);
                    if (parts.Length == 2 && parts[0] == "Account switcher")
                    {
                        List <AccountInfo> ail = AccountInfo.GetAccountInfos();
                        if (ail != null)
                        {
                            AccountInfo ai = (from a in ail where a.Name == parts[1] select a).FirstOrDefault();
                            if (ai != null)
                            {
                                ai.RestoreSettings(Core);
                            }
                        }
                    }
                }
                result = true;
            }
            return(result);
        }