Skip to content
This repository has been archived by the owner on Jun 23, 2021. It is now read-only.

Commit

Permalink
* 增加全局默认设置
Browse files Browse the repository at this point in the history
* 可配置是否共享剪切板
* 可配置选择性共享本地磁盘
  • Loading branch information
xunki committed Nov 26, 2018
1 parent 35a923e commit ddba648
Show file tree
Hide file tree
Showing 13 changed files with 720 additions and 22 deletions.
220 changes: 220 additions & 0 deletions RdpTest/GlobalSettingForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions RdpTest/GlobalSettingForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Dapper;
using MetroFramework.Controls;
using MetroFramework.Forms;
using Newtonsoft.Json;
using RdpTest.Model;

namespace RdpTest
{
public partial class GlobalSettingForm : MetroForm
{
public GlobalSettingForm()
{
InitializeComponent();
}

private void GlobalSettingForm_Load(object sender, System.EventArgs e)
{
gbDisks.Select();

txtUser.Text = GlobalConfig.Instance.User;
txtPwd.Text = GlobalConfig.Instance.Pwd;

chShareClipboard.StyleManager = StyleManager;
chShareClipboard.Checked = GlobalConfig.Instance.ShareClipboard;

chShareAllDisk.StyleManager = StyleManager;
chShareAllDisk.CheckedChanged += (o, args) => gbDisks.Enabled = !chShareAllDisk.Checked;
chShareAllDisk.Checked = GlobalConfig.Instance.ShareAllDisk;

flpDisks.Controls.Clear();
foreach (var driveInfo in DriveInfo.GetDrives())
{
flpDisks.Controls.Add(new MetroCheckBox
{
Text = driveInfo.Name,
AutoSize = true,
StyleManager = StyleManager,
Checked = GlobalConfig.Instance.ShareDiskList.Contains(driveInfo.Name)
});
}
}

private void btnCancel_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.Cancel;
}

private void btnSave_Click(object sender, System.EventArgs e)
{
var config = new GlobalConfig
{
User = txtUser.Text.Trim(),
Pwd = txtPwd.Text.Trim(),
ShareClipboard = chShareClipboard.Checked,
ShareAllDisk = chShareAllDisk.Checked,
ShareDiskList = flpDisks.Controls.OfType<MetroCheckBox>().Where(ch => ch.Checked).Select(ch => ch.Text).ToList()
};

Db.Connection.Execute("UPDATE MyConfig SET FValue=@json WHERE FKey='GlobalConfig'", new { json = JsonConvert.SerializeObject(config) });
GlobalConfig.Instance = config;

DialogResult = DialogResult.OK;
}

}
}
Loading

0 comments on commit ddba648

Please sign in to comment.