示例#1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AccountGridButton button = contextMenu.Tag as AccountGridButton;
            if (button != null && button.AccountData != null)
            {
                try
                {
                    BeforeShowDialog();
                    activeWindows++;
                    var account = button.AccountData;
                    using (formAccount f = new formAccount(account))
                    {
                        var datFile = account.DatFile;

                        if (f.ShowDialog(this) == DialogResult.OK)
                        {
                            if (datFile != null && datFile != account.DatFile && !string.IsNullOrEmpty(datFile.Path) && System.IO.File.Exists(datFile.Path))
                            {
                                if (Util.DatFiles.GetAccounts(datFile).Count == 1)
                                {
                                    if (MessageBox.Show(this, "The following Local.dat file is no longer being used:\n\n" + datFile.Path + "\n\nWould you like to delete it?", "Local.dat not used", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                                    {
                                        try
                                        {
                                            System.IO.File.Delete(datFile.Path);
                                        }
                                        catch { }
                                    }

                                    Settings.DatFiles[datFile.UID].Clear();
                                }
                            }

                            button.AccountData = account;
                            if (string.IsNullOrEmpty(account.WindowsAccount))
                                button.AccountName = "(current user)";
                        }
                    }
                }
                finally
                {
                    activeWindows--;
                }
            }
        }
示例#2
0
 private void AddAccount()
 {
     try
     {
         BeforeShowDialog();
         activeWindows++;
         using (formAccount f = new formAccount())
         {
             if (f.ShowDialog(this) == DialogResult.OK)
             {
                 AddAccount(f.Account, true);
             }
         }
     }
     finally
     {
         activeWindows--;
     }
 }