private void populateTree(TreeStore t, string root, TreeIter parent, bool _f = true) { try { TreeIter p; if (parent.Equals(TreeIter.Zero)) { p = t.AppendValues(new string [] { System.IO.Path.GetFileName(root) + "/", System.IO.Path.GetFullPath(root), }); } else { p = t.AppendValues(parent, new string [] { System.IO.Path.GetFileName(root) + "/", System.IO.Path.GetFullPath(root), }); } //if (_f) tree.ExpandToPath(t.GetPath(p)); if (_f || parent.Equals(TreeIter.Zero)) { foreach (string d in System.IO.Directory.GetDirectories(root)) { this.populateTree(t, d, p, false); } } //new System.Threading.Thread (populateTree).Start (t,d,p,false); foreach (string f in System.IO.Directory.GetFiles(root, "*")) { t.AppendValues(p, new string [] { System.IO.Path.GetFileName(f), System.IO.Path.GetFullPath(f), }); } } catch (Exception e) { Console.WriteLine(e.Message); } return; }
private void populateTree(TreeStore t, string root, TreeIter parent) { try { TreeIter p; if (parent.Equals(TreeIter.Zero)) { p = t.AppendValues(new string [] { System.IO.Path.GetFileName(root) + "/", System.IO.Path.GetFullPath(root), }); } else { p = t.AppendValues(parent, new string [] { System.IO.Path.GetFileName(root) + "/", System.IO.Path.GetFullPath(root), }); } tree.ExpandToPath(t.GetPath(p)); foreach (string d in System.IO.Directory.GetDirectories(root)) { if (parent.Equals(TreeIter.Zero)) { this.populateTree(t, d, p); } continue; } foreach (string f in System.IO.Directory.GetFiles(root, "*")) { t.AppendValues(p, new string [] { System.IO.Path.GetFileName(f), System.IO.Path.GetFullPath(f), }); continue; } } catch (Exception e) { Console.WriteLine(e.Message); } return; }
//Deep Copy SubTree void CopySubTree(TreeIter SourceIter, TreeIter DestIter) { try { if (SourceIter.Equals(DestIter)) { Console.WriteLine("不能拖放到自己下"); return; } TreeIter ChildrenIter; if (SourceIter.Equals(TreeIter.Zero)) { treestore.IterChildren(out ChildrenIter); } else { treestore.IterChildren(out ChildrenIter, SourceIter); } do { TreeIter NewDestIter = treestore.AppendValues(DestIter, new object[] { treestore.GetValue(ChildrenIter, 0), treestore.GetValue(ChildrenIter, 1) }); if (treestore.IterHasChild(ChildrenIter)) { CopySubTree(ChildrenIter, NewDestIter); } } while(treestore.IterNext(ref ChildrenIter)); depth--; } catch (Exception ee) { Console.WriteLine(ee.Message + "\n" + ee.StackTrace); } }
TreeIter GetBranch(TreeIter parent, string name, Gdk.Pixbuf icon) { TreeIter iter; bool more; if (!parent.Equals(TreeIter.Zero)) { more = store.IterChildren(out iter, parent); } else { more = store.GetIterFirst(out iter); } if (more) { do { if (((string)store.GetValue(iter, ColLabel)) == name) { return(iter); } } while (store.IterNext(ref iter)); } if (!parent.Equals(TreeIter.Zero)) { return(store.AppendValues(parent, GLib.Markup.EscapeText(name), null, null, false, false, icon, icon != null, true)); } else { return(store.AppendValues(GLib.Markup.EscapeText(name), null, null, false, false, icon, icon != null, true)); } }
private void PopulateSourceList() { source_model = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(IImportSource)); source_combo_box = new ComboBox(); source_combo_box.Changed += delegate { UpdateImportLabel(); }; source_combo_box.Model = source_model; source_combo_box.RowSeparatorFunc = (model, iter) => model.GetValue(iter, 2) == null; CellRendererPixbuf pixbuf_cr = new CellRendererPixbuf(); CellRendererText text_cr = new CellRendererText(); source_combo_box.PackStart(pixbuf_cr, false); source_combo_box.PackStart(text_cr, true); source_combo_box.SetAttributes(pixbuf_cr, "pixbuf", 0); source_combo_box.SetAttributes(text_cr, "text", 1); TreeIter active_iter = TreeIter.Zero; List <IImportSource> sources = new List <IImportSource> (); // Add the standalone import sources foreach (IImportSource source in ServiceManager.Get <ImportSourceManager> ()) { sources.Add(source); } // Find active sources that implement IImportSource foreach (Source source in ServiceManager.SourceManager.Sources) { if (source is IImportSource) { sources.Add((IImportSource)source); } } // Sort the sources by their SortOrder properties sources.Sort(import_source_comparer); // And actually add them to the dialog int?last_sort_order = null; foreach (IImportSource source in sources) { if (last_sort_order != null && last_sort_order / 10 != source.SortOrder / 10) { source_model.AppendValues(null, null, null); } AddSource(source); last_sort_order = source.SortOrder; } if (!active_iter.Equals(TreeIter.Zero) || (active_iter.Equals(TreeIter.Zero) && source_model.GetIterFirst(out active_iter))) { source_combo_box.SetActiveIter(active_iter); } }
private void OnAccelEdited(object o, AccelEditedArgs args) { TreeIter iter; ListStore store; store = Model as ListStore; store.GetIter(out iter, new TreePath(args.PathString)); string realKey = Services.Keybinder.KeyEventToString(args.AccelKey, (uint)args.AccelMods); if (args.AccelKey == (uint)Gdk.Key.Super_L || args.AccelKey == (uint)Gdk.Key.Super_R) { //setting CellRenderAccelMode to "Other" ignores the Super key as a modifier //this prevents us from grabbing _only_ the Super key. return; } // Look for any other rows that have the same binding and then zero that binding out // PRECONDITION: There is at most one other row with the same binding. TreeIter conflictingBinding = TreeIter.Zero; Model.Foreach((model, path, treeiter) => { if (DoesBindingConflict(model, path, treeiter, realKey)) { conflictingBinding = treeiter; } return(false); }); if (!conflictingBinding.Equals(TreeIter.Zero)) { if (!SetNewBinding(conflictingBinding, Catalog.GetString("Disabled"))) { // Nothing to do here; we can't set conflicting bindings Log <KeybindingTreeView> .Error("Failed to unset conflicting keybinding"); return; } } if (!SetNewBinding(iter, realKey)) { Log <KeybindingTreeView> .Debug("Failed to bind key: {0}", realKey); Services.Notifications.Notify(Catalog.GetString("Failed to bind keyboard shortcut"), Catalog.GetString("This usually means that some other application has already " + "grabbed the key combination"), "error"); if (!conflictingBinding.Equals(TreeIter.Zero)) { // This has failed for some reason; reset the old binding SetNewBinding(conflictingBinding, realKey); } } }
private void PopulateSourceList() { source_model = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(IImportSource)); source_combo_box = new ComboBox(); source_combo_box.Changed += delegate { UpdateImportLabel(); }; source_combo_box.Model = source_model; choose_label.MnemonicWidget = source_combo_box; CellRendererPixbuf pixbuf_cr = new CellRendererPixbuf(); CellRendererText text_cr = new CellRendererText(); source_combo_box.PackStart(pixbuf_cr, false); source_combo_box.PackStart(text_cr, true); source_combo_box.SetAttributes(pixbuf_cr, "pixbuf", 0); source_combo_box.SetAttributes(text_cr, "text", 1); TreeIter active_iter = TreeIter.Zero; List <IImportSource> sources = new List <IImportSource> (); // Add the standalone import sources foreach (IImportSource source in ServiceManager.Get <ImportSourceManager> ()) { sources.Add(source); } // Find active sources that implement IImportSource foreach (Source source in ServiceManager.SourceManager.Sources) { if (source is IImportSource) { sources.Add((IImportSource)source); } } // Sort the sources by their SortOrder properties sources.Sort(import_source_comparer); // And actually add them to the dialog foreach (IImportSource source in sources) { AddSource(source); } if (!active_iter.Equals(TreeIter.Zero) || (active_iter.Equals(TreeIter.Zero) && source_model.GetIterFirst(out active_iter))) { source_combo_box.SetActiveIter(active_iter); } (Glade["ComboVBox"] as Box).PackStart(source_combo_box, false, false, 0); source_combo_box.ShowAll(); }
/// <summary> 判断是否是其某一级父节点 </summary> /// <param name="iter1"></param> /// <param name="iter2"></param> /// <returns></returns> public bool IsParent(TreeIter iter1, TreeIter iter2) { TreeIter parent = iter1; while (!parent.Equals(TreeIter.Zero)) { parent = GetParentTreeIter(parent); if (!parent.Equals(TreeIter.Zero) && parent.Equals(iter2)) { return(true); } } return(false); }
public void ShowGitFolder() { if (projectConfiguration.IsUseGitEnabled && projectConfiguration.UseGit && projectConfiguration.IsNewSolution) { if (gitFolderNode.Equals(TreeIter.Zero)) { gitFolderNode = AddGitFolderToTree(); } } else if (!gitFolderNode.Equals(TreeIter.Zero)) { folderTreeStore.Remove(ref gitFolderNode); gitFolderNode = TreeIter.Zero; } }
public void ShowGitIgnoreFile() { if (projectConfiguration.IsGitIgnoreEnabled && projectConfiguration.CreateGitIgnoreFile && projectConfiguration.IsNewSolution) { if (gitIgnoreNode.Equals(TreeIter.Zero)) { gitIgnoreNode = AddGitIgnoreToTree(); } } else if (!gitIgnoreNode.Equals(TreeIter.Zero)) { folderTreeStore.Remove(ref gitIgnoreNode); gitIgnoreNode = TreeIter.Zero; } }
bool GetNodeBranch(TreeIter parent, string name, ExtensionNodeSet nset, out TreeIter citer, out ExtensionNodeSet cset) { TreeIter iter; bool more; if (!parent.Equals(TreeIter.Zero)) { more = store.IterChildren(out iter, parent); } else { more = store.GetIterFirst(out iter); } if (more) { do { if (((string)store.GetValue(iter, ColLabel)) == name) { ExtensionNodeDescription node = (ExtensionNodeDescription)store.GetValue(iter, ColObject); ExtensionNodeType nt = nset.GetAllowedNodeTypes() [node.NodeName]; cset = nt; citer = iter; return(true); } } while (store.IterNext(ref iter)); } citer = iter; cset = null; return(false); }
void AppendThreads(TreeIter iter, ProcessInfo process) { var threads = process.GetThreads(); Array.Sort(threads, (ThreadInfo t1, ThreadInfo t2) => t1.Id.CompareTo(t2.Id)); DebuggingService.DebuggerSession.FetchFrames(threads); foreach (var thread in threads) { ThreadInfo activeThread = DebuggingService.DebuggerSession.ActiveThread; var name = thread.Name == null && thread.Id == 1 ? "Main Thread" : thread.Name; var weight = thread == activeThread ? Pango.Weight.Bold : Pango.Weight.Normal; var icon = thread == activeThread ? Gtk.Stock.GoForward : null; if (iter.Equals(TreeIter.Zero)) { store.AppendValues(icon, thread.Id.ToString(), name, thread, (int)weight, thread.Location); } else { store.AppendValues(iter, icon, thread.Id.ToString(), name, thread, (int)weight, thread.Location); } } }
void TraverseSubtree(TreeIter iter, Action <TreeIter> action) { TreeIter newIter; if (!iter.Equals(TreeIter.Zero)) { if (!store.IterChildren(out newIter, iter)) { return; } } else { if (!store.GetIterFirst(out newIter)) { return; } } do { action(newIter); if (store.IterHasChild(newIter)) { TraverseSubtree(newIter, action); } } while (store.IterNext(ref newIter)); }
internal TreeIter AddSection(TreeIter parentIter, OptionsDialogSection section, object dataObject) { TreeIter it; if (parentIter.Equals(TreeIter.Zero)) { it = store.AppendValues(section); } else { it = store.AppendValues(parentIter, section); } if (!section.CustomNode) { AddChildSections(it, section, dataObject); } // Remove the section if it doesn't have children nor panels SectionPage page = CreatePage(it, section, dataObject); TreeIter cit; if (removeEmptySections && page.Panels.Count == 0 && !store.IterChildren(out cit, it)) { store.Remove(ref it); pages.Remove(section); return(TreeIter.Zero); } return(it); }
void AppendProperty(TreeIter piter, PropertyDescriptor prop, InstanceData idata) { TreeIter iter; if (piter.Equals(TreeIter.Zero)) { iter = store.AppendValues(prop.DisplayName, prop, false, idata); } else { iter = store.AppendValues(piter, prop.DisplayName, prop, false, idata); } propertyRows [prop] = store.GetStringFromIter(iter); TypeConverter tc = prop.Converter; if (typeof(ExpandableObjectConverter).IsAssignableFrom(tc.GetType())) { object cob = prop.GetValue(idata.Instance); foreach (PropertyDescriptor cprop in TypeDescriptor.GetProperties(cob)) { AppendProperty(iter, cprop, cob); } } }
void ShowStackTrace(ExceptionInfo exc, bool showExceptionNode) { TreeIter it = TreeIter.Zero; if (showExceptionNode) { treeStack.ShowExpanders = true; string tn = exc.Type + ": " + exc.Message; it = stackStore.AppendValues(tn, null, 0, 0); } foreach (ExceptionStackFrame frame in exc.StackTrace) { if (!it.Equals(TreeIter.Zero)) { stackStore.AppendValues(it, frame.DisplayText, frame.File, frame.Line, frame.Column); } else { stackStore.AppendValues(frame.DisplayText, frame.File, frame.Line, frame.Column); } } ExceptionInfo inner = exc.InnerException; if (inner != null) { ShowStackTrace(inner, true); } }
void UpdateSelectionChecks(TreeIter iter, bool expandSelected) { if (iter.Equals(TreeIter.Zero)) { if (!store.GetIterFirst(out iter)) { return; } } else { if (!store.IterChildren(out iter, iter)) { return; } } do { bool sel = selectedEntries.ContainsKey((SolutionItem)store.GetValue(iter, 2)); store.SetValue(iter, 3, sel); if (sel) { tree.ExpandToPath(store.GetPath(iter)); } UpdateSelectionChecks(iter, expandSelected); }while (store.IterNext(ref iter)); }
private SourceModel() : base(typeof(Gdk.Pixbuf), typeof(string), typeof(Source)) { // Initial list of sources Clear(); foreach (Source source in SourceManager.Sources) { SetSource(Append(), source); } // Be prepared for other sources SourceManager.SourceAdded += delegate(SourceAddedArgs args) { if (FindSource(args.Source).Equals(TreeIter.Zero)) { TreeIter iter = Insert(args.Position); SetSource(iter, args.Source); } }; SourceManager.SourceRemoved += delegate(SourceEventArgs args) { TreeIter iter = FindSource(args.Source); if (!iter.Equals(TreeIter.Zero)) { Remove(ref iter); } }; }
private void AddCategory(ArrayList list, string name, string date_format) { if (list.Count == 0) { return; } TreeIter parent = TreeIter.Zero; foreach (ImLog log in list) { if (search_text != null && search_text.Length > 0) { if (!LogContainsString(log, search_text)) { continue; } } if (parent.Equals(TreeIter.Zero)) { parent = tree_store.AppendValues(String.Format("<b>{0}</b>", Catalog.GetString(name)), String.Empty, null); } string date = log.StartTime.ToString(Catalog.GetString(date_format)); tree_store.AppendValues(parent, date, GetPreview(log), log); } }
void AppendProperty(TreeIter piter, PropertyDescriptor prop, InstanceData idata) { TreeIter iter; #region this bugfix was backported to here from a newer MonoDevelop version by P.Eisenmann/S.Lohse 2016-12-06 // only show properties that have BrowsableAttribute set [true], or where BrowsableAttribute is not defined var brows = prop.Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute; if (brows != null && !brows.Browsable) { return; } #endregion if (piter.Equals(TreeIter.Zero)) { iter = store.AppendValues(prop.DisplayName.Localized(), prop, false, idata); } else { iter = store.AppendValues(piter, prop.DisplayName.Localized(), prop, false, idata); } propertyRows [prop] = store.GetStringFromIter(iter); TypeConverter tc = prop.Converter; if (typeof(ExpandableObjectConverter).IsAssignableFrom(tc.GetType())) { object cob = prop.GetValue(idata.Instance); foreach (PropertyDescriptor cprop in TypeDescriptor.GetProperties(cob)) { AppendProperty(iter, cprop, cob); } } }
void FillChanges() { foreach (Change change in changes) { TreeIter iter = GetFile(change); if (iter.Equals(TreeIter.Zero)) { iter = store.AppendValues(ImageService.GetIcon(MonoDevelop.Ide.Gui.Stock.ReplaceIcon, IconSize.Menu), change.Description, change, true); } else { iter = store.AppendValues(iter, ImageService.GetIcon(MonoDevelop.Ide.Gui.Stock.ReplaceIcon, IconSize.Menu), change.Description, change, true); } TextReplaceChange replaceChange = change as TextReplaceChange; if (replaceChange != null && replaceChange.Offset >= 0) { store.AppendValues(iter, null, null, change, false); } } if (changes.Count < 4) { treeviewPreview.ExpandAll(); } else { foreach (TreeIter iter in fileDictionary.Values) { treeviewPreview.ExpandRow(store.GetPath(iter), false); } } }
TreeIter FindCategory(string namePath) { TreeIter iter = TreeIter.Zero; string[] paths = namePath.Split('/'); foreach (string name in paths) { TreeIter child; if (!FindCategory(iter, name, out child)) { if (iter.Equals(TreeIter.Zero)) { iter = treeStore.AppendValues(null, null, name, "", false, false, null, false); } else { iter = treeStore.AppendValues(iter, null, null, name, "", false, false, null, false); } } else { iter = child; } } return(iter); }
public JisonsTreeIter <T> InsertAfterViewItem(TreeIter inserttreeiter, T data) { int position = inserttreeiter.Equals(TreeIter.Zero) ? -1 : this.TreeStore.GetPath(inserttreeiter).Indices.LastOrDefault() + 1; var parenttreeiter = this.GetParentTreeIter(inserttreeiter); return(AddViewItem(parenttreeiter, data, position)); }
void FillTree(TreeIter iter, SolutionItem entry) { TreeIter curIter; if (!iter.Equals(TreeIter.Zero)) { curIter = store.AppendValues(iter, GetIcon(entry), entry is SolutionFolder ? false : IsIncluded(entry), entry.Name, entry, !(entry is SolutionFolder)); } else { curIter = store.AppendValues(GetIcon(entry), entry is SolutionFolder ? false : IsIncluded(entry), entry.Name, entry, !(entry is SolutionFolder)); } if (entry is SolutionFolder) { // Add solutions first, then projects foreach (SolutionItem childEntry in ((SolutionFolder)entry).Items) { if (childEntry is SolutionFolder) { FillTree(curIter, childEntry); } } foreach (SolutionItem childEntry in ((SolutionFolder)entry).Items) { if (!(childEntry is TranslationProject) && (childEntry is Project)) { FillTree(curIter, childEntry); } } } }
void BuildTreeChildren(TreeStore store, TreeIter parent, ParsedDocument parsedDocument) { if (parsedDocument == null) { return; } foreach (var unresolvedCls in parsedDocument.TopLevelTypeDefinitions) { var cls = document.Compilation.MainAssembly.GetTypeDefinition(unresolvedCls.FullTypeName); if (cls == null) { continue; } TreeIter childIter; if (!parent.Equals(TreeIter.Zero)) { childIter = store.AppendValues(parent, cls); } else { childIter = store.AppendValues(cls); } AddTreeClassContents(store, childIter, parsedDocument, cls, unresolvedCls); } }
/* private methods */ internal bool GetValue(TreeIter iter, int dimension, out IComparable val) { val = null; if (model == null || iter.Equals(TreeIter.Zero)) { return(false); } if (col_nums.ContainsKey(dimension)) { int col = (int)col_nums[dimension]; val = (IComparable)model.GetValue(iter, col); return(true); } if (data_funcs.ContainsKey(dimension)) { PlotValueDataFunc func = data_funcs[dimension] as PlotValueDataFunc; if (func == null) { return(false); } val = func(this, dimension, model, iter, cb_data[dimension]); return(true); } return(false); }
IEnumerable <TreeIter> GetAllNodes(TreeIter parent, bool iter_children) { TreeIter child; if (parent.Equals(TreeIter.Zero)) { if (!store.IterChildren(out child)) { yield break; } } else if (!store.IterChildren(out child, parent)) { yield break; } do { yield return(child); if (iter_children && store.IterHasChild(child)) { TreeIter iter; if (store.IterChildren(out iter, child)) { do { yield return(iter); } while (store.IterNext(ref iter)); } } } while (store.IterNext(ref child)); }
TreeIter AddNode(TreeIter parent, ReferenceNode node) { if (entryFilter.Text.Length > 0 && node.TypeName.IndexOf(entryFilter.Text) == -1) { return(TreeIter.Zero); } TreeIter iter; if (parent.Equals(TreeIter.Zero)) { iter = store.AppendValues(node, "class", node.TypeName, !node.HasReferences, node.TotalMemory.ToString("n0"), node.AverageSize.ToString("n0"), node.RefCount.ToString("n0"), "", "", ""); } else { string refs = (InverseReferences ? node.RefsToParent.ToString("n0") : ""); string rootRefs = (InverseReferences ? node.RefsToRoot.ToString("n0") : ""); string rootMem = (InverseReferences ? node.RootMemory.ToString("n0") : ""); iter = store.AppendValues(parent, node, "class", node.TypeName, !node.HasReferences, node.TotalMemory.ToString("n0"), node.AverageSize.ToString("n0"), node.RefCount.ToString("n0"), refs, rootRefs, rootMem); } if (node.HasReferences) { // Add a dummy element to make the expansion icon visible store.AppendValues(iter, null, "", "", true, "", "", "", "", "", ""); } return(iter); }
void RemovePObjects(TreeIter iter, IList <PObject> toRemove) { do { if (toRemove.Contains(treeStore.GetValue(iter, 1))) { if (treeview.Selection.IterIsSelected(iter)) { TreeIter parent; if (treeStore.IterParent(out parent, iter)) { treeview.Selection.SelectIter(parent); } } if (treeStore.Remove(ref iter)) { continue; } } else if (treeStore.IterHasChild(iter)) { TreeIter subIter; if (treeStore.IterChildren(out subIter, iter)) { RemovePObjects(subIter, toRemove); } } } while (!iter.Equals(TreeIter.Zero) && treeStore.IterNext(ref iter)); }
IEnumerable <TreeIter> WalkTree(TreeStore model, TreeIter iter) { if (iter.Equals(TreeIter.Zero)) { if (!model.GetIterFirst(out TreeIter first)) { yield break; } iter = first; } do { yield return(iter); if (model.IterHasChild(iter)) { if (model.IterChildren(out TreeIter childIter, iter)) { foreach (var node in WalkTree(model, childIter)) { yield return(node); } } } } while (model.IterNext(ref iter)); }