public TreeViews() { TreeView view = new TreeView(); TreeStore store = new TreeStore(text, desc); view.Columns.Add("Item", text); view.Columns.Add("Desc", desc); store.AddNode().SetValue(text, "One").SetValue(desc, "First"); store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild() .SetValue(text, "Sub two").SetValue(desc, "Sub second"); store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild() .SetValue(text, "Sub three").SetValue(desc, "Sub third"); PackStart(view); view.DataSource = store; Label la = new Label(); PackStart(la); view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text); view.SetDragSource(DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt(node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) { e.AllowedAction = DragDropAction.None; } else { e.AllowedAction = e.Action; } }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text); e.DragOperation.Data.AddValue(val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine("D:" + args.DeleteSource); }; }; }
void EditClicked(object sender, EventArgs e) { AlgorithmInfo selected = store.GetNavigatorAt(algorithmTree.SelectedRow).GetValue(infoCol); AlgorithmManager.Instance.AlgorithmList.Remove(selected); algorithmView.UpdateAlgorithm(); AlgorithmManager.Instance.AlgorithmList.Add(selected); AlgorithmManager.Instance.Save(); UpdateList(sender, e); SelectAlgorithm(selected); }
void SelectionChangedHandler(object sender, EventArgs e) { if (suppressChangeEvent) { return; } var pos = SelectedRow; if (pos == null) { return; } var nav = store.GetNavigatorAt(pos); var span = nav.GetValue(spanField); var roslynSnapshot = lastSourceText.FindCorrespondingEditorTextSnapshot(); if (roslynSnapshot == null) { return; } var editorSpan = new SnapshotSpan(roslynSnapshot, span.Start, span.Length); suppressChangeEvent = true; try { editorTracker.TextView.Selection.Select(editorSpan, false); } finally { suppressChangeEvent = false; } }
public MainWindow() { this.Examples = ExampleLibrary.Examples.GetList().OrderBy(e => e.Category).ToList(); this.plotView = new PlotView(); this.plotView.MinHeight = 554; this.plotView.MinWidth = 625; this.plotView.DefaultTrackerSettings.Enabled = true; this.plotView.DefaultTrackerSettings.Background = Xwt.Drawing.Colors.AliceBlue.WithAlpha (0.9).ToOxyColor(); this.treeView = new TreeView(); this.treeView.MinWidth = 314; this.treeView.Visible = true; var treeModel = new TreeStore(nameCol); TreePosition categoryNode = null; string categoryName = null; foreach (var ex in this.Examples) { if (categoryName == null || categoryName != ex.Category) { categoryNode = treeModel.AddNode ().SetValue (nameCol, ex.Category).CurrentPosition; categoryName = ex.Category; } treeModel.AddNode (categoryNode).SetValue (nameCol, ex.Title); } treeView.Columns.Add ("Example", nameCol); this.treeView.DataSource = treeModel; this.treeView.SelectionChanged += (s, e) => { if (treeView.SelectedRow != null) { var sample = treeModel.GetNavigatorAt (treeView.SelectedRow).GetValue (nameCol); var info = this.Examples.FirstOrDefault(ex => ex.Title == sample); if (info != null) { this.SelectedExample = info; } } }; var hbox = new HBox(); hbox.Spacing = 6; hbox.MinHeight = 554; hbox.MinWidth = 943; hbox.PackStart(this.treeView); hbox.PackStart(this.plotView, true); Content = hbox; this.SelectedExample = this.Examples.FirstOrDefault(); this.Title = "OxyPlot.Xwt Example Browser"; this.CloseRequested += (s, a) => Application.Exit (); }
void UpdateCheckboxDependencies(TreePosition updatedRow) { var node = store.GetNavigatorAt(updatedRow); bool isRoot = node.GetValue(nodeIconVisible); CheckBoxState newCheck = node.GetValue(nodeCheck); if (isRoot) { UpdateChildrenForRootCheck(node, newCheck); return; } UpdateNextChildrenOffset(node, newCheck); UpdateRootFromChild(node, newCheck); }
void BuildGui() { this.Title = "Select Projects"; this.Resizable = false; var vBox = new VBox(); var hbox = new HBox(); collectionsList.DataSource = collectionStore; collectionsList.Views.Add(new TextCellView(collectionName)); collectionsList.MinWidth = 200; collectionsList.MinHeight = 300; hbox.PackStart(collectionsList); projectsList.DataSource = projectsStore; projectsList.MinWidth = 200; projectsList.MinHeight = 300; var checkView = new CheckBoxCellView(isProjectSelected) { Editable = true }; checkView.Toggled += (sender, e) => { var row = projectsList.CurrentEventRow; var node = projectsStore.GetNavigatorAt(row); var isSelected = !node.GetValue(isProjectSelected); //Xwt gives previous value var project = node.GetValue(projectItem); if (isSelected && !SelectedProjects.Any(p => string.Equals(p.Uri, project.Uri))) { SelectedProjects.Add(project); } if (!isSelected && SelectedProjects.Any(p => string.Equals(p.Uri, project.Uri))) { SelectedProjects.RemoveAll(p => string.Equals(p.Uri, project.Uri)); } }; projectsList.Columns.Add(new ListViewColumn("", checkView)); projectsList.Columns.Add(new ListViewColumn("Name", new TextCellView(projectName))); hbox.PackEnd(projectsList); vBox.PackStart(hbox); Button ok = new Button(GettextCatalog.GetString("OK")); ok.Clicked += (sender, e) => Respond(Command.Ok); Button cancel = new Button(GettextCatalog.GetString("Cancel")); cancel.Clicked += (sender, e) => Respond(Command.Cancel); ok.MinWidth = cancel.MinWidth = Constants.ButtonWidth; var buttonBox = new HBox(); buttonBox.PackEnd(ok); buttonBox.PackEnd(cancel); vBox.PackStart(buttonBox); this.Content = vBox; }
Widget CreateSoundFontListPanel() { var sfList = new TreeView() { UseAlternatingRowColors = true, AnimationsEnabled = true }; var nameCol = new DataField <string> (); var bankCol = new DataField <int> (); var fileCol = new DataField <string> (); var presetCol = new DataField <string> (); var namePresetCol = new DataField <string> (); var patchCol = new DataField <int> (); var store = new TreeStore(fileCol, nameCol, bankCol, patchCol, presetCol, namePresetCol); sfList.DataSource = store; //sfList.Columns.Add ("File", fileCol); //sfList.Columns.Add ("Name", nameCol); sfList.Columns.Add("Patch", patchCol); sfList.Columns.Add("Bank", bankCol); //sfList.Columns.Add ("Preset", presetCol); sfList.Columns.Add("Name/Preset", namePresetCol); update_soundfonts = () => { store.Clear(); foreach (var sf in model.LoadedSoundFonts) { sf.Load(); } foreach (var sf in model.LoadedSoundFonts.Where(_ => _.Entity != null)) { foreach (var preset in sf.Entity.Presets.OrderBy(p => p.PatchNumber).ThenBy(p => p.Bank)) { var node = store.AddNode(); node.SetValues( fileCol, sf.FullPath, nameCol, sf.Entity.FileInfo.BankName, bankCol, preset.Bank, patchCol, preset.PatchNumber, presetCol, preset.Name, namePresetCol, sf.Entity.FileInfo.BankName + " / " + preset.Name); } } }; model.SoundFontListUpdated += update_soundfonts; sfList.SelectionChanged += (o, e) => { var iter = store.GetNavigatorAt(sfList.SelectedRow); model.UpdateSelectedInstrument(new Model.SoundFontSelection { File = iter.GetValue(fileCol), Patch = iter.GetValue(patchCol), Bank = iter.GetValue(bankCol), }); }; return(sfList); }
private void TreeView_DragOver(object sender, DragOverEventArgs e) { if (!PipelineController.Instance.ProjectOpen) { return; } e.AllowedAction = DragDropAction.Copy; RowDropPosition rowpos; TreePosition pos; if (_treeView.GetDropTargetRow(e.Position.X, e.Position.Y, out rowpos, out pos)) { if (rowpos == RowDropPosition.Into && _treeStore.GetNavigatorAt(pos).GetValue(_dataTag) is ContentItem) { e.AllowedAction = DragDropAction.None; } } }
void AttachEvents() { queryView.RowActivated += (sender, e) => { var navigator = queryStore.GetNavigatorAt(e.Position); var query = navigator.GetValue(queryField); if (query != null) { workItemList.LoadQuery(query); } }; }
void HandleSamplesTreeSelectionChanged(object sender, EventArgs e) { if (samplesTree.SelectedRow != null) { // Remove currentInteraction if there is one if (currentInteraction != null) { // must already have a valid plot sample with the interaction added to it PlotSample ps = (PlotSample)currentWidget; PlotCanvas pc = ps.PlotCanvas; // Remove current interaction from PlotCanvas pc.RemoveInteraction(currentInteraction); currentInteraction = null; } // get newSample from selected row TreePosition viewRow = samplesTree.SelectedRow; TreeNavigator storeRow = store.GetNavigatorAt(viewRow); Sample newSample = storeRow.GetValue(sampleCol); TreePosition newCategory = newSample.Category; if (newCategory == interactionCategory) { // only allow interaction if there is already a plotSample if (currentCategory == plotCategory) { PlotSample ps = (PlotSample)currentWidget; PlotCanvas pc = ps.PlotCanvas; // Add new interaction to existing PlotCanvas currentInteraction = newSample.Interaction; pc.AddInteraction(currentInteraction); } } else { // plotCategory or testCategory currentCategory = newCategory; if (currentWidget != null) { sampleBox.Remove(currentWidget); } if (newSample.Type != null) { currentWidget = (Widget)Activator.CreateInstance(newSample.Type); sampleBox.PackStart(currentWidget, true); Dump(currentWidget, 0); } } } }
private void HandleSamplesTreeSelectionChanged(object sender, EventArgs e) { if (samplesTree.SelectedRow == null) { return; } if (currentSample != null) { sampleBox.Remove(currentSample); } Type t = store.GetNavigatorAt(samplesTree.SelectedRow).GetValue(widgetCol); if (t == null) { return; } currentSample = new VBox(); HBox row = null; var icons = t.GetProperties(BindingFlags.Public | BindingFlags.Static); for (int i = 0; i < icons.Length; i++) { if (i % 3 == 0) { if (row != null) { currentSample.PackStart(row); } row = new HBox(); } if (icons [i].PropertyType != typeof(Image)) { continue; } Image img = (Image)(icons [i].GetValue(typeof(Image), null)); row.PackStart(new ImageView(img.WithSize(IconSize.Large))); row.PackStart(new ImageView(img.WithSize(IconSize.Medium))); row.PackStart(new ImageView(img.WithSize(IconSize.Small))); } currentSample.PackStart(row); sampleBox.PackStart(currentSample); }
public TreeViews() { TreeView view = new TreeView (); TreeStore store = new TreeStore (text, desc); view.Columns.Add ("Item", text); view.Columns.Add ("Desc", desc); store.AddNode ().SetValue (text, "One").SetValue (desc, "First"); store.AddNode ().SetValue (text, "Two").SetValue (desc, "Second").AddChild () .SetValue (text, "Sub two").SetValue (desc, "Sub second"); store.AddNode ().SetValue (text, "Three").SetValue (desc, "Third").AddChild () .SetValue (text, "Sub three").SetValue (desc, "Sub third"); PackStart (view); view.DataSource = store; Label la = new Label (); PackStart (la); view.SetDragDropTarget (DragDropAction.All, TransferDataType.Text); view.SetDragSource (DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow (e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt (node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue (text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow (e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) e.AllowedAction = DragDropAction.None; else e.AllowedAction = e.Action; }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt (view.SelectedRow).GetValue (text); e.DragOperation.Data.AddValue (val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine ("D:" + args.DeleteSource); }; }; }
BaseViewModel GetBaseViewModel(TreePosition position) { if (position == null) { return(null); } TreeNavigator navigator = treeStore.GetNavigatorAt(position); if (navigator == null) { return(null); } return(navigator.GetValue(viewModelDataField)); }
async void OnSamplesViewSelectionChanged(object sender, System.EventArgs e) { var row = _samplesView.SelectedRow; if (row != null) { var node = _samplesStore.GetNavigatorAt(row); if (node != null) { var sample = node.GetValue(_sampleField) as Sample; _controller.SelectedSample = sample; await LoadSelectedSampleAsync(); } } }
void HandleSamplesTreeSelectionChanged(object sender, EventArgs e) { if (samplesTree.SelectedRow != null) { if (currentSample != null) { sampleBox.Remove(currentSample); } Sample s = store.GetNavigatorAt(samplesTree.SelectedRow).GetValue(widgetCol); if (s.Type != null) { if (s.Widget == null) { s.Widget = (Widget)Activator.CreateInstance(s.Type); } sampleBox.PackStart(s.Widget, BoxMode.FillAndExpand); } } }
void SelectionChanged(object sender, EventArgs e) { var pos = treeView.SelectedRow; if (pos == null) { propertyGrid.CurrentObject = null; return; } var tag = store.GetNavigatorAt(pos)?.GetValue(tagField); object[] propertyProviders = null; if (tag is ClassificationTag ct) { propertyProviders = new object [] { new ClassificationTagDescriptor(ct) }; } propertyGrid.SetCurrentObject(tag, propertyProviders ?? new object [] { tag }); }
void ProcessUpdateQueue() { IList <IIssueTreeNode> nodes; lock (queueLock) { nodes = new List <IIssueTreeNode> (updateQueue); updateQueue.Clear(); } foreach (var node in nodes) { TreePosition position; if (!nodePositions.TryGetValue(node, out position)) { // This might be an event for a group that has been invalidated and removed continue; } var navigator = store.GetNavigatorAt(position); if (!node.Visible) { // Check above means node is always in nodePositions nodePositions.Remove(node); if (syncedNodes.Contains(node)) { syncedNodes.Remove(node); } ClearChildNodes(navigator); navigator.Remove(); continue; } UpdateText(navigator, node); if (!syncedNodes.Contains(node) && node.HasVisibleChildren) { if (navigator.MoveToChild()) { navigator.MoveToParent(); } else { AddDummyChild(navigator); } } } }
private void OnRowClicked(object sender, TreeViewRowEventArgs e) { var node = _treeStore.GetNavigatorAt(e.Position); var nodeType = node.GetValue(_type); switch (nodeType) { case NodeType.SourceControl: node.MoveToParent(); var project = (ProjectInfo)node.GetValue(_item); SourceControlExplorerView.Open(project); break; case NodeType.WorkItemQuery: var query = (StoredQuery)node.GetValue(_item); WorkItemsView.Open(query); break; default: break; } }
void HandleSamplesTreeSelectionChanged(object sender, EventArgs e) { if (samplesTree.SelectedRow != null) { if (currentSample != null) { sampleBox.Remove(currentSample); } Sample s = store.GetNavigatorAt(samplesTree.SelectedRow).GetValue(widgetCol); if (s.Type != null) { if (s.Widget == null) { s.Widget = (Widget)Activator.CreateInstance(s.Type); } sampleBox.PackStart(s.Widget, true); } // Console.WriteLine (System.Xaml.XamlServices.Save (s.Widget)); currentSample = s.Widget; Dump(currentSample, 0); } }
void HandleSamplesTreeSelectionChanged(object sender, EventArgs e) { if (samplesTree.SelectedItem != null) { if (currentSample != null) { sampleBox.Remove(currentSample); } Sample s = store.GetNavigatorAt(samplesTree.SelectedItem).GetValue(widgetCol); if (s.Type != null) { if (s.Widget == null) { s.Widget = (Widget)Activator.CreateInstance(s.Type); } sampleBox.PackStart(s.Widget, BoxMode.FillAndExpand); } // string txt = System.Xaml.XamlServices.Save (s); currentSample = s.Widget; Dump(currentSample, 0); } }
public MainWindow() { this.Examples = ExampleLibrary.Examples.GetList().OrderBy(e => e.Category).ToList(); this.plotView = new PlotView(); this.plotView.MinHeight = 554; this.plotView.MinWidth = 625; this.plotView.DefaultTrackerSettings.Enabled = true; this.plotView.DefaultTrackerSettings.Background = Xwt.Drawing.Colors.AliceBlue.WithAlpha(0.9).ToOxyColor(); this.treeView = new TreeView(); this.treeView.MinWidth = 314; this.treeView.Visible = true; var treeModel = new TreeStore(nameCol); TreePosition categoryNode = null; string categoryName = null; foreach (var ex in this.Examples) { if (categoryName == null || categoryName != ex.Category) { categoryNode = treeModel.AddNode().SetValue(nameCol, ex.Category).CurrentPosition; categoryName = ex.Category; } treeModel.AddNode(categoryNode).SetValue(nameCol, ex.Title); } treeView.Columns.Add("Example", nameCol); this.treeView.DataSource = treeModel; this.treeView.SelectionChanged += (s, e) => { if (treeView.SelectedRow != null) { var sample = treeModel.GetNavigatorAt(treeView.SelectedRow).GetValue(nameCol); var info = this.Examples.FirstOrDefault(ex => ex.Title == sample); if (info != null) { this.SelectedExample = info; } } }; var hbox = new HBox(); hbox.Spacing = 6; hbox.MinHeight = 554; hbox.MinWidth = 943; hbox.PackStart(this.treeView); hbox.PackStart(this.plotView, true); Content = hbox; this.SelectedExample = this.Examples.FirstOrDefault(); this.Title = "OxyPlot.Xwt Example Browser"; this.CloseRequested += (s, a) => Application.Exit(); }
public TreeViews() { TreeView view = new TreeView(); TreeStore store = new TreeStore(triState, check, option1, option2, option3, text, desc); view.GridLinesVisible = GridLines.Both; var triStateCellView = new CheckBoxCellView(triState) { Editable = true, AllowMixed = true }; triStateCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled"); } }; var checkCellView = new CheckBoxCellView(check) { Editable = true }; checkCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled " + checkCellView.Active); } }; var optionCellView1 = new RadioButtonCellView(option1) { Editable = true }; optionCellView1.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(option2, optionCellView1.Active); } }; var optionCellView2 = new RadioButtonCellView(option2) { Editable = true }; optionCellView2.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(option1, optionCellView2.Active); } }; TreePosition initialActive = null; var optionCellView3 = new RadioButtonCellView(option3) { Editable = true }; optionCellView3.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { if (initialActive != null) { store.GetNavigatorAt(initialActive).SetValue(option3, false); } initialActive = view.CurrentEventRow; } }; view.Columns.Add("TriCheck", triStateCellView); view.Columns.Add("Check", checkCellView); view.Columns.Add("Radio", optionCellView1, optionCellView2, optionCellView3); view.Columns.Add("Item", text); view.Columns.Add("Desc", desc); view.Columns[2].Expands = true; // expand third column, aligning last column to the right side view.Columns[2].CanResize = true; view.Columns[3].CanResize = true; store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed); store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild() .SetValue(text, "Sub two").SetValue(desc, "Sub second"); store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild() .SetValue(text, "Sub three").SetValue(desc, "Sub third"); PackStart(view, true); Menu contextMenu = new Menu(); contextMenu.Items.Add(new MenuItem("Test menu")); view.ButtonPressed += delegate(object sender, ButtonEventArgs e) { TreePosition tmpTreePos; RowDropPosition tmpRowDrop; if ((e.Button == PointerButton.Right) && view.GetDropTargetRow(e.X, e.Y, out tmpRowDrop, out tmpTreePos)) { // Set actual row to selected view.SelectRow(tmpTreePos); contextMenu.Popup(view, e.X, e.Y); } }; view.DataSource = store; Label la = new Label(); PackStart(la); view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text); view.SetDragSource(DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt(node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) { e.AllowedAction = DragDropAction.None; } else { e.AllowedAction = e.Action; } }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text); e.DragOperation.Data.AddValue(val); var img = Image.FromResource(GetType(), "class.png"); e.DragOperation.SetDragImage(img, (int)img.Size.Width, (int)img.Size.Height); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine("D:" + args.DeleteSource); }; }; view.RowExpanding += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Expanding: " + val); }; view.RowExpanded += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Expanded: " + val); }; view.RowCollapsing += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Collapsing: " + val); }; view.RowCollapsed += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Collapsed: " + val); }; RadioButtonGroup group = new RadioButtonGroup(); foreach (SelectionMode mode in Enum.GetValues(typeof(SelectionMode))) { var radio = new RadioButton(mode.ToString()); radio.Group = group; radio.Activated += delegate { view.SelectionMode = mode; }; PackStart(radio); } int addCounter = 0; view.KeyPressed += (sender, e) => { if (e.Key == Key.Insert) { TreeNavigator n; if (view.SelectedRow != null) { n = store.InsertNodeAfter(view.SelectedRow).SetValue(text, "Inserted").SetValue(desc, "Desc"); } else { n = store.AddNode().SetValue(text, "Inserted").SetValue(desc, "Desc"); } view.ExpandToRow(n.CurrentPosition); view.ScrollToRow(n.CurrentPosition); view.UnselectAll(); view.SelectRow(n.CurrentPosition); view.FocusedRow = n.CurrentPosition; } }; Button addButton = new Button("Add"); addButton.Clicked += delegate(object sender, EventArgs e) { addCounter++; TreeNavigator n; if (view.SelectedRow != null) { n = store.AddNode(view.SelectedRow).SetValue(text, "Added " + addCounter).SetValue(desc, "Desc"); } else { n = store.AddNode().SetValue(text, "Added " + addCounter).SetValue(desc, "Desc"); } view.ExpandToRow(n.CurrentPosition); view.ScrollToRow(n.CurrentPosition); view.SelectRow(n.CurrentPosition); }; PackStart(addButton); Button removeButton = new Button("Remove Selection"); removeButton.Clicked += delegate(object sender, EventArgs e) { foreach (TreePosition row in view.SelectedRows) { store.GetNavigatorAt(row).Remove(); } }; PackStart(removeButton); Button clearButton = new Button("Clear"); clearButton.Clicked += delegate(object sender, EventArgs e) { store.Clear(); }; PackStart(clearButton); var label = new Label(); PackStart(label); view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text); }
public TreeViews() { TreeView view = new TreeView (); TreeStore store = new TreeStore (triState, check, text, desc); var triStateCellView = new CheckBoxCellView (triState) { Editable = true, AllowMixed = true }; triStateCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled"); } }; var checkCellView = new CheckBoxCellView (check) { Editable = true }; checkCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled"); } }; view.Columns.Add ("TriCheck", triStateCellView); view.Columns.Add ("Check", checkCellView); view.Columns.Add ("Item", text); view.Columns.Add ("Desc", desc); store.AddNode ().SetValue (text, "One").SetValue (desc, "First").SetValue (triState, CheckBoxState.Mixed); store.AddNode ().SetValue (text, "Two").SetValue (desc, "Second").AddChild () .SetValue (text, "Sub two").SetValue (desc, "Sub second"); store.AddNode ().SetValue (text, "Three").SetValue (desc, "Third").AddChild () .SetValue (text, "Sub three").SetValue (desc, "Sub third"); PackStart (view, true); view.DataSource = store; Label la = new Label (); PackStart (la); view.SetDragDropTarget (DragDropAction.All, TransferDataType.Text); view.SetDragSource (DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow (e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt (node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue (text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow (e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) e.AllowedAction = DragDropAction.None; else e.AllowedAction = e.Action; }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt (view.SelectedRow).GetValue (text); e.DragOperation.Data.AddValue (val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine ("D:" + args.DeleteSource); }; }; Button addButton = new Button ("Add"); addButton.Clicked += delegate(object sender, EventArgs e) { store.AddNode ().SetValue (text, "Added").SetValue (desc, "Desc"); }; PackStart (addButton); Button removeButton = new Button ("Remove Selection"); removeButton.Clicked += delegate(object sender, EventArgs e) { foreach (TreePosition row in view.SelectedRows) { store.GetNavigatorAt (row).Remove (); } }; PackStart (removeButton); var label = new Label (); PackStart (label); view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt (e.Position).GetValue (text); }
public TreeViews() { TreeView view = new TreeView(); TreeStore store = new TreeStore(triState, check, text, desc); view.GridLinesVisible = GridLines.Both; var triStateCellView = new CheckBoxCellView(triState) { Editable = true, AllowMixed = true }; triStateCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled"); } }; var checkCellView = new CheckBoxCellView(check) { Editable = true }; checkCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled"); } }; view.Columns.Add("TriCheck", triStateCellView); view.Columns.Add("Check", checkCellView); view.Columns.Add("Item", text); view.Columns.Add("Desc", desc); store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed); store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild() .SetValue(text, "Sub two").SetValue(desc, "Sub second"); store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild() .SetValue(text, "Sub three").SetValue(desc, "Sub third"); PackStart(view, true); Menu contextMenu = new Menu(); contextMenu.Items.Add(new MenuItem("Test menu")); view.ButtonPressed += delegate(object sender, ButtonEventArgs e) { TreePosition tmpTreePos; RowDropPosition tmpRowDrop; if ((e.Button == PointerButton.Right) && view.GetDropTargetRow(e.X, e.Y, out tmpRowDrop, out tmpTreePos)) { // Set actual row to selected view.SelectRow(tmpTreePos); contextMenu.Popup(view, e.X, e.Y); } }; view.DataSource = store; Label la = new Label(); PackStart(la); view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text); view.SetDragSource(DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt(node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) { e.AllowedAction = DragDropAction.None; } else { e.AllowedAction = e.Action; } }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text); e.DragOperation.Data.AddValue(val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine("D:" + args.DeleteSource); }; }; view.RowExpanding += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Expanding: " + val); }; view.RowExpanded += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Expanded: " + val); }; view.RowCollapsing += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Collapsing: " + val); }; view.RowCollapsed += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Collapsed: " + val); }; int addCounter = 0; view.KeyPressed += (sender, e) => { if (e.Key == Key.Insert) { TreeNavigator n; if (view.SelectedRow != null) { n = store.InsertNodeAfter(view.SelectedRow).SetValue(text, "Inserted").SetValue(desc, "Desc"); } else { n = store.AddNode().SetValue(text, "Inserted").SetValue(desc, "Desc"); } view.ExpandToRow(n.CurrentPosition); view.ScrollToRow(n.CurrentPosition); view.UnselectAll(); view.SelectRow(n.CurrentPosition); view.FocusedRow = n.CurrentPosition; } }; Button addButton = new Button("Add"); addButton.Clicked += delegate(object sender, EventArgs e) { addCounter++; TreeNavigator n; if (view.SelectedRow != null) { n = store.AddNode(view.SelectedRow).SetValue(text, "Added " + addCounter).SetValue(desc, "Desc"); } else { n = store.AddNode().SetValue(text, "Added " + addCounter).SetValue(desc, "Desc"); } view.ExpandToRow(n.CurrentPosition); view.ScrollToRow(n.CurrentPosition); view.SelectRow(n.CurrentPosition); }; PackStart(addButton); Button removeButton = new Button("Remove Selection"); removeButton.Clicked += delegate(object sender, EventArgs e) { foreach (TreePosition row in view.SelectedRows) { store.GetNavigatorAt(row).Remove(); } }; PackStart(removeButton); var label = new Label(); PackStart(label); view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text); }
public TreeViews() { TreeView view = new TreeView(); TreeStore store = new TreeStore(triState, check, text, desc); var triStateCellView = new CheckBoxCellView(triState) { Editable = true, AllowMixed = true }; triStateCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled"); } }; var checkCellView = new CheckBoxCellView(check) { Editable = true }; checkCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled"); } }; view.Columns.Add("TriCheck", triStateCellView); view.Columns.Add("Check", checkCellView); view.Columns.Add("Item", text); view.Columns.Add("Desc", desc); store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed); store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild() .SetValue(text, "Sub two").SetValue(desc, "Sub second"); store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild() .SetValue(text, "Sub three").SetValue(desc, "Sub third"); PackStart(view, true); view.DataSource = store; Label la = new Label(); PackStart(la); view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text); view.SetDragSource(DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt(node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) { e.AllowedAction = DragDropAction.None; } else { e.AllowedAction = e.Action; } }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text); e.DragOperation.Data.AddValue(val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine("D:" + args.DeleteSource); }; }; Button addButton = new Button("Add"); addButton.Clicked += delegate(object sender, EventArgs e) { store.AddNode().SetValue(text, "Added").SetValue(desc, "Desc"); }; PackStart(addButton); Button removeButton = new Button("Remove Selection"); removeButton.Clicked += delegate(object sender, EventArgs e) { foreach (TreePosition row in view.SelectedRows) { store.GetNavigatorAt(row).Remove(); } }; PackStart(removeButton); var label = new Label(); PackStart(label); view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text); }
public TreeViews() { TreeView view = new TreeView (); TreeStore store = new TreeStore (text, desc); view.Columns.Add ("Item", text); view.Columns.Add ("Desc", desc); store.AddNode ().SetValue (text, "One").SetValue (desc, "First"); store.AddNode ().SetValue (text, "Two").SetValue (desc, "Second").AddChild () .SetValue (text, "Sub two").SetValue (desc, "Sub second"); store.AddNode ().SetValue (text, "Three").SetValue (desc, "Third").AddChild () .SetValue (text, "Sub three").SetValue (desc, "Sub third"); PackStart (view, BoxMode.FillAndExpand); view.DataSource = store; Label la = new Label (); PackStart (la); view.SetDragDropTarget (DragDropAction.All, TransferDataType.Text); view.SetDragSource (DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow (e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt (node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue (text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow (e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) e.AllowedAction = DragDropAction.None; else e.AllowedAction = e.Action; }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt (view.SelectedRow).GetValue (text); e.DragOperation.Data.AddValue (val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine ("D:" + args.DeleteSource); }; }; Button addButton = new Button ("Add"); addButton.Clicked += delegate(object sender, EventArgs e) { store.AddNode ().SetValue (text, "Added").SetValue (desc, "Desc"); }; PackStart (addButton); Button removeButton = new Button ("Remove Selection"); removeButton.Clicked += delegate(object sender, EventArgs e) { foreach (TreePosition row in view.SelectedRows) { store.GetNavigatorAt (row).Remove (); } }; PackStart (removeButton); var label = new Label (); PackStart (label); view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt (e.Position).GetValue (text); }
public TreeViews() { TreeView view = new TreeView(); TreeStore store = new TreeStore(triState, check, text, desc); view.GridLinesVisible = GridLines.Both; var triStateCellView = new CheckBoxCellView(triState) { Editable = true, AllowMixed = true }; triStateCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled"); } }; var checkCellView = new CheckBoxCellView(check) { Editable = true }; checkCellView.Toggled += (object sender, WidgetEventArgs e) => { if (view.CurrentEventRow == null) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled"); } }; view.Columns.Add("TriCheck", triStateCellView); view.Columns.Add("Check", checkCellView); view.Columns.Add("Item", text); view.Columns.Add("Desc", desc); store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed); store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild() .SetValue(text, "Sub two").SetValue(desc, "Sub second"); store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild() .SetValue(text, "Sub three").SetValue(desc, "Sub third"); PackStart(view, true); Menu contextMenu = new Menu(); contextMenu.Items.Add(new MenuItem("Test menu")); view.ButtonPressed += delegate(object sender, ButtonEventArgs e) { TreePosition tmpTreePos; RowDropPosition tmpRowDrop; if ((e.Button == PointerButton.Right) && view.GetDropTargetRow(e.X, e.Y, out tmpRowDrop, out tmpTreePos)) { // Set actual row to selected view.SelectRow(tmpTreePos); contextMenu.Popup(view, e.X, e.Y); } }; view.DataSource = store; Label la = new Label(); PackStart(la); view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text); view.SetDragSource(DragDropAction.All, TransferDataType.Text); view.DragDrop += delegate(object sender, DragEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); var nav = store.GetNavigatorAt(node); la.Text += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n"; e.Success = true; }; view.DragOver += delegate(object sender, DragOverEventArgs e) { TreePosition node; RowDropPosition pos; view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node); if (pos == RowDropPosition.Into) e.AllowedAction = DragDropAction.None; else e.AllowedAction = e.Action; }; view.DragStarted += delegate(object sender, DragStartedEventArgs e) { var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text); e.DragOperation.Data.AddValue(val); e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) { Console.WriteLine("D:" + args.DeleteSource); }; }; view.RowExpanding += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Expanding: " + val); }; view.RowExpanded += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Expanded: " + val); }; view.RowCollapsing += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Collapsing: " + val); }; view.RowCollapsed += delegate(object sender, TreeViewRowEventArgs e) { var val = store.GetNavigatorAt(e.Position).GetValue(text); Console.WriteLine("Collapsed: " + val); }; int addCounter = 0; view.KeyPressed += (sender, e) => { if (e.Key == Key.Insert) { TreeNavigator n; if (view.SelectedRow != null) n = store.InsertNodeAfter(view.SelectedRow).SetValue(text, "Inserted").SetValue(desc, "Desc"); else n = store.AddNode().SetValue(text, "Inserted").SetValue(desc, "Desc"); view.ExpandToRow(n.CurrentPosition); view.ScrollToRow(n.CurrentPosition); view.UnselectAll(); view.SelectRow(n.CurrentPosition); view.FocusedRow = n.CurrentPosition; } }; Button addButton = new Button("Add"); addButton.Clicked += delegate(object sender, EventArgs e) { addCounter++; TreeNavigator n; if (view.SelectedRow != null) n = store.AddNode(view.SelectedRow).SetValue(text, "Added " + addCounter).SetValue(desc, "Desc"); else n = store.AddNode().SetValue(text, "Added " + addCounter).SetValue(desc, "Desc"); view.ExpandToRow(n.CurrentPosition); view.ScrollToRow(n.CurrentPosition); view.SelectRow(n.CurrentPosition); }; PackStart(addButton); Button removeButton = new Button("Remove Selection"); removeButton.Clicked += delegate(object sender, EventArgs e) { foreach (TreePosition row in view.SelectedRows) { store.GetNavigatorAt(row).Remove(); } }; PackStart(removeButton); var label = new Label(); PackStart(label); view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text); }
void CreateView() { store = new TreeStore(itemField, descriptionField, propertyNameField, propertiesField, notificationPreferenceField, notificationPreferencesField); treeView = new TreeView(store); treeView.SelectionChanged += (object sender, EventArgs e) => { if (treeView.SelectedRow != null) { var item = store.GetNavigatorAt(treeView.SelectedRow)?.GetValue(itemField) as AbstractCodeStyleOptionViewModel; if (item != null) { this.viewModel.SetOptionAndUpdatePreview(item.SelectedPreference.IsChecked, item.Option, item.GetPreview()); return; } } return; }; var col = treeView.Columns.Add(GettextCatalog.GetString("Description"), descriptionField); col.Expands = true; var propertyCellView = new ComboBoxCellView(propertyNameField); propertyCellView.Editable = true; propertyCellView.ItemsField = propertiesField; propertyCellView.SelectionChanged += delegate(object sender, WidgetEventArgs e) { var treeNavigator = store.GetNavigatorAt(treeView.CurrentEventRow); if (treeNavigator == null) { return; } var item = treeNavigator.GetValue(itemField); if (item == null) { return; } var text2 = treeNavigator.GetValue(propertyNameField); GLib.Timeout.Add(10, delegate { var text = treeNavigator.GetValue(propertyNameField); foreach (var pref in item.Preferences) { if (pref.Name == text) { item.SelectedPreference = pref; this.viewModel.SetOptionAndUpdatePreview(pref.IsChecked, item.Option, item.GetPreview()); } } return(false); }); }; col = new ListViewColumn(GettextCatalog.GetString("Property"), propertyCellView); col.Expands = true; treeView.Columns.Add(col); var severityCellView = new ComboBoxCellView(notificationPreferenceField); severityCellView.Editable = true; severityCellView.ItemsField = notificationPreferencesField; col = new ListViewColumn(GettextCatalog.GetString("Severity"), severityCellView); treeView.Columns.Add(col); this.PackStart(treeView, true, true); var wrappedEditor = Xwt.Toolkit.CurrentEngine.WrapWidget((Gtk.Widget)viewModel.TextViewHost, Xwt.NativeWidgetSizing.DefaultPreferredSize); this.PackEnd(wrappedEditor, true, true); FillTreeStore(); }