Example #1
0
        private void HideSelection()
        {
            if (Selection == null)
            {
                return;
            }

            CanvasFractalView.Children.Remove(Selection.View);
            Selection = null;
        }
Example #2
0
        private void ImageFractalView_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            HideSelection();

            var selectionRect = new Rectangle
            {
                DataContext = Selection,
                Stroke      = Brushes.Blue
            };

            var mouse = e.GetPosition(CanvasFractalView);

            Selection = new SelectionRect(selectionRect)
            {
                X = mouse.X,
                Y = mouse.Y
            };

            var bndX = new Binding("X")
            {
                Source = Selection
            };

            selectionRect.SetBinding(Canvas.LeftProperty, bndX);

            var bndY = new Binding("Y")
            {
                Source = Selection
            };

            selectionRect.SetBinding(Canvas.TopProperty, bndY);

            var bndWidth = new Binding("Width")
            {
                Source = Selection
            };

            selectionRect.SetBinding(WidthProperty, bndWidth);

            var bndHeight = new Binding("Height")
            {
                Source = Selection
            };

            selectionRect.SetBinding(HeightProperty, bndHeight);

            selectionRect.MouseLeftButtonUp += async(o, args) => { await RefreshView(); };

            CanvasFractalView.Children.Add(selectionRect);
        }