public RubberbandAdorner(DiagramControl diagramControl, DesignerCanvas designerCanvas, Point?dragStartPoint)
     : base(designerCanvas)
 {
     this.designerCanvas     = designerCanvas;
     this.startPoint         = dragStartPoint;
     rubberbandPen           = new Pen(Brushes.LightSlateGray, 1);
     rubberbandPen.DashStyle = new DashStyle(new double[] { 2 }, 1);
     DiagramControl          = diagramControl;
 }
Example #2
0
 public DesignerItem(string id, string text, DiagramControl diagramControl)
 {
     this.ItemId  = id;
     Text         = text;
     ItemParentId = string.Empty;
     Loaded      += DesignerItem_Loaded;
     //Data = new CustomItemData(id);
     //Data.DiagramControl = diagramControl;
     DiagramControl    = diagramControl;
     Focusable         = false;
     MouseDoubleClick += (sender, e) =>
     {
         diagramControl.DiagramManager.Edit(this);
     };
 }
Example #3
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;

            if (dragObject != null && !String.IsNullOrEmpty(dragObject.Xaml))
            {
                DesignerItem newItem = null;
                Object       content = XamlReader.Load(XmlReader.Create(new StringReader(dragObject.Xaml)));

                if (content != null)
                {
                    DiagramControl diagramControl = TemplatedParent as DiagramControl;
                    newItem         = new DesignerItem(diagramControl);
                    newItem.Content = content;

                    Point position = e.GetPosition(this);

                    if (dragObject.DesiredSize.HasValue)
                    {
                        Size desiredSize = dragObject.DesiredSize.Value;
                        newItem.Width  = desiredSize.Width;
                        newItem.Height = desiredSize.Height;

                        DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
                        DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));
                    }
                    else
                    {
                        DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X));
                        DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y));
                    }

                    Canvas.SetZIndex(newItem, this.Children.Count);
                    this.Children.Add(newItem);
                    SetConnectorDecoratorTemplate(newItem);

                    //update selection
                    this.SelectionService.SelectItem(newItem);
                    newItem.Focus();
                }

                e.Handled = true;
            }
        }
Example #4
0
 public SelectionService(DesignerCanvas canvas, DiagramControl diagramControl)
 {
     this.designerCanvas  = canvas;
     this._diagramControl = diagramControl;
 }
Example #5
0
 public DesignerItem(string id, string parentItemId, string text, object itemData, DiagramControl diagramControl)
     : this(id, text, itemData, diagramControl)
 {
     ItemParentId = parentItemId;
     Data = itemData;
     //itemData.DiagramControl = diagramControl;
 }
Example #6
0
 public DesignerItem(string id, string text, object itemData, DiagramControl diagramControl)
     : this(id, text, diagramControl)
 {
     Data = itemData;
     //itemData.DiagramControl = diagramControl;
 }
Example #7
0
 public DesignerItem(DiagramControl diagramControl)
     : this(Guid.NewGuid().ToString(), "New Item", diagramControl) { }
Example #8
0
 public DesignerItem(string id, string text, DiagramControl diagramControl)
 {
     this.ItemId = id;
     Text = text;
     ItemParentId = string.Empty;
     Loaded += DesignerItem_Loaded;
     //Data = new CustomItemData(id);
     //Data.DiagramControl = diagramControl;
     DiagramControl = diagramControl;
     Focusable = false;
     MouseDoubleClick += (sender, e) =>
      {
          diagramControl.DiagramManager.Edit(this);
      };
 }
Example #9
0
 public DesignerItem(string id, string parentItemId, string text, object itemData, DiagramControl diagramControl)
     : this(id, text, itemData, diagramControl)
 {
     ItemParentId = parentItemId;
     Data         = itemData;
     //itemData.DiagramControl = diagramControl;
 }
Example #10
0
 public DesignerItem(string id, string text, object itemData, DiagramControl diagramControl)
     : this(id, text, diagramControl)
 {
     Data = itemData;
     //itemData.DiagramControl = diagramControl;
 }
Example #11
0
 public DesignerItem(DiagramControl diagramControl)
     : this(Guid.NewGuid().ToString(), "New Item", diagramControl)
 {
 }
Example #12
0
        List<ItemDataBase> _clipbrd = new List<ItemDataBase>(); //clipboard 复制,剪切板

        #endregion Fields

        #region Constructors

        public DiagramManager(DiagramControl diagramControl)
        {
            _diagramControl = diagramControl;
        }
Example #13
0
 public DiagramManager(DiagramControl diagramControl)
 {
     _diagramControl = diagramControl;
 }