Пример #1
0
        void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            DesignerItemViewModelBase designerItem = this.DataContext as DesignerItemViewModelBase;

            if (designerItem != null && designerItem.IsSelected)
            {
                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                // we only move DesignerItems
                var designerItems = designerItem.SelectedItems;

                foreach (DesignerItemViewModelBase item in designerItems.OfType <DesignerItemViewModelBase>())
                {
                    double left = item.Left;
                    double top  = item.Top;
                    minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
                    minTop  = double.IsNaN(top) ? 0 : Math.Min(top, minTop);

                    double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
                    double deltaVertical   = Math.Max(-minTop, e.VerticalChange);
                    item.Left += deltaHorizontal;
                    item.Top  += deltaVertical;
                }
                e.Handled = true;
            }
        }
Пример #2
0
 static void Fe_MouseEnter(object sender, MouseEventArgs e)
 {
     if (((FrameworkElement)sender).DataContext is DesignerItemViewModelBase)
     {
         DesignerItemViewModelBase designerItem = (DesignerItemViewModelBase)((FrameworkElement)sender).DataContext;
         designerItem.ShowConnectors = true;
     }
 }
Пример #3
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;

            if (dragObject != null)
            {
                (DataContext as IDiagramViewModel).ClearSelectedItemsCommand.Execute(null);
                Point position = e.GetPosition(this);
                DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(dragObject.ContentType);
                itemBase.Left       = Math.Max(0, position.X - DesignerItemViewModelBase.ItemWidth / 2);
                itemBase.Top        = Math.Max(0, position.Y - DesignerItemViewModelBase.ItemHeight / 2);
                itemBase.IsSelected = true;
                labelIndex++;
                itemBase.Label = "步骤" + labelIndex;
                (DataContext as IDiagramViewModel).AddItemCommand.Execute(itemBase);
            }
            e.Handled = true;
        }
Пример #4
0
 public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation)
     : base(orientation)
 {
     this.DataItem = dataItem;
 }