Exemplo n.º 1
0
        private void editSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Program.mutex.WaitOne();
            selectedItems = listViewAccounts.SelectedIndices;
            if (selectedItems.Count == 0)
            {
                return;
            }
            var idx = selectedItems[0];
            var acc = Program.accounts[idx];

            if (acc.email == "")
            {
                return;
            }

            var addaccform = new AddAccountForm();

            addaccform.Text    = "Modify Account";
            addaccform.account = acc;
            addaccform.ShowDialog();

            if (addaccform.finished)
            {
                Program.accounts[idx] = addaccform.account;
            }
            Program.mutex.ReleaseMutex();
        }
Exemplo n.º 2
0
        private void editSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            selectedItems = listViewAccounts.SelectedIndices;
            if (selectedItems.Count == 0)
            {
                return;
            }
            var idx = selectedItems[0];
            var acc = accounts[idx];

            if (acc.email == "")
            {
                return;
            }

            var addaccform = new AddAccountForm();

            addaccform.Text    = "Modify Account";
            addaccform.account = acc;
            addaccform.ShowDialog();

            if (addaccform.finished)
            {
                accounts[idx] = addaccform.account;
                using (StreamWriter sw = new StreamWriter("Accounts.json"))
                {
                    using (JsonWriter jw = new JsonTextWriter(sw))
                    {
                        jw.Formatting = Formatting.Indented;
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(jw, accounts);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Program.mutex.WaitOne();
            AddAccountForm gui = new AddAccountForm();

            gui.ShowDialog();
            Account acc = gui.account;

            if (acc.email != null)
            {
                Account[] new_accs = new Account[Program.accounts.Length + 1];
                Program.accounts.CopyTo(new_accs, 0);
                new_accs[Program.accounts.Length] = acc;
                Program.accounts = new_accs;

                using (StreamWriter sw = new StreamWriter("Accounts.json"))
                {
                    using (JsonWriter jw = new JsonTextWriter(sw))
                    {
                        jw.Formatting = Formatting.Indented;
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(jw, Program.accounts);
                    }
                }

                RefreshUI();
            }
            Program.mutex.ReleaseMutex();
        }
Exemplo n.º 4
0
        private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddAccountForm gui = new AddAccountForm();

            gui.ShowDialog();
            Account acc = gui.account;

            if (acc.email != null)
            {
                Account[] new_accs = new Account[accounts.Length + 1];
                accounts.CopyTo(new_accs, 0);
                new_accs[accounts.Length] = acc;
                accounts = new_accs;

                using (StreamWriter sw = new StreamWriter("Accounts.json"))
                {
                    using (JsonWriter jw = new JsonTextWriter(sw))
                    {
                        jw.Formatting = Formatting.Indented;
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(jw, accounts);
                    }
                }

                this.listViewAccounts.Items.Clear();
                this.OnLoad(new EventArgs());
            }
        }
Exemplo n.º 5
0
        private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Program.mutex.WaitOne();
            AddAccountForm gui = new AddAccountForm();

            gui.ShowDialog();
            Account acc = gui.account;

            if (acc.email != null)
            {
                Program.accounts.Add(acc);
                Program.accounts.Save();
                RefreshUI();
            }
            Program.mutex.ReleaseMutex();
        }