Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 public override bool Action(string action)
 {
     bool result = base.Action(action);
     if (result)
     {
         if (action == ACTION_SHOW)
         {
             List<AccountInfo> ail = AccountInfo.GetAccountInfos(_filename);
             using (AccountsForm dlg = new AccountsForm(Core, AccountInfo.GetAccountInfos(_filename)))
             {
                 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(_filename, 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(_filename);
                 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;
 }