public XnaControlGame(IntPtr handle, global::System.Windows.Forms.Form parentForm, global::System.Windows.Forms.Control surfaceControl) { //graphics = new GraphicsDeviceManager(this); //graphics.GraphicsProfile = GraphicsProfile.Reach; Content.RootDirectory = "C:/Users/user/source/repos/cs/Games/TrainCollapse/TrainCollapse/Content"; this.parentForm = parentForm; this.controlXna = surfaceControl; //gameForm = System.Windows.Forms.Control.FromHandle(this.Window.Handle); //gameForm.VisibleChanged += new EventHandler(gameForm_VisibleChanged); //controlXna.SizeChanged += new EventHandler(pictureBox_SizeChanged); // preparing device settings handler. _XnaDrawingSurface = handle; Mouse.WindowHandle = handle; this.IsMouseVisible = true; //graphics.PreparingDeviceSettings += OnPreparingDeviceSettings; //GraphicsDevice..PreferredBackBufferWidth = 720; //GraphicsDevice.PreferredBackBufferHeight = 720; parentForm.FormClosed += delegate(object sender, global::System.Windows.Forms.FormClosedEventArgs e) { this.Exit(); Application.Exit(); }; }
public void Dispose() { if (Yanesdk.System.Platform.IsWindows) { if (isClickOnlyOnForm) { // Disposeを二重に呼び出されたときに2重解放になるのを防止する isClickOnlyOnForm = false; if (userForm != null) { userForm.Activated -= new global::System.EventHandler(this.Activated); userForm.Deactivate -= new global::System.EventHandler(this.Deactivated); userForm = null; } if (userControl != null) { userControl.MouseEnter -= new global::System.EventHandler(this.Activated); userControl.MouseLeave -= new global::System.EventHandler(this.Deactivated); userControl = null; } } else { userForm = null; userControl = null; } } }
/// <summary> /// 開始執行目前執行緒上的標準應用程式訊息迴圈,並顯示指定的表單。 /// A System.Windows.Forms.Form that represents the form to make visible. (With System.Threading.Mutex) /// </summary> /// <param name="MainForm">application form.</param> public static void Run(global::System.Windows.Forms.Form MainForm) { if (IsFirstInstance()) { Application.ApplicationExit += new EventHandler(OnExit); Application.Run(MainForm); } else { //获得当前正在执行的应用程序集合的版权信息 System.IntPtr __hwnd = Win32.PlatformInvoke.FindWindow(null, AssemblyInfoClass.ProductInfo); Win32.PlatformInvoke.ShowWindow(__hwnd, (int)Win32.PlatformInvoke.ShowWindowStyles.Restore); Win32.PlatformInvoke.SetForegroundWindow(__hwnd); } }
private static void Main(params string[] args) { var webBrowser = new MyWebBrowser { Dock = System.Windows.Forms.DockStyle.Fill, DocumentText = @"<html><head><body><script language='JScript'>alert(""test"")</script></body></head></html>" }; webBrowser.ShowMessage += (sender, e) => { e.Result = 0; e.Handled = true; }; var form = new global::System.Windows.Forms.Form { Controls = { webBrowser } }; global::System.Windows.Forms.Application.Run(form); }
/// <summary> /// あとからforcusのあるformを変更したいときに用いる /// </summary> /// <param name="form"></param> /// <param name="onlyOnForm"></param> public void Init(global::System.Windows.Forms.Form form, bool onlyOnForm) { Dispose(); Reset(); userForm = form; this.isClickOnlyOnForm = onlyOnForm; if (onlyOnForm) { // マウスカーソルが入力フォーカスのあるControl,Formの外にあるのかを // 判定するために入力をhookする。 form.Activated += new global::System.EventHandler(this.Activated); form.Deactivate += new global::System.EventHandler(this.Deactivated); // とりあえずはこいつを初期値としよう isActivated = !IsMouseOutOfForm; } else { isActivated = true; } }
/// <summary> /// あとからforcusのあるformを変更したいときに用いる /// </summary> /// <param name="form"></param> /// <param name="onlyOnForm"></param> public void Init(global::System.Windows.Forms.Form form , bool onlyOnForm) { Dispose(); Reset(); userForm = form; this.isClickOnlyOnForm = onlyOnForm; if ( onlyOnForm ) { // マウスカーソルが入力フォーカスのあるControl,Formの外にあるのかを // 判定するために入力をhookする。 form.Activated += new global::System.EventHandler(this.Activated); form.Deactivate += new global::System.EventHandler(this.Deactivated); // とりあえずはこいつを初期値としよう isActivated = !IsMouseOutOfForm; } else { isActivated = true; } }
public void Dispose() { if (Yanesdk.System.Platform.IsWindows) { if (isClickOnlyOnForm) { // Disposeを二重に呼び出されたときに2重解放になるのを防止する isClickOnlyOnForm = false; if (userForm != null) { userForm.Activated -= new global::System.EventHandler(this.Activated); userForm.Deactivate -= new global::System.EventHandler(this.Deactivated); userForm = null; } if (userControl != null) { userControl.MouseEnter -= new global::System.EventHandler(this.Activated); userControl.MouseLeave -= new global::System.EventHandler(this.Deactivated); userControl = null; } } else { userForm = null; userControl = null; } } }
/// <summary> /// Windowsプラットフォームの場合は、Formを渡して、そのフォームに /// 対するマウス位置を取得できる /// </summary> /// <remarks> /// onlyOnForm == trueであれば、このForm上でマウスが押されたときしか /// このクラスはマウスボタンが押されたと認識しない。 /// </remarks> public MouseInput(global::System.Windows.Forms.Form form, bool onlyOnForm) { Init(form, onlyOnForm); }
/// <summary> /// Windowsプラットフォームの場合は、Formを渡して、そのフォームに /// 対するマウス位置を取得できる /// </summary> public MouseInput(global::System.Windows.Forms.Form form) { Init(form, false); }