当前位置: 首页>>代码示例>>C#>>正文


C# TreeStore.AddNode方法代码示例

本文整理汇总了C#中TreeStore.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# TreeStore.AddNode方法的具体用法?C# TreeStore.AddNode怎么用?C# TreeStore.AddNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeStore的用法示例。


在下文中一共展示了TreeStore.AddNode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainWindow

        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 ();
        }
开发者ID:oxyplot,项目名称:oxyplot-xwt,代码行数:60,代码来源:MainWindow.cs

示例2: TreeViews

        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);
                };
            };
        }
开发者ID:chkn,项目名称:xwt,代码行数:48,代码来源:TreeViews.cs

示例3: CreateScrollableWidget

		public override IScrollableWidget CreateScrollableWidget ()
		{
			DataField<string> text = new DataField<string> ();
			TreeStore s = new TreeStore (text);
			var list = new TreeView (s);
			list.Columns.Add ("Hi", text);

			for (int n = 0; n < 100; n++) {
				var r = s.AddNode ();
				r.SetValue (text, n + new string ('.',100));
			}
			return list;
		}
开发者ID:m13253,项目名称:xwt,代码行数:13,代码来源:TreeViewTests.cs

示例4: HiddenTree

		public void HiddenTree ()
		{
			var f = new DataField<string> ();
			TreeStore ts = new TreeStore (f);
			var node = ts.AddNode ().SetValue (f, "1").AddChild ().SetValue (f, "2").AddChild ().SetValue (f, "3");
			var tree = new TreeView (ts);

			Window w = new Window ();
			Notebook nb = new Notebook ();
			nb.Add (new Label ("Hi"), "One");
			nb.Add (tree, "Two");
			w.Content = nb;
			ShowWindow (w);

			tree.ScrollToRow (node.CurrentPosition);

			tree.Columns.Add ("Hi", f);

			tree.ScrollToRow (node.CurrentPosition);
		}
开发者ID:m13253,项目名称:xwt,代码行数:20,代码来源:TreeViewTests.cs

示例5: CodeIssuePadControl

		public CodeIssuePadControl ()
		{
			var buttonRow = new HBox();
			runButton.Image = ImageService.GetIcon (Ide.Gui.Stock.Execute, IconSize.Menu);
			runButton.Clicked += StartAnalyzation;
			buttonRow.PackStart (runButton);

			cancelButton.Image = ImageService.GetIcon (Ide.Gui.Stock.Stop, IconSize.Menu);
			cancelButton.Clicked += StopAnalyzation;
			cancelButton.Sensitive = false;
			buttonRow.PackStart (cancelButton);
			var groupingProvider = new CategoryGroupingProvider {
				Next = new ProviderGroupingProvider()
			};
			rootGroup = new IssueGroup (groupingProvider, "root group");
			var groupingProviderControl = new GroupingProviderChainControl (rootGroup, groupingProviders);
			buttonRow.PackStart (groupingProviderControl);
			
			PackStart (buttonRow);

			store = new TreeStore (textField, nodeField);
			view.DataSource = store;
			view.HeadersVisible = false;
			view.Columns.Add ("Name", textField);
			view.SelectionMode = SelectionMode.Multiple;

			view.RowActivated += OnRowActivated;
			view.RowExpanding += OnRowExpanding;
			view.ButtonPressed += HandleButtonPressed;
			view.ButtonReleased += HandleButtonReleased;
			PackStart (view, true);
			
			IIssueTreeNode node = rootGroup;
			node.ChildrenInvalidated += (sender, group) => {
				Application.Invoke (delegate {
					ClearSiblingNodes (store.GetFirstNode ());
					store.Clear ();
					foreach(var child in ((IIssueTreeNode)rootGroup).Children) {
						var navigator = store.AddNode ();
						SetNode (navigator, child);
						SyncNode (navigator);
					}
				});
			};
			node.ChildAdded += HandleRootChildAdded;

			IdeApp.Workspace.LastWorkspaceItemClosed += HandleLastWorkspaceItemClosed;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:48,代码来源:CodeIssuePad.cs

示例6: TreeViews

        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);
//.........这里部分代码省略.........
开发者ID:sergueik,项目名称:xwt_swd,代码行数:101,代码来源:ListViews.cs

示例7: TreeViewCellBounds

		public TreeViewCellBounds ()
		{
			MinHeight = 120;
			MinWidth = 100;

			container = new VBox ();
			TreeView = new TreeView ();
			TreeStore = new TreeStore (triState, check, text, desc);
			TreeView.GridLinesVisible = GridLines.Both;

			TreeView.Columns.Add ("TriCheck", triState);
			TreeView.Columns.Add ("Check", check);
			TreeView.Columns.Add ("Item", text);
			TreeView.Columns.Add ("Desc", desc, check, text);

			TreeView.DataSource = TreeStore;

			TreeStore.AddNode ().SetValue (text, "One").SetValue (desc, "First").SetValue (triState, CheckBoxState.Mixed);
			TreeStore.AddNode ().SetValue (text, "Two").SetValue (desc, "Second").AddChild ()
				.SetValue (text, "Sub two").SetValue (desc, "Sub second");
			TreeStore.AddNode ().SetValue (text, "Three").SetValue (desc, "Third").AddChild ()
				.SetValue (text, "Sub three").SetValue (desc, "Sub third");

			TreeView.ExpandAll ();


			TreeView.SelectionChanged += (sender, e) => UpdateTracker (TreeView.SelectedRow);
			TreeView.MouseMoved += (sender, e) => UpdateTracker (TreeView.GetRowAtPosition (e.X, e.Y));

			drawer = new TreeTrackingCanvas (this);

			container.PackStart (TreeView, true);
			container.PackStart (drawer);
			AddChild (container);

			if (currentRow == null)
				currentRow = TreeStore.GetFirstNode ();
		}
开发者ID:m13253,项目名称:xwt,代码行数:38,代码来源:TreeViewCellBounds.cs

示例8: LoadQuery

        public void LoadQuery(StoredQuery query)
        {
            listView.Columns.Clear();
            using (var progress = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor(true, false, false))
            {
                var fields = CachedMetaData.Instance.Fields;
                WorkItemStore store = new WorkItemStore(query);
                var data = store.LoadByPage(progress);
                if (data.Count > 0)
                {
                    var firstItem = data[0];
                    List<IDataField> dataFields = new List<IDataField>();
                    var mapping = new Dictionary<Field, IDataField<object>>();
                    foreach (var item in firstItem.WorkItemInfo.Keys)
                    {
                        var field = fields[item];
                        var dataField = new DataField<object>();
                        dataFields.Add(dataField);
                        mapping.Add(field, dataField);
                    }

                    if (dataFields.Any())
                    {
                        if (ShowCheckboxes)
                        {
                            isCheckedField = new DataField<bool>();
                            dataFields.Insert(0, isCheckedField);
                            var checkColumn = new CheckBoxCellView(isCheckedField) { Editable = true };
                            checkColumn.Toggled += (sender, e) => 
                            {
                                var astore = (TreeStore)listView.DataSource;
                                var node = astore.GetNavigatorAt(listView.CurrentEventRow);
                                var workItem = node.GetValue(workItemField);
                                if (!node.GetValue(isCheckedField))
                                {
                                    if (OnSelectWorkItem != null)
                                        OnSelectWorkItem(workItem);
                                }
                                else
                                {
                                    if (OnRemoveWorkItem != null)
                                        OnRemoveWorkItem(workItem);
                                }
                            };
                            listView.Columns.Add("", checkColumn);
                        }
                        workItemField = new DataField<WorkItem>();
                        dataFields.Insert(0, workItemField);
                        var listStore = new TreeStore(dataFields.ToArray());
                        foreach (var map in mapping)
                        {
                            listView.Columns.Add(map.Key.Name, map.Value);
                        }
                        listView.DataSource = listStore;
                        foreach (var workItem in data)
                        {
                            var row = listStore.AddNode();
                            row.SetValue(workItemField, workItem);
                            foreach (var map in mapping)
                            {
                                object value;
                                if (workItem.WorkItemInfo.TryGetValue(map.Key.ReferenceName, out value))
                                {
                                    row.SetValue(map.Value, value);
                                }
                                else
                                {
                                    row.SetValue(map.Value, null);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:Indomitable,项目名称:monodevelop-tfs-addin,代码行数:75,代码来源:WorkItemListWidget.cs

示例9: TreeViews

        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);
        }
开发者ID:jbeaurain,项目名称:xwt,代码行数:67,代码来源:TreeViews.cs

示例10: TreeViews

        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);
        }
开发者ID:nite2006,项目名称:xwt,代码行数:87,代码来源:TreeViews.cs

示例11: CreateTreeView

 void CreateTreeView(HPaned panel)
 {
     store = new TreeStore (nameCol);
     tree = new TreeView (store);
     tree.Columns.Add ("Name", nameCol);
     panel.Panel1.Content = tree;
     var conns = store.AddNode (null).SetValue (nameCol, "Nodes").CurrentPosition;
     vm.ConnectionAdded += (a, b) =>
         store.AddNode (conns).SetValue (nameCol, a + "-" + b.Id);
     tree.SelectionChanged +=
         HandleSelectionChanged;
 }
开发者ID:stangelandcl,项目名称:Actors,代码行数:12,代码来源:MainWindow.cs


注:本文中的TreeStore.AddNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。