using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
namespace ExtendedWebBrowser2
{
///
/// Used in the new navigation events
///
public class BrowserExtendedNavigatingEventArgs : CancelEventArgs
{
private readonly Uri _Url;
///
/// The URL to navigate to
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public Uri Url
{
get { return _Url; }
}
private readonly string _Frame;
///
/// The name of the frame to navigate to
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public string Frame
{
get { return _Frame; }
}
private readonly UrlContext navigationContext;
///
/// The flags when opening a new window
///
public UrlContext NavigationContext
{
get { return this.navigationContext; }
}
private object _pDisp;
///
/// The pointer to ppDisp
///
public object AutomationObject
{
get { return this._pDisp; }
set { this._pDisp = value; }
}
///
/// Creates a new instance of WebBrowserExtendedNavigatingEventArgs
///
/// Pointer to the automation object of the browser
/// The URL to go to
/// The name of the frame
/// The new window flags
public BrowserExtendedNavigatingEventArgs(object automation, Uri url, string frame, UrlContext navigationContext)
: base()
{
_Url = url;
_Frame = frame;
this.navigationContext = navigationContext;
this._pDisp = automation;
}
}
///
///
///
public class ExtendedCloseEventArgs : CancelEventArgs
{
}
///
/// Used in the new navigation events
///
public class ExtendedBrowserMessageEventArgs : CancelEventArgs
{
private readonly int _hwnd;
///
///
///
public int Hwnd
{
get { return _hwnd; }
}
private string _lpstrText;
///
///
///
public string LpstrText
{
get { return _lpstrText; }
set { _lpstrText = value; }
}
private string _lpstrCaption;
///
///
///
public string LpstrCaption
{
get { return _lpstrCaption; }
set { _lpstrCaption = value; }
}
private int _plResult;
///
///
///
public int PResult
{
get { return _plResult; }
set { _plResult = value; }
}
///
///
///
public System.Windows.Forms.DialogResult DlgResult
{
set { _plResult = (int)value; }
}
///
///
///
public bool DisplayHelpButton
{
get { return (_dwType & (int)MsgBoxHelpButton.MASK) == (int)MsgBoxHelpButton.MB_HELP; }
}
private readonly string _lpstrHelpFile;
///
///
///
public string LpstrHelpFile
{
get { return _lpstrHelpFile; }
}
private readonly uint _dwHelpContext;
///
///
///
public uint DwHelpContext
{
get { return _dwHelpContext; }
}
private readonly uint _dwType;
///
///
///
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;
}
}
}
///
///
///
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;
}
}
}
///
///
///
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;
}
}
}
///
///
///
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;
}
}
}
///
///
///
///
///
///
///
///
///
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;
}
}
///
///
///
public enum MsgBoxButton
{
///
///
///
MASK = 0x0000000F,
///
///
///
MB_OK = 0x00000000,
///
///
///
MB_OKCANCEL = 0x00000001,
///
///
///
MB_ABORTRETRYIGNORE = 0x00000002,
///
///
///
MB_YESNOCANCEL = 0x00000003,
///
///
///
MB_YESNO = 0x00000004,
///
///
///
MB_RETRYCANCEL = 0x00000005
}
///
///
///
public enum MsgBoxIcon
{
///
///
///
MASK = 0x000000F0,
///
///
///
MB_ICONNONE = 0x00000000,
///
///
///
MB_ICONHAND = 0x00000010,
///
///
///
MB_ICONSTOP = 0x00000010,
///
///
///
MB_ICONERROR = 0x00000010,
///
///
///
MB_ICONQUESTION = 0x00000020,
///
///
///
MB_ICONEXCLAMATION = 0x00000030,
///
///
///
MB_ICONWARNING = 0x00000030,
///
///
///
MB_ICONASTERISK = 0x00000040,
///
///
///
MB_ICONINFORMATION = 0x00000040,
///
///
///
MB_USERICON = 0x00000080
}
///
///
///
public enum MsgBoxDefButton
{
///
///
///
MASK = 0x00000F00,
///
///
///
MB_DEFBUTTON1 = 0x00000000,
///
///
///
MB_DEFBUTTON2 = 0x00000100,
///
///
///
MB_DEFBUTTON3 = 0x00000200
//MB_DEFBUTTON4 = 0x00000300
}
///
///
///
public enum MsgBoxOption
{
///
///
///
MASK = 0x003F0000,
//MB_SETFOREGROUND = 0x00010000,
///
///
///
MB_DEFAULT_DESKTOP_ONLY = 0x00020000,
//MB_TOPMOST = 0x00040000,
///
///
///
MB_RIGHT = 0x00080000,
///
///
///
MB_RTLREADING = 0x00100000,
///
///
///
MB_SERVICE_NOTIFICATION1 = 0x00200000,
///
///
///
MB_SERVICE_NOTIFICATION2 = 0x00040000
}
///
///
///
public enum MsgBoxHelpButton
{
///
///
///
MASK = 0x00004000,
///
///
///
MB_HELP = 0x00004000
}
}
}