public WindowImpl() { _touchDevice = new TouchDevice(); _mouseDevice = new WindowsMouseDevice(); #if USE_MANAGED_DRAG _managedDrag = new ManagedWindowResizeDragHelper(this, capture => { if (capture) { UnmanagedMethods.SetCapture(Handle.Handle); } else { UnmanagedMethods.ReleaseCapture(); } }); #endif _windowProperties = new WindowProperties { ShowInTaskbar = false, IsResizable = true, Decorations = SystemDecorations.Full }; _rendererLock = new ManagedDeferredRendererLock(); var glPlatform = AvaloniaLocator.Current.GetService <IPlatformOpenGlInterface>(); var compositionConnector = AvaloniaLocator.Current.GetService <WinUICompositorConnection>(); _isUsingComposition = compositionConnector is { } &&
public static void MoveWindow(IntPtr hWnd, int x, int y) { WindowProperties winProp = new WindowProperties(); winProp = GetWindowProperties(hWnd); SetWindowPos(hWnd, new IntPtr(0), x, y, winProp.Width, winProp.Height, 0x0040); }
public static object InstantiateWindow(WindowProperties properties) { System.Windows.Forms.Form form = new System.Windows.Forms.Form(); form.Text = properties.title; form.Size = new System.Drawing.Size(properties.width, properties.height); return(form); }
public WindowImpl() { _touchDevice = new TouchDevice(); _mouseDevice = new WindowsMouseDevice(); #if USE_MANAGED_DRAG _managedDrag = new ManagedWindowResizeDragHelper(this, capture => { if (capture) UnmanagedMethods.SetCapture(Handle.Handle); else UnmanagedMethods.ReleaseCapture(); }); #endif _windowProperties = new WindowProperties { ShowInTaskbar = false, IsResizable = true, Decorations = SystemDecorations.Full }; _rendererLock = new ManagedDeferredRendererLock(); CreateWindow(); _framebuffer = new FramebufferManager(_hwnd); if (Win32GlManager.EglFeature != null) _gl = new EglGlPlatformSurface(Win32GlManager.EglFeature.DeferredContext, this); Screen = new ScreenImpl(); _nativeControlHost = new Win32NativeControlHost(this); s_instances.Add(this); }
public static void Create(WindowProperties properties, object deviceContext) { switch (GetRenderAPI()) { case RenderAPI.OPENGL: context = new GLContext(properties, deviceContext); break; } }
public WindowFinder() { window = new WindowProperties(); this.MouseDown += new MouseEventHandler(WindowFinder_MouseDown); this.Size = new Size(32, 32); InitializeComponent(); }
public NuGenWindowFinder() { window = new WindowProperties(); this.MouseDown += new MouseEventHandler(WindowFinder_MouseDown); this.Size = new Size(32, 32); InitializeComponent(); }
public WindowFinder() { Window = new WindowProperties(); MouseDown += WindowFinder_MouseDown; Size = new Size(32, 32); InitializeComponent(); }
private void Init(WindowProperties props) { data.Title = props.Title; data.Width = props.Width; data.Height = props.Height; Title = props.Title; Size = new OpenTK.Mathematics.Vector2i(props.Width, props.Height); GL.Viewport(0, 0, Width, Height); Resize += e => { data.Width = e.Width; data.Height = e.Height; data.EventCallback(new WindowResizeEvent(e.Width, e.Height)); }; Closing += e => { data.EventCallback(new WindowCloseEvent()); }; KeyDown += e => { data.EventCallback(new KeyPressedEvent((int)e.Key, e.Control, e.Alt, e.Shift)); }; KeyUp += e => { data.EventCallback(new KeyReleasedEvent((int)e.Key, e.Control, e.Alt, e.Shift)); }; TextInput += e => { data.EventCallback(new TextInputEvent(e.Unicode)); }; MouseDown += e => { data.EventCallback(new MouseButtonPressedEvent(e.Button)); }; MouseUp += e => { data.EventCallback(new MouseButtonReleasedEvent(e.Button)); }; MouseWheel += e => { data.EventCallback(new MouseScrolledEvent(e.OffsetX, e.OffsetY)); }; MouseMove += e => { data.EventCallback(new MouseMovedEvent(e.X, e.Y)); }; }
public AppConfig() { CachedServers = new List <NetworkServerInfo>(); PTTConfiguration = new PTTConfiguration(); ToggleDisplayConfiguration = new ToggleDisplayConfiguration(); RecentConnectionInfo = new List <ConnectInfo>(); VisualClientIPs = new List <string>(); ClientWindowProperties = new WindowProperties(); }
public WindowFinder() { window = new WindowProperties(); this.MouseDown += new MouseEventHandler(WindowFinder_MouseDown); this.Size = new Size(32, 32); InitializeComponent(); this.BackgroundImage = SystemUtils.LoadImage("Hawkeye.gif"); }
/// <summary> /// Retrieves the value to set to the <see cref="MinusOneMinusButtonFlags"/> property. /// </summary> /// <param name="buttonFlags">The currently pressed buttons at this moment in time.</param> private int GetMinusOneButtonFlags(ButtonFlags buttonFlags) { // This function returns 0 if no window is active. if (WindowProperties.IsWindowActivated(Program.GameProcess.Process.MainWindowHandle)) { return(-1 - (int)buttonFlags); } return(0); }
public void PreInit() { guiWindowProperties = new WindowProperties() { id = 0, isOpened = true, windowFunction = OnGUI, closedFunction = OnGUIClosed, windowRect = new Rect(15, 15, 100, 300), }; }
/// <summary> /// Called upon the resizing of the game window. /// </summary> private static void GameWindowResizeDelegate() { // Retrieve window size of target window. Point windowSize = WindowProperties.GetClientAreaSize2(GameProcess.Process.MainWindowHandle); // Resize and/or move elements or needed. // Implementation of this is up to you. // Well, except this, because the old factory for _textFormat will become outdated and will throw a nice fat exception. _initialized = false; }
/// <summary> /// Your own user code starts here. /// If this is your first time, do consider reading the notice above. /// It contains some very useful information. /// </summary> public static void Init() { /* * Reloaded Mod Loader Sample: Universal Borderless Windowed * Architectures supported: X86, X64 * * Waits until the game or process spawns off its initial border and then changes the * window border style of the application to borderless using the Windows API. */ /* * We create our own thread and run it in the background because Reloaded-Loader explicitly waits * for the mod's thread to return before continuing to load other mods and ultimately the game. * * For anything we want to do in the background during initialization with Reloaded or you need to wait * for the process/game for some reason, you are requires to start a background thread. */ Thread setBorderlessThread = new Thread ( () => { // Loop infinitely until a window handle is found. while (GameProcess.Process.MainWindowHandle == IntPtr.Zero) { // Sleep the thread for a sensible amount of time. Thread.Sleep(2000); } // Get the window size. Point windowSize = WindowProperties.GetWindowSize(GameProcess.Process.MainWindowHandle); Structures.WinapiRectangle windowLocation = WindowProperties.GetWindowRectangle(GameProcess.Process.MainWindowHandle); // Get the game's Window Style. uint windowStyle = (uint)GetWindowLongPtr(GameProcess.Process.MainWindowHandle, GWL_STYLE); // Change the window style. windowStyle &= ~WS_BORDER; windowStyle &= ~WS_CAPTION; windowStyle &= ~WS_MAXIMIZEBOX; windowStyle &= ~WS_MINIMIZEBOX; // Set the window style. SetWindowLongPtr(GameProcess.Process.MainWindowHandle, GWL_STYLE, (IntPtr)windowStyle); // Set the window size. WindowFunctions.MoveWindow(GameProcess.Process.MainWindowHandle, windowLocation.LeftBorder, windowLocation.TopBorder, windowSize.X, windowSize.Y, true); } ); setBorderlessThread.Start(); }
/// <summary> /// Gets the properties of the window. It returns the window coordinates, height and width. /// </summary> /// <param name="windowHandle">The handle of the window</param> public static WindowProperties GetWindowProperties(IntPtr windowHandle) { RECT rectangle; WindowProperties windowProperties = new WindowProperties(); if (GetWindowRect(windowHandle, out rectangle)) { windowProperties.X = rectangle.Left; windowProperties.Y = rectangle.Top; windowProperties.Width = rectangle.Right - rectangle.Left + 1; windowProperties.Height = rectangle.Bottom - rectangle.Top + 1; } return(windowProperties); }
/// <summary> Код обработчика закрытия окна </summary> private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MessageBoxResult messageBoxResult = MessageBox.Show(this, "Сохранить данные перед выходом из программы?", "Сохранить?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Cancel) { e.Cancel = true; return; } else if (messageBoxResult == MessageBoxResult.Yes) { this.SaveToNewFileMenuItem_Click(null, null); } WindowProperties.SaveProperties(this); }
public WindowImpl() { _touchDevice = new TouchDevice(); _mouseDevice = new WindowsMouseDevice(); #if USE_MANAGED_DRAG _managedDrag = new ManagedWindowResizeDragHelper(this, capture => { if (capture) { UnmanagedMethods.SetCapture(Handle.Handle); } else { UnmanagedMethods.ReleaseCapture(); } }); #endif _windowProperties = new WindowProperties { ShowInTaskbar = false, IsResizable = true, Decorations = SystemDecorations.Full }; _rendererLock = new ManagedDeferredRendererLock(); CreateWindow(); _framebuffer = new FramebufferManager(_hwnd); var glPlatform = AvaloniaLocator.Current.GetService <IPlatformOpenGlInterface>(); if (glPlatform is EglPlatformOpenGlInterface egl) { _gl = new EglGlPlatformSurface(egl, this); } else if (glPlatform is WglPlatformOpenGlInterface wgl) { _gl = new WglGlPlatformSurface(wgl.PrimaryContext, this); } Screen = new ScreenImpl(); _nativeControlHost = new Win32NativeControlHost(this); s_instances.Add(this); }
/// <summary> /// Executed when the user resizes the window (in the case of a window style hack). /// </summary> private static void WindowEventDelegateImpl(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime) { // Filter out non-HWND changes, e.g. items within a listbox. // Technically speaking shouldn't be necessary, though just in case. if (idObject != 0 || idChild != 0) { return; } // Set the size and location of the external overlay to match the game/target window. // Only if an object has changed location, shape, or size. if (eventType == 0x800B) { var resolution = WindowProperties.GetClientAreaSize(GameProcess.Process.MainWindowHandle); * _resolutionX = resolution.RightBorder; * _resolutionY = resolution.BottomBorder; } }
public GLContext(WindowProperties properties, object deviceContext) { hDc = WinUser.GetDC((IntPtr)deviceContext); IntPtr hrc = WinGDI.wglCreateContext(hDc); if (hrc.ToInt32() != 0) { if (!WinGDI.wglMakeCurrent(hDc, hrc)) { Log.Error("Failed setting OpenGL context!"); Log.Assert(() => false); } } else { Log.Error("Failed creating OpenGL context!"); Log.Assert(() => false); } }
/// <summary> /// A crashfix for running Heroes at extreme resolutions, patches the resolution the rasters are created at. /// </summary> /// <returns></returns> private static int TObjCameraInitHook(int *thisPointer, int cameraLimit) { int resolutionXBackup = *_resolutionX; int resolutionYBackup = *_resolutionY; int greaterResolution = resolutionXBackup > resolutionYBackup ? resolutionXBackup : resolutionYBackup; // Get the window size. Structures.WinapiRectangle windowLocation = WindowProperties.GetWindowRectangle(GameProcess.Process.MainWindowHandle); // Set the window size. WindowFunctions.MoveWindow(GameProcess.Process.MainWindowHandle, windowLocation.LeftBorder, windowLocation.TopBorder, greaterResolution, (int)(greaterResolution / OriginalAspectRatio), false); int result = _someTitlecardCreateHook.OriginalFunction(thisPointer, cameraLimit); // Re-set the window size. WindowFunctions.MoveWindow(GameProcess.Process.MainWindowHandle, windowLocation.LeftBorder, windowLocation.TopBorder, resolutionXBackup, resolutionYBackup, false); return(result); }
/// <summary> /// Sets the overlay window location to overlap the window of the game instance. /// Both moves the window to the game location and sets appropriate height and width for the window. /// </summary> public void AdjustOverlayToGameWindow() { // Get game client edges. Structures.WinapiRectangle gameClientSize = WindowProperties.GetClientRectangle(GameWindowHandle); // Set overlay edges to the edges of the client area. Left = gameClientSize.LeftBorder; Top = gameClientSize.TopBorder; // Set width and height. Width = gameClientSize.RightBorder - gameClientSize.LeftBorder; Height = gameClientSize.BottomBorder - gameClientSize.TopBorder; // Call resize delegate. if (lastWindowSize != WindowProperties.GetClientAreaSize2(GameWindowHandle)) { GameWindowResizeDelegate?.Invoke(); } lastWindowSize = WindowProperties.GetClientAreaSize2(GameWindowHandle); }
private void RefreshDialog() { bool success = RefreshJumpItems(); EnableControls(success); textFolder.Text = ShortcutsFolder; string format = success ? "Jumper - {0}" : "Jumper"; Text = String.Format(format, ShortcutsFolder); if (success) { WindowProperties.SetWindowProperty(GetHandle(), SystemProperties.System.AppUserModel.PreventPinning, false); TaskbarManager.Instance.ApplicationId = "Jumper@" + ShortcutsFolder; RefreshJumpList(GetHandle(), ShortcutsFolder, RefreshOnTop); } RefreshCommand(); }
public WindowFinder() { InitializeComponent(); window = new WindowProperties(); MouseDown += WindowFinder_MouseDown; }
public bool PreFilterMessage(ref Message m) { if (m.Msg == WinApi.WM_MOUSEMOVE && autoHideCursor) { Point p = new Point(m.LParam.ToInt32()); WinApi.ClientToScreen(m.HWnd, ref p); if (p != lastMousePoint) { lastMousePoint = p; ShowCursor(); hideCursorTimer.Reset(); } return(false); // Don't block this message } else if (m.Msg == WinApi.WM_MOUSEWHEEL && dispatchMouseWheel) { Point p = new Point(m.LParam.ToInt32()); // First, see whether there's an open combobox list popup that must be handled differently WindowProperties prop = new WindowProperties(); prop.ProcessId = new Window(m.HWnd).ProcessId; prop.ClassName = "ComboLBox"; prop.Visible = true; Window popup; if (Window.TryFind(prop, out popup)) { // Found a combobox popup window, check coordinates if (popup.Rectangle.Contains(p)) { // Mouse cursor is over visible combo listbox popup, let the message pass return(false); } // Mouse cursor is outside the popup, block the message // (Do not scroll the popup because the mouse is not in it; // but also do not scroll anything else outside the popup) return(true); } // Regular window surface: find the deepest control below the mouse cursor Control control = Form.ActiveForm; while (control != null) { Point clientPoint = control.PointToClient(p); Control subControl = control.GetChildAtPoint(clientPoint, GetChildAtPointSkip.Invisible); if (subControl == null || subControl is ScrollBar || subControl is ComboBox) { break; } //System.Diagnostics.Debug.WriteLine("Found control in " + control.Name + " at " + clientPoint + ": " + subControl.Name); control = subControl; } if (control != null) { if (control.Handle == m.HWnd) { return(false); // The message already arrived for this control, let it pass } // Search up the parents for a scrollable panel Control c = control; while (!(c is Form)) { Panel panel = c as Panel; if (panel != null && panel.AutoScroll) { Point scrollPos = panel.AutoScrollPosition; // Position report is always negative, but new values must be set positive... scrollPos.X = -scrollPos.X; scrollPos.Y = -scrollPos.Y; int delta = m.WParam.ToInt32() >> 16; delta /= 120; // Convert to number of wheel notches scrollPos.Y += -delta * 20; // Delta value is "negative" (neg is downwards, pos is upwards) panel.AutoScrollPosition = scrollPos; return(true); // Block this message } c = c.Parent; } // NOTE: Possible performance improvement: Flag the re-posted message so that we can // recognise it faster when it re-arrives here and we can let it pass. // Use either a very high delta value (HIWORD(wParam)) or one of the modifier // keys MK_* (LOWORD(wParam)) or an unassigned bit of lParam. //System.Diagnostics.Debug.WriteLine("Re-posting message to " + control.Name); WinApi.PostMessage(control.Handle, WinApi.WM_MOUSEWHEEL, m.WParam, m.LParam); // If IMessageModifyAndFilter wasn't System.Windows.Form's internal, we could just // implement that interface, modify the message and let it pass changed. But so we // need to block the message and send a new one that we're going to let pass then. } return(true); // Block this message } return(false); // Don't block this message }
public WindowsWindow(WindowProperties properties) { Init(properties); }
private void Init(WindowProperties properties) { ProfilerTimer.Profile(() => { Logger.Info("Initializing a window for Windows..."); //Initialize glfw if it hasn't already if (windowCount == 0) { bool success = Glfw.Init(); Debug.Assert(success, "GLFW failed to init!"); Glfw.SetErrorCallback(ErrorHandler); } #if DEBUG if (RenderingAPI.GetRenderingAPI() == RenderingAPIType.OpenGL) { Glfw.WindowHint(Hint.OpenglDebugContext, true); } #endif //Set the properties and create the window windowProperties = properties; { ProfilerTimer.Profile("GLFW Create Window", () => { window = new NativeWindow(properties.Width, properties.Height, properties.Title); windowCount++; }); } //Create context context = RenderingAPI.GetRenderingAPI() switch { RenderingAPIType.OpenGL => new OpenGLContext(window), _ => throw new ArgumentOutOfRangeException() }; //Init the context context.Init(); SetVSync(properties.VSync); //Setup input Input.KeyInputImpl = new WindowsInput(window); //GLFW callbacks window.Closed += (sender, args) => OnEvent?.Invoke(new WindowCloseEvent()); window.SizeChanged += delegate(object sender, SizeChangeEventArgs args) { windowProperties.Width = args.Size.Width; windowProperties.Height = args.Size.Height; OnEvent?.Invoke(new WindowResizedEvent(args.Size.Width, args.Size.Height)); }; window.KeyAction += delegate(object sender, KeyEventArgs args) { switch (args.State) { case InputState.Release: OnEvent?.Invoke(new KeyReleasedEvent((KeyCode)args.Key)); break; case InputState.Press: OnEvent?.Invoke(new KeyPressedEvent((KeyCode)args.Key)); break; case InputState.Repeat: OnEvent?.Invoke(new KeyPressedEvent((KeyCode)args.Key, 1)); break; default: throw new ArgumentOutOfRangeException(nameof(args.State), args.State, null); } }; window.MouseButton += delegate(object sender, MouseButtonEventArgs args) { switch (args.Action) { case InputState.Press: OnEvent?.Invoke(new MouseButtonPressedEvent((int)args.Button)); break; case InputState.Release: OnEvent?.Invoke(new MouseButtonReleasedEvent((int)args.Button)); break; } }; window.MouseScroll += (sender, args) => OnEvent?.Invoke(new MouseScrollEvent((float)args.X, (float)args.Y)); window.MouseMoved += (sender, args) => OnEvent?.Invoke(new MouseMovedEvent((float)args.X, (float)args.Y)); Logger.Debug("Created a window for Windows ({@Width}x{@Height}, {@VSync})", properties.Width, properties.Height, properties.VSync); }); }
public void StartModal(int queueActionId, DialogType type, WindowProperties windowProperties, Action<int, UserResponse> resultCallback, float closeTimer, float openBusyDelay) { currentActionId = queueActionId; this.windowProperties = windowProperties; this.type = type; this.resultCallback = resultCallback; if(closeTimer > 0.0f) StartCloseTimer(closeTimer); if(openBusyDelay >= 0.0f) StateChanged(openBusyDelay); // override with user defined open busy delay }
public void StartModal(int queueActionId, DialogType type, WindowProperties windowProperties, Action<int, UserResponse> resultCallback, float closeTimer) { StartModal(queueActionId, type, windowProperties, resultCallback, closeTimer, -1.0f); }
public WindowsWindow(WindowProperties props) : base(NativeWindowSettings.Default) { Init(props); }
public ImageLayout() { WindowProperties = new WindowProperties(); InitializeComponent(); }
/// <summary> /// Returns the current aspect ratio obtained by calculating the width and height of the window. /// </summary> /// <returns>The aspect ratio of the current window.</returns> private static float GetCurrentAspectRatio() { var resolution = WindowProperties.GetClientAreaSize(GameProcess.Process.MainWindowHandle); return(resolution.RightBorder / (float)resolution.BottomBorder); }
/// <summary> /// Gets the properties of the window. It returns the window coordinates, height and width. /// </summary> /// <param name="windowHandle">The handle of the window</param> public static WindowProperties GetWindowProperties(IntPtr windowHandle) { RECT rectangle; WindowProperties windowProperties = new WindowProperties(); if (GetWindowRect(windowHandle, out rectangle)) { windowProperties.X = rectangle.Left; windowProperties.Y = rectangle.Top; windowProperties.Width = rectangle.Right - rectangle.Left + 1; windowProperties.Height = rectangle.Bottom - rectangle.Top + 1; } return windowProperties; }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); WindowProperties.SetProperties(this); }