예제 #1
0
 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;
 }
예제 #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);
     };
 }
예제 #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;
            }
        }
예제 #4
0
 public SelectionService(DesignerCanvas canvas, DiagramControl diagramControl)
 {
     this.designerCanvas  = canvas;
     this._diagramControl = diagramControl;
 }
예제 #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;
 }
예제 #6
0
 public DesignerItem(string id, string text, object itemData, DiagramControl diagramControl)
     : this(id, text, diagramControl)
 {
     Data = itemData;
     //itemData.DiagramControl = diagramControl;
 }
예제 #7
0
 public DesignerItem(DiagramControl diagramControl)
     : this(Guid.NewGuid().ToString(), "New Item", diagramControl) { }
예제 #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);
      };
 }
예제 #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;
 }
예제 #10
0
 public DesignerItem(string id, string text, object itemData, DiagramControl diagramControl)
     : this(id, text, diagramControl)
 {
     Data = itemData;
     //itemData.DiagramControl = diagramControl;
 }
예제 #11
0
 public DesignerItem(DiagramControl diagramControl)
     : this(Guid.NewGuid().ToString(), "New Item", diagramControl)
 {
 }
예제 #12
0
        List<ItemDataBase> _clipbrd = new List<ItemDataBase>(); //clipboard 复制,剪切板

        #endregion Fields

        #region Constructors

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