private DiagramShape _OverlayShape; // What is it that we're using to show where the shape will end up?

        #endregion Fields

        #region Constructors

        public SimpleShapeDragger(DiagramSurface surface, MainWindow window, Point startPoint, DiagramShape originalShape)
            : base(surface, window, startPoint)
        {
            _OriginalShape = originalShape;

            SetupMouse();
        }
Esempio n. 2
0
        private MultiBinding CreateLeftTopWidthHeightBinding(DiagramShape connectable)
        {
            // Create a multibinding collection and assign an appropriate converter to it
            var multiBinding = new MultiBinding {
                Converter = new ConnectorBindingConverter()
            };

            // Create binding #1 to IConnectable to handle Left
            var binding = new Binding {
                Source = connectable, Path = new PropertyPath(Canvas.LeftProperty)
            };

            multiBinding.Bindings.Add(binding);

            // Create binding #2 to IConnectable to handle Top
            binding = new Binding {
                Source = connectable, Path = new PropertyPath(Canvas.TopProperty)
            };
            multiBinding.Bindings.Add(binding);

            // Create binding #3 to IConnectable to handle ActualWidth
            binding = new Binding {
                Source = connectable, Path = new PropertyPath(ActualWidthProperty)
            };
            multiBinding.Bindings.Add(binding);

            // Create binding #4 to IConnectable to handle ActualHeight
            binding = new Binding {
                Source = connectable, Path = new PropertyPath(ActualHeightProperty)
            };
            multiBinding.Bindings.Add(binding);

            // Create binding #5 to ConnectionPoint to handle SideOfShape
            binding = new Binding {
                Source = this, Path = new PropertyPath(SideOfShapeProperty)
            };
            multiBinding.Bindings.Add(binding);

            // Create binding #6 to ConnectionPoint to handle Position
            binding = new Binding {
                Source = this, Path = new PropertyPath(PositionProperty)
            };
            multiBinding.Bindings.Add(binding);

            return(multiBinding);
        }
Esempio n. 3
0
        public ConnectionPoint(DiagramShape parent, SideOfShape side, double position)
        {
            UID      = Guid.NewGuid().ToString();
            Side     = side;
            Position = position;

            ParentShape = parent;

            SetBinding(LocationProperty,
                       CreateLeftTopWidthHeightBinding(parent));

            // The Fill property must be set to a Brush in order for the shape to be considered solid.
            // Otherwise only the edges are considered part of it.
            Fill = Brushes.Transparent;

            MouseEnter += ConnectionPoint_MouseEnter;
            MouseLeave += ConnectionPoint_MouseLeave;
        }
Esempio n. 4
0
        public ConnectionPoint(DiagramShape parent, SideOfShape side, double position)
        {
            UID = Guid.NewGuid().ToString();
            Side = side;
            Position = position;

            ParentShape = parent;

            SetBinding(LocationProperty,
                       CreateLeftTopWidthHeightBinding(parent));

            // The Fill property must be set to a Brush in order for the shape to be considered solid.
            // Otherwise only the edges are considered part of it.
            Fill = Brushes.Transparent;

            MouseEnter += ConnectionPoint_MouseEnter;
            MouseLeave += ConnectionPoint_MouseLeave;
        }
        protected override void CreateOverlay()
        {
            // Add a rectangle to indicate where we'll end up.
            // We'll just use an alpha-blended visual brush.
            var brush = new VisualBrush(_OriginalShape) { Opacity = 0.2 };

            _OverlayShape = new DiagramShape
                                {
                                    Width = _OriginalShape.RenderSize.Width,
                                    Height = _OriginalShape.RenderSize.Height,
                                    Background = brush,
                                    Content = _OriginalShape.Content
                                };

            Canvas.SetLeft(_OverlayShape, -1000);
            Canvas.SetTop(_OverlayShape, -1000);

            _Surface.Children.Add(_OverlayShape);
        }
Esempio n. 6
0
 public Connection(DiagramShape source, DiagramShape target)
     : this()
 {
     Source = source;
     Target = target;
 }
Esempio n. 7
0
 public Connection(DiagramShape source, DiagramShape target) : this()
 {
     Source = source;
     Target = target;
 }
Esempio n. 8
0
 public void ShapeSetAsPrimary(DiagramShape shape)
 {
     OnShapeSetAsPrimary.RaiseEvent(this, new GenericEventArgs<DiagramShape>(shape));
 }
Esempio n. 9
0
 public void ShapeSelected(DiagramShape entity)
 {
     OnShapeSelected.RaiseEvent(this, new SchemaEventArgs<DiagramShape>(entity));
 }
Esempio n. 10
0
        public void SetVisibility(DiagramShape shape, Visibility visibility)
        {
            visibleShapes.Remove(shape);

            if (visibility == Visibility.Visible)
                visibleShapes.Add(shape);
        }
Esempio n. 11
0
 public void RemoveShape(DiagramShape shape)
 {
     Schema.RemoveShape(shape);
     shape.Visible = false;
 }
Esempio n. 12
0
 public bool CanConnect(DiagramShape shape, DiagramShape sourceShape)
 {
     return false;
 }
Esempio n. 13
0
 public void AddShape(DiagramShape shape)
 {
     Schema.AddShape(shape);
     shape.Visible = false;
 }
Esempio n. 14
0
        private MultiBinding CreateLeftTopWidthHeightBinding(DiagramShape connectable)
        {
            // Create a multibinding collection and assign an appropriate converter to it
            var multiBinding = new MultiBinding { Converter = new ConnectorBindingConverter() };

            // Create binding #1 to IConnectable to handle Left
            var binding = new Binding { Source = connectable, Path = new PropertyPath(Canvas.LeftProperty) };
            multiBinding.Bindings.Add(binding);

            // Create binding #2 to IConnectable to handle Top
            binding = new Binding { Source = connectable, Path = new PropertyPath(Canvas.TopProperty) };
            multiBinding.Bindings.Add(binding);

            // Create binding #3 to IConnectable to handle ActualWidth
            binding = new Binding { Source = connectable, Path = new PropertyPath(ActualWidthProperty) };
            multiBinding.Bindings.Add(binding);

            // Create binding #4 to IConnectable to handle ActualHeight
            binding = new Binding { Source = connectable, Path = new PropertyPath(ActualHeightProperty) };
            multiBinding.Bindings.Add(binding);

            // Create binding #5 to ConnectionPoint to handle SideOfShape
            binding = new Binding { Source = this, Path = new PropertyPath(SideOfShapeProperty) };
            multiBinding.Bindings.Add(binding);

            // Create binding #6 to ConnectionPoint to handle Position
            binding = new Binding { Source = this, Path = new PropertyPath(PositionProperty) };
            multiBinding.Bindings.Add(binding);

            return multiBinding;
        }
 public Point Convert(DiagramShape shape, ConnectionPoint connectionPoint)
 {
     return Convert(Canvas.GetLeft(shape), Canvas.GetTop(shape), shape.ActualWidth, shape.ActualHeight,
                    connectionPoint.Side, connectionPoint.Position);
 }
 public Point Convert(DiagramShape shape, SideOfShape side, double position)
 {
     return Convert(Canvas.GetLeft(shape), Canvas.GetTop(shape), shape.ActualWidth, shape.ActualHeight,
                    side, position);
 }
Esempio n. 17
0
 protected override void RemoveOverlay()
 {
     _Surface.Children.Remove(_OverlayShape);
     _OverlayShape = null;
 }