コード例 #1
0
ファイル: ManageForm.cs プロジェクト: SuPair/vpn-1
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditEntityForm addEntityForm = new EditEntityForm();

            addEntityForm.Text = "Add new entity";
            if (addEntityForm.ShowDialog(this) == DialogResult.OK)
            {
                VPNEntity entity = new VPNEntity();
                entity.ConnectionAddr  = addEntityForm.InputAddress;
                entity.AccountName     = addEntityForm.InputAccountName;
                entity.AccountPassword = addEntityForm.InputAccountPassword;
                entity.DialType        = addEntityForm.InputDialType;
                entity.Key             = addEntityForm.InputKey;
                entity.Supplementary   = addEntityForm.InputSupplementary;

                this.controler.AddVpnEntityToSource(entity);
                this.controler.SaveVPNSourceToFile();
                this.controler.RefreshVPNListToView();
            }
        }
コード例 #2
0
ファイル: ManageForm.cs プロジェクト: SuPair/vpn-1
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditEntityForm modifyEntityForm = new EditEntityForm();

            modifyEntityForm.Text = "Modify entity";

            VPNEntity originalEntity = new VPNEntity();

            originalEntity.ConnectionAddr  = this.listView_VPNSourceList.SelectedItems[0].SubItems[0].Text;
            originalEntity.AccountName     = this.listView_VPNSourceList.SelectedItems[0].SubItems[1].Text;
            originalEntity.AccountPassword = this.listView_VPNSourceList.SelectedItems[0].SubItems[2].Text;
            originalEntity.DialType        = this.listView_VPNSourceList.SelectedItems[0].SubItems[3].Text;
            originalEntity.Key             = this.listView_VPNSourceList.SelectedItems[0].SubItems[4].Text;
            originalEntity.Supplementary   = this.listView_VPNSourceList.SelectedItems[0].SubItems[5].Text;

            modifyEntityForm.SetFormByVPNEntity(originalEntity);


            if (modifyEntityForm.ShowDialog(this) == DialogResult.OK)
            {
                VPNEntity modifiedEntity = new VPNEntity();
                modifiedEntity.ConnectionAddr  = modifyEntityForm.InputAddress;
                modifiedEntity.AccountName     = modifyEntityForm.InputAccountName;
                modifiedEntity.AccountPassword = modifyEntityForm.InputAccountPassword;
                modifiedEntity.DialType        = modifyEntityForm.InputDialType;
                modifiedEntity.Key             = modifyEntityForm.InputKey;
                modifiedEntity.Supplementary   = modifyEntityForm.InputSupplementary;

                if (originalEntity.Equals(modifiedEntity))
                {
                    return;
                }
                else
                {
                    controler.ModifyVpnEntityInSource(originalEntity, modifiedEntity);
                    controler.SaveVPNSourceToFile();
                    controler.RefreshVPNListToView();
                }
            }
        }