Пример #1
0
        void dragData_DragCompleted(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ActiveDiagramView.Cursor          = Cursors.Arrow;
            dragData.DraggedObject.Visibility = Visibility.Hidden;
            ActiveDiagramView.Children.Remove(dragData.DraggedObject);
            ActiveDiagramView.State = ECanvasState.Normal;

            NewPositionableElementMacroCommand command = dragData.CreateCommand(ActiveDiagramView.Controller);

            Point p1 = e.GetPosition(ActiveDiagramView);
            Point p2 = e.GetPosition(dragData.Sender);

            if (p1.X >= 0 && p1.Y >= 0 && p1.X <= ActiveDiagramView.ActualWidth && p1.Y <= ActiveDiagramView.ActualHeight)
            {
                command.X = e.GetPosition(ActiveDiagramView).X;
                command.Y = e.GetPosition(ActiveDiagramView).Y;
            }
            else if (p2.X >= 0 && p2.Y >= 0 && p2.X <= dragData.Sender.ActualWidth && p2.Y <= dragData.Sender.ActualHeight)
            {
                command.X = 40;
                command.Y = 40;
            }
            InitializeCommand(command);
            command.Set(ActivePanelWindow.ModelController, ActivePanelWindow.ModelController.Model);
            command.Execute();
            ElementInserted(command.AssociatedElements);
        }
Пример #2
0
 protected override void InitializeCommand(NewPositionableElementMacroCommand command)
 {
     base.InitializeCommand(command);
     ((NewModelCommentToDiagramCommand)command).Text = text;
     if (ActiveDiagramView.SelectedRepresentants.Count() == 1)
     {
         Element element = ActiveDiagramView.ElementRepresentations.GetElementRepresentedBy(ActiveDiagramView.SelectedRepresentants.First());
         if (element is Comment)
         {
             if ((element as Comment).AnnotatedElement != null)
             {
                 ((NewModelCommentToDiagramCommand)command).AnnotatedElement = (element as Comment).AnnotatedElement;
             }
         }
         else
         {
             ((NewModelCommentToDiagramCommand)command).AnnotatedElement = element;
         }
         DragThumb   thumb      = ActiveDiagramView.SelectedRepresentants.First() as DragThumb;
         ISelectable selectable = ActiveDiagramView.SelectedRepresentants.First() as ISelectable;
         if (command.X == 40 && command.Y == 40)
         {
             if (thumb != null)
             {
                 command.X = (thumb).ActualWidth + 20;
                 command.Y = 20;
             }
             else if (selectable != null)
             {
                 command.X = selectable.GetBounds().GetCenter().X + 40;
                 command.X = selectable.GetBounds().GetCenter().Y;
             }
         }
         else
         {
             if (thumb != null)
             {
                 command.X -= (thumb).Left;
                 command.Y -= (thumb).Top;
             }
         }
     }
 }
Пример #3
0
 protected virtual void InitializeCommand(NewPositionableElementMacroCommand command)
 {
 }
Пример #4
0
 protected override void InitializeCommand(NewPositionableElementMacroCommand command)
 {
     base.InitializeCommand(command);
     (command as NewModelClassToDiagramCommand).ClassName = className;
 }