forked from jaysonragasa/MultiRDPClient.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExportWindow.cs
More file actions
137 lines (116 loc) · 5.08 KB
/
ExportWindow.cs
File metadata and controls
137 lines (116 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using Database.Models;
using DataProtection;
using RDPFileReader;
using System;
using System.IO;
using System.Windows.Forms;
namespace MultiRemoteDesktopClient
{
public partial class ExportWindow : Form
{
OpenFileDialog ofd = null;
public ExportWindow()
{
InitializeComponent();
InitializeControls();
InitializeControlEvents();
}
public ExportWindow(ref MultiRemoteDesktopClient.Controls.ListViewEx lv)
{
InitializeComponent();
InitializeControls(ref lv);
InitializeControlEvents();
}
public void InitializeControls()
{
}
public void InitializeControls(ref MultiRemoteDesktopClient.Controls.ListViewEx lv)
{
foreach (ListViewItem thisItem in lv.Items)
{
ListViewItem item = new ListViewItem(thisItem.Text);
item.SubItems.Add("OK");
item.ImageIndex = 0;
item.Tag = thisItem.Tag;
lvRDPFiles.Items.Add(item);
}
}
public void InitializeControlEvents()
{
this.Shown += new EventHandler(ExportWindow_Shown);
this.btnStart.Click += new EventHandler(btnStart_Click);
}
void btnStart_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowDialog();
if (fbd.SelectedPath != string.Empty)
{
foreach (ListViewItem thisItem in lvRDPFiles.Items)
{
if (thisItem.Checked == true)
{
thisItem.SubItems[1].Text = "Importing...";
Model_ServerDetails sd = (Model_ServerDetails)thisItem.Tag;
RDPFile rdp = new RDPFile();
rdp.ScreenMode = 1;
rdp.DesktopWidth = sd.DesktopWidth;
rdp.DesktopHeight = sd.DesktopHeight;
rdp.SessionBPP = (RDPFile.SessionBPPs)sd.ColorDepth;
RDPFile.WindowsPosition winpos = new RDPFile.WindowsPosition();
RDPFile.RECT r = new RDPFile.RECT();
r.Top = 0;
r.Left = 0;
r.Width = sd.DesktopWidth;
r.Height = sd.DesktopHeight;
winpos.Rect = r;
winpos.WinState = RDPFile.WindowState.MAXMIZE;
rdp.WinPosStr = winpos;
rdp.FullAddress = sd.Server;
rdp.Compression = 1;
rdp.KeyboardHook = RDPFile.KeyboardHooks.ON_THE_REMOTE_COMPUTER;
rdp.AudioMode = RDPFile.AudioModes.BRING_TO_THIS_COMPUTER;
rdp.RedirectDrives = 0;
rdp.RedirectPrinters = 0;
rdp.RedirectComPorts = 0;
rdp.RedirectSmartCards = 0;
rdp.DisplayConnectionBar = 1;
rdp.AutoReconnectionEnabled = 1;
rdp.Username = sd.Username;
rdp.Domain = string.Empty;
rdp.AlternateShell = string.Empty;
rdp.ShellWorkingDirectory = string.Empty;
// what's with the ZERO ?
// http://www.remkoweijnen.nl/blog/2008/03/02/how-rdp-passwords-are-encrypted-2/
rdp.Password = (sd.Password == string.Empty ? string.Empty : DataProtectionForRDPWrapper.Encrypt(sd.Password) + "0");
//System.Diagnostics.Debug.WriteLine(ss.Password);
rdp.DisableWallpaper = 1;
rdp.DisableFullWindowDrag = 1;
rdp.DisableMenuAnims = 1;
rdp.DisableThemes = 1;
rdp.DisableCursorSettings = 1;
rdp.BitmapCachePersistEnable = 1;
#region try exporting the file
{
try
{
rdp.Save(Path.Combine(fbd.SelectedPath, sd.ServerName + ".rdp"));
thisItem.SubItems[1].Text = "Done!";
}
catch (Exception ex)
{
MessageBox.Show("An error occured while exporting the server '" + sd.ServerName + "' to RDP file format.\r\n\r\nError Message: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Diagnostics.Debug.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
continue;
}
}
#endregion
}
}
}
}
void ExportWindow_Shown(object sender, EventArgs e)
{
}
}
}