/// <summary> /// Setups the nodeview. /// </summary> private void SetupNodeView() { nvSequenceOptionsStore = new NodeStore(typeof(SequenceOperationTreeNode)); nvSequenceOptions.NodeStore = nvSequenceOptionsStore; nvSequenceOptions.AppendColumn(new TreeViewColumn("Time", new CellRendererText(), "text", 0)); nvSequenceOptions.AppendColumn(new TreeViewColumn("Duration", new CellRendererText(), "text", 1)); nvSequenceOptions.AppendColumn(new TreeViewColumn("State", new CellRendererText(), "text", 2)); nvSequenceOptions.ButtonPressEvent += new ButtonPressEventHandler(OnSequenceOptionsButtonPress); nvSequenceOptions.KeyPressEvent += new KeyPressEventHandler(OnSequenceOptionsKeyPress); nvSequenceOptions.RowActivated += (o, args) => { var node = ((o as NodeView).NodeSelection.SelectedNode as SequenceOperationTreeNode); ActiveNode = node; sbDays.Value = node.SeqOp.Duration.Days; sbHours.Value = node.SeqOp.Duration.Hours; sbMinutes.Value = node.SeqOp.Duration.Minutes; sbSeconds.Value = node.SeqOp.Duration.Seconds; sbMilliSec.Value = node.SeqOp.Duration.Milliseconds; cbState.Active = (node.SeqOp.State == DPinState.HIGH) ? 0 : 1; btnRemoveOperation.Sensitive = true; SwitchToApplyBtn(); }; nvSequenceOptions.Show(); }
/// <summary> /// Removes a operation. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> protected void OnBtnRemoveOperationClicked(object sender, EventArgs e) { if (ActiveNode != null) { PinSequence.Chain.RemoveAt(ActiveNode.Index); DisplaySequenceInfos(); btnRemoveOperation.Sensitive = false; ActiveNode = null; } }
protected void OnSequenceOptionsButtonPress(object o, ButtonPressEventArgs args) { if (args.Event.Button == 3) /* right click */ { Menu m = new Menu(); MenuItem deleteItem = new MenuItem("Delete this operation"); deleteItem.ButtonPressEvent += (obj, e) => { SequenceOperationTreeNode node = ((o as NodeView).NodeSelection.SelectedNode as SequenceOperationTreeNode); PinSequence.Chain.RemoveAt(node.Index); DisplaySequenceInfos(); }; ImageMenuItem clearItem = new ImageMenuItem("Clear operaitons"); clearItem.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); clearItem.ButtonPressEvent += (obj, e) => ClearOperations(); m.Add(deleteItem); m.Add(new SeparatorMenuItem()); m.Add(clearItem); m.ShowAll(); m.Popup(); } }