-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmPopup.cs
223 lines (196 loc) · 7.93 KB
/
frmPopup.cs
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IfacesEnumsStructsClasses;
namespace TestRecorder
{
public partial class frmPopup : Form
{
//Able to handle a popup launched from this browser
private frmPopup newfrm = null;
public bool isSecondaryPopup = false;
public frmPopup()
{
InitializeComponent();
//For IE7, we need to use the new interfaces to deal with javascript moveto and resizeto
this.cEXWB1.HTMLOMWindowServices_moveTo += new csExWB.HTMLOMWindowServicesEventHandler(cEXWB1_HTMLOMWindowServices_moveTo);
this.cEXWB1.HTMLOMWindowServices_resizeTo += new csExWB.HTMLOMWindowServicesEventHandler(cEXWB1_HTMLOMWindowServices_resizeTo);
}
public void AssignBrowserObject(ref object obj)
{
obj = this.cEXWB1.WebbrowserObject;
}
public void PopupNavigate(string Url)
{
this.cEXWB1.Navigate(Url);
}
private void frmPopup_Load(object sender, EventArgs e)
{
this.cEXWB1.RegisterAsBrowser = true;
this.cEXWB1.WBDragDrop += new csExWB.WBDropEventHandler(cEXWB1_WBDragDrop);
this.cEXWB1.NavToBlank();
}
void cEXWB1_WBDragDrop(object sender, csExWB.WBDropEventArgs e)
{
if (e.dataobject.ContainsText())
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_WBDragDrop\r\n" + e.dataobject.GetText());
else if (e.dataobject.ContainsFileDropList())
{
System.Collections.Specialized.StringCollection files = e.dataobject.GetFileDropList();
if (files.Count > 1)
MessageBox.Show("Can not do multi file drop!");
else
{
this.cEXWB1.Navigate(files[0]);
}
}
}
private void frmPopup_FormClosing(object sender, FormClosingEventArgs e)
{
if( (e.CloseReason == CloseReason.UserClosing) && (!isSecondaryPopup) )
{
if (this.cEXWB1 != null)
this.cEXWB1.NavToBlank();
e.Cancel = true;
this.Hide();
}
}
/// <summary>
/// Sets the DL flags of the browser to be as restrictive as possible
/// </summary>
public void SetupAsSandBox()
{
this.cEXWB1.WBDOCDOWNLOADCTLFLAG = (int)(
DOCDOWNLOADCTLFLAG.NO_SCRIPTS |
DOCDOWNLOADCTLFLAG.NO_JAVA |
DOCDOWNLOADCTLFLAG.NOFRAMES |
DOCDOWNLOADCTLFLAG.NO_DLACTIVEXCTLS |
DOCDOWNLOADCTLFLAG.NO_RUNACTIVEXCTLS |
DOCDOWNLOADCTLFLAG.PRAGMA_NO_CACHE |
DOCDOWNLOADCTLFLAG.SILENT |
DOCDOWNLOADCTLFLAG.NO_BEHAVIORS |
DOCDOWNLOADCTLFLAG.NO_CLIENTPULL);
}
private void cEXWB1_StatusTextChange(object sender, csExWB.StatusTextChangeEventArgs e)
{
lblStatus.Text = e.text;
}
private void cEXWB1_TitleChange(object sender, csExWB.TitleChangeEventArgs e)
{
this.Text = e.title;
}
private void cEXWB1_WBDocHostShowUIShowMessage(object sender, csExWB.DocHostShowUIShowMessageEventArgs e)
{
e.handled = true;
e.result = (int)DialogResult.Cancel;
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_WBDocHostShowUIShowMessage\r\n" + e.text);
}
private void cEXWB1_WindowClosing(object sender, csExWB.WindowClosingEventArgs e)
{
if (isSecondaryPopup)
return;
e.Cancel = true;
this.cEXWB1.NavToBlank();
this.Hide();
}
private void cEXWB1_WindowSetHeight(object sender, csExWB.WindowSetHeightEventArgs e)
{
if ((!this.Visible) || (this.WindowState == FormWindowState.Maximized) ||
(this.WindowState == FormWindowState.Minimized) || (e.height < 0))
return;
this.Height = e.height;
}
private void cEXWB1_WindowSetWidth(object sender, csExWB.WindowSetWidthEventArgs e)
{
if ((!this.Visible) || (this.WindowState == FormWindowState.Maximized) ||
(this.WindowState == FormWindowState.Minimized) || (e.width < 0))
return;
this.Width = e.width;
}
private void cEXWB1_ScriptError(object sender, csExWB.ScriptErrorEventArgs e)
{
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_ScriptError");
e.continueScripts = true;
}
private void cEXWB1_NavigateError(object sender, csExWB.NavigateErrorEventArgs e)
{
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NavigateError");
e.Cancel = true;
}
private void SetupNewForm()
{
if (newfrm != null)
return;
newfrm = new frmPopup();
newfrm.isSecondaryPopup = true;
newfrm.Show();
newfrm.BringToFront();
}
private void cEXWB1_NewWindow2(object sender, csExWB.NewWindow2EventArgs e)
{
try
{
this.SetupNewForm();
newfrm.AssignBrowserObject(ref e.browser);
//AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NewWindow2");
//e.Cancel = true;
}
catch (Exception ee)
{
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NewWindow2\r\n" + ee.ToString());
}
}
private void cEXWB1_NewWindow3(object sender, csExWB.NewWindow3EventArgs e)
{
try
{
this.SetupNewForm();
newfrm.AssignBrowserObject(ref e.browser);
//e.Cancel = true;
}
catch (Exception ee)
{
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NewWindow3\r\n" + ee.ToString());
}
}
private void cEXWB1_WBEvaluteNewWindow(object sender, csExWB.EvaluateNewWindowEventArgs e)
{
this.SetupNewForm();
//e.Cancel = true;
}
private void cEXWB1_BeforeNavigate2(object sender, csExWB.BeforeNavigate2EventArgs e)
{
AllForms.m_frmLog.AppendToLog("frmPopup_BeforeNavigate2\r\n" + e.url);
}
private void cEXWB1_WindowSetLeft(object sender, csExWB.WindowSetLeftEventArgs e)
{
if ((!this.Visible) || (this.WindowState == FormWindowState.Maximized) ||
(this.WindowState == FormWindowState.Minimized) || (e.left < 0))
return;
this.Left = e.left;
}
private void cEXWB1_WindowSetTop(object sender, csExWB.WindowSetTopEventArgs e)
{
if ((!this.Visible) || (this.WindowState == FormWindowState.Maximized) ||
(this.WindowState == FormWindowState.Minimized) || (e.top < 0))
return;
this.Top = e.top;
}
private void cEXWB1_WBSecurityProblem(object sender, csExWB.SecurityProblemEventArgs e)
{
AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_WBSecurityProblem\r\n" + e.problem.ToString());
}
void cEXWB1_HTMLOMWindowServices_resizeTo(object sender, csExWB.HTMLOMWindowServicesEventArgs e)
{
this.Size = new Size(e.X, e.Y);
}
void cEXWB1_HTMLOMWindowServices_moveTo(object sender, csExWB.HTMLOMWindowServicesEventArgs e)
{
this.Location = new Point(e.X, e.Y);
}
}
}