Exemple #1
0
        public void AddWindow(IntPtr hWnd)
        {
            WinUtils.Rect rect = new WinUtils.Rect();
            WinUtils.GetWindowRect(hWnd, ref rect);
            WinCtl newWindow = new WinCtl(hWnd, rect);

            newWindow.MouseDown += newWindow_MouseDown;
            newWindow.MouseUp   += newWindow_MouseUp;
            newWindow.MouseMove += newWindow_MouseMove;
            cv.Children.Add(newWindow);
        }
Exemple #2
0
        void newWindow_MouseMove(object sender, MouseEventArgs e)
        {
            WinCtl win  = sender as WinCtl;
            var    cont = VisualTreeHelper.GetParent(win) as UIElement;

            if (dragMode)
            {
                win.SetValue(Canvas.LeftProperty,
                             e.GetPosition(cont).X - FirstXPos);

                win.SetValue(Canvas.TopProperty,
                             e.GetPosition(cont).Y - FirstYPos);
            }
        }
Exemple #3
0
        void newWindow_MouseDown(object sender, MouseButtonEventArgs e)
        {
            WinCtl win = sender as WinCtl;
            Point  ex  = Mouse.GetPosition(win);

            if (ex.X < (win.Width - 103) && ex.Y < 26 && e.LeftButton == MouseButtonState.Pressed)
            {
                dragMode = true;
                win.CaptureMouse();
                var cont = VisualTreeHelper.GetParent(win) as UIElement;
                FirstXPos      = e.GetPosition(win).X;
                FirstYPos      = e.GetPosition(win).Y;
                FirstArrowXPos = e.GetPosition(cont).X - FirstXPos;
                FirstArrowYPos = e.GetPosition(cont).Y - FirstYPos;
            }
        }
Exemple #4
0
        void newWindow_MouseUp(object sender, MouseButtonEventArgs e)
        {
            WinCtl win = sender as WinCtl;

            if (dragMode)
            {
                win.ReleaseMouseCapture();
                dragMode = false;
            }
            Point ex = Mouse.GetPosition(win);

            if (ex.Y <= 32)
            {
                if (ex.Y >= 6 && ex.Y <= 23)
                {
                    if (ex.X >= (win.Width - 103) && ex.X <= (win.Width - 73))
                    {
                        if (win.Width > 160 && win.Height > 26)
                        {
                            WinUtils.ShowWindow((IntPtr)win.Tag, 6);
                        }
                        else
                        {
                            WinUtils.ShowWindow((IntPtr)win.Tag, 9);
                        }
                    }
                    else if (ex.X >= (win.Width - 70) && ex.X <= (win.Width - 40))
                    {
                    }
                    else if (ex.X >= (win.Width - 37) && ex.X <= (win.Width - 7))
                    {
                        cv.Children.Remove(win);
                    }
                }
            }
        }