diff --git a/App.config b/App.config
index dffaa02..a83959c 100644
--- a/App.config
+++ b/App.config
@@ -1,7 +1,31 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Config.cs b/Config.cs
new file mode 100644
index 0000000..01b6da7
--- /dev/null
+++ b/Config.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using Newtonsoft.Json;
+
+namespace RDP_Portal {
+ public class Config {
+
+ private static Config? _instance;
+ public static string filename = "config.json";
+ public static string rdpDir = "rdp-files";
+
+ public static Config GetConfig() {
+ if (!File.Exists(filename)) {
+ File.AppendAllText(filename, "{}");
+ }
+
+ if (!Directory.Exists(rdpDir)) {
+ Directory.CreateDirectory(rdpDir);
+ }
+
+ var json = File.ReadAllText(filename);
+
+ _instance = JsonConvert.DeserializeObject(json);
+
+ if (_instance == null) {
+ throw new Exception("Cannot read config.json");
+ }
+
+ if (_instance.Profiles == null) {
+ _instance.Profiles = new BindingList();
+ _instance.Save();
+ }
+
+ return _instance;
+ }
+
+ public BindingList Profiles { get; set; }
+
+ public bool KeepOpening { get; set; } = true;
+
+ public void Save() {
+ var json = JsonConvert.SerializeObject(this, Formatting.Indented);
+ File.WriteAllText(filename, json);
+ }
+ }
+}
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index 56fb635..7a47471 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -25,49 +25,42 @@
///
private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
- this.listBox1 = new System.Windows.Forms.ListBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
+ this.checkBoxKeepOpening = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
+ this.buttonConnect = new System.Windows.Forms.Button();
+ this.textBoxComputer = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
- this.button3 = new System.Windows.Forms.Button();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.textBox4 = new System.Windows.Forms.TextBox();
+ this.buttonNew = new System.Windows.Forms.Button();
+ this.textBoxUsername = new System.Windows.Forms.TextBox();
+ this.textBoxPassword = new System.Windows.Forms.TextBox();
+ this.textBoxDomain = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.buttonMoreOptions = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonOptions = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.listBox = new System.Windows.Forms.ListBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
- // listBox1
+ // checkBoxKeepOpening
//
- this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left)));
- this.listBox1.FormattingEnabled = true;
- this.listBox1.ItemHeight = 16;
- this.listBox1.Location = new System.Drawing.Point(13, 107);
- this.listBox1.Margin = new System.Windows.Forms.Padding(4);
- this.listBox1.Name = "listBox1";
- this.listBox1.Size = new System.Drawing.Size(211, 276);
- this.listBox1.TabIndex = 0;
- //
- // checkBox1
- //
- this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.checkBox1.Location = new System.Drawing.Point(13, 432);
- this.checkBox1.Margin = new System.Windows.Forms.Padding(4);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(367, 30);
- this.checkBox1.TabIndex = 1;
- this.checkBox1.Text = "Keep opening RDP Portal";
- this.checkBox1.UseVisualStyleBackColor = true;
+ this.checkBoxKeepOpening.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.checkBoxKeepOpening.Location = new System.Drawing.Point(13, 432);
+ this.checkBoxKeepOpening.Margin = new System.Windows.Forms.Padding(4);
+ this.checkBoxKeepOpening.Name = "checkBoxKeepOpening";
+ this.checkBoxKeepOpening.Size = new System.Drawing.Size(367, 30);
+ this.checkBoxKeepOpening.TabIndex = 1;
+ this.checkBoxKeepOpening.Text = "Keep opening RDP Portal";
+ this.checkBoxKeepOpening.UseVisualStyleBackColor = true;
+ this.checkBoxKeepOpening.CheckedChanged += new System.EventHandler(this.checkBoxKeepOpening_CheckedChanged);
//
// button1
//
@@ -80,25 +73,26 @@
this.button1.Text = "About";
this.button1.UseVisualStyleBackColor = true;
//
- // button2
+ // buttonConnect
//
- this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.button2.Location = new System.Drawing.Point(379, 432);
- this.button2.Margin = new System.Windows.Forms.Padding(4);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(100, 28);
- this.button2.TabIndex = 3;
- this.button2.Text = "Connect";
- this.button2.UseVisualStyleBackColor = true;
+ this.buttonConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonConnect.Location = new System.Drawing.Point(358, 432);
+ this.buttonConnect.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonConnect.Name = "buttonConnect";
+ this.buttonConnect.Size = new System.Drawing.Size(121, 28);
+ this.buttonConnect.TabIndex = 3;
+ this.buttonConnect.Text = "Connect";
+ this.buttonConnect.UseVisualStyleBackColor = true;
+ this.buttonConnect.Click += new System.EventHandler(this.buttonConnect_Click);
//
- // textBox1
+ // textBoxComputer
//
- this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
- this.textBox1.Location = new System.Drawing.Point(123, 32);
- this.textBox1.Margin = new System.Windows.Forms.Padding(4);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(209, 22);
- this.textBox1.TabIndex = 4;
+ this.textBoxComputer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxComputer.Location = new System.Drawing.Point(123, 32);
+ this.textBoxComputer.Margin = new System.Windows.Forms.Padding(4);
+ this.textBoxComputer.Name = "textBoxComputer";
+ this.textBoxComputer.Size = new System.Drawing.Size(209, 22);
+ this.textBoxComputer.TabIndex = 4;
//
// label1
//
@@ -136,56 +130,58 @@
this.label4.TabIndex = 8;
this.label4.Text = "Domain:";
//
- // button3
+ // buttonNew
//
- this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.button3.Location = new System.Drawing.Point(13, 396);
- this.button3.Margin = new System.Windows.Forms.Padding(4);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(103, 28);
- this.button3.TabIndex = 9;
- this.button3.Text = "New";
- this.button3.UseVisualStyleBackColor = true;
+ this.buttonNew.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonNew.Location = new System.Drawing.Point(13, 396);
+ this.buttonNew.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonNew.Name = "buttonNew";
+ this.buttonNew.Size = new System.Drawing.Size(103, 28);
+ this.buttonNew.TabIndex = 9;
+ this.buttonNew.Text = "New";
+ this.buttonNew.UseVisualStyleBackColor = true;
+ this.buttonNew.Click += new System.EventHandler(this.buttonNew_Click);
//
- // textBox2
+ // textBoxUsername
//
- this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
- this.textBox2.Location = new System.Drawing.Point(123, 69);
- this.textBox2.Margin = new System.Windows.Forms.Padding(4);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(209, 22);
- this.textBox2.TabIndex = 10;
+ this.textBoxUsername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxUsername.Location = new System.Drawing.Point(123, 69);
+ this.textBoxUsername.Margin = new System.Windows.Forms.Padding(4);
+ this.textBoxUsername.Name = "textBoxUsername";
+ this.textBoxUsername.Size = new System.Drawing.Size(209, 22);
+ this.textBoxUsername.TabIndex = 10;
//
- // textBox3
+ // textBoxPassword
//
- this.textBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
- this.textBox3.Location = new System.Drawing.Point(124, 106);
- this.textBox3.Margin = new System.Windows.Forms.Padding(4);
- this.textBox3.Name = "textBox3";
- this.textBox3.Size = new System.Drawing.Size(208, 22);
- this.textBox3.TabIndex = 11;
+ this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxPassword.Location = new System.Drawing.Point(124, 106);
+ this.textBoxPassword.Margin = new System.Windows.Forms.Padding(4);
+ this.textBoxPassword.Name = "textBoxPassword";
+ this.textBoxPassword.Size = new System.Drawing.Size(208, 22);
+ this.textBoxPassword.TabIndex = 11;
+ this.textBoxPassword.UseSystemPasswordChar = true;
//
- // textBox4
+ // textBoxDomain
//
- this.textBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
- this.textBox4.Location = new System.Drawing.Point(124, 143);
- this.textBox4.Margin = new System.Windows.Forms.Padding(4);
- this.textBox4.Name = "textBox4";
- this.textBox4.Size = new System.Drawing.Size(208, 22);
- this.textBox4.TabIndex = 12;
+ this.textBoxDomain.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxDomain.Location = new System.Drawing.Point(124, 143);
+ this.textBoxDomain.Margin = new System.Windows.Forms.Padding(4);
+ this.textBoxDomain.Name = "textBoxDomain";
+ this.textBoxDomain.Size = new System.Drawing.Size(208, 22);
+ this.textBoxDomain.TabIndex = 12;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.label3);
- this.groupBox1.Controls.Add(this.textBox4);
- this.groupBox1.Controls.Add(this.textBox1);
- this.groupBox1.Controls.Add(this.textBox3);
+ this.groupBox1.Controls.Add(this.textBoxDomain);
+ this.groupBox1.Controls.Add(this.textBoxComputer);
+ this.groupBox1.Controls.Add(this.textBoxPassword);
this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.textBox2);
+ this.groupBox1.Controls.Add(this.textBoxUsername);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label4);
- this.groupBox1.Location = new System.Drawing.Point(234, 107);
+ this.groupBox1.Location = new System.Drawing.Point(234, 141);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
@@ -194,37 +190,40 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection";
//
- // button4
+ // buttonSave
//
- this.button4.Location = new System.Drawing.Point(232, 305);
- this.button4.Margin = new System.Windows.Forms.Padding(4);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(100, 28);
- this.button4.TabIndex = 14;
- this.button4.Text = "Save";
- this.button4.UseVisualStyleBackColor = true;
+ this.buttonSave.Location = new System.Drawing.Point(232, 339);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(100, 28);
+ this.buttonSave.TabIndex = 14;
+ this.buttonSave.Text = "Save";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
- // button5
+ // buttonDelete
//
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.button5.Location = new System.Drawing.Point(124, 396);
- this.button5.Margin = new System.Windows.Forms.Padding(4);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(100, 28);
- this.button5.TabIndex = 15;
- this.button5.Text = "Delete";
- this.button5.UseVisualStyleBackColor = true;
+ this.buttonDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonDelete.Location = new System.Drawing.Point(124, 396);
+ this.buttonDelete.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(100, 28);
+ this.buttonDelete.TabIndex = 15;
+ this.buttonDelete.Text = "Delete";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
- // buttonMoreOptions
+ // buttonOptions
//
- this.buttonMoreOptions.Location = new System.Drawing.Point(340, 305);
- this.buttonMoreOptions.Margin = new System.Windows.Forms.Padding(4);
- this.buttonMoreOptions.Name = "buttonMoreOptions";
- this.buttonMoreOptions.Size = new System.Drawing.Size(232, 28);
- this.buttonMoreOptions.TabIndex = 16;
- this.buttonMoreOptions.Text = "Show External RDP Options";
- this.buttonMoreOptions.UseVisualStyleBackColor = true;
- this.buttonMoreOptions.Click += new System.EventHandler(this.buttonMoreOptions_Click);
+ this.buttonOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonOptions.Location = new System.Drawing.Point(487, 339);
+ this.buttonOptions.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonOptions.Name = "buttonOptions";
+ this.buttonOptions.Size = new System.Drawing.Size(100, 28);
+ this.buttonOptions.TabIndex = 16;
+ this.buttonOptions.Text = "Options";
+ this.buttonOptions.UseVisualStyleBackColor = true;
+ this.buttonOptions.Click += new System.EventHandler(this.buttonMoreOptions_Click);
//
// pictureBox1
//
@@ -237,61 +236,119 @@
this.pictureBox1.TabIndex = 17;
this.pictureBox1.TabStop = false;
//
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(340, 339);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(100, 28);
+ this.buttonCancel.TabIndex = 18;
+ this.buttonCancel.Text = "Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(232, 339);
+ this.buttonEdit.Margin = new System.Windows.Forms.Padding(4);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(100, 28);
+ this.buttonEdit.TabIndex = 19;
+ this.buttonEdit.Text = "Edit";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // textBoxName
+ //
+ this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxName.Location = new System.Drawing.Point(234, 107);
+ this.textBoxName.Margin = new System.Windows.Forms.Padding(4);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(353, 22);
+ this.textBoxName.TabIndex = 13;
+ //
+ // listBox
+ //
+ this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left)));
+ this.listBox.DisplayMember = "Name";
+ this.listBox.FormattingEnabled = true;
+ this.listBox.ItemHeight = 16;
+ this.listBox.Location = new System.Drawing.Point(13, 107);
+ this.listBox.Margin = new System.Windows.Forms.Padding(4);
+ this.listBox.Name = "listBox";
+ this.listBox.Size = new System.Drawing.Size(211, 276);
+ this.listBox.TabIndex = 0;
+ this.listBox.SelectedValueChanged += new System.EventHandler(this.listBox_SelectedValueChanged);
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(600, 473);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.pictureBox1);
- this.Controls.Add(this.buttonMoreOptions);
- this.Controls.Add(this.button5);
- this.Controls.Add(this.button4);
+ this.Controls.Add(this.buttonOptions);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonSave);
this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.button2);
+ this.Controls.Add(this.buttonNew);
+ this.Controls.Add(this.buttonConnect);
this.Controls.Add(this.button1);
- this.Controls.Add(this.checkBox1);
- this.Controls.Add(this.listBox1);
+ this.Controls.Add(this.checkBoxKeepOpening);
+ this.Controls.Add(this.listBox);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.Location = new System.Drawing.Point(15, 15);
this.Margin = new System.Windows.Forms.Padding(4);
- this.MaximumSize = new System.Drawing.Size(900, 5528);
- this.MinimumSize = new System.Drawing.Size(600, 520);
+ this.MaximizeBox = false;
+ this.MaximumSize = new System.Drawing.Size(618, 5528);
+ this.MinimumSize = new System.Drawing.Size(618, 520);
this.Name = "MainForm";
this.Text = "RDP Portal";
+ this.Load += new System.EventHandler(this.MainForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
+ this.PerformLayout();
}
+ private System.Windows.Forms.TextBox textBoxName;
+
+ private System.Windows.Forms.Button buttonEdit;
+
+ private System.Windows.Forms.ListBox listBox;
+
+ private System.Windows.Forms.Button buttonCancel;
+
private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.Button buttonMoreOptions;
+ private System.Windows.Forms.Button buttonOptions;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button5;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonDelete;
private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.TextBox textBox4;
+ private System.Windows.Forms.TextBox textBoxUsername;
+ private System.Windows.Forms.TextBox textBoxPassword;
+ private System.Windows.Forms.TextBox textBoxDomain;
- private System.Windows.Forms.Button button3;
+ private System.Windows.Forms.Button buttonNew;
- private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.TextBox textBoxComputer;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.Button buttonConnect;
private System.Windows.Forms.Button button1;
- private System.Windows.Forms.CheckBox checkBox1;
-
- private System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.CheckBox checkBoxKeepOpening;
#endregion
}
diff --git a/MainForm.cs b/MainForm.cs
index 875dcdd..268fbca 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -11,8 +11,49 @@ using System.Windows.Forms;
namespace RDP_Portal {
public partial class MainForm : Form {
+
+ private Config _config;
+ private bool _editMode = false;
+ private Profile selectedProfile = null;
+
public MainForm() {
InitializeComponent();
+ _config = Config.GetConfig();
+ }
+
+ private void MainForm_Load(object sender, EventArgs e) {
+ listBox.DataSource = _config.Profiles;
+
+ if (_config.Profiles.Count == 0) {
+ AddNewProfile();
+ }
+
+ checkBoxKeepOpening.Checked = _config.KeepOpening;
+ }
+
+ public bool EditMode {
+ get => _editMode;
+ set {
+ buttonEdit.Visible = !value;
+ buttonSave.Visible = value;
+ buttonCancel.Visible = value;
+ buttonOptions.Enabled = !value;
+
+ buttonConnect.Enabled = !value;
+
+ textBoxName.Enabled = value;
+ textBoxComputer.Enabled = value;
+ textBoxUsername.Enabled = value;
+ textBoxPassword.Enabled = value;
+ textBoxDomain.Enabled = value;
+ }
+ }
+
+ private void AddNewProfile() {
+ var profile = new Profile();
+ profile.JustAdded = true;
+ _config.Profiles.Add(profile);
+ listBox.SelectedIndex = _config.Profiles.Count - 1;
}
private void buttonMoreOptions_Click(object sender, EventArgs e) {
@@ -20,7 +61,7 @@ namespace RDP_Portal {
CreateNoWindow = false,
UseShellExecute = false,
FileName = "mstsc.exe",
- Arguments = "/edit test.rdp"
+ Arguments = "/edit " + GetSelectedProfile().Filename,
};
try {
@@ -30,5 +71,108 @@ namespace RDP_Portal {
MessageBox.Show(ex.ToString());
}
}
+
+
+ private void buttonConnect_Click(object sender, EventArgs e) {
+ GetSelectedProfile().PrepareRdpFile();
+
+ ProcessStartInfo startInfo = new ProcessStartInfo {
+ CreateNoWindow = false,
+ UseShellExecute = false,
+ FileName = "mstsc.exe",
+ Arguments = GetSelectedProfile().Filename,
+ };
+
+ try {
+ var exeProcess = Process.Start(startInfo) ?? throw new InvalidOperationException();
+ exeProcess.WaitForExit();
+ } catch (Exception ex) {
+ MessageBox.Show(ex.ToString());
+ }
+ }
+
+ private void listBox_SelectedValueChanged(object sender, EventArgs e) {
+ SelectProfile();
+ }
+
+ private Profile GetSelectedProfile() {
+ return (Profile) listBox.SelectedItem;
+ }
+
+ private void SelectProfile(bool force = false) {
+ var profile = (Profile) listBox.SelectedItem;
+
+ // Avoid click empty area reset value
+ if (profile == selectedProfile && !force) {
+ return;
+ }
+
+ selectedProfile = profile;
+
+ EditMode = profile.JustAdded;
+
+ textBoxName.Text = profile.Name ;
+ textBoxComputer.Text = profile.Computer;
+ textBoxUsername.Text = profile.Username ;
+ textBoxPassword.Text = profile.Password;
+ textBoxDomain.Text = profile.Domain;
+ }
+
+ private void buttonEdit_Click(object sender, EventArgs e) {
+ EditMode = true;
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e) {
+ EditMode = false;
+
+ var profile = GetSelectedProfile();
+
+ if (profile.JustAdded && _config.Profiles.Count > 1) {
+ buttonDelete_Click(null, null);
+ } else {
+ SelectProfile(true);
+ }
+ }
+
+ private void buttonNew_Click(object sender, EventArgs e) {
+ AddNewProfile();
+ }
+
+ private void buttonDelete_Click(object sender, EventArgs e) {
+ var selectedItems = (Profile) listBox.SelectedItem;
+ selectedItems.Delete();
+ _config.Profiles.Remove(selectedItems);
+ _config.Save();
+ if (_config.Profiles.Count == 0) {
+ AddNewProfile();
+ SelectProfile(true);
+ }
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e) {
+ var profile = (Profile) listBox.SelectedItem;
+
+ profile.JustAdded = false;
+
+ profile.Name = textBoxName.Text;
+ profile.Computer = textBoxComputer.Text;
+ profile.Username = textBoxUsername.Text;
+ profile.Password = textBoxPassword.Text;
+ profile.Domain = textBoxDomain.Text;
+
+ profile.PrepareRdpFile();
+
+ _config.Save();
+ EditMode = false;
+
+ // Refresh the list
+ listBox.DisplayMember = null;
+ listBox.DisplayMember = "Name";
+ }
+
+ private void checkBoxKeepOpening_CheckedChanged(object sender, EventArgs e) {
+ _config.KeepOpening = checkBoxKeepOpening.Checked;
+ _config.Save();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Profile.cs b/Profile.cs
new file mode 100644
index 0000000..294a70c
--- /dev/null
+++ b/Profile.cs
@@ -0,0 +1,99 @@
+using System;
+using System.IO;
+using System.Windows.Forms;
+using Newtonsoft.Json;
+
+namespace RDP_Portal {
+ public class Profile {
+ private string _name = "";
+
+ public string Name {
+ get {
+ if (_name == "") {
+ return "";
+ }
+ return _name;
+ }
+ set => _name = value;
+ }
+
+ public string Filename { get; set; } = "";
+ public string Computer { get; set; }
+ public string Username { get; set; }
+
+ public string EncryptedPassword { get; set; } = "";
+
+ [JsonIgnore]
+ public string Password {
+ get {
+ if (EncryptedPassword == "") {
+ return EncryptedPassword;
+ }
+ return EncryptedPassword.Decrypt();
+ }
+ set => EncryptedPassword = value.Encrypt();
+ }
+
+ public string Domain { get; set; }
+
+ public void PrepareRdpFile() {
+ var justCreated = false;
+
+ if (Filename == null || Filename == "") {
+ String name;
+ while (true) {
+ name = Config.rdpDir + "\\" + StringUtil.GenerateName(8) + ".rdp";
+ if (!File.Exists(name)) {
+ var file = File.Create(name);
+ file.Close();
+ justCreated = true;
+ break;
+ }
+ }
+ Filename = name;
+ }
+
+ if (!File.Exists(Filename)) {
+ var file = File.Create(Filename);
+ file.Close();
+ justCreated = true;
+ }
+
+ var writer = File.AppendText(Filename);
+
+ if (Computer != "") {
+ writer.WriteLine("full address:s:" + Computer);
+ }
+
+ if (Username != "") {
+ writer.WriteLine("username:s:" + Username);
+ }
+
+ if (Password != "") {
+ // TODO
+ writer.WriteLine("password 51:b:" + Password);
+ }
+
+ if (Domain != "") {
+ writer.WriteLine("domain:s:" + Domain);
+ }
+
+ if (justCreated) {
+ writer.WriteLine("authentication level:i:0");
+ writer.WriteLine("prompt for credentials:i:0");
+ }
+
+ writer.Close();
+ }
+
+ [JsonIgnore] public bool JustAdded { get; set; } = false;
+
+ public void Delete() {
+ try {
+ File.Delete(Filename);
+ } catch (Exception ex) {
+
+ }
+ }
+ }
+}
diff --git a/RdpFile.cs b/RdpFile.cs
new file mode 100644
index 0000000..f5b7a79
--- /dev/null
+++ b/RdpFile.cs
@@ -0,0 +1,5 @@
+namespace RDP_Portal {
+ public class RdpFile {
+
+ }
+}
\ No newline at end of file
diff --git a/StringUtil.cs b/StringUtil.cs
new file mode 100644
index 0000000..bff91f0
--- /dev/null
+++ b/StringUtil.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+
+public static class StringUtil {
+ private static byte[] key = new byte[8] {226, 175, 129, 22, 187, 4, 143, 171};
+ private static byte[] iv = new byte[8] {181, 239, 77, 174, 238, 148, 206, 164};
+
+ public static string Encrypt(this string text) {
+ SymmetricAlgorithm algorithm = DES.Create();
+ ICryptoTransform transform = algorithm.CreateEncryptor(key, iv);
+ byte[] inputbuffer = Encoding.Unicode.GetBytes(text);
+ byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
+ return Convert.ToBase64String(outputBuffer);
+ }
+
+ public static string Decrypt(this string text) {
+ SymmetricAlgorithm algorithm = DES.Create();
+ ICryptoTransform transform = algorithm.CreateDecryptor(key, iv);
+ byte[] inputbuffer = Convert.FromBase64String(text);
+ byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
+ return Encoding.Unicode.GetString(outputBuffer);
+ }
+
+ public static string GenerateName(int len) {
+ Random random = new Random();
+ const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ return new string(Enumerable.Repeat(chars, len)
+ .Select(s => s[random.Next(s.Length)]).ToArray());
+ }
+}
diff --git a/icon.ico b/icon.ico
index b191977..23fc6ef 100644
Binary files a/icon.ico and b/icon.ico differ
diff --git a/packages.config b/packages.config
new file mode 100644
index 0000000..256a74a
--- /dev/null
+++ b/packages.config
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rdp-portal.csproj b/rdp-portal.csproj
index 91fcc3a..aa6fba0 100644
--- a/rdp-portal.csproj
+++ b/rdp-portal.csproj
@@ -1,5 +1,6 @@
+
Debug
@@ -39,27 +40,118 @@
app.manifest
+
+ packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll
+
+
+ packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll
+
+
+
+ packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+ packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll
+
+
+
+ packages\System.Console.4.3.0\lib\net46\System.Console.dll
+
+
+ packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll
+
+
+ packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll
+
+
+ packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll
+
+
+ packages\System.IO.4.3.0\lib\net462\System.IO.dll
+
+
+ packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll
+
+
+
+ packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll
+
+
+ packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll
+
+
+ packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll
+
+
+ packages\System.Linq.4.3.0\lib\net463\System.Linq.dll
+
+
+ packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll
+
+
+ packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll
+
+
+ packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll
+
+
+
+ packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll
+
+
+ packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll
+
+
+ packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll
+
+
+ packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll
+
+
+ packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
+
+
+ packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll
+
+
+ packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
+
+
+ packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
+
+
+ packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll
+
+
+ packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll
+
-
+
+ packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll
+
+
Form
MainForm.cs
+
+
+
MainForm.cs
@@ -73,6 +165,7 @@
Resources.resx
+
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -91,5 +184,15 @@
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file