コード例 #1
0
 private void InitializeUiElements()
 {
     _ApOff        = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("ApOff");
     _GearDownOff  = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("GearDownOff");
     _GearUpOff    = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("GearUpOff");
     _StallOff     = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("StallOff");
     _StallWarnOff = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("StallWarnOff");
 }
コード例 #2
0
ファイル: TileDrawer.cs プロジェクト: wardump/UglyTetris
        private Rectangle NewRectangle(Color color)
        {
            var r = new Rectangle
            {
                Width  = FieldHelper.BlockWidth * 0.9,
                Height = FieldHelper.BlockHeight * 0.9,

                Fill = new SolidColorBrush(color, 1)
            };

            _canvas.Children.Add(r);
            return(r);
        }
コード例 #3
0
        /// <summary>
        /// Invoked when the mouse is moved around after the left button has been pressed on the NavigatorCanvas. Moves the DisplayArea around.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NavigatorPointerMoved(object sender, PointerEventArgs e)
        {
            if (IsMouseDown)
            {
                PDFRenderer renderer = this.FindControl <PDFRenderer>("MuPDFRenderer");
                Avalonia.Controls.Shapes.Rectangle displayRect = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("DisplayAreaRectangle");

                Point point = e.GetPosition(this.FindControl <Canvas>("NavigatorCanvas"));

                double deltaX = -(-point.X + MouseDownPoint.X) / displayRect.Width * MouseDownDisplayArea.Width;
                double deltaY = -(-point.Y + MouseDownPoint.Y) / displayRect.Height * MouseDownDisplayArea.Height;

                renderer.SetDisplayAreaNow(new Rect(new Point(this.MouseDownDisplayArea.X + deltaX, this.MouseDownDisplayArea.Y + deltaY), new Point(this.MouseDownDisplayArea.Right + deltaX, this.MouseDownDisplayArea.Bottom + deltaY)));
            }
        }
コード例 #4
0
        protected void NewWindowOnOpened(object?sender, EventArgs e)
        {
            Screens    screens = new Window().Screens;
            PixelRect  pr      = screens.Primary.Bounds;
            PixelPoint pp      = new PixelPoint(pr.BottomRight.X / 5, pr.BottomRight.Y / 5);

            Position = pp;

            RectangleBoundWindow = this.FindControl <Rectangle>("RectangleBound");
            GridMain             = this.FindControl <Grid>("GridMain");

            ColumnDefinition column2 = GridMain.ColumnDefinitions[0];

            column2.MaxWidth = 500;
            column2.MinWidth = 200;
        }
コード例 #5
0
        /// <summary>
        /// Invoked when a mouse button is clicked on the NavigatorCanvas. Centers the DisplayArea around the clicked point and starts panning.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NavigatorPointerPressed(object sender, PointerPressedEventArgs e)
        {
            if (e.GetCurrentPoint(this).Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonPressed)
            {
                IsMouseDown          = true;
                MouseDownPoint       = e.GetPosition(this.FindControl <Canvas>("NavigatorCanvas"));
                MouseDownDisplayArea = this.FindControl <PDFRenderer>("MuPDFRenderer").DisplayArea;

                Avalonia.Controls.Shapes.Rectangle displayRect = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("DisplayAreaRectangle");

                double areaCenterX = ((TranslateTransform)displayRect.RenderTransform).X + displayRect.Width * 0.5;
                double areaCenterY = ((TranslateTransform)displayRect.RenderTransform).Y + displayRect.Height * 0.5;

                double deltaX = (-areaCenterX + MouseDownPoint.X) / displayRect.Width * MouseDownDisplayArea.Width;
                double deltaY = (-areaCenterY + MouseDownPoint.Y) / displayRect.Height * MouseDownDisplayArea.Height;

                MouseDownDisplayArea = new Rect(new Point(this.MouseDownDisplayArea.X + deltaX, this.MouseDownDisplayArea.Y + deltaY), new Point(this.MouseDownDisplayArea.Right + deltaX, this.MouseDownDisplayArea.Bottom + deltaY));

                this.FindControl <PDFRenderer>("MuPDFRenderer").DisplayArea = MouseDownDisplayArea;
            }
        }
コード例 #6
0
        /// <summary>
        /// Invoked when a property of the <see cref="PDFRenderer"/> changes; used to update the NavigatorCanvas when the DisplayArea changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RendererPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
        {
            if (e.Property == PDFRenderer.DisplayAreaProperty)
            {
                PDFRenderer renderer = this.FindControl <PDFRenderer>("MuPDFRenderer");

                Rect displayArea = renderer.DisplayArea;
                Rect pageSize    = renderer.PageSize;

                double minX = Math.Min(displayArea.Left, pageSize.Left);
                double minY = Math.Min(displayArea.Top, pageSize.Top);
                double maxX = Math.Max(displayArea.Right, pageSize.Right);
                double maxY = Math.Max(displayArea.Bottom, pageSize.Bottom);

                double width  = maxX - minX;
                double height = maxY - minY;

                double size = Math.Max(width, height);

                minX -= (size - width) * 0.5;
                maxX += (size - width) * 0.5;
                minY -= (size - height) * 0.5;
                maxY += (size - height) * 0.5;

                Image  pageRect   = this.FindControl <Image>("PageAreaImage");
                Canvas pageCanavs = this.FindControl <Canvas>("PageAreaCanvas");
                Avalonia.Controls.Shapes.Rectangle displayRect = this.FindControl <Avalonia.Controls.Shapes.Rectangle>("DisplayAreaRectangle");

                pageRect.Width  = pageSize.Width / (maxX - minX) * 200;
                pageRect.Height = pageSize.Height / (maxY - minY) * 200;

                pageCanavs.Width           = pageSize.Width / (maxX - minX) * 200;
                pageCanavs.Height          = pageSize.Height / (maxY - minY) * 200;
                pageCanavs.RenderTransform = new TranslateTransform((pageSize.Left - minX) / (maxX - minX) * 200, (pageSize.Top - minY) / (maxY - minY) * 200);

                displayRect.Width           = displayArea.Width / (maxX - minX) * 200;
                displayRect.Height          = displayArea.Height / (maxY - minY) * 200;
                displayRect.RenderTransform = new TranslateTransform((displayArea.Left - minX) / (maxX - minX) * 200, (displayArea.Top - minY) / (maxY - minY) * 200);
            }
        }