Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 /// <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));
 }
Exemplo n.º 3
0
 /// <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));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Activates the window.
 /// </summary>
 public void Activate()
 {
     PlatformImpl.Activate();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Draws a custom drawing operation
 /// </summary>
 /// <param name="custom">custom operation</param>
 public void Custom(ICustomDrawOperation custom) => PlatformImpl.Custom(custom);
Exemplo n.º 6
0
 /// <summary>
 /// Closes the window.
 /// </summary>
 public void Close()
 {
     s_windows.Remove(this);
     PlatformImpl.Dispose();
 }
Exemplo n.º 7
0
 /// <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);
Exemplo n.º 8
0
 /// <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();
Exemplo n.º 9
0
 /// <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);
Exemplo n.º 10
0
 /// <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);
Exemplo n.º 11
0
 /// <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);
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
0
 /// <summary>
 /// Closes the window.
 /// </summary>
 public void Close()
 {
     s_windows.Remove(this);
     PlatformImpl?.Dispose();
     IsVisible = false;
 }
Exemplo n.º 14
0
 public void Dispose()
 {
     PlatformImpl?.Dispose();
 }
Exemplo n.º 15
0
 /// <inheritdoc/>
 Point IRenderRoot.PointToClient(PixelPoint p)
 {
     return(PlatformImpl?.PointToClient(p) ?? default);
 }
Exemplo n.º 16
0
 /// <inheritdoc/>
 public virtual void Dispose()
 {
     PlatformImpl.Dispose();
 }
Exemplo n.º 17
0
 /// <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); };
 }
Exemplo n.º 19
0
 /// <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);
Exemplo n.º 20
0
 /// <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);
 }
Exemplo n.º 21
0
 /// <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));
 }
Exemplo n.º 22
0
 /// <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;
Exemplo n.º 23
0
 /// <summary>
 /// Handles a render request from <see cref="RenderManager.RenderNeeded"/>.
 /// </summary>
 private void HandleRenderNeeded()
 {
     _dispatcher.InvokeAsync(
         () => PlatformImpl.Invalidate(new Rect(ClientSize)),
         DispatcherPriority.Render);
 }
Exemplo n.º 24
0
 /// <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);
 }
Exemplo n.º 25
0
 /// <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));
 }
Exemplo n.º 26
0
 /// <inheritdoc/>
 Point IRenderRoot.PointToClient(Point p)
 {
     return(PlatformImpl.PointToClient(p));
 }
Exemplo n.º 27
0
 /// <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));
 }
Exemplo n.º 28
0
 /// <inheritdoc/>
 void IRenderRoot.Invalidate(Rect rect)
 {
     PlatformImpl?.Invalidate(rect);
 }
Exemplo n.º 29
0
        /// <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);
        }
Exemplo n.º 30
0
 /// <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);
 }