Example #1
0
        static void dragData_DragCompleted(object sender, MouseButtonEventArgs e)
        {
            DragButtonData dragData          = (DragButtonData)sender;
            PIM_Class      draggedClass      = ((PIM_Class)dragData.DraggedObject);
            XCaseCanvas    ActiveDiagramView = draggedClass.XCaseCanvas;

            dragData.DraggedObject.Visibility = Visibility.Hidden;
            ActiveDiagramView.Children.Remove(dragData.DraggedObject);
            ActiveDiagramView.State = ECanvasState.Normal;

            if (draggedClass.Left > 0 && draggedClass.Top > 0)
            {
                if (ActiveDiagramView.Diagram is PIMDiagram)
                {
                    ElementToDiagramCommand <Class, ClassViewHelper> command =
                        (ElementToDiagramCommand <Class, ClassViewHelper>)dragData.CommandFactory.Create(ActiveDiagramView.Controller);

                    command.ViewHelper.X    = draggedClass.Left;
                    command.ViewHelper.Y    = draggedClass.Top;
                    command.IncludedElement = new ElementHolder <Class> {
                        Element = (Class)draggedClass.ModelElement
                    };
                    command.Execute();
                }
                else if (ActiveDiagramView.Diagram is PSMDiagram)
                {
                    DerivePSMClassToDiagramCommand c = (DerivePSMClassToDiagramCommand)DerivePSMClassToDiagramCommandFactory.Factory().Create(ActiveDiagramView.Controller.ModelController);
                    c.Set(draggedClass.ClassController.Class, (PSMDiagram)ActiveDiagramView.Diagram);
                    if (c.CanExecute())
                    {
                        c.Execute();
                    }
                }
            }
        }
Example #2
0
        public override void Execute(object parameter)
        {
            ActiveDiagramView.State = ECanvasState.DraggingElement;

            ActiveDiagramView.Cursor = Cursors.Hand;
            dragData = PrepareButtonData();
            dragData.DragCompleted += dragData_DragCompleted;
            ActiveDiagramView.Children.Add(dragData.DraggedObject);
            DragButtonData classButtonData = dragData;

            classButtonData.AssociateWithControl(Control);
            ActiveDiagramView.draggingElementState.DragData = classButtonData;
            classButtonData.DraggedObject.Visibility        = Visibility.Hidden;
            classButtonData.Sender = Control;
            ActiveDiagramView.CaptureMouse();
        }
Example #3
0
        public static void Executed(object sender, ExecutedRoutedEventArgs e)
        {
            PIMClass    modelClass        = (PIMClass)(((StackPanel)((Button)e.OriginalSource).Parent).DataContext);
            XCaseCanvas ActiveDiagramView = ((MainWindow)sender).ActiveDiagram;

            if (ActiveDiagramView != null && !ActiveDiagramView.ElementRepresentations.IsElementPresent(modelClass) && !(modelClass is AssociationClass))
            {
                ActiveDiagramView.State = ECanvasState.DraggingElement;

                PIM_Class draggedObject = new PIM_Class(ActiveDiagramView);
                draggedObject.InitializeRepresentant(modelClass, new ClassViewHelper(ActiveDiagramView.Diagram), new ClassController(modelClass, ActiveDiagramView.Controller));

                DragButtonData dragData = new DragButtonData(ElementToDiagramCommandFactory <Class, ClassViewHelper> .Factory(), draggedObject);
                dragData.DragCompleted += dragData_DragCompleted;

                DragButtonData classButtonData = dragData;
                classButtonData.AssociateWithControl((Button)e.OriginalSource);
                ActiveDiagramView.draggingElementState.DragData = classButtonData;
                classButtonData.DraggedObject.Visibility        = Visibility.Hidden;
                classButtonData.Sender = (Button)e.OriginalSource;
                ActiveDiagramView.CaptureMouse();
            }
        }