/// <summary>Moves the specified node up 1 position.</summary> /// <param name="nodePath">The path of the node to move.</param> public void MoveUp(string nodePath) { TreeIter node = FindNode(nodePath); TreePath path = treemodel.GetPath(node); TreeIter prevnode; if (path.Prev() && treemodel.GetIter(out prevnode, path)) { treemodel.MoveBefore(node, prevnode); } }
public virtual bool IsVisible(ChatView chatView) { if (chatView == null) { throw new ArgumentNullException("chatView"); } Gtk.TreePath visibleStart, visibleEnd; GetVisibleRange(out visibleStart, out visibleEnd); var chatIter = FindChatIter(chatView); var chatPath = TreeStore.GetPath(chatIter); // we ignore 0 on purpose, say if a few pixels of a row are returned // as visible by GetVisibleRange() that is not good enough for us return(visibleStart.Compare(chatPath) <= 0 && visibleEnd.Compare(chatPath) >= 0); }
//add in the row position by alfabetical order public void Add(string jumperID, string jumperName) { TreeIter iter = new TreeIter(); bool iterOk = store.GetIterFirst(out iter); int found = -1; int count = 0; if (iterOk) { do { //search until find when jumperName is lexicographically > than current row if (String.Compare(jumperName.ToUpper(), ((string)treeview.Model.GetValue(iter, 1)).ToUpper()) < 0) { found = count; break; } count++; } while (store.IterNext(ref iter)); } TreeIter iter2 = new TreeIter(); if (found != -1) { //store.Insert (out iter2, found); iter2 = store.InsertNode(found); //first ID, then Name store.SetValue(iter2, 0, jumperID); store.SetValue(iter2, 1, jumperName); store.SetValue(iter2, 2, ""); //restTime } else { //first ID, then Name iter2 = store.AppendValues(jumperID, jumperName, ""); } //scroll treeview if needed TreePath path = store.GetPath(iter2); treeview.ScrollToCell(path, null, true, 0, 0); }
/// <summary>Moves the specified node up 1 position.</summary> /// <param name="nodePath">The path of the node to move.</param> public void MoveUp(string nodePath) { TreeIter node = FindNode(nodePath); TreePath path = treemodel.GetPath(node); TreeIter prevnode; if (path.Prev() && treemodel.GetIter(out prevnode, path)) { treemodel.MoveBefore(node, prevnode); } treeview1.ScrollToCell(path, treeview1.Columns[0], false, 0, 0); }
//startOrEnd is true at start, false at end public static void TreeviewAddRow(Gtk.TreeView tv, TreeStore store, string [] row, bool startOrEnd) { TreeIter iter = new TreeIter(); bool iterOk = store.GetIterFirst(out iter); if (startOrEnd) { iter = store.InsertWithValues(0, row); } else { iter = store.AppendValues(row); } //scroll treeview if needed TreePath path = store.GetPath(iter); tv.ScrollToCell(path, null, true, 0, 0); }
/// <summary> /// Find a specific node with the node path. /// NodePath format: .Parent.Child.SubChild /// </summary> /// <param name="namePath">The name path.</param> /// <returns></returns> /// <exception cref="System.Exception">Invalid name path ' + namePath + '</exception> private TreeIter FindNode(string namePath) { if (!namePath.StartsWith(".", StringComparison.CurrentCulture)) { throw new Exception("Invalid name path '" + namePath + "'"); } namePath = namePath.Remove(0, 1); // Remove the leading '.' string[] namePathBits = namePath.Split(".".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); TreeIter result = TreeIter.Zero; TreeIter iter; treemodel.GetIterFirst(out iter); foreach (string pathBit in namePathBits) { string nodeName = (string)treemodel.GetValue(iter, 0); while (nodeName != pathBit && treemodel.IterNext(ref iter)) { nodeName = (string)treemodel.GetValue(iter, 0); } if (nodeName == pathBit) { result = iter; TreePath path = treemodel.GetPath(iter); if (!treeview1.GetRowExpanded(path)) { treeview1.ExpandRow(path, false); } treemodel.IterChildren(out iter, iter); } else { return(TreeIter.Zero); } } return(result); }
public void addTreeView_runs_interval_sprint(RunInterval runI, RunType runIType) { LogB.Information("SPRINT add START"); if (storeSprint == null) { createTreeView_runs_interval_sprint(treeview_runs_interval_sprint); return; } string positions = getSprintPositions( runI.DistanceInterval, //distanceInterval. == -1 means variable distances runI.IntervalTimesString, runIType.DistancesString //distancesString ); if (positions == "") { return; } TreeIter iter = new TreeIter(); bool iterOk = storeSprint.GetIterFirst(out iter); if (!iterOk) { iter = new TreeIter(); } iter = storeSprint.AppendValues( runI.Type, runI.UniqueID.ToString(), positions, getSplitTimes(runI.IntervalTimesString), Util.TrimDecimals(runI.TimeTotal, preferences.digitsNumber) ); //scroll treeview if needed TreePath path = storeSprint.GetPath(iter); treeview_runs_interval_sprint.ScrollToCell(path, null, true, 0, 0); LogB.Information("SPRINT add END"); }
void HandlePositionChanged(object sender, DocumentLocationEventArgs e) { var node = unit.GetNodeAt(editor.Caret.Line, editor.Caret.Column); if (node == null) { return; } TreeIter iter; if (!iterDict.TryGetValue(node, out iter)) { return; } this.treeviewNodes.Selection.Changed -= SelectionChanged; treeviewNodes.Selection.SelectIter(iter); treeviewNodes.ScrollToCell(store.GetPath(iter), null, true, 0, 0); this.treeviewNodes.Selection.Changed += SelectionChanged; }
void SetDiffCellData(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { if (disposed) { return; } CellRendererDiff rc = (CellRendererDiff)cell; string[] lines = (string[])filestore.GetValue(iter, ColPath); TreePath path = filestore.GetPath(iter); if (filestore.IterDepth(iter) == 0) { rc.InitCell(filelist, false, lines, path); } else { rc.InitCell(filelist, true, lines, path); } }
private void OnGrammarPatternDefined(Pattern pattern) { Application.Invoke(delegate { string name = TypeNames.GetName(pattern.Type); if (pattern is AbstractPattern) { name += " (abstract)"; } TreeIter iter = store.AppendValues(name, pattern); AddNode(iter, pattern.ParseGraph); patternPaths[pattern] = store.GetPath(iter); signal.Send(); }); signal.WaitFor(); }
void HandleMoveCursor(object o, MoveCursorArgs args) { int cp = textview1.Buffer.CursorPosition; var textIter = textview1.Buffer.GetIterAtOffset(cp); var node = unit.GetNodeAt(textIter.Line + 1, textIter.LineOffset + 1); if (node == null) { return; } TreeIter iter; if (!iterDict.TryGetValue(node, out iter)) { return; } this.treeviewNodes.Selection.Changed -= SelectionChanged; treeviewNodes.Selection.SelectIter(iter); treeviewNodes.ScrollToCell(store.GetPath(iter), null, true, 0, 0); this.treeviewNodes.Selection.Changed += SelectionChanged; }
void CreateNode(TreeIter it, Extension ext, ExtensionNodeDescription node, ExtensionNodeType nt) { ExtensionNodeDescription newNode = new ExtensionNodeDescription(nt.NodeName); if (ext != null) { if (ext.Parent == null) { adesc.MainModule.Extensions.Add(ext); } ext.ExtensionNodes.Add(newNode); } else { node.ChildNodes.Add(newNode); } TreeIter nit = AddNode(it, newNode); tree.ExpandRow(store.GetPath(it), false); tree.Selection.SelectIter(nit); NotifyChanged(); }
int GetRowNumber(Gtk.TreePath path) { Gtk.TreeIter iter; if (!TreeStore.GetIter(out iter, path)) { // invalid path return(-1); } Gtk.TreeIter walkerIter; TreeStore.GetIterFirst(out walkerIter); var walker = TreeStore.GetPath(walkerIter); for (var i = 0; TreeStore.GetIter(out walkerIter, walker); i++) { if (walker.Compare(path) == 0) { return(i); } if (TreeStore.IterHasChild(walkerIter)) { walker.Down(); } else { walker.Next(); if (!TreeStore.GetIter(out walkerIter, walker)) { // invalid path: reached last row walker.Up(); walker.Next(); } } } return(-1); }
public virtual void Append(ChatView chatView) { if (chatView == null) { throw new ArgumentNullException("chatView"); } if (chatView is SessionChatView || chatView is ProtocolChatView) { // top level chats TreeStore.AppendValues(chatView); ReparentOrphans(); if (TreeStore.IterNChildren() == 1) { // first node, usualy Smuxi chat CurrentChatView = chatView; } } else { // childs with parents, hopefully var parentIter = FindProtocolChatIter(chatView); if (TreeStore.IterIsValid(parentIter)) { TreeStore.AppendValues(parentIter, chatView); var path = TreeStore.GetPath(parentIter); ExpandRow(path, true); } else { // parent chat doesn't exist yet, thus it has to become // a top level chat for now and re-parent later TreeStore.AppendValues(chatView); } } }
public void NextSong() { TreeIter iter; TreePath path; TreeViewColumn col; if (tv_list.Selection.GetSelected(out iter)) { tv_list.GetCursor(out path, out col); path.Next(); if (path.ToString() == SongCount.ToString()) { store.GetIterFirst(out iter); path = store.GetPath(iter); } tv_list.SetCursor(path, col, false); } if (tv_list.Selection.GetSelected(out iter)) { controller.MediaPlayer_LoadFile(String.Format("{0}", store.GetValue(iter, 0))); controller.MediaPlayer_Play(); } }
void Tree_DragDataReceived(object o, DragDataReceivedArgs args) { TreeView treeView = (TreeView)o; TreeIter DestIter, TmpNewNodeIter, DestIterParent, SourceIterParent; TreePath path; TreeViewDropPosition pos; //获取目标行path, pos if (treeView.GetDestRowAtPos(args.X, args.Y, out path, out pos)) { treeView.Model.GetIter(out DestIter, path); treestore.IterParent(out DestIterParent, DestIter); treestore.IterParent(out SourceIterParent, SourceIter); if (DestIter.Equals(SourceIter)) { Console.WriteLine("Can not move to self"); return; } switch (pos) { case TreeViewDropPosition.Before: treeView.SetDragDestRow(path, TreeViewDropPosition.Before); //如果是同层节点,则MoveBefore if (DestIterParent.Equals(SourceIterParent) && treestore.GetPath(DestIter).Depth == treestore.GetPath(SourceIter).Depth) { Console.WriteLine("同层节点,Before same level"); treestore.MoveBefore(SourceIter, DestIter); } //如果非异层节点 else { TreeIter ParentIter; //获取目标节点的父节点 treestore.IterParent(out ParentIter, DestIter); //如果目标节点有父节点,则在父节点添加一个新节点 if (treestore.IterParent(out ParentIter, DestIter)) { //添加新节点 TmpNewNodeIter = treestore.AppendValues(ParentIter, new object[] { treestore.GetValue(SourceIter, 0), treestore.GetValue(SourceIter, 1) }); } //如果没父节点,则在treenode做为父节点 else { //添加新节点 TmpNewNodeIter = treestore.AppendValues(new object[] { treestore.GetValue(SourceIter, 0), treestore.GetValue(SourceIter, 1) }); } //移动新节点到目标节点前 treestore.MoveBefore(TmpNewNodeIter, DestIter); //复制SourceIter节点的子节点到TmpNewNodeIter新节点下 if (treestore.IterHasChild(SourceIter)) { CopySubTree(SourceIter, TmpNewNodeIter); } //删除源SourceIter节点 treestore.Remove(ref SourceIter); } break; case TreeViewDropPosition.IntoOrBefore: treeView.SetDragDestRow(path, TreeViewDropPosition.IntoOrBefore); Console.WriteLine("IntoOrBefore: "); //在DestIter下添加新节点 TmpNewNodeIter = treestore.AppendValues(DestIter, new object[] { treestore.GetValue(SourceIter, 0), treestore.GetValue(SourceIter, 1) }); //如果源节点有子节点,则复制子节点 if (treestore.IterHasChild(SourceIter)) { CopySubTree(SourceIter, TmpNewNodeIter); } //删除源节点 treestore.Remove(ref SourceIter); break; case TreeViewDropPosition.After: treeView.SetDragDestRow(path, TreeViewDropPosition.After); //同层 if (DestIterParent.Equals(SourceIterParent) && treestore.GetPath(DestIter).Depth == treestore.GetPath(SourceIter).Depth) { Console.WriteLine("After same level"); //直接MoveAfter treestore.MoveAfter(SourceIter, DestIter); } //异层节点 else { Console.WriteLine("After Not same level"); TreeIter ParentIter; //如果有父节点 if (treestore.IterParent(out ParentIter, DestIter)) { TmpNewNodeIter = treestore.AppendValues(ParentIter, new object[] { treestore.GetValue(SourceIter, 0), treestore.GetValue(SourceIter, 1) }); } else { TmpNewNodeIter = treestore.AppendValues(new object[] { treestore.GetValue(SourceIter, 0), treestore.GetValue(SourceIter, 1) }); } //添加Move新节点到DestIter后 treestore.MoveAfter(TmpNewNodeIter, DestIter); //如果源节点有子节点,则复制子节点 if (treestore.IterHasChild(SourceIter)) { CopySubTree(SourceIter, TmpNewNodeIter); } //删除源节点 treestore.Remove(ref SourceIter); } break; case TreeViewDropPosition.IntoOrAfter: Console.WriteLine("IntoOrAfter"); treeView.SetDragDestRow(path, TreeViewDropPosition.IntoOrAfter); TmpNewNodeIter = treestore.AppendValues(DestIter, new object[] { treestore.GetValue(SourceIter, 0), treestore.GetValue(SourceIter, 1) }); if (treestore.IterHasChild(SourceIter)) { CopySubTree(SourceIter, TmpNewNodeIter); } treestore.Remove(ref SourceIter); break; } } Gtk.Drag.Finish(args.Context, false, false, args.Time); }
public bool RefillOutlineStore() { DispatchService.AssertGuiThread(); Gdk.Threads.Enter(); //refreshingOutline = false; if (TreeStore == null || !TreeView.IsRealized) { refillOutlineStoreId = 0; return(false); } outlineReady = false; // Save last selection int[] lastSelectedItem; TreeIter i; if (TreeView.Selection.GetSelected(out i)) { lastSelectedItem = TreeStore.GetPath(i).Indices; } else { lastSelectedItem = null; } // Save previously expanded items if wanted var lastExpanded = new List <int[]>(); if (DCompilerService.Instance.Outline.ExpansionBehaviour == DocOutlineCollapseBehaviour.ReopenPreviouslyExpanded && TreeStore.GetIterFirst(out i)) { do { var path = TreeStore.GetPath(i); if (TreeView.GetRowExpanded(path)) { lastExpanded.Add(path.Indices); } }while(TreeStore.IterNext(ref i)); } // Clear the tree TreeStore.Clear(); try { // Build up new tree if (SyntaxTree != null) { var caretLocation = Document.Editor.Caret.Location; BuildTreeChildren(TreeIter.Zero, SyntaxTree, new CodeLocation(caretLocation.Column, caretLocation.Line)); } } catch (Exception ex) { LoggingService.LogError("Error while updating document outline panel", ex); } finally { // Re-Expand tree items switch (DCompilerService.Instance.Outline.ExpansionBehaviour) { case DocOutlineCollapseBehaviour.ExpandAll: TreeView.ExpandAll(); break; case DocOutlineCollapseBehaviour.ReopenPreviouslyExpanded: foreach (var path in lastExpanded) { TreeView.ExpandToPath(new TreePath(path)); } break; } // Restore selection if (lastSelectedItem != null) { try { TreeView.ExpandToPath(new TreePath(lastSelectedItem)); } catch { } } outlineReady = true; } Gdk.Threads.Leave(); //stop timeout handler refillOutlineStoreId = 0; return(false); }
protected void OnTreeViewGlobalCursorChanged(object sender, EventArgs e) { TreeView tv = (TreeView)sender; TreeStore tm = (TreeStore)tv.Model; TreeIter root; TreeIter ti; TreePath tp; tm.GetIterFirst(out root); TreeViewColumn tvc; tv.GetCursor(out tp, out tvc); tm.GetIter(out ti, tp); this.lblFrmEditor.Text = (string)tm.GetValue(ti, 0); if (1 == tm.GetPath(ti).Depth) // Project level { this.addAction.Sensitive = false; this.deleteAction.Sensitive = false; this.alignFrmEditor.Remove(this.alignFrmEditor.Child); this.alignFrmEditor.Child = eprj; eprj.LoadData(GPrj); } else if (2 == tm.GetPath(ti).Depth) // Sub levels, like Tasks { this.addAction.Sensitive = true; this.deleteAction.Sensitive = false; this.alignFrmEditor.Remove(this.alignFrmEditor.Child); this.alignFrmEditor.Child = egrp; switch ((string)tm.GetValue(ti, 0)) { case "StateMachines": egrp.LoadData(GPrj.StateMachines); break; case "Tasks": egrp.LoadData(GPrj.Tasks); break; case "Processes": egrp.LoadData(GPrj.Processes); break; case "Messages": egrp.LoadData(GPrj.Messages); break; case "CompuMethods": egrp.LoadData(GPrj.CompuMethods); break; case "Units": egrp.LoadData(GPrj.Units); break; default: break; } } else if (3 == tm.GetPath(ti).Depth) // Sub levels, like Task { this.addAction.Sensitive = true; this.deleteAction.Sensitive = true; TreeIter tiL2; tm.IterParent(out tiL2, ti); this.alignFrmEditor.Remove(this.alignFrmEditor.Child); string itemName = (string)tm.GetValue(ti, 0); switch ((string)tm.GetValue(tiL2, 0)) { case "StateMachines": this.alignFrmEditor.Child = esm; StateMachine sm = this.GPrj.StateMachines.FindWithName(itemName); esm.LoadData(sm); PopTreeViewGlobalContextMenu(3, sm); break; case "Tasks": this.alignFrmEditor.Child = etsk; Task tsk = this.GPrj.Tasks.FindWithName(itemName); etsk.LoadData(tsk); PopTreeViewGlobalContextMenu(3, tsk); break; case "Processes": this.alignFrmEditor.Child = eprc; Process prc = this.GPrj.Processes.FindWithName(itemName); eprc.LoadData(prc); PopTreeViewGlobalContextMenu(3, prc); break; case "Messages": this.alignFrmEditor.Child = emsg; Message msg = this.GPrj.Messages.FindWithName(itemName); emsg.LoadData(msg); PopTreeViewGlobalContextMenu(3, msg); break; case "CompuMethods": this.alignFrmEditor.Child = ecpmd; CompuMethod cpmd = this.GPrj.CompuMethods.FindWithName(itemName); ecpmd.LoadData(cpmd); PopTreeViewGlobalContextMenu(3, cpmd); break; case "Units": this.alignFrmEditor.Child = eunt; EasyOS.Unit unt = this.GPrj.Units.FindWithName(itemName); eunt.LoadData(unt); PopTreeViewGlobalContextMenu(3, unt); break; default: this.alignFrmEditor.Child = egrp; break; } } else { } }
protected void OnTreeViewGlobalKeyPress(object o, KeyPressEventArgs args) { TreeView tv = (TreeView)o; TreeStore tm = (TreeStore)tv.Model; TreeIter root; TreeIter ti; TreePath tp; tm.GetIterFirst(out root); TreeViewColumn tvc; tv.GetCursor(out tp, out tvc); tm.GetIter(out ti, tp); int level = tm.GetPath(ti).Depth; AbstractData dat; if (1 == level) // Project level { dat = GPrj; } else if (2 == tm.GetPath(ti).Depth) // Groups, like Tasks { switch ((string)tm.GetValue(ti, 0)) { case "StateMachines": dat = GPrj.StateMachines; if (args.Event.Key == Gdk.Key.KP_Add) { StateMachine sm = new StateMachine(); this.GPrj.StateMachines.Add(sm); ti = tm.AppendValues(TIstatemachines, sm.name); tp = tm.GetPath(ti); tv.ExpandToPath(tp); tv.SetCursor(tp, tvc, true); //esm.LoadData (sm); } else { } break; case "Tasks": dat = GPrj.Tasks; if (args.Event.Key == Gdk.Key.KP_Add) { Task tsk = new Task(); this.GPrj.Tasks.Add(tsk); ti = tm.AppendValues(TItasks, tsk.name); tp = tm.GetPath(ti); tv.ExpandToPath(tp); tv.SetCursor(tp, tvc, true); //etsk.LoadData (tsk); } else { } break; case "Processes": dat = GPrj.Processes; if (args.Event.Key == Gdk.Key.KP_Add) { Process prc = new Process(); this.GPrj.Processes.Add(prc); ti = tm.AppendValues(TIprocesses, prc.name); tp = tm.GetPath(ti); tv.ExpandToPath(tp); tv.SetCursor(tp, tvc, true); //eprc.LoadData (prc); } else { } break; case "Messages": dat = GPrj.Messages; if (args.Event.Key == Gdk.Key.KP_Add) { Message msg = new Message(); this.GPrj.Messages.Add(msg); ti = tm.AppendValues(TImessages, msg.name); tp = tm.GetPath(ti); tv.ExpandToPath(tp); tv.SetCursor(tp, tvc, true); //emsg.LoadData (msg); } else { } break; case "CompuMethods": dat = GPrj.CompuMethods; if (args.Event.Key == Gdk.Key.KP_Add) { CompuMethod cpmd; int resp = SelectCompuMethodToCreate(this); if (1 == resp) { cpmd = new RationalFunction(); } else if (2 == resp) { cpmd = new VerbalTable(); } else { return; } this.GPrj.CompuMethods.Add(cpmd); ti = tm.AppendValues(TIcompumethods, cpmd.name); tp = tm.GetPath(ti); tv.ExpandToPath(tp); tv.SetCursor(tp, tvc, true); //ecpmd.LoadData (cpmd); } else { } break; case "Units": dat = GPrj.Units; if (args.Event.Key == Gdk.Key.KP_Add) { EasyOS.Unit unt = new EasyOS.Unit(); this.GPrj.Units.Add(unt); ti = tm.AppendValues(TIunits, unt.name); tp = tm.GetPath(ti); tv.ExpandToPath(tp); tv.SetCursor(tp, tvc, true); //eunt.LoadData (unt); } else { } break; default: break; } this.statusBarLabel1.Text = tp.ToString(); } else if (3 == level) // Item, like Task { TreeIter tiL2; tm.IterParent(out tiL2, ti); this.alignFrmEditor.Remove(this.alignFrmEditor.Child); string itemName = (string)tm.GetValue(ti, 0); switch ((string)tm.GetValue(tiL2, 0)) { case "StateMachines": StateMachine sm = this.GPrj.StateMachines.FindWithName(itemName); if (args.Event.Key == Gdk.Key.KP_Add) { sm = new StateMachine(); this.GPrj.StateMachines.Add(sm); ti = tm.AppendValues(TIstatemachines, sm.name); tp = tm.GetPath(ti); tv.SetCursor(tp, tvc, true); //esm.LoadData (sm); } else if (args.Event.Key == Gdk.Key.KP_Subtract) { this.GPrj.StateMachines.Remove(sm); tm.Remove(ref ti); } else { } break; case "Tasks": Task tsk = this.GPrj.Tasks.FindWithName(itemName); if (args.Event.Key == Gdk.Key.KP_Add) { tsk = new Task(); this.GPrj.Tasks.Add(tsk); ti = tm.AppendValues(TItasks, tsk.name); tp = tm.GetPath(ti); tv.SetCursor(tp, tvc, true); //etsk.LoadData (tsk); } else if (args.Event.Key == Gdk.Key.KP_Subtract) { this.GPrj.Tasks.Remove(tsk); tm.Remove(ref ti); } else { } break; case "Processes": Process prc = this.GPrj.Processes.FindWithName(itemName); if (args.Event.Key == Gdk.Key.KP_Add) { prc = new Process(); this.GPrj.Processes.Add(prc); ti = tm.AppendValues(TIprocesses, prc.name); tp = tm.GetPath(ti); tv.SetCursor(tp, tvc, true); //eprc.LoadData (prc); } else if (args.Event.Key == Gdk.Key.KP_Subtract) { this.GPrj.Processes.Remove(prc); tm.Remove(ref ti); } else { } break; case "Messages": Message msg = this.GPrj.Messages.FindWithName(itemName); if (args.Event.Key == Gdk.Key.KP_Add) { msg = new Message(); this.GPrj.Messages.Add(msg); ti = tm.AppendValues(TImessages, msg.name); tp = tm.GetPath(ti); tv.SetCursor(tp, tvc, true); //emsg.LoadData (msg); } else if (args.Event.Key == Gdk.Key.KP_Subtract) { this.GPrj.Messages.Remove(msg); tm.Remove(ref ti); } else { } break; case "CompuMethods": CompuMethod cpmd = this.GPrj.CompuMethods.FindWithName(itemName); if (args.Event.Key == Gdk.Key.KP_Add) { int resp = SelectCompuMethodToCreate(this); if (1 == resp) { cpmd = new RationalFunction(); } else if (2 == resp) { cpmd = new VerbalTable(); } else { return; } this.GPrj.CompuMethods.Add(cpmd); ti = tm.AppendValues(TIcompumethods, cpmd.name); tp = tm.GetPath(ti); tv.SetCursor(tp, tvc, true); //ecpmd.LoadData (cpmd); } else if (args.Event.Key == Gdk.Key.KP_Subtract) { this.GPrj.CompuMethods.Remove(cpmd); tm.Remove(ref ti); } else { } break; case "Units": EasyOS.Unit unt = this.GPrj.Units.FindWithName(itemName); if (args.Event.Key == Gdk.Key.KP_Add) { unt = new EasyOS.Unit(); this.GPrj.Units.Add(unt); ti = tm.AppendValues(TIunits, unt.name); tp = tm.GetPath(ti); tv.SetCursor(tp, tvc, true); //eunt.LoadData (unt); } else if (args.Event.Key == Gdk.Key.KP_Subtract) { this.GPrj.Units.Remove(unt); tm.Remove(ref ti); } else { } break; default: this.alignFrmEditor.Child = egrp; break; } this.statusBarLabel1.Text = tp.ToString(); } else { } }
void ShowTestResult(UnitTest test, UnitTestResult result) { if (result.IsSuccess) { if (!buttonSuccess.Active) { return; } TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Success, Escape(test.FullName), test); failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } if (result.IsFailure) { if (!buttonFailures.Active) { return; } string file = test.SourceCodeLocation != null ? test.SourceCodeLocation.FileName + ":" + test.SourceCodeLocation.Line : null; TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Failure, Escape(test.FullName), test, file); bool hasMessage = result.Message != null && result.Message.Length > 0; if (hasMessage) { failuresStore.AppendValues(testRow, null, Escape(result.Message), test); } if (result.StackTrace != null && result.StackTrace.Length > 0) { TreeIter row = testRow; if (hasMessage) { row = failuresStore.AppendValues(testRow, null, GettextCatalog.GetString("Stack Trace"), test); } AddStackTrace(row, result.StackTrace, test); } failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } if (result.IsNotRun) { if (!buttonIgnored.Active) { return; } TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.NotRun, Escape(test.FullName), test); if (result.Message != null) { failuresStore.AppendValues(testRow, null, Escape(result.Message), test); } failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } if (result.IsInconclusive) { if (!buttonInconclusive.Active) { return; } TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Inconclusive, Escape(test.FullName), test); if (result.Message != null) { failuresStore.AppendValues(testRow, null, Escape(result.Message), test); } failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } string msg = GettextCatalog.GetString("Running {0} ...", test.FullName); TextIter it = outputView.Buffer.EndIter; outIters [test] = it.Offset; outputView.Buffer.InsertWithTags(ref it, msg, bold); outputView.Buffer.Insert(ref it, "\n"); if (result.ConsoleOutput != null) { outputView.Buffer.Insert(ref it, result.ConsoleOutput); } if (result.ConsoleError != null) { outputView.Buffer.Insert(ref it, result.ConsoleError); } outputView.ScrollMarkOnscreen(outputView.Buffer.InsertMark); }
private void SearchTimeline() { // Remove all timeline entries that don't match the search results ImLog selected = GetSelectedLog(); TreeIter iter; if (!tree_store.GetIterFirst(out iter)) { return; } ArrayList to_remove = new ArrayList(); do { if (tree_store.IterHasChild(iter)) { TreeIter child; tree_store.IterNthChild(out child, iter, 0); do { ImLog log = tree_store.GetValue(child, 2) as ImLog; if (LogContainsString(log, search_text)) { continue; } to_remove.Add(tree_store.GetPath(child)); if (log == selected) { selected = null; } } while (tree_store.IterNext(ref child)); } } while (tree_store.IterNext(ref iter)); for (int i = to_remove.Count - 1; i >= 0; i--) { if (!tree_store.GetIter(out iter, to_remove [i] as TreePath)) { break; } tree_store.Remove(ref iter); } // Remove all the categories that dont have any matches tree_store.GetIterFirst(out iter); do { if (tree_store.IterNChildren(iter) < 1) { tree_store.Remove(ref iter); } } while (tree_store.IterNext(ref iter)); ScrollToLog(selected); RenderConversation(selected); }
void ShowTestResult(UnitTest test, UnitTestResult result) { if (result.IsSuccess) { if (!buttonSuccess.Active) { return; } TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Success, Escape(test.FullName), test); failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } if (result.IsFailure) { if (!buttonFailures.Active) { return; } string file = test.SourceCodeLocation != null ? test.SourceCodeLocation.FileName + ":" + test.SourceCodeLocation.Line : null; TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Failure, Escape(test.FullName), test, file); bool hasMessage = !string.IsNullOrEmpty(result.Message); if (hasMessage) { var sb = StringBuilderCache.Allocate(); string curLineText; int curLine = 1; const int maxLineLength = 255; const int maxLineNumber = 255; sb.Append("<span font='"); sb.Append(IdeServices.FontService.MonospaceFontName); sb.Append("'>"); using (var sr = new StringReader(Escape(result.Message))) { while (null != (curLineText = sr.ReadLine())) { if (curLineText == null) { continue; } if (curLine < maxLineNumber) { if (curLineText.Length > maxLineLength) { sb.Append(curLineText, 0, maxLineLength); sb.AppendLine("…"); } else { sb.AppendLine(curLineText); } } curLine++; } } if (curLine > maxLineNumber) { sb.Append("<span foreground='darkgrey'>"); sb.Append(GettextCatalog.GetString("(+{0} lines not shown - see output view for full result message)", curLine - maxLineNumber)); sb.Append("</span>"); } sb.Append("</span>"); failuresStore.AppendValues(testRow, null, StringBuilderCache.ReturnAndFree(sb), test, null, 0, ErrorMessage); } if (!string.IsNullOrEmpty(result.StackTrace)) { TreeIter row = testRow; if (hasMessage) { row = failuresStore.AppendValues(testRow, null, GettextCatalog.GetString("Stack Trace"), test, null, 0, StackTrace); } AddStackTrace(row, result.StackTrace, test); } failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } if (result.IsNotRun) { if (!buttonIgnored.Active) { return; } TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.NotRun, Escape(test.FullName), test); if (result.Message != null) { failuresStore.AppendValues(testRow, null, Escape(result.Message), test); } failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } if (result.IsInconclusive) { if (!buttonInconclusive.Active) { return; } TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Inconclusive, Escape(test.FullName), test); if (result.Message != null) { failuresStore.AppendValues(testRow, null, Escape(result.Message), test); } failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0); } string msg = GettextCatalog.GetString("Running {0} ...", test.FullName); TextIter it = outputView.Buffer.EndIter; outIters [test] = it.Offset; outputView.Buffer.InsertWithTags(ref it, msg, bold); outputView.Buffer.Insert(ref it, "\n"); if (result.ConsoleOutput != null) { outputView.Buffer.Insert(ref it, result.ConsoleOutput); } if (result.ConsoleError != null) { outputView.Buffer.Insert(ref it, result.ConsoleError); } if (!string.IsNullOrEmpty(result.Message)) { outputView.Buffer.Insert(ref it, GettextCatalog.GetString("Result message:")); outputView.Buffer.Insert(ref it, "\n"); outputView.Buffer.Insert(ref it, result.Message); } outputView.ScrollMarkOnscreen(outputView.Buffer.InsertMark); }
public CoverageView(string fileName, ProgressBar status) { store = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(object)); tree = new TreeView(store); CellRendererText renderer = new CellRendererText(); CellRendererText coverageRenderer = new CellRendererText(); // LAME: Why is this property a float instead of a double ? renderer.Xalign = 0.5f; tree.AppendColumn("Classes", new CellRendererText(), "text", 0); tree.AppendColumn("Lines Hit", renderer, "text", 1); tree.AppendColumn("Lines Missed", renderer, "text", 2); tree.AppendColumn("Coverage", coverageRenderer, "text", 3); tree.GetColumn(0).Resizable = true; tree.GetColumn(1).Alignment = 0.0f; tree.GetColumn(1).Resizable = true; tree.GetColumn(2).Alignment = 0.0f; tree.GetColumn(2).Resizable = true; tree.GetColumn(3).Alignment = 0.0f; tree.GetColumn(3).Resizable = true; tree.GetColumn(3).SetCellDataFunc(coverageRenderer, new TreeCellDataFunc(RenderCoverage)); tree.HeadersVisible = true; model = new CoverageModel(); foreach (string filter in DEFAULT_FILTERS) { model.AddFilter(filter); } this.status = status; model.Progress += Progress; model.ReadFromFile(fileName); TreeItem root = new TreeItem(store, null, model, "PROJECT"); Hashtable classes2 = model.Classes; namespaces = new Hashtable(); string[] sorted_names = new string [classes2.Count]; classes2.Keys.CopyTo(sorted_names, 0); Array.Sort(sorted_names); Progress("Building tree", 0.95); foreach (string name in sorted_names) { ClassCoverageItem klass = (ClassCoverageItem)classes2 [name]; if (klass.filtered) { continue; } string namespace2 = klass.name_space; TreeItem nsItem = (TreeItem)namespaces [namespace2]; if (nsItem == null) { nsItem = new TreeItem(store, root, (CoverageItem)model.Namespaces [namespace2], namespace2); // nsItem.SetPixmap (0, namespaceOpenPixmap); namespaces [namespace2] = nsItem; } if (nsItem.model.filtered) { continue; } ClassItem classItem = new ClassItem(store, nsItem, klass, klass.name); if (klass.ChildCount != 0) { TreeIter treeIter = store.AppendNode(classItem.iter); store.SetValues(treeIter, "<loading>"); } } tree.ExpandRow(store.GetPath(root.Iter), false); // it becomes very hard to navigate if everything is expanded //foreach (string ns in namespaces.Keys) // tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false); tree.RowExpanded += new RowExpandedHandler(OnRowExpanded); tree.RowCollapsed += new RowCollapsedHandler(OnRowCollapsed); tree.ButtonPressEvent += new ButtonPressEventHandler(OnButtonPress); tree.Selection.Mode = SelectionMode.Single; source_views = new Hashtable(); window_maps = new Hashtable(); Progress("Done", 1.0); // LAME: Why doesn't widgets visible by default ??? tree.Show(); }
protected override void OnDragDataReceived(DragContext context, int x, int y, SelectionData selection, uint info, uint time) { TreeIter iter; TreePath path; TreeViewDropPosition pos; Playlist destPlaylist; IPlaylistElement destElement; TreeStore store = Model as TreeStore; if (GetDestRowAtPos(x, y, out path, out pos)) { store.GetIter(out iter, path); FillElementAndPlaylist(iter, out destPlaylist, out destElement); /* Moving playlists */ if (dragSourceElement == null) { project.Playlists.Remove(dragSourcePlaylist); project.Playlists.Insert(path.Indices [0], dragSourcePlaylist); if (pos == TreeViewDropPosition.Before || pos == TreeViewDropPosition.IntoOrBefore) { store.MoveBefore(selectedIter, iter); } else { store.MoveAfter(selectedIter, iter); } } else { /* For elements moves can happen between 2 playlists and Move{Before|After} * requires iter to have the same parent */ TreeIter newIter; IPlaylistElement srcCurrent, dstCurrent; if (pos == TreeViewDropPosition.Before || pos == TreeViewDropPosition.IntoOrBefore) { newIter = (Model as TreeStore).InsertNodeBefore(iter); } else { newIter = (Model as TreeStore).InsertNodeAfter(iter); } store.SetValue(newIter, 0, dragSourceElement); store.Remove(ref selectedIter); srcCurrent = dragSourcePlaylist.Selected; dstCurrent = destPlaylist.Selected; dragSourcePlaylist.Elements.Remove(dragSourceElement); destPlaylist.Elements.Insert(store.GetPath(newIter).Indices [1], dragSourceElement); if (dragSourcePlaylist != destPlaylist) { dragSourcePlaylist.SetActive(srcCurrent); } destPlaylist.SetActive(dstCurrent); } } Gtk.Drag.Finish(context, true, false, time); }
protected bool timer_Elapsed() { var recentPosts = GetRecentPosts(); try { if (recentPosts.Count != 0) { bool alreadyPlayedSound = false; foreach (var post in recentPosts) { //check if post hasn't already been notified if (!lastRecentPosts.Any(x => x.pid == post.pid) && IsCategoryEnabled(post.category.cid)) { if (cbOnlyNewTopics.Active && !post.isMainPost) { continue; } string decodedTitle = HttpUtility.HtmlDecode(post.topic.title), decodedContent = HttpUtility.HtmlDecode(RemoveHTML(post.content)); if (cbTitleContains.Active || cbBodyContains.Active) { string strToSearch = ""; if (cbTitleContains.Active) { strToSearch += decodedTitle; } if (cbBodyContains.Active) { strToSearch += decodedContent; } if (!strToSearch.Contains(textviewContains.Buffer.Text)) { continue; } } if (cbIgnoreUsers.Active && ignoredUsers.Contains(post.user.username)) { continue; } string linkToPost = "https://forums.gta5-mods.com/post/" + post.pid.ToString(); string decodedCategory = HttpUtility.HtmlDecode(post.category.name); string body; if (decodedContent.Length > 100) { body = decodedContent.Substring(0, 97) + "..."; } else { body = decodedContent; } TreeIter iter; if (treeStore.IterNChildren() == 50) { //remove oldest item treeStore.IterNthChild(out iter, 49); treeStore.Remove(ref iter); } iter = treeStore.InsertWithValues(0, decodedCategory, decodedTitle, body, linkToPost); tvNotifications.Selection.SelectIter(iter); tvNotifications.ScrollToCell(treeStore.GetPath(iter), columnCategory, true, 0f, 0f); if (!alreadyPlayedSound) { alreadyPlayedSound = true; if (cbPlayNotificationSound.Active) { SystemSounds.Beep.Play(); Thread.Sleep(150); SystemSounds.Beep.Play(); } } int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128) //Unix { var notify = new Notifications.Notification(decodedTitle, body, Gdk.Pixbuf.LoadFromResource("GTA5MFNotifier.Resources.icon.png")); notify.Timeout = 5000; notify.AddAction("click", "View in browser", (object o, ActionArgs args) => { Process.Start(linkToPost); }); notify.Show(); } else if (platform != 6) //Windows (6 == MacOS) { var notification = new GTA5MFNotifier.Notification(linkToPost, decodedTitle, body, 10, FormAnimator.AnimationMethod.Slide, FormAnimator.AnimationDirection.Left); notification.Show(); } } } } } catch (Exception ex) { throw ex; } finally { lastRecentPosts = recentPosts; } return(true); }
ChildInfo FillDirRec(Gtk.TreeIter iter, IWorkspaceFileObject item, HashSet <string> itemFiles, HashSet <string> knownPaths, FilePath dir, bool forceSet) { ChildInfo cinfo = ChildInfo.AllSelected; bool hasChildren = false; foreach (string sd in knownSubdirs) { if (dir == item.BaseDirectory.Combine(sd)) { forceSet = true; break; } } TreeIter dit; if (!iter.Equals(TreeIter.Zero)) { dit = store.AppendValues(iter, false, DesktopService.GetPixbufForFile(dir, IconSize.Menu), dir.FileName.ToString(), dir.ToString()); fileList.ExpandRow(store.GetPath(iter), false); } else { dit = store.AppendValues(false, DesktopService.GetPixbufForFile(dir, IconSize.Menu), dir.FileName.ToString(), dir.ToString()); } paths [dir] = dit; foreach (string file in Directory.GetFiles(dir)) { string path = System.IO.Path.GetFileName(file); Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(file, IconSize.Menu); bool active = itemFiles.Contains(file); string color = null; if (!active) { pix = ImageService.MakeTransparent(pix, 0.5); color = "dimgrey"; } else { cinfo |= ChildInfo.HasProjectFiles; } active = active || forceSet || knownPaths.Contains(file); if (!active) { cinfo &= ~ChildInfo.AllSelected; } else { cinfo |= ChildInfo.SomeSelected; } paths [file] = store.AppendValues(dit, active, pix, path, file, color); if (!hasChildren) { hasChildren = true; fileList.ExpandRow(store.GetPath(dit), false); } } foreach (string cdir in Directory.GetDirectories(dir)) { hasChildren = true; ChildInfo ci = FillDirRec(dit, item, itemFiles, knownPaths, cdir, forceSet); if ((ci & ChildInfo.AllSelected) == 0) { cinfo &= ~ChildInfo.AllSelected; } cinfo |= ci & (ChildInfo.SomeSelected | ChildInfo.HasProjectFiles); } if ((cinfo & ChildInfo.AllSelected) != 0 && hasChildren) { store.SetValue(dit, 0, true); } if ((cinfo & ChildInfo.HasProjectFiles) == 0) { Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(dir, IconSize.Menu); pix = ImageService.MakeTransparent(pix, 0.5); store.SetValue(dit, 1, pix); store.SetValue(dit, 4, "dimgrey"); } if ((cinfo & ChildInfo.SomeSelected) != 0 && (cinfo & ChildInfo.AllSelected) == 0) { fileList.ExpandRow(store.GetPath(dit), false); } else { fileList.CollapseRow(store.GetPath(dit)); } return(cinfo); }
protected virtual bool HandleDragReceived(List <IViewModel> draggedViewModels, int x, int y, bool internalDrop) { IViewModel destParentVM, destChildVM; TreePath path; TreeViewDropPosition pos; TreeIter iter; var elementsToRemove = new Dictionary <INestedViewModel, List <IViewModel> > (); var elementsToAdd = new KeyValuePair <INestedViewModel, List <IViewModel> > (); if (GetDestRowAtPos(x, y, out path, out pos)) { int destIndex; store.GetIter(out iter, path); FillParentAndChild(iter, out destParentVM, out destChildVM); store.GetIter(out iter, path); int [] Indices = store.GetPath(iter).Indices; if (pos == TreeViewDropPosition.Before || pos == TreeViewDropPosition.IntoOrBefore) { destIndex = Indices [Indices.Length - 1]; } else { destIndex = Indices [Indices.Length - 1] + 1; } if (destChildVM == null) { if (internalDrop) { elementsToRemove.Add(ViewModel as INestedViewModel, draggedViewModels.ToList()); } elementsToAdd = new KeyValuePair <INestedViewModel, List <IViewModel> > (ViewModel as INestedViewModel, draggedViewModels); } else { if (internalDrop) { TreeIter parent; //Get the parentVM for every drag ViewModel foreach (IViewModel vm in draggedViewModels) { foreach (TreeIter element in dictionaryStore[vm]) { if (Model.IterParent(out parent, element)) { INestedViewModel sourceParentVM = Model.GetValue(parent, COL_DATA) as INestedViewModel; if (!elementsToRemove.ContainsKey(sourceParentVM)) { elementsToRemove.Add(sourceParentVM, new List <IViewModel> ()); } elementsToRemove [sourceParentVM].Add(vm); } } } } elementsToAdd = new KeyValuePair <INestedViewModel, List <IViewModel> > (destParentVM as INestedViewModel, draggedViewModels); } return(MoveElements(elementsToRemove, elementsToAdd, destIndex)); } return(false); }
void OnAddCategory(object sender, EventArgs args) { TreeIter it = store.AppendValues(""); categoryTree.SetCursor(store.GetPath(it), textColumn, true); }