示例#1
0
        protected virtual void OnDesignerCanvasChanged(DesignerCanvas oldDesignerCanvas, DesignerCanvas newDesignerCanvas)
        {
            if (oldDesignerCanvas != null)
            {
                oldDesignerCanvas.LayoutUpdated -= DesignerCanvas_LayoutUpdated;
                oldDesignerCanvas.MouseWheel -= DesignerCanvas_MouseWheel;
            }

            if (newDesignerCanvas != null)
            {
                newDesignerCanvas.LayoutUpdated += DesignerCanvas_LayoutUpdated;
                newDesignerCanvas.MouseWheel += DesignerCanvas_MouseWheel;
                newDesignerCanvas.LayoutTransform = _scaleTransform;
            }
        }
示例#2
0
        public RubberbandAdorner(DesignerCanvas designerCanvas, Point? dragStartPoint)
            : base(designerCanvas)
        {
            _designerCanvas = designerCanvas;
            _startPoint = dragStartPoint;

            _adornerCanvas = new Canvas {Background = Brushes.Transparent};

            _visuals = new VisualCollection(this) {_adornerCanvas};

            var fillBrushColor = Colors.MediumBlue;
            fillBrushColor.A = 48;
            var fillBrush = new SolidColorBrush(fillBrushColor);

            var strokeBrushColor = Colors.Navy;
            strokeBrushColor.A = 64;
            var strokeBrush = new SolidColorBrush(strokeBrushColor);

            _rubberband = new Rectangle {Stroke = strokeBrush, StrokeThickness = 2, Fill = fillBrush};

            _adornerCanvas.Children.Add(_rubberband);
        }