private void InitializeComponent() { AvaloniaXamlLoader.Load(this); TitleBarGrid = this.FindControl <Grid>("TitleBarGrid"); CloseGrid = this.FindControl <Grid>("CloseGrid"); CloseButton = this.FindControl <Button>("CloseButton"); ResizeGrid = this.FindControl <Grid>("ResizeGrid"); ResizeButton = this.FindControl <Button>("ResizeButton"); MinimizeGrid = this.FindControl <Grid>("MinimizeGrid"); MinimizeButton = this.FindControl <Button>("MinimizeButton"); SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West); SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East); SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North); SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South); SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest); SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); TitleBarGrid.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e); CloseGrid.PointerEnter += CloseGrid_PointerEnter; CloseGrid.PointerLeave += CloseGrid_PointerLeave; ResizeGrid.PointerEnter += ResizeGrid_PointerEnter; ResizeGrid.PointerLeave += ResizeGrid_PointerLeave; MinimizeButton.PointerLeave += MinimizeButton_PointerLeave; MinimizeButton.PointerEnter += MinimizeButton_PointerEnter; CloseButton.Click += CloseButton_Click; ResizeButton.Click += ResizeButton_Click; MinimizeButton.Click += MinimizeButton_Click; PlatformImpl.WindowStateChanged = WindowStateChanged; var openBtn = this.FindControl <Button>("OpenSaveButton"); openBtn.Click += OpenFileButton_Click; this.FindControl <Button>("SaveButton").Click += SaveButton_Click; playerPocketsGrid = new ItemGrid(40, 10, 4, 16); playerStorageGrid = new ItemGrid(5000, 50, 100, 16); villagerFurnitureGrid = new ItemGrid(16, 8, 2, 16) { HorizontalAlignment = HorizontalAlignment.Left }; var playersGrid = this.FindControl <StackPanel>("PocketsPanel"); playersGrid.Children.Add(playerPocketsGrid); this.FindControl <ScrollViewer>("StorageScroller").Content = playerStorageGrid; this.FindControl <StackPanel>("VillagerFurniturePanel").Children.Add(villagerFurnitureGrid); openBtn.IsVisible = true; this.FindControl <TabControl>("EditorTabControl").IsVisible = false; this.FindControl <Grid>("BottomBar").IsVisible = false; }
/// <summary> /// Pushes a clip geometry. /// </summary> /// <param name="clip">The clip geometry.</param> /// <returns>A disposable used to undo the clip geometry.</returns> public PushedState PushGeometryClip(Geometry clip) { Contract.Requires <ArgumentNullException>(clip != null); PlatformImpl.PushGeometryClip(clip.PlatformImpl); return(new PushedState(this, PushedState.PushedStateType.GeometryClip)); }
/// <summary> /// Pushes an opacity mask. /// </summary> /// <param name="mask">The opacity mask.</param> /// <param name="bounds"> /// The size of the brush's target area. TODO: Are we sure this is needed? /// </param> /// <returns>A disposable to undo the opacity mask.</returns> public PushedState PushOpacityMask(IBrush mask, Rect bounds) { PlatformImpl.PushOpacityMask(mask, bounds); return(new PushedState(this, PushedState.PushedStateType.OpacityMask)); }
/// <summary> /// Activates the window. /// </summary> public void Activate() { PlatformImpl.Activate(); }
/// <summary> /// Draws a custom drawing operation /// </summary> /// <param name="custom">custom operation</param> public void Custom(ICustomDrawOperation custom) => PlatformImpl.Custom(custom);
/// <summary> /// Closes the window. /// </summary> public void Close() { s_windows.Remove(this); PlatformImpl.Dispose(); }
/// <summary> /// Starts resizing a window. This function is used if an application has window resizing controls. /// Should be called from left mouse button press event handler /// </summary> public void BeginResizeDrag(WindowEdge edge, PointerPressedEventArgs e) => PlatformImpl?.BeginResizeDrag(edge, e);
/// <summary> /// Starts moving a window with left button being held. Should be called from left mouse button press event handler /// </summary> public void BeginMoveDrag() => PlatformImpl?.BeginMoveDrag();
/// <summary> /// Starts resizing a window. This function is used if an application has window resizing controls. /// Should be called from left mouse button press event handler /// </summary> public void BeginResizeDrag(WindowEdge edge) => PlatformImpl?.BeginResizeDrag(edge);
/// <summary> /// Tries to match a specified character to a <see cref="Typeface"/> that supports specified font properties. /// </summary> /// <param name="codepoint">The codepoint to match against.</param> /// <param name="fontStyle">The font style.</param> /// <param name="fontWeight">The font weight.</param> /// <param name="fontFamily">The font family. This is optional and used for fallback lookup.</param> /// <param name="culture">The culture.</param> /// <param name="typeface">The matching <see cref="Typeface"/>.</param> /// <returns> /// <c>True</c>, if the <see cref="FontManager"/> could match the character to specified parameters, <c>False</c> otherwise. /// </returns> public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight, FontFamily fontFamily, CultureInfo culture, out Typeface typeface) => PlatformImpl.TryMatchCharacter(codepoint, fontStyle, fontWeight, fontFamily, culture, out typeface);
/// <summary> /// Get all installed font family names. /// </summary> /// <param name="checkForUpdates">If <c>true</c> the font collection is updated.</param> public IEnumerable <string> GetInstalledFontFamilyNames(bool checkForUpdates = false) => PlatformImpl.GetInstalledFontFamilyNames(checkForUpdates);
public MainWindow() { InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif TitleBarGrid = this.FindControl <Grid>("TitleBarGrid"); CloseGrid = this.FindControl <Grid>("CloseGrid"); CloseButton = this.FindControl <Button>("CloseButton"); ResizeGrid = this.FindControl <Grid>("ResizeGrid"); ResizeButton = this.FindControl <Button>("ResizeButton"); MinimizeGrid = this.FindControl <Grid>("MinimizeGrid"); MinimizeButton = this.FindControl <Button>("MinimizeButton"); SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West); SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East); SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North); SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South); SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest); SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); TitleBarGrid.PointerPressed += (i, e) => PlatformImpl?.BeginMoveDrag(e); CloseGrid.PointerEnter += CloseGrid_PointerEnter; CloseGrid.PointerLeave += CloseGrid_PointerLeave; ResizeGrid.PointerEnter += ResizeGrid_PointerEnter; ResizeGrid.PointerLeave += ResizeGrid_PointerLeave; MinimizeButton.PointerLeave += MinimizeButton_PointerLeave; MinimizeButton.PointerEnter += MinimizeButton_PointerEnter; CloseButton.Click += CloseButton_Click; ResizeButton.Click += ResizeButton_Click; MinimizeButton.Click += MinimizeButton_Click; PlatformImpl.WindowStateChanged = WindowStateChanged; var openBtn = this.FindControl <Button>("OpenSaveButton"); openBtn.Click += OpenFileButton_Click; this.FindControl <Button>("SaveButton").Click += SaveButton_Click; playerPocketsGrid = new ItemGrid(40, 10, 16); playerStorageGrid = new ItemGrid(5000, 50, 16); villagerFurnitureGrid = new ItemGrid(32, 8, 16) { HorizontalAlignment = HorizontalAlignment.Left }; villagerWallpaperGrid = new ItemGrid(1, 1, 16) { HorizontalAlignment = HorizontalAlignment.Left }; villagerFlooringGrid = new ItemGrid(1, 1, 16) { HorizontalAlignment = HorizontalAlignment.Left }; var playersGrid = this.FindControl <StackPanel>("PocketsPanel"); playersGrid.Children.Add(playerPocketsGrid); this.FindControl <ScrollViewer>("StorageScroller").Content = playerStorageGrid; this.FindControl <StackPanel>("VillagerFurniturePanel").Children.Add(villagerFurnitureGrid); this.FindControl <StackPanel>("VillagerWallpaperPanel").Children.Add(villagerWallpaperGrid); this.FindControl <StackPanel>("VillagerFlooringPanel").Children.Add(villagerFlooringGrid); SetSelectedItemIndex(); openBtn.IsVisible = true; this.FindControl <TabControl>("EditorTabControl").IsVisible = false; this.FindControl <Grid>("BottomBar").IsVisible = false; _singleton = this; }
/// <summary> /// Closes the window. /// </summary> public void Close() { s_windows.Remove(this); PlatformImpl?.Dispose(); IsVisible = false; }
public void Dispose() { PlatformImpl?.Dispose(); }
/// <inheritdoc/> Point IRenderRoot.PointToClient(PixelPoint p) { return(PlatformImpl?.PointToClient(p) ?? default); }
/// <inheritdoc/> public virtual void Dispose() { PlatformImpl.Dispose(); }
/// <inheritdoc/> PixelPoint IRenderRoot.PointToScreen(Point p) { return(PlatformImpl?.PointToScreen(p) ?? default); }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); this.FindControl <Control>("TitleBar").PointerPressed += (i, e) => { PlatformImpl?.BeginMoveDrag(e); }; }
/// <summary> /// Starts moving a window with left button being held. Should be called from left mouse button press event handler /// </summary> public void BeginMoveDrag(PointerPressedEventArgs e) => PlatformImpl?.BeginMoveDrag(e);
/// <summary> /// Indicates whether the geometry's stroke contains the specified point. /// </summary> /// <param name="pen">The pen to use.</param> /// <param name="point">The point.</param> /// <returns><c>true</c> if the geometry contains the point; otherwise, <c>false</c>.</returns> public bool StrokeContains(Pen pen, Point point) { return(PlatformImpl?.StrokeContains(pen, point) == true); }
/// <summary> /// Translates a point from window coordinates into screen coordinates. /// </summary> /// <param name="p">The point.</param> /// <returns>The point in screen coordinates.</returns> Point IRenderRoot.TranslatePointToScreen(Point p) { return(PlatformImpl.PointToScreen(p)); }
/// <summary> /// Gets the geometry's bounding rectangle with the specified pen. /// </summary> /// <param name="pen">The stroke thickness.</param> /// <returns>The bounding rectangle.</returns> public Rect GetRenderBounds(Pen pen) => PlatformImpl?.GetRenderBounds(pen) ?? Rect.Empty;
/// <summary> /// Handles a render request from <see cref="RenderManager.RenderNeeded"/>. /// </summary> private void HandleRenderNeeded() { _dispatcher.InvokeAsync( () => PlatformImpl.Invalidate(new Rect(ClientSize)), DispatcherPriority.Render); }
/// <summary> /// Indicates whether the geometry's fill contains the specified point. /// </summary> /// <param name="point">The point.</param> /// <returns><c>true</c> if the geometry contains the point; otherwise, <c>false</c>.</returns> public bool FillContains(Point point) { return(PlatformImpl?.FillContains(point) == true); }
/// <summary> /// Pushes a clip rectangle. /// </summary> /// <param name="clip">The clip rectangle.</param> /// <returns>A disposable used to undo the clip rectangle.</returns> public PushedState PushClip(Rect clip) { PlatformImpl.PushClip(clip); return(new PushedState(this, PushedState.PushedStateType.Clip)); }
/// <inheritdoc/> Point IRenderRoot.PointToClient(Point p) { return(PlatformImpl.PointToClient(p)); }
/// <summary> /// Pushes an opacity value. /// </summary> /// <param name="opacity">The opacity.</param> /// <returns>A disposable used to undo the opacity.</returns> public PushedState PushOpacity(double opacity) //TODO: Eliminate platform-specific push opacity call { PlatformImpl.PushOpacity(opacity); return(new PushedState(this, PushedState.PushedStateType.Opacity)); }
/// <inheritdoc/> void IRenderRoot.Invalidate(Rect rect) { PlatformImpl?.Invalidate(rect); }
/// <summary> /// Draws a bitmap image. /// </summary> /// <param name="source">The bitmap image.</param> /// <param name="opacity">The opacity to draw with.</param> /// <param name="sourceRect">The rect in the image to draw.</param> /// <param name="destRect">The rect in the output to draw to.</param> /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param> public void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode = default) { Contract.Requires <ArgumentNullException>(source != null); PlatformImpl.DrawImage(source.PlatformImpl, opacity, sourceRect, destRect, bitmapInterpolationMode); }
/// <summary> /// Sets the foreground brush for the specified text range. /// </summary> /// <param name="brush">The brush.</param> /// <param name="startIndex">The start of the text range.</param> /// <param name="length">The length of the text range.</param> public void SetForegroundBrush(Brush brush, int startIndex, int length) { PlatformImpl.SetForegroundBrush(brush, startIndex, length); }