コード例 #1
0
        private void ListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.ListView.SelectedItems.Count > 0)
            {
                ListViewItem item = this.ListView.SelectedItems[0];
                string       id   = item.Tag.ToString();
                if (AccountList.ContainsKey(id))
                {
                    SelectedAccount = AccountList[id];
                    ShowMsg("当前选择:{0}", SelectedAccount.Account);
                    this.CmbPlatform.Text = SelectedAccount.Platform;
                    this.TxtAccount.Text  = SelectedAccount.Account;
                    this.TxtPassword.Text = SelectedAccount.Password;
                    this.TxtRemark.Text   = SelectedAccount.Remarks;
                    SetBtnEnabled(true);
                }
                else
                {
                    ShowMsg("账号 {0} 不存在!", id);
                    SetBtnEnabled(false);
                }
            }
            else
            {
                this.CmbPlatform.Text = "";
                this.TxtAccount.Text  = "";
                this.TxtPassword.Text = "";
                this.TxtRemark.Text   = "";

                SelectedAccount = null;
                SetBtnEnabled(false);
            }
        }
コード例 #2
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            CAccount account = new CAccount()
            {
                ID       = CAccount.GetID(),
                Platform = this.CmbPlatform.Text,
                Account  = this.TxtAccount.Text,
                Password = this.TxtPassword.Text,
                Remarks  = this.TxtRemark.Text
            };

            AccountList.Add(account.ID, account);

            ListViewItem item = new ListViewItem(account.Platform);

            item.SubItems.Add(account.Account);
            item.SubItems.Add(account.Password);
            item.SubItems.Add(account.Remarks);
            item.Tag = account.ID;

            this.ListView.Items.Add(item);
            ShowMsg("添加账号 {0}", account.ID);

            this.CmbPlatform.Text = "";
            this.TxtAccount.Text  = "";
            this.TxtPassword.Text = "";
            this.TxtRemark.Text   = "";
        }
コード例 #3
0
        private Task InitAsync()
        {
            Task t = new Task(() =>
            {
                AccountList.Clear();

                this.Invoke(new MethodInvoker(() =>
                {
                    this.ListView.Items.Clear();
                }));

                try
                {
                    foreach (KeyValuePair <string, QDataSection> p in QSettings.Account.Sections)
                    {
                        QDataSection ds  = p.Value;
                        CAccount account = new CAccount()
                        {
                            ID       = p.Key,
                            Platform = AES.AESDecrypt(ds["platform"], Key),
                            Account  = AES.AESDecrypt(ds["account"], Key),
                            Password = AES.AESDecrypt(ds["password"], Key),
                            Remarks  = AES.AESDecrypt(ds["remarks"], Key)
                        };

                        ListViewItem item = new ListViewItem(account.Platform);
                        item.SubItems.Add(account.Account);
                        item.SubItems.Add("不给看");
                        item.SubItems.Add(account.Remarks);
                        item.Tag = p.Key;

                        AccountList.Add(p.Key, account);

                        this.Invoke(new MethodInvoker(() =>
                        {
                            this.ListView.Items.Add(item);
                        }));
                    }
                }
                catch (Exception ex)
                {
                    Qdb.Error(QFrameworkOne.Diagnostics.QDebugErrorType.Fatal, ex.Message, "FrmMain.InitAsync");
                    this.Invoke(new MethodInvoker(() =>
                    {
                        ShowMsg("密码错误!");
                    }));
                }

                //this.Invoke(new MethodInvoker(() => { ShowMsg("双击可以复制密码!"); }));
            });

            t.Start();
            return(t);
        }
コード例 #4
0
        private void Save()
        {
            foreach (KeyValuePair <string, CAccount> p in AccountList)
            {
                CAccount account = p.Value;

                Application.DoEvents();
                ShowMsg("正在保存 {0}", account.Account);

                QSettings.Account[p.Key]["platform"] = AES.AESEncrypt(account.Platform, Key);
                QSettings.Account[p.Key]["account"]  = AES.AESEncrypt(account.Account, Key);
                QSettings.Account[p.Key]["password"] = AES.AESEncrypt(account.Password, Key);
                QSettings.Account[p.Key]["remarks"]  = AES.AESEncrypt(account.Remarks, Key);
            }
        }
コード例 #5
0
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            if (SelectedAccount != null)
            {
                CAccount account = new CAccount()
                {
                    ID       = SelectedAccount.ID,
                    Platform = this.CmbPlatform.Text,
                    Account  = this.TxtAccount.Text,
                    Password = this.TxtPassword.Text,
                    Remarks  = this.TxtRemark.Text
                };

                SelectedAccount         = account;
                AccountList[account.ID] = account;

                ShowMsg("账号 {0} - {1} 已经更新。", account.ID, account.Account);
            }
        }
コード例 #6
0
        private void BtnDel_Click(object sender, EventArgs e)
        {
            if (SelectedAccount != null)
            {
                CAccount     account = SelectedAccount;
                DialogResult dr      = MessageBox.Show("确认删除 " + SelectedAccount.Account + " ?", "想清楚好吗", MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    AccountList.Remove(account.ID);
                    this.ListView.Items.Remove(this.ListView.SelectedItems[0]);

                    ShowMsg("已经删除 {0} 了", account.Account);
                }
                else if (dr == DialogResult.No)
                {
                    ShowMsg("大家当无事发生过。");
                }
            }
        }