diff options
author | Marc-André Moreau <marcandre.moreau@gmail.com> | 2012-09-03 22:32:28 +0400 |
---|---|---|
committer | Marc-André Moreau <marcandre.moreau@gmail.com> | 2012-09-03 22:32:28 +0400 |
commit | da2f7ce2dcdac4a94d21a60b0e537460b7f63be3 (patch) | |
tree | c3660905321c483e1e6d75b208fe656fe0bc1892 /NFreeRDP | |
parent | 4a612fb70ae3d86862eede13c83d60f0c3c2a0c0 (diff) |
NFreeRDP: added connection dialog
Diffstat (limited to 'NFreeRDP')
-rw-r--r-- | NFreeRDP/ConnectionDialog.Designer.cs | 127 | ||||
-rw-r--r-- | NFreeRDP/ConnectionDialog.cs | 32 | ||||
-rw-r--r-- | NFreeRDP/ConnectionDialog.resx | 120 | ||||
-rw-r--r-- | NFreeRDP/ConnectionSettings.cs | 13 | ||||
-rw-r--r-- | NFreeRDP/MainWindow.cs | 20 | ||||
-rw-r--r-- | NFreeRDP/NFreeRDP.csproj | 13 | ||||
-rw-r--r-- | NFreeRDP/RdpClient.cs | 18 |
7 files changed, 317 insertions, 26 deletions
diff --git a/NFreeRDP/ConnectionDialog.Designer.cs b/NFreeRDP/ConnectionDialog.Designer.cs new file mode 100644 index 0000000..fa3c4e0 --- /dev/null +++ b/NFreeRDP/ConnectionDialog.Designer.cs @@ -0,0 +1,127 @@ +namespace NFreeRDP +{ + partial class ConnectionDialog + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.lblHostname = new System.Windows.Forms.Label(); + this.lblUsername = new System.Windows.Forms.Label(); + this.txtHostname = new System.Windows.Forms.TextBox(); + this.txtUsername = new System.Windows.Forms.TextBox(); + this.btnConnect = new System.Windows.Forms.Button(); + this.lblPassword = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // lblHostname + // + this.lblHostname.AutoSize = true; + this.lblHostname.Location = new System.Drawing.Point(28, 31); + this.lblHostname.Name = "lblHostname"; + this.lblHostname.Size = new System.Drawing.Size(58, 13); + this.lblHostname.TabIndex = 0; + this.lblHostname.Text = "Hostname:"; + // + // lblUsername + // + this.lblUsername.AutoSize = true; + this.lblUsername.Location = new System.Drawing.Point(28, 59); + this.lblUsername.Name = "lblUsername"; + this.lblUsername.Size = new System.Drawing.Size(58, 13); + this.lblUsername.TabIndex = 1; + this.lblUsername.Text = "Username:"; + // + // txtHostname + // + this.txtHostname.Location = new System.Drawing.Point(104, 28); + this.txtHostname.Name = "txtHostname"; + this.txtHostname.Size = new System.Drawing.Size(191, 20); + this.txtHostname.TabIndex = 2; + // + // txtUsername + // + this.txtUsername.Location = new System.Drawing.Point(104, 54); + this.txtUsername.Name = "txtUsername"; + this.txtUsername.Size = new System.Drawing.Size(191, 20); + this.txtUsername.TabIndex = 3; + // + // btnConnect + // + this.btnConnect.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnConnect.Location = new System.Drawing.Point(220, 106); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(75, 23); + this.btnConnect.TabIndex = 4; + this.btnConnect.Text = "Connect"; + this.btnConnect.UseVisualStyleBackColor = true; + // + // lblPassword + // + this.lblPassword.AutoSize = true; + this.lblPassword.Location = new System.Drawing.Point(28, 83); + this.lblPassword.Name = "lblPassword"; + this.lblPassword.Size = new System.Drawing.Size(56, 13); + this.lblPassword.TabIndex = 5; + this.lblPassword.Text = "Password:"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(104, 80); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.Size = new System.Drawing.Size(191, 20); + this.txtPassword.TabIndex = 6; + // + // ConnectionDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(324, 145); + this.Controls.Add(this.txtPassword); + this.Controls.Add(this.lblPassword); + this.Controls.Add(this.btnConnect); + this.Controls.Add(this.txtUsername); + this.Controls.Add(this.txtHostname); + this.Controls.Add(this.lblUsername); + this.Controls.Add(this.lblHostname); + this.Name = "ConnectionDialog"; + this.Text = "Connection"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblHostname; + private System.Windows.Forms.Label lblUsername; + private System.Windows.Forms.TextBox txtHostname; + private System.Windows.Forms.TextBox txtUsername; + private System.Windows.Forms.Button btnConnect; + private System.Windows.Forms.Label lblPassword; + private System.Windows.Forms.TextBox txtPassword; + } +}
\ No newline at end of file diff --git a/NFreeRDP/ConnectionDialog.cs b/NFreeRDP/ConnectionDialog.cs new file mode 100644 index 0000000..79dcc9b --- /dev/null +++ b/NFreeRDP/ConnectionDialog.cs @@ -0,0 +1,32 @@ +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; + +namespace NFreeRDP +{ + public partial class ConnectionDialog : Form + { + public ConnectionDialog() + { + InitializeComponent(); + } + + public ConnectionSettings GetConnectionSettings() + { + ConnectionSettings settings = new ConnectionSettings(); + + settings.port = 3389; + settings.hostname = txtHostname.Text; + settings.username = txtUsername.Text; + settings.domain = ""; + settings.password = txtPassword.Text; + + return settings; + } + } +} diff --git a/NFreeRDP/ConnectionDialog.resx b/NFreeRDP/ConnectionDialog.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/NFreeRDP/ConnectionDialog.resx @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/NFreeRDP/ConnectionSettings.cs b/NFreeRDP/ConnectionSettings.cs new file mode 100644 index 0000000..4378daa --- /dev/null +++ b/NFreeRDP/ConnectionSettings.cs @@ -0,0 +1,13 @@ +using System; + +namespace NFreeRDP +{ + public class ConnectionSettings + { + public int port; + public string hostname; + public string username; + public string domain; + public string password; + } +} diff --git a/NFreeRDP/MainWindow.cs b/NFreeRDP/MainWindow.cs index 4964a89..a89f557 100644 --- a/NFreeRDP/MainWindow.cs +++ b/NFreeRDP/MainWindow.cs @@ -12,12 +12,6 @@ namespace NFreeRDP { public partial class MainWindow : Form { - int port; - string hostname; - string username; - string domain; - string password; - RdpClient rdpClient; public MainWindow() @@ -27,15 +21,15 @@ namespace NFreeRDP private void newConnectionToolStripMenuItem_Click(object sender, EventArgs e) { - rdpClient = new RdpClient(); + ConnectionDialog dialog = new ConnectionDialog(); - port = 3389; - hostname = "localhost"; - username = "Administrator"; - domain = ""; - password = "Password123!"; + if (dialog.ShowDialog() == DialogResult.OK) + { + rdpClient = new RdpClient(); + rdpClient.Connect(dialog.GetConnectionSettings()); + } - rdpClient.Connect(hostname, port, username, domain, password); + dialog.Dispose(); } } } diff --git a/NFreeRDP/NFreeRDP.csproj b/NFreeRDP/NFreeRDP.csproj index dd7eac6..2d2d214 100644 --- a/NFreeRDP/NFreeRDP.csproj +++ b/NFreeRDP/NFreeRDP.csproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -87,6 +87,14 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="ConnectionDialog.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="ConnectionDialog.Designer.cs"> + <DependentUpon>ConnectionDialog.cs</DependentUpon> + </Compile> + <Compile Include="ConnectionDialogTest.cs" /> + <Compile Include="ConnectionSettings.cs" /> <Compile Include="MainWindow.cs"> <SubType>Form</SubType> </Compile> @@ -96,6 +104,9 @@ <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="RdpClient.cs" /> + <EmbeddedResource Include="ConnectionDialog.resx"> + <DependentUpon>ConnectionDialog.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="MainWindow.resx"> <DependentUpon>MainWindow.cs</DependentUpon> </EmbeddedResource> diff --git a/NFreeRDP/RdpClient.cs b/NFreeRDP/RdpClient.cs index 08e9cdc..171db35 100644 --- a/NFreeRDP/RdpClient.cs +++ b/NFreeRDP/RdpClient.cs @@ -26,11 +26,7 @@ namespace NFreeRDP public unsafe class RdpClient : IUpdate, IPrimaryUpdate { private RDP rdp; - private int port; - private string hostname; - private string username; - private string domain; - private string password; + private ConnectionSettings settings; private Thread thread; private static bool procRunning = true; @@ -40,11 +36,6 @@ namespace NFreeRDP */ public RdpClient() { - port = 3389; - hostname = "localhost"; - username = "Administrator"; - domain = ""; - password = ""; rdp = new RDP(); thread = new Thread(() => ThreadProc(rdp)); } @@ -52,11 +43,14 @@ namespace NFreeRDP /** * Connect to FreeRDP server, start thread */ - public void Connect(string hostname, int port, string username, string domain, string password) + public void Connect(ConnectionSettings settings) { rdp.SetUpdateInterface(this); rdp.SetPrimaryUpdateInterface(this); - rdp.Connect(hostname, port, username, domain, password); + + rdp.Connect(settings.hostname, settings.port, + settings.username, settings.domain, settings.password); + procRunning = true; thread.Start(); } |