Exemplo n.º 1
0
        private void ReleaseAll()
        {
            if (dhpActiveMain.DiabloWindow != null)
            {
                dhpActiveMain.ReleaseDiabloWindow();
            }

            foreach (TabPage tab in this.tabControl1.TabPages)
            {
                if (tab is DiabloTab)
                {
                    DiabloHostPanel diabloPanel = tab.Controls[0] as DiabloHostPanel;
                    if (diabloPanel != null)
                    {
                        diabloPanel.ReleaseDiabloWindow();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public DiabloTab(string text, string path)
        {
            this.exePath = path;
            this.Text    = text;

            diabloPanel          = new DiabloHostPanel();
            diabloPanel.Width    = Convert.ToInt32(800m * 1);
            diabloPanel.Height   = Convert.ToInt32(600m * 1);;
            diabloPanel.Location = new Point(10, 14);
            this.Controls.Add(diabloPanel);

            Button LoadDiabloButton = new Button();

            LoadDiabloButton.Text     = "Load D2";
            LoadDiabloButton.Location = new Point(Convert.ToInt32(800m * 1 + 20m), 10);
            LoadDiabloButton.Click   += new EventHandler(LoadDiabloButton_Click);
            this.Controls.Add(LoadDiabloButton);

            CheckBox checkBox = new CheckBox();

            checkBox.Text     = "Sound";
            checkBox.Location = new Point(Convert.ToInt32(800m * 1 + 20m), 40);
            this.Controls.Add(checkBox);
        }
Exemplo n.º 3
0
        private void UpdateFlows()
        {
            if (this.tabControl1.SelectedTab is DiabloTab)
            {
                ((DiabloTab)this.tabControl1.SelectedTab).Activate();
            }
            else // main tab
            {
                foreach (TabPage tab in tabControl1.TabPages)
                {
                    if (dhpActiveMain.DiabloWindow != null && tab.Text == dhpActiveMain.DiabloWindow.Text)
                    {
                    }
                    else if (tab is DiabloTab)
                    {
                        // Look through the current panels to see if we have added it already.
                        DiabloHostPanel existingPanel = null;

                        foreach (Panel panel in flpDiabloWindows.Controls)
                        {
                            if (panel.Controls.Count > 0 && ((DiabloTab)tab).DiabloWindow == ((DiabloHostPanel)panel.Controls[0]).DiabloWindow)
                            {
                                existingPanel = (DiabloHostPanel)panel.Controls[0];
                                break;
                            }
                        }

                        // If we have, activate it.
                        if (existingPanel != null)
                        {
                            existingPanel.DiabloWindow.SetHostPanel(existingPanel);
                            existingPanel.DiabloWindow.Activate();
                        }
                        // If we havnt, Add it.
                        else
                        {
                            if (((DiabloTab)tab).DiabloWindow != null)
                            {
                                existingPanel          = new DiabloHostPanel();
                                existingPanel.Width    = 334; // Convert.ToInt32(400m * 1);
                                existingPanel.Height   = 250; // Convert.ToInt32(300m * 1);
                                existingPanel.Location = new Point(10, 10);
                                ((Panel)flpDiabloWindows.Controls[((DiabloTab)tab).Text]).Controls.Add(existingPanel);
                                //flpDiabloWindows.Controls.Add(existingPanel);
                                //main.Controls.Add(existingPanel); // here
                                existingPanel.BindDiabloWindow(((DiabloTab)tab).DiabloWindow);
                                existingPanel.DiabloWindow.SetHostPanel(existingPanel);
                                existingPanel.DiabloWindow.Activate();
                            }
                        }
                    }
                }

                // Remove any inactive panels
                for (int i = flpDiabloWindows.Controls.Count; i > 0; i--)
                {
                    if (((Panel)flpDiabloWindows.Controls[i - 1]).Controls.Count > 0)
                    {
                        DiabloHostPanel panel = ((Panel)flpDiabloWindows.Controls[i - 1]).Controls[0] as DiabloHostPanel;
                        if (panel != null)
                        {
                            if (panel.DiabloWindow == null || panel.DiabloWindow.Disposed)
                            {
                                ((Panel)flpDiabloWindows.Controls[0]).Controls.Remove(panel);
                                //flpDiabloButtons
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void SetHostPanel(DiabloHostPanel hostPanel)
 {
     this.targetControl = hostPanel;
 }
Exemplo n.º 5
0
        public DiabloWindow(Form mainWindow, DiabloHostPanel overlayControl, IntPtr diablo2Handle, string text)
        {
            this.Text          = text;
            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            = "GreenVex 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("GreenVex.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();
        }