/// <summary> /// Fires when the size of the element changes /// </summary> protected virtual void OnSizeChanged() { SizeChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Triggering the size changed event /// </summary> private void OnSizeChanged() { SizeChanged?.Invoke(this, EventArgs.Empty); }
protected void RecalculateRelativeSize() { relativeSize = new Vector2(NonScaledSize.X, NonScaledSize.Y) / new Vector2(NonScaledParentRect.Width, NonScaledParentRect.Height); recalculateRect = true; SizeChanged?.Invoke(); }
public override void SetFrameSize(CGSize newSize) { base.SetFrameSize(newSize); NeedsNewContext = true; SizeChanged?.Invoke(this, EventArgs.Empty); }
internal void RaiseSizeChanged(SizeChangedEventArgs args) { SizeChanged?.Invoke(this, args); _renderTransform?.UpdateSize(args.NewSize); }
void OnSizeChanged() => SizeChanged?.Invoke(this, EventArgs.Empty);
protected virtual void OnSizeChanged(EventArgs e) { SizeChanged?.Invoke(this, e); }
private Boolean CommenceCopy(List <SourceTarget> fileInfos) { foreach (SourceTarget fileInfo in fileInfos) { if (CancellationToken.IsCancellationRequested) { UIServices.ShowMessageBox("The Copy process was aborted.", String.Empty, Buttons.OK, Icon.Warning); return(true); } String path = IOServices.Path.Combine(fileInfo.TargetFolder.FullName, fileInfo.SourceFile.Name); IFileInfo targetFileInfo = IOServices.GetFileInfo(path); Result result = GetOverwriteResult(fileInfo, targetFileInfo); if (result == Result.Cancel) { return(true); } else if (result == Result.No) { m_Size -= fileInfo.SourceFile.Length; SizeChanged?.Invoke(this, EventArgs.Empty); continue; } else if (result == Result.Yes) { try { if (IOServices.File.Exists(targetFileInfo.FullName)) { IOServices.File.SetAttributes(targetFileInfo.FullName, System.IO.FileAttributes.Normal | System.IO.FileAttributes.Archive); } IOServices.File.Copy(fileInfo.SourceFile.FullName, targetFileInfo.FullName, true); } catch (Exception ex) { Int64 startTicks = DateTime.Now.Ticks; if (UIServices.ShowMessageBox(ex.Message + "\nContinue?", "Continue?", Buttons.YesNo, Icon.Question) == Result.Yes) { Int64 endTicks = DateTime.Now.Ticks; TimeSpan span = new TimeSpan(endTicks - startTicks); CopyPaused?.Invoke(this, new EventArgs <TimeSpan>(span)); continue; } else { return(true); } } ProgressValue += fileInfo.SourceFile.Length; ProgressChanged?.Invoke(this, EventArgs.Empty); } } return(false); }
private void ResetSize() { m_Size = null; SizeChanged?.Invoke(this, EventArgs.Empty); }
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( Macros.GET_X_LPARAM(message.LParam) - _location.X, Macros.GET_Y_LPARAM(message.LParam) - _location.Y ); HitTestEventArgs e = new HitTestEventArgs(p, HitResult.Caption); HitTest(this, e); message.Result = (IntPtr)e.HitResult; } } break; case WM_NCLBUTTONDBLCLK: { MouseDoubleClick?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 2, Macros.GET_X_LPARAM(message.LParam) - _location.X, Macros.GET_Y_LPARAM(message.LParam) - _location.Y, 0)); message.Result = IntPtr.Zero; } break; case WM_NCRBUTTONDOWN: { message.Result = IntPtr.Zero; } break; case WM_NCRBUTTONUP: { if (ContextMenu != null) { ShowContextMenu(new Point(Macros.GET_X_LPARAM(message.LParam), Macros.GET_Y_LPARAM(message.LParam))); } 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 Rectangle(wp.x, wp.y, wp.cx, wp.cy)); 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); LocationChanged?.Invoke(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); SizeChanged?.Invoke(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; // suppress any frame changed events wp.flags &= ~SWP_FRAMECHANGED; Marshal.StructureToPtr(wp, message.LParam, false); message.Result = IntPtr.Zero; } break; default: { base.WndProc(ref message); } break; } }
public override void EnterMessageLoop(bool runInBackground) { IntPtr wmDeleteWindow = XInternAtom(_display, "WM_DELETE_WINDOW", false); XSetWMProtocols(_display, _window, new IntPtr[] { wmDeleteWindow }, 1); IntPtr e = System.Runtime.InteropServices.Marshal.AllocHGlobal(24 * sizeof(long)); bool running = true; while (running) { while (XPending(_display) != 0) { XNextEvent(_display, e); if (XFilterEvent(e, IntPtr.Zero)) { continue; } XAnyEvent anyEvent = (XAnyEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XAnyEvent)); switch ((Event)anyEvent.type) { case Event.ClientMessage: { XClientMessageEvent clientEvent = (XClientMessageEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XClientMessageEvent)); if (clientEvent.l0 == wmDeleteWindow) { bool cancel = false; Closing?.Invoke(this, ref cancel); if (!cancel) { Closed?.Invoke(this); running = false; } } break; } case Event.ConfigureNotify: { XConfigureEvent configureEvent = (XConfigureEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XConfigureEvent)); LocationChanged?.Invoke(this, configureEvent.x, configureEvent.y); SizeChanged?.Invoke(this, configureEvent.width, configureEvent.height); break; } case Event.FocusIn: { Activated?.Invoke(this); break; } case Event.FocusOut: { Deactivated?.Invoke(this); break; } case Event.MotionNotify: { XMotionEvent motionEvent = (XMotionEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XMotionEvent)); MouseMove?.Invoke(this, motionEvent.x, motionEvent.y); break; } case Event.ButtonPress: { XButtonEvent buttonEvent = (XButtonEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XButtonEvent)); switch ((Button)buttonEvent.button) { case Button.Button1: { MouseButtonDown?.Invoke(this, buttonEvent.x, buttonEvent.y, MouseButton.Left); break; } case Button.Button2: { MouseButtonDown?.Invoke(this, buttonEvent.x, buttonEvent.y, MouseButton.Middle); break; } case Button.Button3: { MouseButtonDown?.Invoke(this, buttonEvent.x, buttonEvent.y, MouseButton.Right); break; } case Button.Button4: { MouseWheel?.Invoke(this, buttonEvent.x, buttonEvent.y, 120); break; } case Button.Button5: { MouseWheel?.Invoke(this, buttonEvent.x, buttonEvent.y, -120); break; } } break; } case Event.ButtonRelease: { XButtonEvent buttonEvent = (XButtonEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XButtonEvent)); switch ((Button)buttonEvent.button) { case Button.Button1: { MouseButtonUp?.Invoke(this, buttonEvent.x, buttonEvent.y, MouseButton.Left); break; } case Button.Button2: { MouseButtonUp?.Invoke(this, buttonEvent.x, buttonEvent.y, MouseButton.Middle); break; } case Button.Button3: { MouseButtonUp?.Invoke(this, buttonEvent.x, buttonEvent.y, MouseButton.Right); break; } } break; } case Event.KeyPress: { XKeyEvent keyEvent = (XKeyEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XKeyEvent)); KeySym ks = XLookupKeysym(ref keyEvent, 0); Key key = NoesisKey(ks); if (key != Key.None) { KeyDown?.Invoke(this, key); } if (_xic != IntPtr.Zero) { Status status = 0; byte[] buffer = new byte[256]; KeySym ret_ks = (KeySym)0; int size = Xutf8LookupString(_xic, e, buffer, 255, ref ret_ks, ref status); if (size > 0 && ((int)status == XLookupChars || (int)status == XLookupBoth)) { buffer[size] = 0; Decoder decoder = _utf8.GetDecoder(); char[] text = new char[256]; int bytesUsed = 0; int charsUsed = 0; bool completed = false; decoder.Convert(buffer, 0, size, text, 0, 255, true, out bytesUsed, out charsUsed, out completed); for (int i = 0; i < charsUsed; ++i) { Char?.Invoke(this, text[i]); } } } break; } case Event.KeyRelease: { XKeyEvent keyEvent = (XKeyEvent)System.Runtime.InteropServices.Marshal.PtrToStructure(e, typeof(XKeyEvent)); KeySym ks = XLookupKeysym(ref keyEvent, 0); Key key = NoesisKey(ks); if (key != Key.None) { KeyUp?.Invoke(this, key); } break; } } } Render?.Invoke(this); } System.Runtime.InteropServices.Marshal.FreeHGlobal(e); XCloseDisplay(_display); }
/// <summary> /// Gets called whenever the size of the window changes. /// </summary> /// <param name="width">The new width of the window.</param> /// <param name="height">The new height of the window.</param> protected virtual void OnSizeChanged(int width, int height) { SizeChanged?.Invoke(this, new OverlaySizeEventArgs(width, height)); }
/// <summary> /// Occurs when border's size changed /// </summary> protected virtual void OnSizeChanged(SizeF size) { SizeChanged?.Invoke(this, size.ToSize()); OnLookChanged(new EventArgs()); }
protected virtual IntPtr WndProc(IntPtr hWnd, uint message, IntPtr wParam, IntPtr lParam) { WM msg = (WM)message; switch (msg) { case WM.HOTKEY: { if (wParam == (IntPtr)1) { PostMessage(_handle, (uint)WM.CLOSE, IntPtr.Zero, IntPtr.Zero); return(IntPtr.Zero); } break; } case WM.SYSKEYDOWN: { if (_options.KioskMode && (wParam == (IntPtr)Keyboard.VirtualKeyStates.VK_F4)) { return(IntPtr.Zero); } break; } case WM.CREATE: { NativeInstance = this; _handle = hWnd; var createdEvent = new CreatedEventArgs(IntPtr.Zero, _handle, _handle); Created?.Invoke(this, createdEvent); _isInitialized = true; break; } case WM.ERASEBKGND: return(new IntPtr(1)); case WM.NCHITTEST: if (_options.WindowFrameless) { return((IntPtr)HT_CAPTION); } break; case WM.MOVING: case WM.MOVE: { Moving?.Invoke(this, new MovingEventArgs()); return(IntPtr.Zero); } case WM.SIZE: { var size = GetClientSize(); SizeChanged?.Invoke(this, new SizeChangedEventArgs(size.Width, size.Height)); break; } case WM.CLOSE: { if (_handle != IntPtr.Zero && _isInitialized) { Close?.Invoke(this, new CloseEventArgs()); } PostQuitMessage(0); Environment.Exit(0); break; } } return(DefWindowProc(hWnd, message, wParam, lParam)); }
public static Task <bool> UpdateWindowSize(int width, int height) { SizeChanged?.Invoke(null, new Rectangle(0, 0, width, height)); return(Task.FromResult(true)); }
public override void Show() { SizeChanged?.Invoke(this, ClientWidth, ClientHeight); LocationChanged?.Invoke(this, 0, 0); Window.MakeKeyAndVisible(); }
protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom) { try { base.OnLayoutCore(changed, left, top, right, bottom); Size newSize; if (ArrangeLogicalSize is Rect als) { // If the parent element is from managed code, // we can recover the "Arrange" with double accuracy. // We use that because the conversion to android's "int" is loosing too much precision. newSize = new Size(als.Width, als.Height); } else { // Here the "arrange" is coming from a native element, // so we convert those measurements to logical ones. newSize = new Size(right - left, bottom - top).PhysicalToLogicalPixels(); } if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().DebugFormat( "[{0}/{1}] OnLayoutCore({2}, {3}, {4}, {5}) (parent: {5},{6})", GetType(), Name, left, top, right, bottom, MeasuredWidth, MeasuredHeight ); } var previousSize = _actualSize; _actualSize = newSize; if ( // If the layout has changed, but the final size has not, this is just a translation. // So unless there was a layout requested, we can skip arranging the children. (changed && _lastLayoutSize != newSize) // Even if nothing changed, but a layout was requested, arrange the children. || IsLayoutRequested ) { _lastLayoutSize = newSize; var finalRect = new Rect(0, 0, newSize.Width, newSize.Height); OnBeforeArrange(); _layouter.Arrange(finalRect); OnAfterArrange(); } if (previousSize != newSize) { SizeChanged?.Invoke(this, new SizeChangedEventArgs(this, previousSize, newSize)); _renderTransform?.UpdateSize(newSize); } } catch (Exception e) { Application.Current.RaiseRecoverableUnhandledExceptionOrLog(e, this); } }
private void Provider_SizeChanged(object sender, SizeChangedEventArgs e) => SizeChanged?.Invoke(this, e);
private void FireSizeChanged() { SizeChanged.Invoke(this); }
/// <summary> /// Raised by the SizeChanged event. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> protected virtual void OnSizeChanged(object sender, EventArgs e) { SizeChanged?.Invoke(this, e); }
protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom) { try { base.OnLayoutCore(changed, left, top, right, bottom); Rect finalRect; if (TransientArrangeFinalRect is Rect tafr) { // If the parent element is from managed code, // we can recover the "Arrange" with double accuracy. // We use that because the conversion to android's "int" is loosing too much precision. finalRect = tafr; } else { // Here the "arrange" is coming from a native element, // so we convert those measurements to logical ones. finalRect = new Rect(left, top, right - left, bottom - top).PhysicalToLogicalPixels(); // We also need to set the LayoutSlot as it was not set by the parent. // Note: This is only an approximation of the LayoutSlot as margin and alignment might already been applied at this point. LayoutInformation.SetLayoutSlot(this, finalRect); LayoutSlotWithMarginsAndAlignments = finalRect; } if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug)) { this.Log().DebugFormat( "[{0}/{1}] OnLayoutCore({2}, {3}, {4}, {5}) (parent: {5},{6})", GetType(), Name, left, top, right, bottom, MeasuredWidth, MeasuredHeight ); } var previousSize = AssignedActualSize; AssignedActualSize = finalRect.Size; if ( // If the layout has changed, but the final size has not, this is just a translation. // So unless there was a layout requested, we can skip arranging the children. (changed && _lastLayoutSize != finalRect.Size) // Even if nothing changed, but a layout was requested, arrange the children. || IsLayoutRequested ) { _lastLayoutSize = finalRect.Size; OnBeforeArrange(); _layouter.Arrange(finalRect); OnAfterArrange(); } if (previousSize != finalRect.Size) { SizeChanged?.Invoke(this, new SizeChangedEventArgs(this, previousSize, finalRect.Size)); _renderTransform?.UpdateSize(finalRect.Size); } } catch (Exception e) { Application.Current.RaiseRecoverableUnhandledExceptionOrLog(e, this); } }
public WindowsNativeConsoleProvider() { _threadToken = new CancellationTokenSource(); _buffer = (CHAR_INFO *)Marshal.AllocHGlobal(BufferSize * BufferSize * CHAR_INFO.SizeOf).ToPointer(); _buffer2 = (CHAR_INFO *)Marshal.AllocHGlobal(BufferSize * BufferSize * CHAR_INFO.SizeOf).ToPointer(); _stdin = GetStdHandle(-10); _stdout = GetStdHandle(-11); { var info = new CONSOLE_SCREEN_BUFFER_INFO(); GetConsoleScreenBufferInfo(_stdout, ref info); WindowWidth = info.Window.Right - info.Window.Left + 1; WindowHeight = info.Window.Bottom - info.Window.Top + 1; _prevBuf = info.Size; SetConsoleScreenBufferSize(_stdout, new COORD { X = (short)WindowWidth, Y = (short)WindowHeight }); } new Thread(() => // window size monitor { while (!_threadToken.IsCancellationRequested) { var info = new CONSOLE_SCREEN_BUFFER_INFO(); GetConsoleScreenBufferInfo(_stdout, ref info); int nw = info.Window.Right - info.Window.Left + 1, nh = info.Window.Bottom - info.Window.Top + 1; if (nw < 0) { nw = WindowWidth; } if (nh < 0) { nh = WindowHeight; // fukken winapi bugs } if (nw == WindowWidth && nh == WindowHeight) { continue; } var pw = WindowWidth; var ph = WindowHeight; _resizeFlag = true; WindowWidth = nw; WindowHeight = nh; SetConsoleScreenBufferSize(_stdout, new COORD { X = (short)WindowWidth, Y = (short)WindowHeight }); try { SizeChanged?.Invoke(this, new SizeChangedEventArgs(new Size(pw, ph), new Size(nw, nh))); } catch { /* Do not care if subscriber f****d up */ } //Refresh(); Thread.Sleep(16); } }) { Priority = ThreadPriority.Lowest }.Start(); _keyboardThread = new Thread(() => // keyboard monitor { INPUT_RECORD *charBuf = stackalloc INPUT_RECORD[1]; var ptr = new IntPtr(charBuf); var sizeOf = Marshal.SizeOf(typeof(INPUT_RECORD)); while (!_threadToken.IsCancellationRequested) { uint nchars = 0; Memset(ptr, 0, sizeOf); ReadConsoleInputW(_stdin, ptr, 1, ref nchars); if (charBuf->EventType == 1 && nchars == 1 && charBuf->KeyEvent.KeyDown) { KeyPressed?.Invoke( this, new KeyPressedEventArgs(new ConsoleKeyInfo( charBuf->KeyEvent.Char, (ConsoleKey)charBuf->KeyEvent.KeyCode, (charBuf->KeyEvent.ControlKeyState & 0x10) > 0, (charBuf->KeyEvent.ControlKeyState & 0x03) > 0, (charBuf->KeyEvent.ControlKeyState & 0x0c) > 0 ))); } } }); _keyboardThread.Start(); }
/// <summary> /// To be called by view /// </summary> public async Task SetSize(TerminalSize size) { await _trayProcessCommunicationService.ResizeTerminal(Id, size); SizeChanged?.Invoke(this, size); }
protected override void OnResized(Vector2D <int> size) { graphicsDevice.SetViewport(0, 0, (uint)size.X, (uint)size.Y); SizeChanged?.Invoke(this, EventArgs.Empty); }
private void ControlOnSizeChanged(object sender, System.EventArgs args) => SizeChanged?.Invoke(sender, new SizeEventArgs(Control.Size));
private void ElementSizeChanged(object sender, SizeChangedEventArgs e) { SizeChanged.SafeInvoke(); }
protected virtual void OnSizeChanged() { SizeChanged?.Invoke(this); }
/// <summary> /// To be called by view /// </summary> public async Task SetSizeAsync(TerminalSize size) { await _trayProcessCommunicationService.ResizeTerminalAsync(Id, size).ConfigureAwait(false); SizeChanged?.Invoke(this, size); }