private void RefreshView(FileModel aFile) { DebugConsole.Trace("Refresh..."); classTree.BeginStatefulUpdate(); try { classTree.Nodes.Clear(); TreeNode root = new TreeNode(aFile.FileName, 9, 9); classTree.Nodes.Add(root); //if (aFile.Version < 1) // return; TreeNodeCollection folders = root.Nodes; TreeNodeCollection nodes; TreeNode node; int img; // imports if (showImports) { node = new TreeNode("Imports", 1, 1); folders.Add(node); nodes = node.Nodes; foreach (MemberModel import in aFile.Imports) { if (import.Type.EndsWith(".*")) { nodes.Add(new TreeNode(import.Type, 6, 6)); } else { img = ((import.Flags & FlagType.Intrinsic) > 0) ? 7 : 0; nodes.Add(new TreeNode(import.Type, img, img)); } } } // class members if (aFile.Members.Count > 0) { AddMembers(folders, aFile.Members); } // classes if (aFile.Classes.Count > 0) { //node = new TreeNode("Classes", 1,1); //folders.Add(node); nodes = folders; //node.Nodes; foreach (ClassModel aClass in aFile.Classes) { img = ((aClass.Flags & FlagType.Intrinsic) > 0) ? 7 : 0; node = new TreeNode(aClass.ClassName, img, img); nodes.Add(node); AddMembers(node.Nodes, aClass.Members); node.Expand(); } } root.Expand(); } catch (Exception ex) { ErrorHandler.ShowError(ex.Message, ex); } finally { classTree.EndStatefulUpdate(); } }
private void RefreshView(FileModel aFile) { findProcTxt.Text = ""; FindProcTxtLeave(null, null); //TraceManager.Add("Outline refresh..."); outlineTree.BeginStatefulUpdate(); try { currentHighlight = null; outlineTree.Nodes.Clear(); TreeNode root = new TreeNode(System.IO.Path.GetFileName(aFile.FileName), ICON_FILE, ICON_FILE); outlineTree.Nodes.Add(root); if (aFile == FileModel.Ignore) { return; } TreeNodeCollection folders = root.Nodes; TreeNodeCollection nodes; TreeNode node; int img; // imports if (settings.ShowImports && aFile.Imports.Count > 0) { node = new TreeNode(TextHelper.GetString("Info.ImportsNode"), ICON_FOLDER_OPEN, ICON_FOLDER_OPEN); folders.Add(node); nodes = node.Nodes; foreach (MemberModel import in aFile.Imports) { if (import.Type.EndsWith(".*")) { nodes.Add(new TreeNode(import.Type, ICON_PACKAGE, ICON_PACKAGE)); } else { img = ((import.Flags & FlagType.Intrinsic) > 0) ? ICON_INTRINSIC_TYPE : ICON_TYPE; node = new TreeNode(import.Type, img, img); node.Tag = "import"; nodes.Add(node); } } } // class members if (aFile.Members.Count > 0) { AddMembersSorted(folders, aFile.Members); } // regions if (settings.ShowRegions) { if (aFile.Regions.Count > 0) { node = new TreeNode(TextHelper.GetString("Info.RegionsNode"), ICON_PACKAGE, ICON_PACKAGE); folders.Add(node); //AddRegions(node.Nodes, aFile.Regions); AddRegionsExtended(node.Nodes, aFile); } } // classes if (aFile.Classes.Count > 0) { nodes = folders; foreach (ClassModel aClass in aFile.Classes) { img = ((aClass.Flags & FlagType.Intrinsic) > 0) ? ICON_INTRINSIC_TYPE : ((aClass.Flags & FlagType.Interface) > 0) ? ICON_INTERFACE : ICON_TYPE; node = new TreeNode(aClass.FullName, img, img); node.Tag = "class"; nodes.Add(node); if (settings.ShowExtends) { AddExtend(node.Nodes, aClass); } if (settings.ShowImplements) { AddImplements(node.Nodes, aClass.Implements); } AddMembersSorted(node.Nodes, aClass.Members); node.Expand(); } } root.Expand(); } catch (Exception ex) { ErrorManager.ShowError(/*ex.Message,*/ ex); } finally { // outline state will be restored/saved from the model data if (aFile.OutlineState == null) { aFile.OutlineState = new TreeState(); } // restore collapsing state outlineTree.EndStatefulUpdate(aFile.OutlineState); // restore highlighted item if (aFile.OutlineState.highlight != null) { TreeNode toHighligh = outlineTree.FindClosestPath(outlineTree.State.highlight); if (toHighligh != null) { SetHighlight(toHighligh); } } } }
public void UpdateView(ASClass aClass) { bool updateToken = false; try { DebugConsole.Trace("UI: update " + aClass.ClassName); if (aClass.IsVoid()) { return; } // compute class data "checksum" to know if it changed string fileName = aClass.FileName; string prevDataCheck = (string)checkEntries[fileName]; StringBuilder sb = new StringBuilder().Append(aClass.Extends.ClassName); foreach (ASMember import in aClass.Imports) { sb.Append(import.Name); } foreach (ASMember method in aClass.Methods) { sb.Append(method.Flags.ToString()).Append(method.ToString()); } foreach (ASMember prop in aClass.Properties) { sb.Append(prop.Flags.ToString()).Append(prop.ToString()); } foreach (ASMember var in aClass.Vars) { sb.Append(var.Flags.ToString()).Append(var.ToString()); } string classDataCheck = sb.ToString(); // for tree exploration TreeNodeCollection nodes = classTree.Nodes; TreeNode node = null; TreeNode insertBefore = null; // re-sort imports by package aClass.Sort(); ASMemberList import2 = new ASMemberList(); ASMember newImport; foreach (ASMember import in aClass.Imports) { newImport = new ASMember(); newImport.Name = import.Type; import2.Add(newImport); } import2.Sort(); // search item insertion/update position string cname = aClass.ClassName; bool entryExists = false; foreach (TreeNode sub in nodes) { if (sub.Text == cname) { node = sub; entryExists = true; break; } else if (sub.Text.CompareTo(cname) > 0) { insertBefore = sub; break; } } // New class if (node == null) { updateToken = true; classTree.BeginStatefulUpdate(); // create class node node = new TreeNode(cname); node.Tag = aClass.FileName; if (insertBefore != null) { nodes.Insert(insertBefore.Index, node); } else { nodes.Add(node); } // class details nodes if (showExtend) { node.Nodes.Add(new TreeNode("Extends", 1, 1)); } if (showImports) { node.Nodes.Add(new TreeNode("Imports", 1, 1)); } // class members nodes if (memberGroups == 1) { node.Nodes.Add(new TreeNode("Members", 1, 1)); } else { if (memberGroups > 1) { node.Nodes.Add(new TreeNode("Methods", 1, 1)); node.Nodes.Add(new TreeNode("Properties", 1, 1)); } if (memberGroups > 2) { node.Nodes.Add(new TreeNode("Variables", 1, 1)); } } } // Check class infos else { if (classDataCheck == prevDataCheck) { return; } updateToken = true; classTree.BeginStatefulUpdate(); } // // UPDATE CLASS INFO // checkEntries[fileName] = classDataCheck; int index = 0; TreeNode sub2; // entends if (showExtend) { nodes = node.Nodes[index++].Nodes; nodes.Clear(); if (!aClass.Extends.IsVoid()) { if ((aClass.Extends.Flags & FlagType.Intrinsic) > 0) { sub2 = new TreeNode(aClass.Extends.ClassName, 7, 7); } else { sub2 = new TreeNode(aClass.Extends.ClassName, 0, 0); } sub2.Tag = aClass.Extends.FileName; nodes.Add(sub2); } } // imports if (showImports) { nodes = node.Nodes[index++].Nodes; nodes.Clear(); foreach (ASMember import in import2) { if ((import.Flags & FlagType.Intrinsic) > 0) { nodes.Add(new TreeNode(import.Name, 7, 7)); } else { nodes.Add(new TreeNode(import.Name, 0, 0)); } } } // methods int img; if (memberGroups > 0) { nodes = node.Nodes[index++].Nodes; nodes.Clear(); foreach (ASMember method in aClass.Methods) { img = ((method.Flags & FlagType.Private) > 0) ? 12 : 3; sub2 = new TreeNode(method.ToString(), img, img); sub2.Tag = method.Name; nodes.Add(sub2); } // properties if (memberGroups > 1) { nodes = node.Nodes[index++].Nodes; nodes.Clear(); } foreach (ASMember prop in aClass.Properties) { img = ((prop.Flags & FlagType.Private) > 0) ? 13 : 4; sub2 = new TreeNode(prop.ToString(), img, img); sub2.Tag = prop.Name; nodes.Add(sub2); } // variables if (memberGroups > 2) { nodes = node.Nodes[index++].Nodes; nodes.Clear(); } foreach (ASMember var in aClass.Vars) { img = ((var.Flags & FlagType.Private) > 0) ? 14 : 5; sub2 = new TreeNode(var.ToString(), img, img); sub2.Tag = var.Name; nodes.Add(sub2); } } // expand index = 0; if (showExtend) { index++; } if (showImports) { index++; } for (int i = 0; i < memberGroups; i++) { node.Nodes[index++].Expand(); } node.Expand(); if (!entryExists) { node.EnsureVisible(); } } finally { if (updateToken) { classTree.EndStatefulUpdate(); } } }