public void SetSelection(Component component, bool focusComponent = false) { ClearSelection(false); ComponentViewBase view = RepresentantsCollection[component]; if (view != null) { view.Selected = true; if (focusComponent) { view.Focus(); double x = 0; double y = 0; if (view is INodeComponentViewBase) { x = Canvas.GetLeft(((INodeComponentViewBase)view).MainNode); y = Canvas.GetTop(((INodeComponentViewBase)view).MainNode); } if (view is IConnectorViewBase) { x = Canvas.GetLeft(((IConnectorViewBase)view).Connector); y = Canvas.GetTop(((IConnectorViewBase)view).Connector); } ScrollViewer scrollViewer = ExolutioCanvasWithZoomer.scrollViewer; scrollViewer.ScrollToHorizontalOffset(x); scrollViewer.ScrollToVerticalOffset(y); } } InvokeSelectionChanged(); }
public void SetSelection(IEnumerable <Component> components) { ClearSelection(false); foreach (Component component in components) { ComponentViewBase componentViewBase = RepresentantsCollection[component]; SelectedViews.Add(componentViewBase); componentViewBase.SelectAndSelectCreatedControls(); } InvokeSelectionChanged(); }
/// <summary> /// Draws all children of given root element and counts width of its subtree. /// </summary> /// <param name="psmDiagramView">Diagram to be layouted</param> /// <param name="root">Root element of layouted subtree</param> /// <param name="top">Location of the upper border of the root's children</param> /// <param name="left">Location of the left border of the entire subtree</param> /// <returns>Width of the subtree (root not included)</returns> protected virtual double DrawSubtree(PSMDiagramView psmDiagramView, PSMComponent root, double top, double left) { double right = left; if (root is PSMAssociationMember) { ComponentViewBase componentView = psmDiagramView.RepresentantsCollection[root]; if (componentView is IComponentViewBaseVH && ((IComponentViewBaseVH)componentView).ViewHelper is IFoldableComponentViewHelper) { if (((IFoldableComponentViewHelper)((IComponentViewBaseVH)componentView).ViewHelper).IsFolded) { return(right - left); } } PSMAssociationMember rootAM = (PSMAssociationMember)root; if (rootAM.ChildPSMAssociations.Count > 0) { foreach (PSMAssociation childAssociation in rootAM.ChildPSMAssociations) { if (childAssociation.Child.ParentAssociation != childAssociation) { continue; } right += DrawTree(psmDiagramView, (childAssociation).Child, top, right) + horizontalSpace; } if (rootAM is PSMClass) { foreach (PSMGeneralization generalization in (rootAM as PSMClass).GeneralizationsAsGeneral) { right += DrawTree(psmDiagramView, (generalization).Specific, top, right) + horizontalSpace; } } } if (right != left) { right -= horizontalSpace; } } return(right - left); }
public static void FoldChildrenRecursive(PSMComponent parent, DiagramView activeDiagramView, EFoldingAction foldingAction) { IEnumerable <PSMComponent> childComponents = ModelIterator.GetPSMChildren(parent, false, true); foreach (PSMComponent childComponent in childComponents) { if (!activeDiagramView.RepresentantsCollection.IsElementPresent(childComponent)) { continue; } ComponentViewBase childView = activeDiagramView.RepresentantsCollection[childComponent]; bool proceed = true; if (childView.DownCastSatisfies <IComponentViewBaseVH>(c => c.ViewHelper.DownCastSatisfies <IFoldableComponentViewHelper>( fvh => (fvh.IsFolded && foldingAction == EFoldingAction.Fold) || fvh.IsFolded && foldingAction == EFoldingAction.Unfold))) { proceed = false; } FoldRecursive(childComponent, activeDiagramView, proceed, foldingAction); } }
public static void FoldRecursive(PSMComponent psmComponent, DiagramView activeDiagramView, bool proceed, EFoldingAction foldingAction) { if (!activeDiagramView.RepresentantsCollection.IsElementPresent(psmComponent)) { return; } ComponentViewBase componentView = activeDiagramView.RepresentantsCollection[psmComponent]; if (foldingAction == EFoldingAction.Fold) { componentView.HideAllControls(); } else { componentView.UnHideAllControls(); } if (proceed) { FoldChildrenRecursive(psmComponent, activeDiagramView, foldingAction); } }
private ComponentViewBase CreateItemView(Component component, ViewHelper viewHelper, List <ComponentViewBase> withoutViewHelpers) { if (!this.RepresentantsCollection.Registrations.ContainsKey(component.GetType())) { System.Diagnostics.Debug.WriteLine("Cannot represent type {0}.", component); return(null); } ComponentViewBase representant = this.RepresentantsCollection.Registrations[component.GetType()].RepresentantFactoryMethod(); if (viewHelper == null) { viewHelper = this.RepresentantsCollection.Registrations[component.GetType()].ViewHelperFactoryMethod(); ((IComponentViewHelper)viewHelper).Component = component; Diagram.ViewHelpers[component] = viewHelper; if (withoutViewHelpers != null) { withoutViewHelpers.Add(representant); } } representant.PutInDiagramDeferred(this, component, viewHelper); return(representant); }