437 lines
14 KiB
C#
437 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
namespace ExtendedWebBrowser2
|
|
{
|
|
/// <summary>
|
|
/// Used in the new navigation events
|
|
/// </summary>
|
|
public class BrowserExtendedNavigatingEventArgs : CancelEventArgs
|
|
{
|
|
private readonly Uri _Url;
|
|
/// <summary>
|
|
/// The URL to navigate to
|
|
/// </summary>
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public Uri Url
|
|
{
|
|
get { return _Url; }
|
|
}
|
|
|
|
private readonly string _Frame;
|
|
/// <summary>
|
|
/// The name of the frame to navigate to
|
|
/// </summary>
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public string Frame
|
|
{
|
|
get { return _Frame; }
|
|
}
|
|
|
|
private readonly UrlContext navigationContext;
|
|
/// <summary>
|
|
/// The flags when opening a new window
|
|
/// </summary>
|
|
public UrlContext NavigationContext
|
|
{
|
|
get { return this.navigationContext; }
|
|
}
|
|
|
|
private object _pDisp;
|
|
/// <summary>
|
|
/// The pointer to ppDisp
|
|
/// </summary>
|
|
public object AutomationObject
|
|
{
|
|
get { return this._pDisp; }
|
|
set { this._pDisp = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of WebBrowserExtendedNavigatingEventArgs
|
|
/// </summary>
|
|
/// <param name="automation">Pointer to the automation object of the browser</param>
|
|
/// <param name="url">The URL to go to</param>
|
|
/// <param name="frame">The name of the frame</param>
|
|
/// <param name="navigationContext">The new window flags</param>
|
|
public BrowserExtendedNavigatingEventArgs(object automation, Uri url, string frame, UrlContext navigationContext)
|
|
: base()
|
|
{
|
|
_Url = url;
|
|
_Frame = frame;
|
|
this.navigationContext = navigationContext;
|
|
this._pDisp = automation;
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class ExtendedCloseEventArgs : CancelEventArgs
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// Used in the new navigation events
|
|
/// </summary>
|
|
public class ExtendedBrowserMessageEventArgs : CancelEventArgs
|
|
{
|
|
private readonly int _hwnd;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public int Hwnd
|
|
{
|
|
get { return _hwnd; }
|
|
}
|
|
private string _lpstrText;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string LpstrText
|
|
{
|
|
get { return _lpstrText; }
|
|
set { _lpstrText = value; }
|
|
}
|
|
private string _lpstrCaption;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string LpstrCaption
|
|
{
|
|
get { return _lpstrCaption; }
|
|
set { _lpstrCaption = value; }
|
|
}
|
|
private int _plResult;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public int PResult
|
|
{
|
|
get { return _plResult; }
|
|
set { _plResult = value; }
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public System.Windows.Forms.DialogResult DlgResult
|
|
{
|
|
set { _plResult = (int)value; }
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool DisplayHelpButton
|
|
{
|
|
get { return (_dwType & (int)MsgBoxHelpButton.MASK) == (int)MsgBoxHelpButton.MB_HELP; }
|
|
}
|
|
private readonly string _lpstrHelpFile;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string LpstrHelpFile
|
|
{
|
|
get { return _lpstrHelpFile; }
|
|
}
|
|
private readonly uint _dwHelpContext;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public uint DwHelpContext
|
|
{
|
|
get { return _dwHelpContext; }
|
|
}
|
|
private readonly uint _dwType;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public System.Windows.Forms.MessageBoxButtons DlgButtons
|
|
{
|
|
get
|
|
{
|
|
switch (_dwType & (int)MsgBoxButton.MASK)
|
|
{
|
|
case (int)MsgBoxButton.MB_OKCANCEL:
|
|
return System.Windows.Forms.MessageBoxButtons.OKCancel;
|
|
case (int)MsgBoxButton.MB_ABORTRETRYIGNORE:
|
|
return System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore;
|
|
case (int)MsgBoxButton.MB_YESNOCANCEL:
|
|
return System.Windows.Forms.MessageBoxButtons.YesNoCancel;
|
|
case (int)MsgBoxButton.MB_YESNO:
|
|
return System.Windows.Forms.MessageBoxButtons.YesNo;
|
|
case (int)MsgBoxButton.MB_RETRYCANCEL:
|
|
return System.Windows.Forms.MessageBoxButtons.RetryCancel;
|
|
case (int)MsgBoxButton.MB_OK:
|
|
default:
|
|
return System.Windows.Forms.MessageBoxButtons.OK;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public System.Windows.Forms.MessageBoxIcon DlgIcon
|
|
{
|
|
get
|
|
{
|
|
switch (_dwType & (int)MsgBoxIcon.MASK)
|
|
{
|
|
case (int)MsgBoxIcon.MB_ICONHAND:
|
|
return System.Windows.Forms.MessageBoxIcon.Hand;
|
|
//case (int)MsgBoxIcon.MB_ICONSTOP:
|
|
// return System.Windows.Forms.MessageBoxIcon.Stop;
|
|
//case (int)MsgBoxIcon.MB_ICONERROR:
|
|
// return System.Windows.Forms.MessageBoxIcon.Error;
|
|
case (int)MsgBoxIcon.MB_ICONQUESTION:
|
|
return System.Windows.Forms.MessageBoxIcon.Question;
|
|
case (int)MsgBoxIcon.MB_ICONEXCLAMATION:
|
|
return System.Windows.Forms.MessageBoxIcon.Exclamation;
|
|
//case (int)MsgBoxIcon.MB_ICONWARNING:
|
|
// return System.Windows.Forms.MessageBoxIcon.Warning;
|
|
case (int)MsgBoxIcon.MB_ICONASTERISK:
|
|
return System.Windows.Forms.MessageBoxIcon.Asterisk;
|
|
//case (int)MsgBoxIcon.MB_ICONINFORMATION:
|
|
// return System.Windows.Forms.MessageBoxIcon.Information;
|
|
case (int)MsgBoxIcon.MB_ICONNONE:
|
|
case (int)MsgBoxIcon.MB_USERICON:
|
|
default:
|
|
return System.Windows.Forms.MessageBoxIcon.None;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public System.Windows.Forms.MessageBoxDefaultButton DlgDefaultButtons
|
|
{
|
|
get
|
|
{
|
|
switch (_dwType & (int)MsgBoxDefButton.MASK)
|
|
{
|
|
case (int)MsgBoxDefButton.MB_DEFBUTTON2:
|
|
return System.Windows.Forms.MessageBoxDefaultButton.Button2;
|
|
case (int)MsgBoxDefButton.MB_DEFBUTTON3:
|
|
return System.Windows.Forms.MessageBoxDefaultButton.Button3;
|
|
case (int)MsgBoxDefButton.MB_DEFBUTTON1:
|
|
default:
|
|
return System.Windows.Forms.MessageBoxDefaultButton.Button1;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public System.Windows.Forms.MessageBoxOptions DlgOptions
|
|
{
|
|
get
|
|
{
|
|
switch (_dwType & (int)MsgBoxOption.MASK)
|
|
{
|
|
case (int)MsgBoxOption.MB_DEFAULT_DESKTOP_ONLY:
|
|
return System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly;
|
|
case (int)MsgBoxOption.MB_RIGHT:
|
|
return System.Windows.Forms.MessageBoxOptions.RightAlign;
|
|
case (int)MsgBoxOption.MB_RTLREADING:
|
|
return System.Windows.Forms.MessageBoxOptions.RtlReading;
|
|
case (int)MsgBoxOption.MB_SERVICE_NOTIFICATION1:
|
|
case (int)MsgBoxOption.MB_SERVICE_NOTIFICATION2:
|
|
return System.Windows.Forms.MessageBoxOptions.ServiceNotification;
|
|
default:
|
|
return 0;
|
|
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="Hwnd"></param>
|
|
/// <param name="LpstrText"></param>
|
|
/// <param name="LpstrCaption"></param>
|
|
/// <param name="DwType"></param>
|
|
/// <param name="LpstrHelpFile"></param>
|
|
/// <param name="DwHelpContext"></param>
|
|
public ExtendedBrowserMessageEventArgs(int Hwnd, string LpstrText, string LpstrCaption, uint DwType, string LpstrHelpFile, uint DwHelpContext)
|
|
{
|
|
this._hwnd = Hwnd;
|
|
_lpstrText = LpstrText;
|
|
_lpstrCaption = LpstrCaption;
|
|
_dwType = DwType;
|
|
_lpstrHelpFile = LpstrHelpFile;
|
|
_dwHelpContext = DwHelpContext;
|
|
switch (DlgButtons)
|
|
{
|
|
case System.Windows.Forms.MessageBoxButtons.OKCancel:
|
|
case System.Windows.Forms.MessageBoxButtons.RetryCancel:
|
|
case System.Windows.Forms.MessageBoxButtons.YesNoCancel:
|
|
DlgResult = System.Windows.Forms.DialogResult.Cancel;
|
|
break;
|
|
case System.Windows.Forms.MessageBoxButtons.YesNo:
|
|
DlgResult = System.Windows.Forms.DialogResult.No;
|
|
break;
|
|
case System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore:
|
|
DlgResult = System.Windows.Forms.DialogResult.Abort;
|
|
break;
|
|
case System.Windows.Forms.MessageBoxButtons.OK:
|
|
default:
|
|
DlgResult = System.Windows.Forms.DialogResult.OK;
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public enum MsgBoxButton
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MASK = 0x0000000F,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_OK = 0x00000000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_OKCANCEL = 0x00000001,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ABORTRETRYIGNORE = 0x00000002,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_YESNOCANCEL = 0x00000003,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_YESNO = 0x00000004,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_RETRYCANCEL = 0x00000005
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public enum MsgBoxIcon
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MASK = 0x000000F0,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONNONE = 0x00000000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONHAND = 0x00000010,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONSTOP = 0x00000010,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONERROR = 0x00000010,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONQUESTION = 0x00000020,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONEXCLAMATION = 0x00000030,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONWARNING = 0x00000030,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONASTERISK = 0x00000040,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_ICONINFORMATION = 0x00000040,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_USERICON = 0x00000080
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public enum MsgBoxDefButton
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MASK = 0x00000F00,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_DEFBUTTON1 = 0x00000000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_DEFBUTTON2 = 0x00000100,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_DEFBUTTON3 = 0x00000200
|
|
//MB_DEFBUTTON4 = 0x00000300
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public enum MsgBoxOption
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MASK = 0x003F0000,
|
|
//MB_SETFOREGROUND = 0x00010000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_DEFAULT_DESKTOP_ONLY = 0x00020000,
|
|
//MB_TOPMOST = 0x00040000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_RIGHT = 0x00080000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_RTLREADING = 0x00100000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_SERVICE_NOTIFICATION1 = 0x00200000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_SERVICE_NOTIFICATION2 = 0x00040000
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public enum MsgBoxHelpButton
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MASK = 0x00004000,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
MB_HELP = 0x00004000
|
|
}
|
|
}
|
|
}
|