コード例 #1
0
 public static void SaveWindowPosition(SavedWindows window, System.Windows.Forms.Form f)
 {
     WindowPos wp = new WindowPos();
     wp.maximized = f.WindowState == System.Windows.Forms.FormWindowState.Maximized;
     wp.x = f.Location.X;
     wp.y = f.Location.Y;
     wp.width = f.ClientSize.Width;
     wp.height = f.ClientSize.Height;
     windowPositions[(int)window] = wp;
 }
コード例 #2
0
        public static void SaveWindowPosition(SavedWindows window, Form f)
        {
            WindowPos wp = new WindowPos();

            wp.maximized = f.WindowState == FormWindowState.Maximized;
            wp.x         = f.Location.X;
            wp.y         = f.Location.Y;
            wp.width     = f.ClientSize.Width;
            wp.height    = f.ClientSize.Height;
            windowPositions[(int)window] = wp;
        }
コード例 #3
0
ファイル: ReportForm.cs プロジェクト: ewin66/VideoManager
        private void SaveRegData()
        {
            WindowPos windowPo = new WindowPos()
            {
                Width  = base.Width,
                Height = base.Height,
                PosX   = base.Location.X,
                PosY   = base.Location.Y
            };

            Registry.SetWindowPos(windowPo, "ReportWindow");
        }
コード例 #4
0
ファイル: ReportForm.cs プロジェクト: ewin66/VideoManager
        private void LoadRegData()
        {
            WindowPos windowPos = Registry.GetWindowPos("ReportWindow");

            if (windowPos.Height == 0 || windowPos.Width == 0)
            {
                base.StartPosition = FormStartPosition.CenterScreen;
                base.Width         = 800;
                base.Height        = 600;
                return;
            }
            base.Width    = windowPos.Width;
            base.Height   = windowPos.Height;
            base.Location = new Point(windowPos.PosX, windowPos.PosY);
        }
コード例 #5
0
        public static void SetupWindowPosition(SavedWindows window, Form f)
        {
            WindowPos wp = windowPositions[(int)window];

            if (wp.width == 0)
            {
                return;
            }
            f.Location = new System.Drawing.Point(wp.x, wp.y);
            if (wp.maximized)
            {
                f.WindowState = FormWindowState.Maximized;
            }
            else
            {
                f.ClientSize = new System.Drawing.Size(wp.width, wp.height);
            }
            f.StartPosition = FormStartPosition.Manual;
        }
コード例 #6
0
ファイル: GlobalCatForm.cs プロジェクト: ewin66/VideoManager
 private void LoadRegData()
 {
     try
     {
         WindowPos windowPos = Registry.GetWindowPos("GlobalCatWindow");
         if (windowPos.Height != 0 && windowPos.Width != 0)
         {
             Width    = windowPos.Width;
             Height   = windowPos.Height;
             Location = new Point(windowPos.PosX, windowPos.PosY);
         }
         else
         {
             StartPosition = FormStartPosition.CenterScreen;
             Width         = 800;
             Height        = 600;
         }
     }
     catch
     {
     }
 }
コード例 #7
0
ファイル: VMMgr.cs プロジェクト: ewin66/VideoManager
 private void LoadRegData()
 {
     try
     {
         WindowPos windowPos = Registry.GetWindowPos("StudioWindow");
         if (windowPos.Height == 0 || windowPos.Width == 0)
         {
             base.StartPosition = FormStartPosition.CenterScreen;
             base.Width         = 800;
             base.Height        = 600;
         }
         else
         {
             base.Width    = windowPos.Width;
             base.Height   = windowPos.Height;
             base.Location = new Point(windowPos.PosX, windowPos.PosY);
         }
     }
     catch
     {
     }
 }
コード例 #8
0
    protected override void WndProc(ref Message m)
    {
        const int WM_WINDOWPOSCHANGING = 0x0046;

        if (m.Msg == WM_WINDOWPOSCHANGING)
        {
            WindowPos mwp = (WindowPos)Marshal.PtrToStructure(m.LParam, typeof(WindowPos));
            if (mwp.hwnd == Handle.ToInt32())
            {
                const int SWP_NOMOVE = 0x0002;
                const int SWP_NOSIZE = 0x0001;
                int       x          = mwp.x;
                int       y          = mwp.y;
                if (x < Owner.Left || y < Owner.Top || x + mwp.cx > Owner.Right || y + mwp.cy > Owner.Bottom)
                {
                    m.Result   = IntPtr.Zero;
                    mwp.flags |= SWP_NOMOVE | SWP_NOSIZE;
                    Marshal.StructureToPtr(mwp, m.LParam, true);
                }
            }
        }
        base.WndProc(ref m);
    }
コード例 #9
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_WINDOWPOSCHANGING)
            {
                WindowPos windowPos = (WindowPos)m.GetLParam(typeof(WindowPos));

                // Make changes to windowPos

                // Then marshal the changes back to the message
                Marshal.StructureToPtr(windowPos, m.LParam, true);
            }

            base.WndProc(ref m);

            // Make changes to WM_GETMINMAXINFO after it has been handled by the underlying
            // WndProc, so we only need to repopulate the minimum size constraints
            if (m.Msg == WM_GETMINMAXINFO)
            {
                MinMaxInfo minMaxInfo = (MinMaxInfo)m.GetLParam(typeof(MinMaxInfo));
                minMaxInfo.ptMinTrackSize.x = this.MinimumSize.Width;
                minMaxInfo.ptMinTrackSize.y = this.MinimumSize.Height;
                Marshal.StructureToPtr(minMaxInfo, m.LParam, true);
            }
        }
コード例 #10
0
ファイル: User32.cs プロジェクト: oneminot/greenshot
 public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, WindowPos uFlags);
コード例 #11
0
        protected override void draw_gui()
        {
            //handle collapsed state
            if (Collapsed)
            {
                if (ShowOnHover)
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        draw_main_window = WindowPos.Contains(Event.current.mousePosition);
                    }
                    if (!draw_main_window)
                    {
                        UnlockControls();
                        var prefix = CFG.Enabled?
                                     "<b><color=lime>TCA: </color></b>" :
                                     (VSL.LandedOrSplashed? "<b>TCA: </b>" : "<b><color=red>TCA: </color></b>");
                        GUI.Label(collapsed_rect, prefix + StatusString(), Styles.boxed_label);
                    }
                }
                else
                {
                    UnlockControls();
                    GUI.Label(collapsed_rect, new GUIContent("TCA", "Push to show Main Window"),
                              CFG.Enabled? Styles.green : (VSL.LandedOrSplashed? Styles.white : Styles.red));
                    if (Input.GetMouseButton(0) && collapsed_rect.Contains(Event.current.mousePosition))
                    {
                        Collapsed = false;
                    }
                    TooltipManager.GetTooltip();
                }
            }
            else
            {
                draw_main_window = true;
            }
            //draw main window if allowed
            if (draw_main_window)
            {
                LockControls();
                WindowPos =
                    GUILayout.Window(TCA.GetInstanceID(),
                                     WindowPos,
                                     DrawMainWindow,
                                     RemoteControl? "RC: " + vessel.vesselName : vessel.vesselName,
                                     GUILayout.Width(ControlsWidth),
                                     GUILayout.Height(50)).clampToScreen();
                update_collapsed_rect();
            }
            //draw waypoints and all subwindows
            if (RemoteControl && Event.current.type == EventType.Repaint)
            {
                Markers.DrawWorldMarker(TCA.vessel.transform.position, Color.green,
                                        "Remotely Controlled Vessel", NavigationTab.PathNodeMarker, 8);
            }
            if (NAV != null)
            {
                NAV.DrawWaypoints();
            }
            AllWindows.ForEach(w => w.Draw());
            ModulesGraph.Draw();

                        #if DEBUG
            GUI.Label(debug_rect,
                      string.Format("[{0}] {1:HH:mm:ss.fff}",
                                    TCA != null && vessel != null? vessel.situation.ToString() : "",
                                    DateTime.Now),
                      Styles.boxed_label);
                        #endif
        }
コード例 #12
0
        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
            case WM_COMMAND: {
                // need to dispatch the message for the context menu
                if (message.LParam == IntPtr.Zero)
                {
                    commandDispatch.Invoke(null, new object[] {
                            message.WParam.ToInt32()& 0xFFFF
                        });
                }
            } break;

            case WM_NCHITTEST: {
                message.Result = (IntPtr)HitResult.Caption;
                if (HitTest != null)
                {
                    Point p = new Point(
                        (int)((uint)message.LParam & 0xFFFF) - location.X,
                        (int)(((uint)message.LParam >> 16) & 0xFFFF) - location.Y);
                    HitTestEventArgs e = new HitTestEventArgs(p, HitResult.Caption);
                    HitTest(this, e);
                    message.Result = (IntPtr)e.HitResult;
                }
            } break;

            case WM_NCLBUTTONDBLCLK: {
                message.Result = IntPtr.Zero;
            } break;

            case WM_NCRBUTTONDOWN: {
                message.Result = IntPtr.Zero;
            } break;

            case WM_NCRBUTTONUP: {
                if (contextMenu != null)
                {
                    ShowContextMenu(new Point(
                                        (int)((uint)message.LParam & 0xFFFF),
                                        (int)(((uint)message.LParam >> 16) & 0xFFFF)));
                }
                message.Result = IntPtr.Zero;
            } break;

            case WM_WINDOWPOSCHANGING: {
                WindowPos wp = (WindowPos)Marshal.PtrToStructure(
                    message.LParam, typeof(WindowPos));

                if (!lockPositionAndSize)
                {
                    // prevent the window from leaving the screen
                    if ((wp.flags & SWP_NOMOVE) == 0)
                    {
                        Rectangle rect   = Screen.GetWorkingArea(new Point(wp.x, wp.y));
                        const int margin = 16;
                        wp.x = Math.Max(wp.x, rect.Left - wp.cx + margin);
                        wp.x = Math.Min(wp.x, rect.Right - margin);
                        wp.y = Math.Max(wp.y, rect.Top - wp.cy + margin);
                        wp.y = Math.Min(wp.y, rect.Bottom - margin);
                    }

                    // update location and fire event
                    if ((wp.flags & SWP_NOMOVE) == 0)
                    {
                        if (location.X != wp.x || location.Y != wp.y)
                        {
                            location = new Point(wp.x, wp.y);
                            if (LocationChanged != null)
                            {
                                LocationChanged(this, EventArgs.Empty);
                            }
                        }
                    }

                    // update size and fire event
                    if ((wp.flags & SWP_NOSIZE) == 0)
                    {
                        if (size.Width != wp.cx || size.Height != wp.cy)
                        {
                            size = new Size(wp.cx, wp.cy);
                            if (SizeChanged != null)
                            {
                                SizeChanged(this, EventArgs.Empty);
                            }
                        }
                    }

                    // update the size of the layered window
                    if ((wp.flags & SWP_NOSIZE) == 0)
                    {
                        NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero,
                                                          IntPtr.Zero, ref size, IntPtr.Zero, IntPtr.Zero, 0,
                                                          IntPtr.Zero, 0);
                    }

                    // update the position of the layered window
                    if ((wp.flags & SWP_NOMOVE) == 0)
                    {
                        NativeMethods.SetWindowPos(Handle, IntPtr.Zero,
                                                   location.X, location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE |
                                                   SWP_NOZORDER | SWP_NOSENDCHANGING);
                    }
                }

                // do not forward any move or size messages
                wp.flags |= SWP_NOSIZE | SWP_NOMOVE;
                Marshal.StructureToPtr(wp, message.LParam, false);
                message.Result = IntPtr.Zero;
            } break;

            default: {
                base.WndProc(ref message);
            } break;
            }
        }
コード例 #13
0
ファイル: User32.cs プロジェクト: rzstead/ShareXFork
 public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, WindowPos uFlags);
コード例 #14
0
 protected override void draw_gui()
 {
     //draw main window if allowed
     if (draw_main_window)
     {
         LockControls();
         WindowPos =
             GUILayout.Window(TCA.GetInstanceID(),
                              WindowPos,
                              DrawMainWindow,
                              RemoteControl? "RC: " + vessel.vesselName : vessel.vesselName,
                              GUILayout.Width(ControlsWidth),
                              GUILayout.Height(50)).clampToScreen();
         update_collapsed_rect();
     }
     //handle collapsed state
     if (Collapsed)
     {
         if (ShowOnHover)
         {
             if (!draw_main_window)
             {
                 UnlockControls();
                 var prefix = CFG.Enabled?
                              Colors.Enabled.Tag("<b>TCA</b>") :
                              (VSL.LandedOrSplashed? "<b>TCA</b>" :
                               Colors.Danger.Tag("<b>TCA</b>"));
                 GUI.Label(collapsed_rect, prefix, Styles.boxed_label);
             }
             if (Event.current.type == EventType.Repaint)
             {
                 if (WindowPos.Contains(Event.current.mousePosition))
                 {
                     draw_main_window = ShowOnHover_fade_in_timer.TimePassed;
                     if (draw_main_window)
                     {
                         ShowOnHover_fade_out_timer.Reset();
                     }
                 }
                 else
                 {
                     draw_main_window = !ShowOnHover_fade_out_timer.TimePassed;
                     if (!draw_main_window)
                     {
                         ShowOnHover_fade_in_timer.Reset();
                     }
                 }
             }
         }
         else
         {
             UnlockControls();
             draw_main_window = false;
             GUI.Label(collapsed_rect, new GUIContent("TCA", "Push to show Main Window"),
                       CFG.Enabled? Styles.enabled : (VSL.LandedOrSplashed? Styles.white : Styles.danger));
             if (Input.GetMouseButton(0) && collapsed_rect.Contains(Event.current.mousePosition))
             {
                 draw_main_window = true;
                 Collapsed        = false;
             }
             TooltipManager.GetTooltip();
         }
     }
     else
     {
         draw_main_window = true;
     }
     //draw waypoints
     NAV?.DrawWaypoints();
     if (RemoteControl &&
         Event.current.type == EventType.Repaint)
     {
         Markers.DrawWorldMarker(TCA.vessel.transform.position, Colors.Good,
                                 "Remotely Controlled Vessel", NavigationTab.PathNodeMarker, 8);
     }
 }