2 Star 3 Fork 0

[email protected]/RdpClient

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
frmChoiceAccount.cs 4.11 KB
一键复制 编辑 原始数据 按行查看 历史
[email protected] 提交于 2021-03-20 13:08 . 初始化项目
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;
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/mylikekefu/RdpClient.git
[email protected]:mylikekefu/RdpClient.git
mylikekefu
RdpClient
RdpClient
master

搜索帮助