コード例 #1
0
ファイル: DragThumb.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Called during dragging. Checks whether dragging can proceed (not out of bounds) and
        /// also calls virtual method <see cref="AdjustDrag"/> that allows subclasses of DragThumb
        /// to alter default dragging.
        /// </summary>
        /// <param name="deltaEventArgs">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
        protected virtual void DragDelta(DragDeltaEventArgs deltaEventArgs)
        {
            IEnumerable <ISelectable> draggedElements = XCaseCanvas.SelectedItems.Where(item => item is DragThumb && (item.CanBeDraggedInGroup || DraggingAllone(item)));

            if (draggedElements.Count() > 0)
            {
                double minLeft = draggedElements.Min(item => item.GetBounds().Left);
                double minTop  = draggedElements.Min(item => item.GetBounds().Top);

                double deltaHorizontal = Math.Max(-minLeft, deltaEventArgs.HorizontalChange);
                double deltaVertical   = Math.Max(-minTop, deltaEventArgs.VerticalChange);
                deltaEventArgs = new DragDeltaEventArgs(deltaHorizontal, deltaVertical);

                AdjustDrag(ref deltaEventArgs);

                foreach (DragThumb element in draggedElements)
                {
                    element.x = element.x + deltaEventArgs.HorizontalChange;
                    element.y = element.y + deltaEventArgs.VerticalChange;
                    if (element.Placement == EPlacementKind.ParentAutoPos)
                    {
                        element.Placement = EPlacementKind.AbsoluteSubCanvas;
                    }
                    UpdatePos(element);
                }
                XCaseCanvas.InvalidateMeasure();
                if (visualAidsAdorner != null)
                {
                    visualAidsAdorner.d = deltaEventArgs;
                    visualAidsAdorner.InvalidateVisual();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XCaseJunction"/> class.
 /// </summary>
 /// <param name="xCaseCanvas">canvas where the control is placed</param>
 /// <param name="generalization">generalization that owns the junction</param>
 /// <param name="viewHelperPointsCollection">Reference to a collection of points (in ViewHelper)</param>
 public XCaseJunction(XCaseCanvas xCaseCanvas, PIM_Generalization generalization, ObservablePointCollection viewHelperPointsCollection) :
     this(xCaseCanvas, viewHelperPointsCollection)
 {
     this.Generalization = generalization;
     this.SelectionOwner = generalization;
     InitializeContextMenu();
 }
コード例 #3
0
        /// <summary>
        /// Creates new instance of <see cref="XCaseJunction"/>.
        /// </summary>
        /// <param name="xCaseCanvas">canvas where the control is placed</param>
        /// <param name="viewHelperPointsCollection">Reference to a collection of points (in ViewHelper)</param>
        public XCaseJunction(XCaseCanvas xCaseCanvas, ObservablePointCollection viewHelperPointsCollection)
            : this(xCaseCanvas)
        {
            this.viewHelperPointsCollection = viewHelperPointsCollection;

            viewHelperPointsCollection.CollectionChanged += viewHelperPointsCollection_CollectionChanged;
        }
コード例 #4
0
        /// <summary>
        /// Creates new instance of <see cref="PSM_ComponentConnector" />.
        /// </summary>
        public PSM_ComponentConnector(XCaseCanvas canvas, IConnectable parentControl, IConnectable childControl, ComponentConnectorViewHelper viewHelper)
        {
            ParentControl = parentControl;
            ChildControl  = childControl;
            XCaseCanvas   = canvas;
            ViewHelper    = viewHelper;
            if (viewHelper.Points.Count < 2)
            {
                viewHelper.Points.Clear();
                viewHelper.Points.AppendRange(JunctionGeometryHelper.ComputeOptimalConnection(parentControl, childControl));
                viewHelper.Points.PointsInvalid = true;
            }

            Junction = new XCaseJunction(canvas, viewHelper.Points);
            Junction.AutoPosModeOnly = true;
            XCaseCanvas.Children.Add(Junction);
            Junction.NewConnection(parentControl, null, childControl, null, viewHelper.Points);
            if (childControl is System.Windows.Controls.Control)
            {
                if (childControl is PSM_ContentContainer)
                {
                    Junction.ContextMenu = ((PSM_ContentContainer)childControl).ContextMenu;
                }
                Junction.ContextMenu = ((System.Windows.Controls.Control)childControl).ContextMenu;
            }
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XCaseJunction"/> class.
 /// </summary>
 /// <param name="xCaseCanvas">canvas where the control is placed</param>
 /// <param name="association">association that owns the junction</param>
 /// <param name="viewHelperPointsCollection">Reference to a collection of points (in ViewHelper)</param>
 public XCaseJunction(XCaseCanvas xCaseCanvas, PIM_Association association, ObservablePointCollection viewHelperPointsCollection) :
     this(xCaseCanvas, viewHelperPointsCollection)
 {
     this.Association    = association;
     this.SelectionOwner = association;
     InitializeContextMenu();
 }
コード例 #6
0
ファイル: PSM_ClassUnion.cs プロジェクト: mff-uk/xcase
        public PSM_ClassUnion(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Template init
            Template = Application.Current.Resources["PSM_ClassUnionTemplate"] as ControlTemplate;
            ApplyTemplate();

            PSM_ClassUnionTemplate gr = Template.FindName("PSM_ClassUnionGrid", this) as PSM_ClassUnionTemplate;
            Border             = gr.FindName("Border") as Border;
            connectorDecorator = gr.FindName("ConnectorDecorator") as Control;
            connectorDecorator.ApplyTemplate();
            #endregion

            ContextMenu = new ContextMenu();
            ContextMenuItem m = new ContextMenuItem("Remove");
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += delegate(object sender, RoutedEventArgs e) { ClassUnionController.Remove(); };
            ContextMenu.Items.Add(m);

            ContextMenu.Items.Add(new Separator());
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                ContextMenu.Items.Add(item);
            }
        }
コード例 #7
0
ファイル: DragThumb.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Returns
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. The event data reports that one or more mouse buttons were pressed.</param>
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseDown(e);

            if (XCaseCanvas != null && this is ISelectable)
            {
                XCaseCanvas.SelectableItemPreviewMouseDown(this as ISelectable, e);
            }
        }
コード例 #8
0
        /// <summary>
        /// Creates new instance of <see cref="XCaseJunction" />.
        /// </summary>
        /// <param name="xCaseCanvas">canvas where the control is placed</param>
        public XCaseJunction(XCaseCanvas xCaseCanvas)
        {
            this.XCaseCanvas = xCaseCanvas;

            Points = new List <JunctionPoint>();
            Fill   = Brushes.White;
            Pen    = MediaLibrary.SolidBlackPen;
            InitializeContextMenu();
        }
コード例 #9
0
ファイル: ResizeThumb.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Initializes the resizing process, stores old sizes of all the selected resizable elements.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragStartedEventArgs"/> instance containing the event data.</param>
        void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            Control     designerItem = this.belongsTo;
            XCaseCanvas designer     = VisualTreeHelper.GetParent(designerItem) as XCaseCanvas;

            startSizes = new Dictionary <Control, Size>();
            foreach (Control item in (designer.SelectedItems).OfType <IResizable>())
            {
                startSizes[item] = new Size(item.Width, item.Height);
            }
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PIM_AssociationEnd"/> class.
 /// </summary>
 /// <param name="xCaseCanvas">canvas where the control is placed</param>
 /// <param name="viewHelper">ViewHelper of the control, stores visualization information.</param>
 /// <param name="associationEnd">reprsented association end.</param>
 public PIM_AssociationEnd(XCaseCanvas xCaseCanvas, AssociationEndViewHelper viewHelper, AssociationEnd associationEnd)
     : base(xCaseCanvas)
 {
     PositionChanged += AdjustLabelsPositions;
     AssociationEnd   = associationEnd;
     ViewHelper       = viewHelper;
     if (multiplicityLabel != null)
     {
         multiplicityLabel.ViewHelper = ViewHelper.MultiplicityLabelViewHelper;
     }
 }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XCasePrimitiveJunction"/> class.
        /// </summary>
        /// <param name="xCaseCanvas">canvas where the control is placed</param>
        /// <param name="sourceElement">source element</param>
        /// <param name="targetElement">target element</param>
        public XCasePrimitiveJunction(XCaseCanvas xCaseCanvas, IHasBounds sourceElement, IPrimitiveJunctionTarget targetElement)
        {
            SourceElement = sourceElement;
            TargetElement = targetElement;
            XCaseCanvas   = xCaseCanvas;

            ((FrameworkElement)sourceElement).SizeChanged += delegate { InvalidateVisual(); };
            ((Control)sourceElement).LayoutUpdated        += Source_LayoutUpdated;
            XCaseCanvas.Children.Add(this);
            Source_LayoutUpdated(null, null);
            Pen = MediaLibrary.SolidBlackPen;
        }
コード例 #12
0
        public PSM_AttributeContainer(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            SizeChanged += delegate(object sender, SizeChangedEventArgs e) { xCaseCanvas.InvokeElementSizeChanged(this, e); };

            InitTemplate();

            InitContextMenu();

            classProperties = new PSMAttributesContainer(ACSection, xCaseCanvas);
            //Movable = false;
        }
コード例 #13
0
ファイル: TextBoxContainer.cs プロジェクト: mff-uk/xcase
 /// <summary>
 /// Initializes a new instance of the <see cref="TextBoxContainer&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="container">Panel where <see cref="EditableTextBox">EditableTextBoxes</see>
 /// are created</param>
 /// <param name="xCaseCanvas"><see cref="XCaseCanvas"/> containing the control</param>
 public TextBoxContainer(Panel container, XCaseCanvas xCaseCanvas)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     if (xCaseCanvas == null)
     {
         throw new ArgumentNullException("xCaseCanvas");
     }
     this.container   = container;
     this.XCaseCanvas = xCaseCanvas;
 }
コード例 #14
0
ファイル: VisualAidsAdorner.cs プロジェクト: mff-uk/xcase
        public VisualAidsAdorner(XCaseCanvas designerCanvas, DragThumb draggedObject)
            : base(designerCanvas)
        {
            this.draggedObject = (IAlignable)draggedObject;

            foreach (object element in designerCanvas.Children)
            {
                if (element is IAlignable && draggedObject != element)
                {
                    otherVisualAidsPoints.AddRange((element as IAlignable).GetVisualAidsPoints());
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Draws junction between <paramref name="c1"/> and <paramref name="endPoint"/>. This method is supposed
        /// to be used when connection is dragged between two elements (one of them is <paramref name="c1"/>)
        /// and <paramref name="endPoint"/> is being dragged "on the way" to the second element.
        /// </summary>
        /// <param name="c1">connected element</param>
        /// <param name="endPoint">dragged point</param>
        /// <param name="canvas">canvas where the junction is created</param>
        internal void DragConnection(IConnectable c1, JunctionPoint endPoint, XCaseCanvas canvas)
        {
            SourceElement = c1 as Control;

            JunctionPoint startPoint = c1.CreateJunctionEnd();

            startPoint.Junction        = this;
            startPoint.OrderInJunction = 0;
            endPoint.Junction          = this;
            endPoint.OrderInJunction   = 1;
            Points.Add(startPoint);
            Points.Add(endPoint);
            TargetElement = null;
        }
コード例 #16
0
        public PSM_ContentContainer(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Template Init
            base.Template = Application.Current.Resources["PSM_ContentContainerTemplate"] as ControlTemplate;
            ApplyTemplate();

            PSM_ContentContainerTemplate gr = Template.FindName("PSM_ContentContainerGrid", this) as PSM_ContentContainerTemplate;

            Border  = gr.FindName("Border") as Border;
            TextBox = gr.FindName("txtName") as EditableTextBox;

            connectorDecorator = gr.FindName("ConnectorDecorator") as Control;
            connectorDecorator.ApplyTemplate();
            #endregion

            TextBox.mi_Rename.Header = "Rename content container";

            ContextMenuItem m = new ContextMenuItem("Remove content container");
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += delegate(object sender, RoutedEventArgs e) { ContentContainerController.Remove(); };
            TextBox.ContextMenu.Items.Add(m);

            ContextMenuItem moveToContentContainer = new ContextMenuItem("Move to content container");
            moveToContentContainer.Click += delegate
            {
                ContentContainerController.MoveToContentContainer(null);
            };

            TextBox.ContextMenu.Items.Add(moveToContentContainer);

            ContextMenuItem moveToContentChoice = new ContextMenuItem("Move to content choice");
            moveToContentChoice.Click += delegate
            {
                ContentContainerController.MoveToContentChoice(null);
            };

            TextBox.ContextMenu.Items.Add(moveToContentChoice);



            TextBox.ContextMenu.Items.Add(new Separator());
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                TextBox.ContextMenu.Items.Add(item);
            }

            TextBox.TextEdited += delegate(object sender, StringEventArgs args) { Controller.RenameElement <NamedElement>(args.Data, null); XCaseCanvas.InvokeElementSizeChanged(this, null); };
        }
コード例 #17
0
ファイル: PSM_ComponentsManager.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Creates new instance of <see cref="PSM_ComponentsManager" />.
        /// </summary>
        /// <param name="xCaseCanvas">canvas of the PSM diagram</param>
        /// <param name="superordinateElement">element whose components are visualized by the created PSM_ComponentsManager</param>
        /// <param name="superordinateRepresentation">representation of <paramref name="superordinateElement"/> on <paramref name="xCaseCanvas"/></param>
        public PSM_ComponentsManager(XCaseCanvas xCaseCanvas, PSMSuperordinateComponent superordinateElement, XCaseViewBase superordinateRepresentation)
        {
            if (!(xCaseCanvas.Diagram is PSMDiagram))
            {
                throw new ArgumentException("Component manager can be put only on canvas representing PSM diagram. ", "xCaseCanvas");
            }

            XCaseCanavs                 = xCaseCanvas;
            SuperordinateElement        = superordinateElement;
            SuperordinateRepresentation = superordinateRepresentation;

            ComponentsData = new Dictionary <PSMSubordinateComponent, ComponentData>();

            SuperordinateElement.Components.CollectionChanged += Components_CollectionChanged;
        }
コード例 #18
0
ファイル: VisualAidsAdorner.cs プロジェクト: mff-uk/xcase
        public static List <Point> GetVisualAidsPointsForDiagram(XCaseCanvas diagramView, params Type[] excluded)
        {
            List <Point> points = new List <Point>();

            foreach (object element in diagramView.Children)
            {
                if (element is IAlignable && !excluded.Contains(element.GetType()))
                {
                    points.AddRange((element as IAlignable).GetVisualAidsPoints());
                }
            }
            points.Add(new Point(0, 0));
            points.Add(new Point(0, diagramView.ActualHeight - 10));
            points.Add(new Point(diagramView.ActualWidth - 10, 0));
            points.Add(new Point(diagramView.ActualWidth - 10, diagramView.ActualHeight - 10));
            return(points);
        }
コード例 #19
0
ファイル: AssociationDiamond.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Initializes a new instance of the <see cref="AssociationDiamond"/> class.
        /// </summary>
        /// <param name="xCaseCanvas">Canvas where the control is placed</param>
        /// <param name="association">Association belonging to the association diamond</param>
        /// <param name="viewHelper">ViewHelper for the control</param>
        public AssociationDiamond(XCaseCanvas xCaseCanvas, PIM_Association association, PositionableElementViewHelper viewHelper)
            : base(xCaseCanvas)
        {
            #region AssociationDiamond Template init
            Template = (ControlTemplate)Application.Current.Resources["AssociationDiamondTemplate"];
            ApplyTemplate();

            AssociationDiamondTemplate gr = (AssociationDiamondTemplate)Template.FindName("AssociationDiamondGrid", this);

            connectorDecorator = (Control)gr.FindName("ConnectorDecorator");
            connectorDecorator.ApplyTemplate();
            #endregion

            Association     = association;
            this.viewHelper = viewHelper;

            this.StartBindings(TypeBindingData.EBindingSourceType.View);
        }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RubberbandAdorner"/> class.
        /// </summary>
        /// <param name="xCaseCanvas">The designer canvas.</param>
        /// <param name="dragStartPoint">The drag start point.</param>
        public RubberbandAdorner(XCaseCanvas xCaseCanvas, Point?dragStartPoint)
            : base(xCaseCanvas)
        {
            this.xCaseCanvas = xCaseCanvas;
            this.startPoint  = dragStartPoint;
            this.endPoint    = dragStartPoint;

            this.adornerCanvas            = new Canvas();
            this.adornerCanvas.Background = Brushes.Transparent;
            this.visuals = new VisualCollection(this);
            this.visuals.Add(this.adornerCanvas);

            this.rubberband                 = new Rectangle();
            this.rubberband.Stroke          = Brushes.Navy;
            this.rubberband.StrokeThickness = 1;
            this.rubberband.StrokeDashArray = new DoubleCollection(new double[] { 2 });

            this.adornerCanvas.Children.Add(this.rubberband);
        }
コード例 #21
0
        public XCaseComment(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Commentary Template Init

            Template = (ControlTemplate)Application.Current.Resources["XCaseCommentaryTemplate"];
            ApplyTemplate();

            XCaseCommentTemplate gr = (XCaseCommentTemplate)Template.FindName("CommentaryGrid", this);

            if (gr != null)
            {
                CommentBorder  = gr.FindName("CommentBorder") as Border;
                CommentTextBox = (EditableTextBox)gr.FindName("txtText");

                resizeDecorator = (Control)gr.FindName("ResizeDecorator");
                resizeDecorator.ApplyTemplate();
                Grid g = (Grid)resizeDecorator.Template.FindName("ResizeDecoratorGrid", resizeDecorator);
                foreach (ResizeThumb t in g.Children)
                {
                    t.belongsTo = this;
                }

                connectorDecorator = (Control)gr.FindName("ConnectorDecorator");
                connectorDecorator.ApplyTemplate();
            }

            #endregion

            #region Commentary Context Menu

            ContextMenuItem m = new ContextMenuItem("Remove from diagram");
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += new RoutedEventHandler(Remove_Click);
            CommentTextBox.ContextMenu.Items.Add(m);
            CommentTextBox.mi_Rename.Header = "Change";

            #endregion

            CommentTextBox.TextEdited += delegate(object sender, StringEventArgs args) { Controller.ChangeComment(args.Data); };
            PositionChanged           += delegate { CommentTextBox.myEditable = false; };
        }
コード例 #22
0
ファイル: PIM_Class.cs プロジェクト: mff-uk/xcase
        public PIM_Class(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            InitTemplate();

            classAttributes = new AttributesContainer(AttributesSection, xCaseCanvas);
            classOperations = new OperationsContainer(OperationsSection, xCaseCanvas);
            Border[]            stackBorders    = new Border[] { HeaderBorder, PropertiesBorder, MethodsBorder };
            ITextBoxContainer[] stackContainers = new ITextBoxContainer[] { classAttributes, classOperations };
            classAttributes.StackBorders    = stackBorders;
            classAttributes.StackContainers = stackContainers;
            classOperations.StackBorders    = stackBorders;
            classOperations.StackContainers = stackContainers;

            InitContextMenu();

            txtClassName.TextEdited       += delegate(object sender, StringEventArgs args) { Controller.RenameElement <PIMClass>(args.Data, ((PIMClass)ModelElement).Package.Classes); };
            PositionChanged               += CancelAllEdits;
            txtClassName.MouseDoubleClick += txtClassName_MouseDoubleClick;
        }
コード例 #23
0
        public AssociationLabel(XCaseCanvas xCaseCanvas, AssociationLabelViewHelper labelViewHelper) :
            base(xCaseCanvas)
        {
            FontWeight = FontWeights.Bold;

            Margin = new Thickness(0);

            Template = (ControlTemplate)Application.Current.Resources["XCaseJunctionLabelTemplate"];
            ApplyTemplate();

            XCaseJunctionLabelTemplate gr = (XCaseJunctionLabelTemplate)Template.FindName("JunctionLabelGrid", this);

            TextBox = gr.txtText;

            OriginalTextBrush = Brushes.Blue;
            ViewHelper        = labelViewHelper;
            FocusVisualStyle  = null;

            this.StartBindings(TypeBindingData.EBindingSourceType.View);
        }
コード例 #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JunctionPoint"/> class.
        /// </summary>
        /// <param name="xCaseCanvas">Canvas where the point is created.</param>
        public JunctionPoint(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            Width           = 0;
            Height          = 0;
            OrderInJunction = -1;
            Background      = Brushes.Gold;

            Opacity = MediaLibrary.PointOpacityNormal;
            Cursor  = Cursors.Hand;

            ContextMenu m = new ContextMenu();

            m.Items.Add(new ContextMenuItem("Straighten line here"));
            ((ContextMenuItem)m.Items[0]).Click += Remove_click;

            ContextMenu = m;

            this.SetValue(TemplateProperty, null);
        }
コード例 #25
0
ファイル: PSM_DiagramReference.cs プロジェクト: mff-uk/xcase
        public PSM_DiagramReference(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Template Init
            base.Template = Application.Current.Resources["PSM_DiagramReferenceTemplate"] as ControlTemplate;
            ApplyTemplate();

            PSM_DiagramReferenceTemplate gr = Template.FindName("PSM_DiagramReferenceGrid", this) as PSM_DiagramReferenceTemplate;

            Border  = gr.FindName("Border") as Border;
            TextBox = gr.FindName("txtName") as EditableTextBox;

            tLocal             = gr.FindName("tLocal") as EditableTextBox;
            tSchemaLocation    = gr.FindName("tSchemaLocation") as EditableTextBox;
            tNamespacePrefix   = gr.FindName("tNamespacePrefix") as EditableTextBox;
            tNamespace         = gr.FindName("tNamespace") as EditableTextBox;
            tReferencedDiagram = gr.FindName("tReferencedDiagram") as EditableTextBox;

            connectorDecorator = gr.FindName("ConnectorDecorator") as Control;
            connectorDecorator.ApplyTemplate();
            #endregion
        }
コード例 #26
0
ファイル: ResizeThumb.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Finalizes the resizing process, issues the resize command (see <see cref="ResizeElementCommand"/>).
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragCompletedEventArgs"/> instance containing the event data.</param>
        void ResizeThumb_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            Control     designerItem = this.belongsTo;
            XCaseCanvas designer     = VisualTreeHelper.GetParent(designerItem) as XCaseCanvas;

            if (designer != null)
            {
                MacroCommand <DiagramController> macroResize = MacroCommandFactory <DiagramController> .Factory().Create(designer.Controller);

                macroResize.Description = CommandDescription.RESIZE_MACRO;
                // generate move Commands for all resized elements and execute them as macro
                foreach (Control item in designer.SelectedItems.OfType <IResizable>())
                {
                    item.Width  = startSizes[item].Width;
                    item.Height = startSizes[item].Height;

                    CommandBase command =
                        ViewController.CreateResizeCommand(item.ActualWidth, item.ActualHeight, ((IResizable)item).ViewHelper,
                                                           designer.Controller);
                    macroResize.Commands.Add(command);
                }
                macroResize.Execute();
            }
        }
コード例 #27
0
ファイル: ResizeThumb.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Proceeds with resizing, checks the bounds.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
        void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            Control     designerItem = this.belongsTo;
            XCaseCanvas designer     = VisualTreeHelper.GetParent(designerItem) as XCaseCanvas;

            if (designerItem != null && designer != null)
            {
                double minLeft            = double.MaxValue;
                double minTop             = double.MaxValue;
                double minDeltaHorizontal = double.MaxValue;
                double minDeltaVertical   = double.MaxValue;

                // drag limits are set by these parameters: canvas top, canvas left, minHeight, minWidth
                // calculate min value for each parameter for each item
                foreach (Control item in designer.SelectedItems.OfType <IResizable>())
                {
                    double left = Canvas.GetLeft(item);
                    double top  = Canvas.GetTop(item);

                    minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
                    minTop  = double.IsNaN(top) ? 0 : Math.Min(top, minTop);

                    minDeltaVertical   = Math.Min(minDeltaVertical, item.ActualHeight - item.MinHeight);
                    minDeltaHorizontal = Math.Min(minDeltaHorizontal, item.ActualWidth - item.MinWidth);
                }

                double dragDeltaVertical, dragDeltaHorizontal;
                foreach (Control item in designer.SelectedItems.OfType <IResizable>())
                {
                    switch (VerticalAlignment)
                    {
                    case VerticalAlignment.Bottom:
                        dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
                        item.Height       = item.ActualHeight - dragDeltaVertical;
                        break;

                    case VerticalAlignment.Top:
                        double top = Canvas.GetTop(item);
                        dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
                        Canvas.SetTop(item, top + dragDeltaVertical);
                        item.Height = item.ActualHeight - dragDeltaVertical;
                        break;

                    default:
                        break;
                    }

                    switch (HorizontalAlignment)
                    {
                    case HorizontalAlignment.Left:
                        double left = Canvas.GetLeft(item);
                        dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
                        Canvas.SetLeft(item, left + dragDeltaHorizontal);
                        item.Width = item.ActualWidth - dragDeltaHorizontal;
                        break;

                    case HorizontalAlignment.Right:
                        dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
                        item.Width          = item.ActualWidth - dragDeltaHorizontal;
                        break;

                    default:
                        break;
                    }
                }
                e.Handled = true;
            }
        }
コード例 #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PSM_Association"/> class.
 /// </summary>
 /// <param name="xCaseCanvas">canvas where the control is placed</param>
 public PSM_Association(XCaseCanvas xCaseCanvas)
 {
     this.XCaseCanvas = xCaseCanvas;
 }
コード例 #29
0
 protected override void OnMouseLeave(MouseEventArgs e)
 {
     base.OnMouseLeave(e);
     XCaseCanvas.InvokeVersionedElementMouseLeave(this, Association);
 }
コード例 #30
0
 void junction_MouseEnter(object sender, MouseEventArgs e)
 {
     XCaseCanvas.InvokeVersionedElementMouseEnter(sender, Association);
 }