示例#1
0
        public static void DrawField(Point pt, WindowRect wrBlockAdj)
        {
            int w = TetrisField.width;
            int h = TetrisField.height;

            for (int row = 0; row < h; row++)
            {
                for (int col = 0; col < w; col++)
                {
                    if (((StructBlockStyle)arrField[col + row * w]).isBlock)
                    {
                        Console.ForegroundColor = ((StructBlockStyle)arrField[col + row * w]).color;
                        Console.SetCursorPosition(TetrisField.left + col, TetrisField.top + row);
                        Console.Write("@");
                    }
                    else
                    {
                        Console.SetCursorPosition(TetrisField.left + col, TetrisField.top + row);
                        Console.Write(" ");
                    }
                }
            }

            Console.ResetColor();
        }
示例#2
0
        private void CheckWindowLock()
        {
            if (Display)
            {
                if (MainSystem.NetworkState < ClientState.Running || HighLogic.LoadedSceneIsFlight)
                {
                    RemoveWindowLock();
                    return;
                }

                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;

                var shouldLock = WindowRect.Contains(mousePos);
                if (shouldLock && !IsWindowLocked)
                {
                    InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, "LMP_PlayerStatusLock");
                    IsWindowLocked = true;
                }
                if (!shouldLock && IsWindowLocked)
                {
                    RemoveWindowLock();
                }
            }

            if (!Display && IsWindowLocked)
            {
                RemoveWindowLock();
            }
        }
示例#3
0
        private static Rectangle GetWindowPlacement(IntPtr hWnd)
        {
            WindowRect rect = new WindowRect();

            Win32Ext.GetWindowRect(hWnd, ref rect);
            return(rect);
        }
示例#4
0
        public bool IsCollided(Point pt, WindowRect wrBlockAdj)
        {
            int sx = pt.x - TetrisField.left;
            int sy = pt.y - TetrisField.top;
            int w  = TetrisField.width;

            int blockIndex;
            int fieldIndex;

            for (int row = 0; row < wrBlockAdj.height; row++)
            {
                for (int col = 0; col < wrBlockAdj.width; col++)
                {
                    blockIndex = (wrBlockAdj.left + col) + ((wrBlockAdj.top + row) * BLOCK_SIZE);
                    fieldIndex = ((sx + sy * w) + col) + row * w;

                    if (arrBlock[blockIndex] && ((StructBlockStyle)arrField[fieldIndex]).isBlock)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#5
0
        private void OnGUI()
        {
            if (DisplayingWindow)
            {
                if (Event.current.type == UnityEngine.EventType.KeyUp && Event.current.keyCode == _keybind.Value.MainKey)
                {
                    DisplayingWindow = false;
                    return;
                }

                if (GUI.Button(_screenRect, string.Empty, GUI.skin.box) &&
                    !WindowRect.Contains(Input.mousePosition))
                {
                    DisplayingWindow = false;
                }

                GUI.Box(WindowRect, GUIContent.none, new GUIStyle {
                    normal = new GUIStyleState {
                        background = WindowBackground
                    }
                });
                WindowRect = GUILayout.Window(-69, WindowRect, MultiplayerWindow, "Multiplayer Mod");
                EatInputInRect(WindowRect);
            }
            if (DisplayingChat)
            {
                GUI.Box(ChatRect, GUIContent.none, new GUIStyle {
                    normal = new GUIStyleState {
                        background = ChatBackground
                    }
                });
                ChatRect = GUILayout.Window(-70, ChatRect, ChatWindow, "Chat");
                EatInputInRect(ChatRect);
            }
        }
示例#6
0
        internal override void OnGUIEvery()
        {
            if (Visible && !UIHidden)
            {
                Boolean oldMouseOver = MouseOver;
                MouseOver = (Event.current.type == EventType.repaint) && WindowRect.Contains(Event.current.mousePosition);

                if (oldMouseOver != MouseOver)
                {
                    if (MouseOver)
                    {
                        OnMouseEnter();
                    }
                    else
                    {
                        OnMouseLeave();
                    }
                }

                //Heres where all the line stuff goes - still need to hide it on F2
                Single WindowEndX = WindowRect.x + 5;
                if (LeftSide)
                {
                    WindowEndX = WindowRect.x + WindowRect.width - 5;
                }
                Single WindowEndY = Screen.height - WindowRect.y - (WindowRect.height / 2);
                Drawing.DrawLine(new Vector2((Single)PartScreenPos.x, Screen.height - (Single)PartScreenPos.y),
                                 new Vector2(WindowEndX, Screen.height - WindowEndY), colorLineCurrent, 2);
            }
            base.OnGUIEvery();
        }
示例#7
0
        public static Rect GetWindowRect()
        {
            var _rect = new WindowRect();

            GetWindowRect(GetWindow(), ref _rect);
            return(new Rect(_rect.x, _rect.y, _rect.width, _rect.height));
        }
示例#8
0
        public void SendToField(Point pt, WindowRect wrBlockAdj)
        {
            // This function sends the block data to field.
            int blockIndex;
            int fieldIndex;

            for (int row = 0; row < wrBlockAdj.height; row++)
            {
                for (int col = 0; col < wrBlockAdj.width; col++)
                {
                    blockIndex = (wrBlockAdj.left + col) +
                                 (wrBlockAdj.top + row) *
                                 Block.Size;
                    fieldIndex = (pt.x - TetrisField.left + col) +
                                 (pt.y - TetrisField.top + row) *
                                 TetrisField.width;

                    if (arrBlock[blockIndex])
                    {
                        arrField[fieldIndex] = new StructBlockStyle(Block.Color(Block.Type), true);
                    }
                }
            }

            ProcessRows();
        }
示例#9
0
        public void Preview(Point pt, StructBlock structBlock)
        {
            // shows a preview of a block
            WindowRect wrBlockAdj = new WindowRect();

            bool[] arrData = GetBlockData(structBlock);

            //  retrieve the exact measurement of the block
            // so we can able to draw the block in correct position.
            Adjustment(ref wrBlockAdj, arrData);

            Console.ForegroundColor = Color(structBlock.type);
            for (int row = wrBlockAdj.top; row < wrBlockAdj.top + wrBlockAdj.height; row++)
            {
                for (int col = wrBlockAdj.left; col < wrBlockAdj.left + wrBlockAdj.width; col++)
                {
                    if (arrData[col + row * BLOCK_SIZE])
                    {
                        Console.SetCursorPosition(pt.x + col - wrBlockAdj.left - wrBlockAdj.width / 2,
                                                  pt.y + row - wrBlockAdj.top - wrBlockAdj.height / 2);
                        Console.Write("#");
                    }
                }
            }
            Console.ResetColor();
        }
示例#10
0
        void mouse_OnMouseActivity(object sender, MouseEventArgs e)
        {
            if (flag > 0)
            {
                this.Text = string.Format("Capture({0},{1})", e.X, e.Y);
                if (((e.Button == System.Windows.Forms.MouseButtons.Left) ||
                     (e.Button == System.Windows.Forms.MouseButtons.Right)) && e.Clicks > 0)
                {
                    int  hdl  = NativeMethods.WindowFromPoint(e.X, e.Y);
                    RECT rect = new RECT();
                    NativeMethods.GetWindowRect(new IntPtr(hdl), ref rect);
                    if (flag < 10)
                    {
                        var wnd_rect = new WindowRect(hdl, rect.Top, rect.Left, rect.Right - rect.Left, rect.Bottom - rect.Top);
                        Capture(flag, wnd_rect);
                    }
                    else
                    {
                        Capture(flag, new Point(e.X, e.Y));
                    }


                    flag = 0;
                    mouse.Stop();
                }
            }
        }
示例#11
0
        /// <summary> TopMost,在子线程中设置TopMost=true不管用,用这个api设置就可以
        /// </summary>
        /// <param name="hWnd"></param>
        public static void SetTopomost(IntPtr hWnd)
        {
            WindowRect rect = new WindowRect();

            GetWindowRect(hWnd, out rect);
            SetWindowPos(hWnd, (IntPtr)HWND_TOPMOST, rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, 0);
        }
示例#12
0
        public void Update()
        {
            Vector2 mouse = Input.mousePosition;

            mouse.y = Screen.height - mouse.y;

            if (Input.GetMouseButton(0))
            {
                if (!WindowRect.Contains(mouse))
                {
                    Visible = false;
                    return;
                }
            }
            else
            {
                return;
            }

            mouse -= WindowRect.position;

            if (hueBarRect.Contains(mouse))
            {
                currentHSV.H = (1.0f - Mathf.Clamp01((mouse.y - hueBarRect.y) / hueBarRect.height)) * 360.0f;
                UpdateColorTexture();
            }

            if (colorPickerRect.Contains(mouse))
            {
                currentHSV.S = Mathf.Clamp01((mouse.x - colorPickerRect.x) / colorPickerRect.width);
                currentHSV.V = Mathf.Clamp01((mouse.y - colorPickerRect.y) / colorPickerRect.height);
            }
        }
示例#13
0
        private bool IsRectVisibleOnScreen(WindowRect windowRect, Window w)
        {
            int minimumVisiblePixels = 10;
            var source         = PresentationSource.FromVisual(w);
            var toDeviceMatrix = source.CompositionTarget.TransformToDevice;

            Rect rect           = new Rect(windowRect.Left, windowRect.Top, windowRect.Width, windowRect.Height);
            var  pixelRect      = Rect.Transform(rect, toDeviceMatrix);
            var  pixelRectangle =
                new System.Drawing.Rectangle(
                    (int)pixelRect.X,
                    (int)pixelRect.Y,
                    (int)pixelRect.Width,
                    (int)pixelRect.Height
                    );

            foreach (var screen in System.Windows.Forms.Screen.AllScreens)
            {
                var intersection = pixelRectangle;
                intersection.Intersect(screen.WorkingArea);
                if (intersection.Width >= minimumVisiblePixels &&
                    intersection.Height >= minimumVisiblePixels)
                {
                    // sufficiently visible on at least one screen
                    return(true);
                }
            }

            // Window rect does not overlap any current screens
            return(false);
        }
        internal WindowRect GetRect()
        {
            WindowRect rect = new WindowRect();

            rect.Height = wordsManager.GetConfig().ListWidowHeight;
            rect.Width  = wordsManager.GetConfig().ListWidowWidth;
            rect.SetRightBottom();
            return(rect);
        }
示例#15
0
        internal WindowRect GetRect()
        {
            WindowRect rect = new WindowRect();

            rect.Height = config.WidowHeight;
            rect.Width  = config.WidowWidth;
            rect.SetRightBottom();
            return(rect);
        }
        internal override void Start()
        {
            DragEnabled = true;
            WindowRect.Set((Screen.width - WindowWidth) / 4, (Screen.height - WindowHeight) / 2, WindowWidth, WindowHeight);

            WindowCaption = "Extensive Engineer Report";

            OnAppLauncherReady();
        }
示例#17
0
        public static Rectangle GetWindowRect(IntPtr hWnd)
        {
            WindowRect rect = new WindowRect();

            GetWindowRect(hWnd, out rect);

            return(new Rectangle(rect.left, rect.top,
                                 rect.right - rect.left, rect.bottom - rect.top));
        }
示例#18
0
        public WindowRect Rotate(RotationEnum newAngle)
        {
            WindowRect wrBlock = new WindowRect();

            Angle = newAngle;
            Build();
            Adjustment(ref wrBlock);

            return(wrBlock);
        }
示例#19
0
        /// <summary>
        /// Captures an Oculus Mirror screenshot.
        /// </summary>
        private void CaptureScreenshot()
        {
            Process[] processes = Process.GetProcessesByName("GalGun2-Win64-Shipping");
            Process   proc      = null;

            if (processes.Length > 0)
            {
                proc = processes[0];
            }
            else
            {
                return;
            }
            var rect = new WindowRect();

            APIMethods.GetClientRect(proc.MainWindowHandle, ref rect);

            int width  = rect.Right - rect.Left;
            int height = rect.Bottom - rect.Top;

            Bitmap   bmp       = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Graphics graphics  = Graphics.FromImage(bmp);
            IntPtr   hdcBitmap = graphics.GetHdc();

            APIMethods.PrintWindow(proc.MainWindowHandle, hdcBitmap, 1);

            graphics.ReleaseHdc();
            graphics.Dispose();

            string picFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

            try
            {
                string targetFolder = picFolder + @"\GG2VR";
                if (!Directory.Exists(targetFolder))
                {
                    Directory.CreateDirectory(targetFolder);
                }

                DateTime dt   = DateTime.Now;
                string   fn   = dt.ToString("yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture);
                int      add  = 1;
                string   addS = "";
                while (File.Exists(targetFolder + "\\" + fn + addS + ".png"))
                {
                    add++;
                    addS = add.ToString();
                }
                bmp.Save(targetFolder + "\\" + fn + addS + ".png", ImageFormat.Png);
            } catch (Exception ex)
            {
                //Apparently I'm not allowed to write the library. Ah well.
            }
        }
示例#20
0
        protected override void DrawWindowPre(int id)
        {
            if (bigmap != null)
            {
                mapTypeTitle = SCANmapType.mapTypeNames[(int)bigmap.MType];
            }
            else
            {
                mapTypeTitle = "";
            }

            WindowCaption = string.Format("{0} Map of {1}", mapTypeTitle, bigmap.Body.theName);

            //Disable any errant drop down menus
            if (!drop_down_open)
            {
                projection_drop_down = false;
                mapType_drop_down    = false;
                resources_drop_down  = false;
                planetoid_drop_down  = false;
            }

            //Lock space center click through
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }

            //Lock tracking scene click through
            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }
        }
示例#21
0
        /// <summary>
        /// Checks to see if the mouse is over the window.
        /// Requires the window to be visible
        /// </summary>
        /// <returns>True if over the window, false otherwise.</returns>
        protected bool checkMouseOver()
        {
            if (!IsVisible)
            {
                return(false);
            }
            Vector2 mousePos = Input.mousePosition;

            mousePos.y = Screen.height - mousePos.y;
            return(WindowRect.Contains(mousePos));
        }
        public static WindowRect GetWindowRectangle(Window window)
        {
            var rect = new WindowRect();

            if (window == null)
            {
                return(rect);
            }

            var interop = new WindowInteropHelper(window);

            return(interop.Handle != IntPtr.Zero ? GetWindowRectangle(interop.Handle) : rect);
        }
示例#23
0
 internal override void Start()
 {
     DragEnabled = true;
     WindowRect.Set((Screen.width - WindowWidth) / 4, (Screen.height - WindowHeight) / 2, WindowWidth, WindowHeight);
     WindowCaption = nameof(ShipSections);
     if (ApplicationLauncher.Instance != null && ApplicationLauncher.Ready)
     {
         OnAppLauncherReady();
     }
     else
     {
         GameEvents.onGUIApplicationLauncherReady.Add(OnAppLauncherReady);
     }
 }
示例#24
0
        void InputLockMonitor()
        {
            MouseOverWindow = Visible && WindowRect.Contains(Event.current.mousePosition);

            //If the setting is on and the mouse is over any window then lock it
            if (MouseOverWindow && !InputLockExists)
            {
                Boolean AddLock = false;
                switch (HighLogic.LoadedScene)
                {
                case GameScenes.SPACECENTER: AddLock = !(InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None); break;

                case GameScenes.EDITOR: AddLock = !(InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None); break;

                case GameScenes.FLIGHT: AddLock = !(InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None); break;

                case GameScenes.TRACKSTATION:
                    break;

                default:
                    break;
                }
                if (AddLock)
                {
                    LogFormatted_DebugOnly("AddingLock-{0}", "KSPTipsControlLock");

                    switch (HighLogic.LoadedScene)
                    {
                    case GameScenes.SPACECENTER: InputLockManager.SetControlLock(ControlTypes.KSC_FACILITIES, "KSPTipsControlLock"); break;

                    case GameScenes.EDITOR: InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK, "KSPTipsControlLock"); break;

                    case GameScenes.FLIGHT: InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "KSPTipsControlLock"); break;

                    case GameScenes.TRACKSTATION:
                        break;

                    default:
                        break;
                    }
                    InputLockExists = true;
                }
            }
            //Otherwise make sure the lock is removed
            else if (!MouseOverWindow && InputLockExists)
            {
                RemoveInputLock();
            }
        }
示例#25
0
        private WindowRect InitWindowRect(WindowRect rect)
        {
            if (rect == null || !IsRectVisibleOnScreen(rect, Owner))
            {
                rect = new WindowRect();
                WindowStartupLocation = WindowStartupLocation.CenterOwner;

                LocationChanged += ModelessChildWindow_LocationChanged;
                SizeChanged     += ModelessChildWindow_SizeChanged;
            }
            else
            {
                WindowStartupLocation = WindowStartupLocation.Manual;
                Loaded += ModelessChildWindow_Loaded;
            }

            SavedWindowRect = rect;
            return(rect);
        }
示例#26
0
        Configuration createConfig()
        {
            var config = new Configuration();
            var rect   = new WindowRect
            {
                Left   = (int)_window.Left,
                Top    = (int)_window.Top,
                Width  = (int)_window.ActualWidth,
                Height = (int)_window.ActualHeight
            };

            config.WindowRect_ = rect;

            foreach (var test in _tests)
            {
                config.AssemblyTests.Add(test.Config);
            }
            return(config);
        }
示例#27
0
        protected override void DrawWindowPre(int id)
        {
            //Lock space center click through
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }

            //Lock tracking scene click through
            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    InputLockManager.RemoveControlLock(lockID);
                    controlLock = false;
                }
            }

            if (!popup)
            {
                warningBoxOne   = false;
                warningBoxAll   = false;
                warningResource = false;
            }
        }
示例#28
0
        /// <summary>
        /// Construct a ModelessChildWindow.
        /// </summary>
        /// <param name="viewParent">A UI object in the Dynamo visual tree.</param>
        /// <param name="rect">A reference to the Rect object that will store the window's position during this session.</param>
        public ModelessChildWindow(DependencyObject viewParent, ref WindowRect rect)
        {
            Owner          = WpfUtilities.FindUpVisualTree <DynamoView>(viewParent);
            Owner.Closing += OwnerWindow_Closing;

            if (rect == null || !IsRectVisibleOnScreen(rect, Owner))
            {
                rect = new WindowRect();
                WindowStartupLocation = WindowStartupLocation.CenterOwner;

                LocationChanged += ModelessChildWindow_LocationChanged;
                SizeChanged     += ModelessChildWindow_SizeChanged;
            }
            else
            {
                WindowStartupLocation = WindowStartupLocation.Manual;
                Loaded += ModelessChildWindow_Loaded;
            }

            SavedWindowRect = rect;
        }
示例#29
0
        private void btn_capture_sale_all_Click(object sender, EventArgs e)
        {
            if (process != null)
            {
                WindowRect wnd_rect;
                RECT       main = new RECT();
                NativeMethods.GetWindowRect(process.MainWindowHandle, ref main);

                for (int id = 5; id <= 8; id++)
                {
                    switch (id)
                    {
                    case 5:
                        wnd_rect = TaskManager.Instance.Configuration.TradeInfoEntity.SaleInfo.CodeRect;
                        break;

                    case 6:
                        wnd_rect = TaskManager.Instance.Configuration.TradeInfoEntity.SaleInfo.PriceRect;
                        break;

                    case 7:
                        wnd_rect = TaskManager.Instance.Configuration.TradeInfoEntity.SaleInfo.AmountRect;
                        break;

                    case 8:
                        wnd_rect = TaskManager.Instance.Configuration.TradeInfoEntity.SaleInfo.ConfirmRect;
                        break;

                    default:
                        return;
                    }
                    WindowRect wnd_rect_temp = new WindowRect(0,
                                                              main.Top + wnd_rect.Top,
                                                              main.Left + wnd_rect.Left,
                                                              wnd_rect.Width,
                                                              wnd_rect.Height);
                    Capture(id, wnd_rect_temp);
                }
            }
        }
示例#30
0
        public void Draw(Point pt, WindowRect wrBlockAdj, Boolean isRotateUpdate)
        {
            // Draw the block.
            if (!Location.x.Equals(pt.x) || !Location.y.Equals(pt.y) || isRotateUpdate)
            {
                TetrisClass.DrawField(pt, wrBlockAdj);
                Console.ForegroundColor = Color(Type);
                for (int row = wrBlockAdj.top; row < wrBlockAdj.top + wrBlockAdj.height; row++)
                {
                    for (int col = wrBlockAdj.left; col < wrBlockAdj.left + wrBlockAdj.width; col++)
                    {
                        if (arrBlock[col + row * BLOCK_SIZE])
                        {
                            Console.SetCursorPosition(pt.x + col - wrBlockAdj.left, pt.y + row - wrBlockAdj.top);
                            Console.Write("#");
                        }
                    }
                }
                Console.ResetColor();

                Location = pt;
            }
        }
示例#31
0
		private void SaveWindowSize(object sender, EventArgs e)
		{
			try
			{
				string key = "WindowRect." + _model.GetType().AssemblyQualifiedName;
				var windowRect = new WindowRect()
				{
					Left = Left,
					Top = Top,
					Width = Width,
					Height = Height
				};
				RegistrySettingsHelper.SetWindowRect(key, windowRect);
			}
			catch (Exception ex)
			{
				Logger.Error(ex, "WindowBaseView.SaveWindowSize");
			}
		}