public MainWindow()
        {
            this.InitializeComponent();
            this.model          = new PlotModel();
            this.horizontalAxis = new LinearAxis {
                Position = AxisPosition.Bottom
            };
            this.verticalAxis = new LinearAxis {
                Position = AxisPosition.Left
            };
            this.model.Axes.Add(this.horizontalAxis);
            this.model.Axes.Add(this.verticalAxis);
            plot1.Model      = this.model;
            this.DataContext = this;

            // Subscribe to transform changes on both axes
            this.horizontalAxis.TransformChanged += this.HandleTransformChanged;
            this.verticalAxis.TransformChanged   += this.HandleTransformChanged;

            this.rect = new Rectangle
            {
                Fill = new LinearGradientBrush
                {
                    GradientStops = new System.Collections.Generic.List <GradientStop>
                    {
                        new GradientStop(Colors.Black, 0),
                        new GradientStop(Colors.Red, 1)
                    }
                }
            };
            canvas1.Children.Add(this.rect);
        }
Example #2
0
        public void Should_Track_Bounds()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                var target = new BoundsTracker();
                var control = default(Rectangle);
                var tree = new Decorator
                {
                    Padding = new Thickness(10),
                    Child = new Decorator
                    {
                        Padding = new Thickness(5),
                        Child = control = new Rectangle
                        {
                            Width = 15,
                            Height = 15,
                        },
                    }
                };

                var context = new DrawingContext(Mock.Of<IDrawingContextImpl>());

                tree.Measure(Size.Infinity);
                tree.Arrange(new Rect(0, 0, 100, 100));
                context.Render(tree);

                var track = target.Track(control);
                var results = new List<TransformedBounds?>();
                track.Subscribe(results.Add);

                Assert.Equal(new Rect(0, 0, 15, 15), results[0].Value.Bounds);
                Assert.Equal(Matrix.CreateTranslation(42, 42), results[0].Value.Transform);
            }
        }
Example #3
0
        public void Right_Property_Should_Work()
        {
            Rectangle rect;
            var target = new Canvas
            {
                Width = 400,
                Height = 400,
                Children =
                {
                    (rect = new Rectangle
                    {
                        MinWidth = 20,
                        MinHeight = 25,
                        [Canvas.RightProperty] = 30,
                    })
                }
            };

            target.Measure(new Size(400, 400));
            target.Arrange(new Rect(target.DesiredSize));

            Assert.Equal(new Rect(350, 0, 20, 25), rect.Bounds);
        }
Example #4
0
        private void UpdateSelectionBoxItem(object item)
        {
            var contentControl = item as IContentControl;

            if (contentControl != null)
            {
                item = contentControl.Content;
            }

            var control = item as IControl;

            if (control != null)
            {
                control.Measure(Size.Infinity);

                SelectionBoxItem = new Rectangle
                {
                    Width = control.DesiredSize.Width,
                    Height = control.DesiredSize.Height,
                    Fill = new VisualBrush
                    {
                        Visual = control,
                        Stretch = Stretch.None,
                        AlignmentX = AlignmentX.Left,
                    }
                };
            }
            else
            {
                SelectionBoxItem = item;
            }
        }