/// <summary> /// Initializes this <see cref="ColorPicker"/> object's events. /// </summary> protected sealed override void InitializeEvents() { if (IsInvalid) { throw new InvalidHandleException(); } LibuiEx.ColorButtonOnChanged(Handle, (button, data) => OnColorChanged(this), IntPtr.Zero); }
/// <summary> /// Scrolls the surface view to the specified location and size. /// </summary> /// <param name="x">The x-coordinate of the view.</param> /// <param name="y">The y-coordinate of the view.</param> /// <param name="width">The width of the view.</param> /// <param name="height">The height of the view.</param> public void ScrollTo(double x, double y, double width, double height) { if (IsInvalid) { throw new InvalidHandleException(); } LibuiEx.AreaScrollTo(Handle, x, y, width, height); }
public void BeginUserWindowResize(WindowEdge edge) { if (IsInvalid) { throw new InvalidHandleException(); } LibuiEx.AreaBeginUserWindowResize(Handle, edge); }
public void BeginUserWindowMove() { if (IsInvalid) { throw new InvalidHandleException(); } LibuiEx.AreaBeginUserWindowMove(Handle); }
/// <summary> /// Queues a redraw of the surface. /// </summary> public void QueueRedrawAll() { Thread.Sleep(200); // Must sleep for 200ms or else crashes if (IsInvalid) { throw new InvalidHandleException(); } LibuiEx.AreaQueueRedrawAll(Handle); }
protected sealed override void ReleaseUnmanagedResources() { if (font != null) { LibuiEx.FreeFontButtonFont(font); font = null; } base.ReleaseUnmanagedResources(); }
private static SafeControlHandle GetHandle(SurfaceHandler handler, bool scrollable, int width, int height, out LibuiEx.AreaHandler outHandler) { outHandler = new LibuiEx.AreaHandler { Draw = (nativeHandler, surface, args) => handler.Draw(surfaceCache[surface], ref args), MouseEvent = (nativeHandler, surface, args) => handler.MouseEvent(surfaceCache[surface], ref args), MouseCrossed = (nativeHandler, surface, left) => handler.MouseCrossed(surfaceCache[surface], left), DragBroken = (nativeHandler, surface) => handler.DragBroken(surfaceCache[surface]), KeyEvent = (nativeHandler, surface, args) => handler.KeyEvent(surfaceCache[surface], ref args) }; return(!scrollable ? new SafeControlHandle(LibuiEx.NewArea(outHandler)) : new SafeControlHandle(LibuiEx.NewScrollingArea(outHandler, width, height))); }
/// <summary> /// Executes the code required to free the handle. /// </summary> /// <returns><see langword="true"/> if the handle is released successfully; otherwise, in the event of a catastrophic failure, <see langword="false"/>.</returns> protected override bool ReleaseHandle() { bool released; try { LibuiEx.FreeAttribute(handle); handle = IntPtr.Zero; released = true; } catch { released = false; } return(released); }
/// <summary> /// Initializes a new instance of the <see cref="ColorPicker"/> class. /// </summary> public ColorPicker() : base(new SafeControlHandle(LibuiEx.NewColorButton())) => InitializeEvents();
/// <summary> /// Initializes a new instance of the <see cref="Path"/> class with the specified <see cref="FillMode"/>. /// </summary> /// <param name="mode">The <see cref="FillMode"/> specifying how the initialized <see cref="Path"/> should be filled.</param> public Path(FillMode mode) : base(new SafePathHandle(LibuiEx.DrawNewPath(mode))) => FillMode = mode;
/// <summary> /// Initializes a new instance of the <see cref="FontPicker"/> class. /// </summary> public FontPicker() : base(new SafeControlHandle(LibuiEx.NewFontButton())) => InitializeEvents();