예제 #1
0
        public DragItemsAdorner(Canvas designerCanvas, List <ContentPresenter> contentPresenters, List <Rect> thumbRects, Point startPoint) : base(designerCanvas)
        {
            this._designerCanvas    = designerCanvas;
            this._tabViewModel      = this._designerCanvas.DataContext as SchemeTabViewModel;
            this._contentPresenters = contentPresenters;
            this._thumbRects        = thumbRects;
            this._dragStartPoint    = startPoint;

            this._dragCanvas = new Canvas
            {
                Height  = this._designerCanvas.Height,
                Width   = this._designerCanvas.Width,
                Opacity = 0.5
            };

            foreach (var rect in this._thumbRects)
            {
                var rectangle = new Rectangle();
                rectangle.Height = rect.Height;
                rectangle.Width  = rect.Width;
                Canvas.SetLeft(rectangle, rect.Left);
                Canvas.SetTop(rectangle, rect.Top);
                rectangle.Stroke = Brushes.Gray;
                rectangle.Fill   = Brushes.Transparent;
                this._dragCanvas.Children.Add(rectangle);
            }
        }
예제 #2
0
        protected override void OnAttached()
        {
            this.DesignerCanvas = AssociatedObject;

            this.TabViewModel = this.DesignerCanvas.DataContext as SchemeTabViewModel;
            if (this.TabViewModel != null)
            {
                this.TabViewModel.SelfBehavior = this;

                var adornerLayer = AdornerLayer.GetAdornerLayer(this.DesignerCanvas);
                if (adornerLayer != null)
                {
                    var designerCanvasAdorner = new DesignerCanvasAdorner(this.DesignerCanvas, this.TabViewModel)
                    {
                        IsHitTestVisible = false
                    };
                    adornerLayer.Add(designerCanvasAdorner);
                }
            }

            var outerGrid = this.GetOuterGrid(this.DesignerCanvas);

            if (outerGrid != null)
            {
                this._scaleTransform = new ScaleTransform();
                UpdateScaleTransform();
                outerGrid.LayoutTransform = this._scaleTransform;
            }
            this.DesignerCanvas.MouseDown += this.OnMouseDown;
            this.DesignerCanvas.MouseMove += this.OnMouseMove;
            this.DesignerCanvas.MouseUp   += this.OnMouseUp;
            this.DesignerCanvas.Drop      += this.OnDrop;
            base.OnAttached();
        }
예제 #3
0
        protected override void OnAttached()
        {
            base.OnAttached();
            this._sinkArea = AssociatedObject;
            this._sinkArea.MouseLeftButtonDown += this.SinkAreaOnMouseLeftButtonDown;
            this._sinkArea.MouseMove           += this.SinkAreaOnMouseMove;
            this._sinkArea.MouseLeftButtonUp   += this.SinkAreaOnMouseLeftButtonUp;

            this.Connector            = AssociatedObject.DataContext as ConnectorViewModel;
            this._connectionViewModel = Connector.Connection;

            this._designerCanvas = CommonHelper.GetDesignerCanvas(this._sinkArea);

            this._tabViewModel = this._designerCanvas.DataContext as SchemeTabViewModel;

            this._dragEnter = false;

            if (VisualTreeHelper.GetParent(this._sinkArea) is Canvas parent)
            {
                this._connectionPath = parent.Children.OfType <Path>().First(p => p.Name == PATH_NAME);
                if (this._connectionPath != null)
                {
                    this._connectionPath.PreviewMouseLeftButtonDown += this.OnPreviewLeftMouseDown;
                }
            }
        }
예제 #4
0
 public RubberbandAdorner(DesignerCanvasBehavior dcb, SchemeTabViewModel schemeTabViewModel) : base(dcb.DesignerCanvas)
 {
     this._designerCanvasBehavior = dcb;
     this._schemeTabViewModel     = schemeTabViewModel;
     this._startPoint             = dcb.RubberbandSelectionStartPoint;
     this._rubberbandPen          = new Pen(Brushes.LightSlateGray, 1)
     {
         DashStyle = new DashStyle(new double[] { 2 }, 1)
     };
 }
예제 #5
0
        public ConnectorAdorner(Canvas designer, ConnectorViewModel sourceConnectorViewModel) : base(designer)
        {
            this._designerCanvas     = designer;
            this._schemeTabViewModel = this._designerCanvas.DataContext as SchemeTabViewModel;
            this._sourceConnector    = sourceConnectorViewModel;
            this._drawingPen         = new Pen(Brushes.LightSlateGray, 1)
            {
                LineJoin  = PenLineJoin.Round,
                DashStyle = new DashStyle(new List <double> {
                    8, 3
                }, 0)
            };

            Cursor             = Cursors.Cross;
            this._pathGeometry = new PathGeometry();
            _pathPoints        = new List <Point>();
        }
예제 #6
0
 protected override void OnAttached()
 {
     base.OnAttached();
     AssociatedObject.MouseMove        += this.OnMouseMove;
     AssociatedObject.PreviewMouseDown += this.OnPreviewMouseDown;
     AssociatedObject.MouseDoubleClick += this.OnMouseDoubleClick;
     this._currentItemContent           = AssociatedObject.DataContext as LogicElementViewModel; //VM текущего элемента
     if (this._currentItemContent == null)
     {
         return;
     }
     this._designerCanvas = CommonHelper.GetDesignerCanvas(AssociatedObject); //Canvas, на котором отображаются элементы
     if (this._designerCanvas != null)
     {
         this._tabViewModel = this._designerCanvas.DataContext as SchemeTabViewModel;// VM текущей вкладки схемы
     }
     this._contentPresenters = new List <ContentPresenter>();
     this._thumbRects        = new List <Rect>();
 }
예제 #7
0
        protected override void OnAttached()
        {
            base.OnAttached();

            if (AssociatedObject.Visibility == Visibility.Collapsed)
            {
                return;
            }

            this._isDrag = false;
            AssociatedObject.MouseLeftButtonDown += this.OnPreviewMouseLeftButtonDown;
            AssociatedObject.MouseMove           += this.OnMouseMove;
            AssociatedObject.MouseLeftButtonUp   += this.OnMouseLeftButtonUp;
            AssociatedObject.Loaded += this.OnBorderLoaded;

            this._designerCanvas = CommonHelper.GetDesignerCanvas(AssociatedObject);
            this._tabViewModel   = this._designerCanvas.DataContext as SchemeTabViewModel;

            this._connectorViewModel = (ConnectorViewModel)AssociatedObject.DataContext;
        }
예제 #8
0
 public DesignerCanvasAdorner(Canvas designerCanvas, SchemeTabViewModel schemeTabViewModel) : base(designerCanvas)
 {
     this._schemeTabViewModel = schemeTabViewModel;
     this._rectPen            = new Pen(Brushes.Black, 1);
     this._gridPen            = new Pen(Brushes.Black, 0.1);
 }