代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using RdpClient.Library;
using System.IO;
namespace RdpClient
{
public partial class frmChoiceAccount : Form
{
public frmChoiceAccount()
{
InitializeComponent();
}
private void frmChoiceAccount_Load(object sender, EventArgs e)
{
string IconLocation = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "RdpClient.ico";
DesktopShortcut.CreateDesktopShortcut("远程桌面", Application.ExecutablePath, "远程桌面", "", IconLocation);
ConfigurationAccountFile.Instance.Load();
if (ConfigurationAccountFile.Instance.Account.Count > 0)
{
foreach (RemoteAccounts ra in ConfigurationAccountFile.Instance.Account)
{
cbbRemoteServerList.Items.Add(ra);
}
}
if (cbbRemoteServerList.Items.Count > 0)
{
cbbRemoteServerList.SelectedIndex = 0;
RemoteAccounts ra = (RemoteAccounts)cbbRemoteServerList.Items[cbbRemoteServerList.SelectedIndex];
txtRemoteAccount.Text = ra.RemoteAccount;
txtRemotePassword.Text = ra.RemotePassword;
}
}
public void ChoiceAccount()
{
using (frmRdpClient client = new frmRdpClient())
{
Hide();
client.Connection(cbbRemoteServerList.Text, txtRemoteAccount.Text, txtRemotePassword.Text);
client.ShowDialog();
Show();
}
}
private void btnRemoteConnection_Click(object sender, EventArgs e)
{
ChoiceAccount();
}
private void btnSaveConnection_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(cbbRemoteServerList.Text))
{
MessageBox.Show(lblRemoteServer.Text + "不能为空", "提示框");
return;
}
if (string.IsNullOrEmpty(txtRemoteAccount.Text))
{
MessageBox.Show(lblRemoteAccount.Text + "不能为空", "提示框");
return;
}
if (string.IsNullOrEmpty(txtRemotePassword.Text))
{
MessageBox.Show(lblRemotePassword.Text + "不能为空", "提示框");
return;
}
RemoteAccounts oldra = null;
RemoteAccounts ra = new RemoteAccounts();
ra.RemoteServer = cbbRemoteServerList.Text;
ra.RemoteAccount = txtRemoteAccount.Text;
ra.RemotePassword = txtRemotePassword.Text;
bool isAdd = true;
foreach (RemoteAccounts item in ConfigurationAccountFile.Instance.Account)
{
if ((item.RemoteServer == ra.RemoteServer))
{
oldra = item;
isAdd = false;
break;
}
}
if (isAdd)
{
ConfigurationAccountFile.Instance.Account.Add(ra);
}
else
{
ConfigurationAccountFile.Instance.Account.Remove(oldra);
ConfigurationAccountFile.Instance.Account.Add(ra);
}
ConfigurationAccountFile.Instance.Save();
MessageBox.Show("保存成功!", "提示框");
}
private void cbbRemoteServerList_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbbRemoteServerList.SelectedIndex > -1)
{
RemoteAccounts ra = (RemoteAccounts)cbbRemoteServerList.Items[cbbRemoteServerList.SelectedIndex];
txtRemoteAccount.Text = ra.RemoteAccount;
txtRemotePassword.Text = ra.RemotePassword;
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。