/// <summary>Selects the first subtitle.</summary> /// <remarks>The subtitle is only selected if it exists.</remarks> public void SelectFirst() { if (Base.Document.Subtitles.Count > 0) { Select(TreePath.NewFirst(), false, false); } }
protected override TreePath GetNewPath() { subtitleTime = Base.Ui.Video.Position.CurrentTime; if (Base.Ui.Video.IsStatePlaying && Base.Config.VideoApplyReactionDelay) { subtitleTime -= TimeSpan.FromMilliseconds(Base.Config.VideoReactionDelay); } if (Base.Document.Subtitles.Count == 0) { return(TreePath.NewFirst()); } int index = Base.Ui.Video.Tracker.FindSubtitleNearPosition(subtitleTime); Subtitle nearestSubtitle = Base.Document.Subtitles[index]; if (subtitleTime < nearestSubtitle.Times.Start) { return(Util.IntToPath(index)); } else { return(Util.PathNext(Util.IntToPath(index))); } }
public RepositoryView(Driver driver) { this.driver = driver; HeadersVisible = false; AppendColumn("", new Gtk.CellRendererText(), "text", 0); TreeViewColumn fullPath = AppendColumn("", new Gtk.CellRendererText(), "text", 0); fullPath.Visible = false; itemStore = new Gtk.TreeStore(typeof(string), typeof(string)); Gtk.TreeIter root = itemStore.AppendValues(VersionControlPath.RootFolder, VersionControlPath.RootFolder); Microsoft.TeamFoundation.VersionControl.Client.Item[] items = ItemsForPath(VersionControlPath.RootFolder); foreach (Microsoft.TeamFoundation.VersionControl.Client.Item item in items) { if (item.ServerItem == VersionControlPath.RootFolder) { continue; } string shortPath = item.ServerItem.Substring(item.ServerItem.LastIndexOf('/') + 1) + "/"; Gtk.TreeIter iter = itemStore.AppendValues(root, shortPath, item.ServerItem); itemStore.AppendValues(iter, ""); } Model = itemStore; ExpandRow(TreePath.NewFirst(), false); RowExpanded += MyRowExpandedHandler; KeyReleaseEvent += MyKeyReleaseEventHandler; }
/* * Retornará el ProjectDTO del modelo de datos. */ public IDataTransferObject GetDataForm() { if (componentNodeStore.GetNode(TreePath.NewFirst()) != null) { return(((GenericNode)componentNodeStore.GetNode(TreePath.NewFirst())).DataTransferObject); } else { return(null); } }
public void ScrollFirst(bool selectFirst) { if (!IsRealized) { return; } ScrollToPoint(0, 0); if (selectFirst) { Selection.SelectPath(TreePath.NewFirst()); } }
private void UpdateList() { visibility.Clear(); TreeStore store = new TreeStore(typeof(System.Object)); foreach (Tilemap Tilemap in sector.GetObjects(typeof(Tilemap))) { store.AppendValues(Tilemap); visibility[Tilemap] = application.CurrentRenderer.GetTilemapColor(Tilemap).Alpha; // if no tilemap is yet selected, select the first solid one if ((application.CurrentTilemap == null) && (Tilemap.Solid)) { application.CurrentTilemap = Tilemap; application.EditProperties(application.CurrentTilemap, "Tilemap (" + application.CurrentTilemap.ZPos + ")"); } } store.SetSortFunc(0, compareZPos); store.SetSortColumnId(0, SortType.Ascending); store.AppendValues(separatorObject); visibility[separatorObject] = 0; if (sector.GetObjects(typeof(Background)).Count > 0) { store.AppendValues(backgroundObject); visibility[backgroundObject] = application.CurrentRenderer.GetBackgroundColor().Alpha; } store.AppendValues(badguysObject); visibility[badguysObject] = application.CurrentRenderer.GetObjectsColor().Alpha; Model = store; // Visibly select current Tilemap if (application.CurrentTilemap != null) { TreePath path = TreePath.NewFirst(); TreeIter iter; while (Model.GetIter(out iter, path)) { object obj = Model.GetValue(iter, 0); if (obj == application.CurrentTilemap) { HasFocus = true; ActivateRow(path, GetColumn(0)); SetCursor(path, GetColumn(0), false); } path.Next(); } } }
public override void FocusNearest(int x, int y) { if (!CanFocus) { return; } TreeIter iter; if (!model.GetIterFirst(out iter)) { return; } if ((x_axis == null || !x_axis.HasValidRange) || (y_axis == null || !y_axis.HasValidRange)) { return; } // find the point with the min distance to x (since the // user hit up/down) TreePath min_path = TreePath.NewFirst(); double min_distance = Double.MaxValue; do { IComparable x_val, y_val; if (!GetValue(iter, 0, out x_val) || !GetValue(iter, 1, out y_val)) { return; } // we need it relative to the plot field, so // subtract the X allocation. int plot_x = GridXToRender(x_axis.ValueToGridCoords(x_val)) - Allocation.X; double distance = Math.Abs(plot_x - x); if (min_distance > distance) { min_distance = distance; min_path = model.GetPath(iter); } } while (model.IterNext(ref iter)); focused_path = min_path; }
private void OnTilemapChanged(Tilemap Tilemap) { // Visibly select new Tilemap if (Tilemap != null) { TreePath path = TreePath.NewFirst(); TreeIter iter; while (Model.GetIter(out iter, path)) { object obj = Model.GetValue(iter, 0); if (obj == Tilemap) { HasFocus = true; ActivateRow(path, GetColumn(0)); SetCursor(path, GetColumn(0), false); } path.Next(); } } }
public KeybindingTreeView() { Model = new ListStore(typeof(string), typeof(string), typeof(string), typeof(KeyBinding)); CellRendererText actionCell = new CellRendererText(); actionCell.Width = 175; InsertColumn(-1, Catalog.GetString("Action"), actionCell, "text", (int)Column.Action); CellRendererAccel bindingCell = new CellRendererAccel(); bindingCell.AccelMode = CellRendererAccelMode.Other; bindingCell.Editable = true; bindingCell.AccelEdited += new AccelEditedHandler(OnAccelEdited); bindingCell.AccelCleared += new AccelClearedHandler(OnAccelCleared); InsertColumn(-1, Catalog.GetString("Shortcut"), bindingCell, "text", (int)Column.BoundKeyString); RowActivated += new RowActivatedHandler(OnRowActivated); ButtonPressEvent += new ButtonPressEventHandler(OnButtonPress); AddBindings(); Selection.SelectPath(TreePath.NewFirst()); }
// Methods :: Public :: SelectFirst public void SelectFirst() { TreePath path = TreePath.NewFirst(); SetCursor(path, Columns [0], false); }
protected override bool OnKeyPressEvent(Gdk.EventKey ev) { if (model == null) { return(false); } int r, c; TreePath tmp; // Lame workaround for GtkBinding not being bound switch (ev.Key) { // Activate keycodes case Gdk.Key.space: case Gdk.Key.Return: case Gdk.Key.ISO_Enter: case Gdk.Key.KP_Enter: // Remove this when we can use OnActivate () if (focused_path == null) { return(false); } if ((ev.State & Gdk.ModifierType.ControlMask) == 0) { UnselectAll(); } if (selected_paths.Contains(focused_path)) { UnselectPath(focused_path); } else { SelectPath(focused_path); } if (ItemActivated != null) { ItemActivatedArgs activated_args = new ItemActivatedArgs(); activated_args.Args = new object[] { focused_path }; ItemActivated(this, activated_args); } return(true); case Gdk.Key.a: // if control down, select all if (selection_mode == SelectionMode.Multiple && (ev.State & Gdk.ModifierType.ControlMask) > 0) { SelectAll(); } return(true); case Gdk.Key.A: // if control down and shift down, unselect all if (selection_mode == SelectionMode.Multiple && (ev.State & Gdk.ModifierType.ControlMask) > 0 && (ev.State & Gdk.ModifierType.ShiftMask) > 0) { UnselectAll(); } return(true); case Gdk.Key.Up: case Gdk.Key.KP_Up: // Move focus or selection up if (layout_mode == LayoutMode.Vertical || layout_mode == LayoutMode.Grid) { // find out the currently focused r and c GetRowAndColForPath(focused_path, out r, out c); // decrement the row by 1 if (r > 0) { r--; // find the path at new r, c if (GetPathAtRowAndCol(r, c, out tmp)) { focused_path = tmp; } } } break; case Gdk.Key.Down: case Gdk.Key.KP_Down: // move down if (layout_mode == LayoutMode.Vertical || layout_mode == LayoutMode.Grid) { // find out the currently focused r and c GetRowAndColForPath(focused_path, out r, out c); // increment the row by 1 r++; // find the path at new r, c if (GetPathAtRowAndCol(r, c, out tmp)) { focused_path = tmp; } } break; case Gdk.Key.Left: case Gdk.Key.KP_Left: // move left if (layout_mode == LayoutMode.Horizontal || layout_mode == LayoutMode.Grid) { tmp = focused_path.Copy(); // don't wrap around if (tmp.Prev()) { focused_path = tmp; } } break; case Gdk.Key.Right: case Gdk.Key.KP_Right: // move right if (layout_mode == LayoutMode.Horizontal || layout_mode == LayoutMode.Grid) { tmp = focused_path.Copy(); tmp.Next(); if (PathIsValid(tmp)) { focused_path = tmp; } } break; case Gdk.Key.Home: case Gdk.Key.KP_Home: // select and focus the first item, dropping // current selection tmp = TreePath.NewFirst(); // verify that the path is valid if (PathIsValid(tmp)) { selected_paths.Clear(); focused_path = tmp; SelectPath(focused_path); } return(true); case Gdk.Key.End: case Gdk.Key.KP_End: // select and focus the first item, dropping // current selection tmp = new TreePath(new int[] { n_cells - 1 }); // verify that the path is valid if (PathIsValid(tmp)) { selected_paths.Clear(); focused_path = tmp; SelectPath(focused_path); } return(true); } if (selection_mode == SelectionMode.Multiple && (ev.State & Gdk.ModifierType.ShiftMask) > 0) { selected_paths.Clear(); SelectAllBetween(selection_anchor, focused_path); return(true); } if (selection_mode == SelectionMode.Browse) { SelectPath(focused_path); } else { // TODO: Constrain this to only the previous focus and QueueDraw(); } return(true); }
protected override TreePath GetNewPath() { return(TreePath.NewFirst()); }
private void FocusHelper(bool move_next) { if (focused_path == null) { return; } TreeIter focused_iter; if (!model.GetIter(out focused_iter, focused_path)) { return; } int focus_x, focus_y; GetPlotPoint(focused_iter, out focus_x, out focus_y); // we can't just do focused_path.Prev () since there is // a disconnect between the order in the model and // where the axis has us place points. besides, we // need to clamp the focus region to the zoom rect. TreeIter iter; if (!model.GetIterFirst(out iter)) { return; } int total_height = (Allocation.Y + Allocation.Height); TreePath min_path = null; int min_x_delta = Int32.MaxValue; int min_y_delta = Int32.MaxValue; do { TreePath path = model.GetPath(iter); // don't try to focus the same point again if (path.Compare(focused_path) == 0) { continue; } int x, y; GetPlotPoint(iter, out x, out y); // if its out of bounds, throw it out if (IsBarOutOfBounds(x, y)) { continue; } int x_delta = 0, y_delta = 0; if (move_next) { // find the bar with the smallest positive x // delta, and smallest y, or if there // is a tie, the one that's larger on the y // axis x_delta = x - focus_x; y_delta = (focus_x != x) ? total_height - y : focus_y - y; } else { // find the bar with the smallest positive x // delta, and largest y, or if there // is a tie, the one that's larger on the y // axis x_delta = focus_x - x; y_delta = (focus_x != x) ? y : y - focus_y; } // don't go backward, and don't pick a bigger // delta than we already have if (x_delta < 0 || x_delta > min_x_delta) { continue; } if (x_delta == min_x_delta && y_delta >= min_y_delta) { continue; } // if we're at the same X value, make sure // we're moving forward in the y direction so // we don't get stuck in loops if (x_delta == 0 && y_delta < 0) { continue; } min_x_delta = x_delta; min_y_delta = y_delta; min_path = path; } while (model.IterNext(ref iter)); if (min_path != null) { focused_path = min_path; } else { if (move_next) { focused_path = TreePath.NewFirst(); } else { focused_path = new TreePath(new int[] { model.IterNChildren() - 1 }); } } if (Changed != null) { Changed(this, new EventArgs()); } }