void postfix_nodes(TreeNodeCollection nodes, bool is_visible) { foreach (TreeNode t in nodes) { if (t.Tag != null && t.Tag is NodeTag) { NodeTag nt = (NodeTag)t.Tag; UmlObject obj = nt.n as UmlObject; if (obj != null) { if (is_visible) { ArrayList l = new ArrayList(); get_children(obj, l); if (!nt.initialized) { add_nodes(t.Nodes, l, -1); nt.initialized = true; } else { merge_nodes(t.Nodes, l, -1); postfix_nodes(t.Nodes, t.IsExpanded); } } else { t.Nodes.Clear(); nt.initialized = false; } } } } }
void init_children(TreeNode t) { if (t.Tag != null && t.Tag is NodeTag) { NodeTag nt = (NodeTag)t.Tag; UmlObject obj = nt.n as UmlObject; if (!nt.initialized && obj != null) { ArrayList l = new ArrayList(); get_children(obj, l); add_nodes(t.Nodes, l, -1); nt.initialized = true; } } }
public void VisitClassAndImport(UmlObject v, UmlObject parent) { if (v.Kind == UmlKind.Class || v.Kind == UmlKind.Interface) { if (((UmlClass)v).BaseObjects != null) { foreach (string s in ((UmlClass)v).BaseObjects) { if (s.Equals(name)) { ImportClass((UmlClass)v); } } } } }
/// <summary> /// returns the number of icon for the given element /// </summary> /// <param name="e">C# element</param> public static int IconForElement(UmlObject e) { switch (e.Kind) { case UmlKind.Project: return(1); case UmlKind.Namespace: return(5); case UmlKind.Class: return(6 + access_of_modifier(e)); case UmlKind.Interface: return(9 + access_of_modifier(e)); case UmlKind.Struct: return(12 + access_of_modifier(e)); case UmlKind.Method: case UmlKind.Constructor: case UmlKind.Destructor: return(15 + access_of_modifier(e)); case UmlKind.Delegate: return(18 + access_of_modifier(e)); case UmlKind.Enum: return(21 + access_of_modifier(e)); case UmlKind.Field: case UmlKind.Constant: return(25 + access_of_modifier(e)); case UmlKind.Event: return(28 + access_of_modifier(e)); case UmlKind.Indexer: return(31 + access_of_modifier(e)); case UmlKind.Operator: return(34); } // unknown element, strange return(24); }
public static GuiItem CreateElement(UmlObject obj) { if (obj is UmlClass) { return(GuiClass.fromUML(obj as UmlClass)); } else if (obj is UmlEnum) { return(GuiEnum.fromUML(obj as UmlEnum)); } else if (obj is UmlNamespace) { return(GuiPackage.fromUML(obj as UmlNamespace)); } else { return(null); } }
// Drag-n-drop functions public override void StartDrag(UmlObject elem) { dropobj = elem; dropitem = GuiElementFactory.CreateElement(elem); if (dropitem != null) { System.Diagnostics.Debug.Assert(dropitem is IMoveable && dropitem is IRemoveable, "wrong element created"); dropitem.parent = parent; if (dropitem is INeedRefresh) { parent.RefreshObject((INeedRefresh)dropitem); } action = MouseAction.Drag; } else { action = MouseAction.None; } }
void get_children(UmlObject obj, ArrayList to) { if (obj is UmlProject) { obj = ((UmlProject)obj).root; } UmlTypeHolder from = obj as UmlTypeHolder; if (from == null) { return; } UmlNamespace ns = from as UmlNamespace; if (ns != null && ns.SubNamespaces != null) { foreach (UmlObject s in ns.SubNamespaces) { to.Add(s); } } foreach (UmlObject s in ((UmlTypeHolder)from).Types) { to.Add(s); } if (from is UmlClass) { UmlClass cl = (UmlClass)from; if (cl.Members != null) { foreach (UmlObject m in cl.Members) { to.Add(m); } } } }
void TreeMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { TreeNode node = (sender as TreeView).GetNodeAt(e.X, e.Y); if (node == null) { return; } object obj = ProjectTree.GetNodeObject(node); dragbox = Rectangle.Empty; if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { if (obj is UMLDes.GUI.View) { if (e.Clicks == 2) { UMLDes.GUI.View v = obj as UMLDes.GUI.View; SelectView(v, true); } } else if (!(obj is UmlDesignerSolution)) { Size dragSize = SystemInformation.DragSize; dragbox = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize); dragobject = obj as UmlObject; } } else if ((e.Button & MouseButtons.Right) == MouseButtons.Right) { ProjectTree.SelectedNode = node; if (obj != null) { TryDropDownMenu(e.X, e.Y, obj, node); } } }
/// <summary> /// determines the visibility of the element (looks at modifiers) /// </summary> /// <param name="e">C# element</param> /// <returns>0 - public, 1 - private, 2 - protected</returns> private static int access_of_modifier(UmlObject e) { if (e is UmlMember) { switch (((UmlMember)e).visibility) { case UmlVisibility.Public: return(0); case UmlVisibility.Internal: case UmlVisibility.Private: return(1); case UmlVisibility.Protected: case UmlVisibility.ProtectedInternal: return(2); } } else if (e is UmlClass) { return(0); // TODO } return(1); }
public abstract void StartDrag(UmlObject elem);
public static void ClearDeleted(UmlObject v, UmlObject parent) { v.Deleted = false; }
public static void ClearDeleted( UmlObject v, UmlObject parent) { v.Deleted = false; }