private void TreeView_RowActivated(object sender, TreeViewRowEventArgs e) { if (PipelineController.Instance.ProjectOpen) { _contextMenu.Show(_etoView); } }
private void Handle_ButtonReleased(object sender, ButtonEventArgs e) { if (e.Button == PointerButton.Right) { #if WINDOWS var crow = _treeView.GetRowAtPosition(e.X, e.Y); if (crow == null) { return; } if (!_treeView.SelectedRows.ToList().Contains(crow)) { _treeView.UnselectAll(); _treeView.SelectRow(crow); _treeView.FocusedRow = crow; } #endif if (_showContextMenu && _contextMenu.Items.Count > 0) { _contextMenu.Show(_etoView); } } }
static Control TextReplacementsDropDown(TextArea text) { var control = new Button { Text = "TextReplacements" }; control.Click += (sender, e) => { var replacements = text.TextReplacements; var supported = text.SupportedTextReplacements; var contextMenu = new ContextMenu(); foreach (var val in Enum.GetValues(typeof(TextReplacements)).OfType<TextReplacements>()) { if (val == TextReplacements.All || val == TextReplacements.None) { var item = new ButtonMenuItem { Text = val.ToString() }; item.Click += (sender2, e2) => text.TextReplacements = val; contextMenu.Items.Add(item); continue; } if (!supported.HasFlag(val)) continue; var checkItem = new CheckMenuItem { Text = val.ToString(), Checked = replacements.HasFlag(val) }; checkItem.CheckedChanged += (sender2, e2) => { var rep = text.TextReplacements; if (checkItem.Checked) rep |= val; else rep &= ~val; text.TextReplacements = rep; }; contextMenu.Items.Add(checkItem); } contextMenu.Show(control); }; return control; }