public void NotifyParseInfoChange(string file, ClassUpdateInformation res, Project project) { ClassInformationEventArgs args = new ClassInformationEventArgs (file, res, project); OnClassInformationChanged (args); }
void OnClassInformationChanged(object sender, ClassInformationEventArgs e) { Hashtable oldStatus = new Hashtable (); ArrayList namespacesToClean = new ArrayList (); ITreeBuilder tb = Context.GetTreeBuilder (); foreach (IClass cls in e.ClassInformation.Removed) { if (tb.MoveToObject (new ClassData (e.Project, cls))) { oldStatus [tb.DataItem] = tb.Expanded; ITreeNavigator np = tb.Clone (); np.MoveToParent (); oldStatus [np.DataItem] = np.Expanded; tb.Remove (true); } namespacesToClean.Add (cls.Namespace); } foreach (IClass cls in e.ClassInformation.Modified) { if (tb.MoveToObject (new ClassData (e.Project, cls))) { oldStatus [tb.DataItem] = tb.Expanded; ITreeNavigator np = tb.Clone (); np.MoveToParent (); oldStatus [np.DataItem] = np.Expanded; tb.Remove (true); tb.AddChild (new ClassData (e.Project, cls)); } } foreach (IClass cls in e.ClassInformation.Added) { AddClass (e.Project, cls); } // Clean empty namespaces foreach (string ns in namespacesToClean) { string subns = ns; while (subns != null) { bool found = tb.MoveToObject (new NamespaceData (e.Project, subns)); if (!found) found = tb.MoveToObject (new NamespaceData (null, subns)); if (found) { while (tb.DataItem is NamespaceData && !tb.HasChildren()) tb.Remove (true); break; } int i = subns.LastIndexOf ('.'); if (i != -1) subns = subns.Substring (0,i); else subns = null; } } // Restore expand status foreach (DictionaryEntry de in oldStatus) { if ((bool)de.Value && tb.MoveToObject (de.Key)) { tb.ExpandToNode (); tb.Expanded = true; } } }
protected virtual void OnClassInformationChanged(ClassInformationEventArgs e) { if (ClassInformationChanged != null) { ClassInformationChanged(this, e); } }