public void Activate() { this.isActive = true; RegisterThumbnail(); OnParentMove(null, null); overlayForm.Show(); mainWindow.Focus(); }
public DiabloWindow(Form mainWindow, DiabloHostPanel overlayControl, IntPtr diablo2Handle, string keyOwner) { this.keyOwner = keyOwner; this.mainWindow = mainWindow; this.handle = diablo2Handle; this.targetControl = overlayControl; this.mainWindow.Move += new EventHandler(OnParentMove); this.targetControl.KeyDown += new System.Windows.Forms.KeyEventHandler(targetControl_KeyDown); this.targetControl.KeyUp += new System.Windows.Forms.KeyEventHandler(targetControl_KeyUp); this.targetControl.RegisterEvents(); DiabloWindows.Add(this); underlayForm = new Form(); underlayForm.FormBorderStyle = FormBorderStyle.None; underlayForm.Text = "BlueVex 2 Container Window"; underlayForm.Controls.Add(new Panel() { Width = Screen.PrimaryScreen.WorkingArea.Width, Height = Screen.PrimaryScreen.WorkingArea.Height } ); underlayForm.ShowInTaskbar = false; underlayForm.Show(); Mouse.OverrideCursor = System.Windows.Input.Cursors.None; overlayForm = new OverlayWindow(); overlayForm.MouseMove += new System.Windows.Input.MouseEventHandler(overlayForm_MouseMove); overlayForm.Width = 1600; overlayForm.Height = 1200; overlayForm.Show(); HwndSource hwndSource = PresentationSource.FromVisual(overlayForm) as HwndSource; System.Windows.Point formSize = hwndSource.CompositionTarget.TransformFromDevice.Transform(new System.Windows.Point(targetControl.Width, targetControl.Height)); scaleX = formSize.X / 800; scaleY = formSize.Y / 600; this.overlayForm.Canvas.RenderTransform = new ScaleTransform(scaleX, scaleY); System.IO.Stream fileStream = this.GetType().Assembly.GetManifestResourceStream("BlueVex2.Resources.D2Cursor.png"); if (fileStream != null) { PngBitmapDecoder bitmapDecoder = new PngBitmapDecoder(fileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); ImageSource imageSource = bitmapDecoder.Frames[0]; d2Cursor = new System.Windows.Controls.Image(); d2Cursor.IsHitTestVisible = false; //d2Cursor.MouseMove += new System.Windows.Input.MouseEventHandler(d2Cursor_MouseMove); d2Cursor.Source = imageSource; d2Cursor.Stretch = Stretch.Uniform; d2Cursor.Visibility = Visibility.Hidden; overlayForm.Canvas.Children.Add(d2Cursor); } RegisterThumbnail(); Hide(); OnParentMove(null, null); this.mainWindow.Activate(); }
public DiabloWindow(Form mainWindow, DiabloHostPanel overlayControl, IntPtr diablo2Handle, string keyOwner) { this.keyOwner = keyOwner; this.mainWindow = mainWindow; this.handle = diablo2Handle; this.targetControl = overlayControl; this.mainWindow.Move += new EventHandler(OnParentMove); this.targetControl.KeyDown += new System.Windows.Forms.KeyEventHandler(targetControl_KeyDown); this.targetControl.KeyUp += new System.Windows.Forms.KeyEventHandler(targetControl_KeyUp); this.targetControl.RegisterEvents(); DiabloWindows.Add(this); underlayForm = new Form(); underlayForm.FormBorderStyle = FormBorderStyle.None; underlayForm.Text = "BlueVex 2 Container Window"; underlayForm.Controls.Add(new Panel() { Width = Screen.PrimaryScreen.WorkingArea.Width, Height = Screen.PrimaryScreen.WorkingArea.Height }); underlayForm.ShowInTaskbar = false; underlayForm.Show(); Mouse.OverrideCursor = System.Windows.Input.Cursors.None; overlayForm = new OverlayWindow(); overlayForm.MouseMove += new System.Windows.Input.MouseEventHandler(overlayForm_MouseMove); overlayForm.Width = 1600; overlayForm.Height = 1200; overlayForm.Show(); HwndSource hwndSource = PresentationSource.FromVisual(overlayForm) as HwndSource; System.Windows.Point formSize = hwndSource.CompositionTarget.TransformFromDevice.Transform(new System.Windows.Point(targetControl.Width, targetControl.Height)); scaleX = formSize.X / 800; scaleY = formSize.Y / 600; this.overlayForm.Canvas.RenderTransform = new ScaleTransform(scaleX, scaleY); System.IO.Stream fileStream = this.GetType().Assembly.GetManifestResourceStream("BlueVex2.Resources.D2Cursor.png"); if (fileStream != null) { PngBitmapDecoder bitmapDecoder = new PngBitmapDecoder(fileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); ImageSource imageSource = bitmapDecoder.Frames[0]; d2Cursor = new System.Windows.Controls.Image(); d2Cursor.IsHitTestVisible = false; //d2Cursor.MouseMove += new System.Windows.Input.MouseEventHandler(d2Cursor_MouseMove); d2Cursor.Source = imageSource; d2Cursor.Stretch = Stretch.Uniform; d2Cursor.Visibility = Visibility.Hidden; overlayForm.Canvas.Children.Add(d2Cursor); } RegisterThumbnail(); Hide(); OnParentMove(null, null); this.mainWindow.Activate(); }