public void SetHostPanel(DiabloHostPanel hostPanel) { this.targetControl = hostPanel; }
public DiabloWindow(Form mainWindow, DiabloHostPanel overlayControl, IntPtr diablo2Handle) { 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("D2PartyTime.Resources.D2Cursor.png"); var pic = Imaging.CreateBitmapSourceFromHBitmap((new Bitmap(D2PartyTime.Properties.Resources.D2Cursor)).GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); 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 = pic; d2Cursor.Stretch = Stretch.Uniform; d2Cursor.Visibility = Visibility.Hidden; overlayForm.Canvas.Children.Add(d2Cursor); } RegisterThumbnail(); Hide(); OnParentMove(null, null); this.mainWindow.Activate(); }