protected void OnButtonDownClicked(object sender, EventArgs e) { TreeIter ti; if (this.treeviewProcesses.Selection.GetSelected(out ti)) { TreePath tp = lsPrcs.GetPath(ti); TreeIter ti_next = ti; if (lsPrcs.IterNext(ref ti_next)) { lsPrcs.MoveAfter(ti, ti_next); Process selectedPrc = currentTsk.processes [tp.Indices [0]]; currentTsk.processes.Remove(selectedPrc); currentTsk.processes.Insert(tp.Indices [0] + 1, selectedPrc); } } }
internal SignatureChangeDialog() : base(GettextCatalog.GetString("Change Signature"), IdeApp.Workbench.RootWindow, DialogFlags.Modal) { this.Build(); previewEditor = TextEditorFactory.CreateNewEditor(TextEditorFactory.CreateNewDocument()); previewEditor.IsReadOnly = true; previewEditor.MimeType = "text/x-csharp"; var options = new CustomEditorOptions { ShowLineNumberMargin = false, ShowFoldMargin = false, ShowIconMargin = false, ShowRuler = false, EditorTheme = DefaultSourceEditorOptions.Instance.EditorTheme, FontName = DefaultSourceEditorOptions.Instance.FontName }; previewEditor.Options = options; vbox4.PackStart(previewEditor, true, true, 0); vbox4.ShowAll(); var tr = new CellRendererText(); var col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Modifier"), tr); col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => { var param = model.GetValue(iter, 0) as IParameterSymbol; if (param == parameters.ThisParameter) { ((CellRendererText)cell).Text = "this"; return; } if (param == parameters.ParamsParameter) { ((CellRendererText)cell).Text = "params"; return; } switch (param.RefKind) { case RefKind.Out: ((CellRendererText)cell).Text = "out"; break; case RefKind.Ref: ((CellRendererText)cell).Text = "ref"; break; default: ((CellRendererText)cell).Text = ""; break; } })); col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Type"), tr); col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => { var param = model.GetValue(iter, 0) as IParameterSymbol; ((CellRendererText)cell).Text = param.Type.ToDisplayString(); })); col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Parameter"), tr); col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => { var param = model.GetValue(iter, 0) as IParameterSymbol; ((CellRendererText)cell).Text = param.Name; })); col = this.treeviewParameterList.AppendColumn(GettextCatalog.GetString("Standard"), tr); col.SetCellDataFunc(tr, new TreeCellDataFunc((column, cell, model, iter) => { var param = model.GetValue(iter, 0) as IParameterSymbol; ((CellRendererText)cell).Text = param.HasExplicitDefaultValue ? param.ExplicitDefaultValue.ToString() : ""; })); this.treeviewParameterList.Model = store; this.treeviewParameterList.Selection.Changed += delegate { UpdateSensitivity(); }; this.buttonUp.Clicked += delegate { Gtk.TreeIter iter, iter2; if (!treeviewParameterList.Selection.GetSelected(out iter)) { return; } var path = store.GetPath(iter); if (!path.Prev()) { return; } if (!store.GetIter(out iter2, path)) { return; } store.MoveBefore(iter, iter2); UpdatePreview(); }; this.buttonDown.Clicked += delegate { Gtk.TreeIter iter, iter2; if (!treeviewParameterList.Selection.GetSelected(out iter)) { return; } var path = store.GetPath(iter); path.Next(); if (!store.GetIter(out iter2, path)) { return; } store.MoveAfter(iter, iter2); UpdatePreview(); }; this.buttonRemove.Clicked += delegate { Gtk.TreeIter iter; if (!treeviewParameterList.Selection.GetSelected(out iter)) { return; } store.Remove(ref iter); UpdatePreview(); }; this.buttonRefresh.Clicked += delegate { Refresh(); }; }
void OnDragDataReceived(object o, DragDataReceivedArgs args) { Console.WriteLine("OnDragDataReceived: {0}", (TargetType)args.Info); Console.WriteLine("Position: {0} {1}", args.X, args.Y); switch ((TargetType)args.Info) { case TargetType.Text: // preprocess input string... String input = Encoding.UTF8.GetString(args.SelectionData.Data).Trim(); string[] words = input.Split('\n'); List <string> nwords = new List <string>(); foreach (string word in words) { String nword = word; // let's just ignore anything that's not a zip or jar if (!word.ToLower().Contains(".jar") && !word.ToLower().Contains(".zip")) { continue; } // trim nonsense if (word.StartsWith("file://")) { nword = nword.Substring(7); } nwords.Add(nword); } // filtered away everything... just stop. if (nwords.Count == 0) { return; } // if the drop target is the jar list if (o == jarModList) { TreePath path; TreeIter iter; TreeViewDropPosition droppos; jarModList.GetDestRowAtPos(args.X, args.Y, out path, out droppos); jarModList.Model.GetIter(out iter, path); if (path != null) { Console.WriteLine("Got position ;) " + path.Indices[0]); switch (droppos) { case TreeViewDropPosition.Before: case TreeViewDropPosition.IntoOrBefore: AddJarMods(nwords.ToArray(), path.Indices[0]); break; case TreeViewDropPosition.After: case TreeViewDropPosition.IntoOrAfter: AddJarMods(nwords.ToArray(), path.Indices[0] + 1); break; } } else { Console.WriteLine("Indeterminate position... "); AddJarMods(nwords.ToArray(), -1); } } // if it's the modloader list else if (o == mlModList) { AddMLMods(nwords.ToArray()); } break; // let's hope this never happens, because it sure doesn't happen here. :whistles: case TargetType.Uri: foreach (string uri in Encoding.UTF8.GetString(args.SelectionData.Data).Trim().Split('\n')) { Console.WriteLine("Uri: {0}", Uri.UnescapeDataString(uri)); } break; // Handle reorder events inside the list. // This is only needed because the Reorderable property stops working // when you use custom drag&drop handling case TargetType.Movement: if (o == jarModList) { TreePath path; TreeIter srcIter; TreeIter destIter; TreeViewDropPosition droppos; jarModList.GetDestRowAtPos(args.X, args.Y, out path, out droppos); String sourceStr = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); int sourceInt = int.Parse(sourceStr); int destInt = -1; modStore.IterNthChild(out srcIter, sourceInt); if (path != null) { jarModList.Model.GetIter(out destIter, path); destInt = path.Indices[0]; switch (droppos) { case TreeViewDropPosition.Before: case TreeViewDropPosition.IntoOrBefore: modStore.MoveBefore(srcIter, destIter); break; case TreeViewDropPosition.After: case TreeViewDropPosition.IntoOrAfter: modStore.MoveAfter(srcIter, destIter); break; } Console.WriteLine("Moving something!: from {0} to {1}", sourceInt, destInt); } else { // HACK : this is needed becuase of a GTK# API bug. // See: http://mono.1490590.n4.nabble.com/On-a-ListStore-moving-items-on-the-list-some-questions-td2222829.html TreeIter stDestIter; modStore.GetIterFromString(out stDestIter, (Convert.ToUInt16(modStore.IterNChildren()) - 1).ToString()); modStore.MoveAfter(srcIter, stDestIter); Console.WriteLine("Moving something!: from {0} to End", sourceInt); } // mod order most probably did change. changed_mod_order = true; } break; } Console.WriteLine(); bool success = true; Gtk.Drag.Finish(args.Context, success, false, args.Time); }