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


C# ListStore.InsertAfter方法代码示例

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


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

示例1: LaunchDialogue

		public override void LaunchDialogue ()
		{
			//the Type in the collection
			IList collection = (IList) Value;
			string displayName = Property.DisplayName;

			//populate list with existing items
			ListStore itemStore = new ListStore (typeof (object), typeof (int), typeof (string));
			for (int i=0; i<collection.Count; i++)
				itemStore.AppendValues(collection [i], i, collection [i].ToString ());

			#region Building Dialogue
			
			TreeView itemTree;
			PropertyGrid grid;
			TreeIter previousIter = TreeIter.Zero;

			//dialogue and buttons
			Dialog dialog = new Dialog () {
				Title = displayName + " Editor",
				Modal = true,
				AllowGrow = true,
				AllowShrink = true,
			};
			var toplevel = this.Container.Toplevel as Window;
			if (toplevel != null)
				dialog.TransientFor = toplevel;
			
			dialog.AddActionWidget (new Button (Stock.Cancel), ResponseType.Cancel);
			dialog.AddActionWidget (new Button (Stock.Ok), ResponseType.Ok);
			
			//three columns for items, sorting, PropGrid
			HBox hBox = new HBox ();
			dialog.VBox.PackStart (hBox, true, true, 5);

			//propGrid at end
			grid = new PropertyGrid (base.EditorManager) {
				CurrentObject = null,
				WidthRequest = 200,
				ShowHelp = false
			};
			hBox.PackEnd (grid, true, true, 5);

			//followed by a ButtonBox
			VBox buttonBox = new VBox ();
			buttonBox.Spacing = 6;
			hBox.PackEnd (buttonBox, false, false, 5);
			
			//add/remove buttons
			Button addButton = new Button (new Image (Stock.Add, IconSize.Button));
			buttonBox.PackStart (addButton, false, false, 0);
			if (types [0].IsAbstract)
				addButton.Sensitive = false;
			Button removeButton = new Button (new Gtk.Image (Stock.Remove, IconSize.Button));
			buttonBox.PackStart (removeButton, false, false, 0);
			
			//sorting buttons
			Button upButton = new Button (new Image (Stock.GoUp, IconSize.Button));
			buttonBox.PackStart (upButton, false, false, 0);
			Button downButton = new Button (new Image (Stock.GoDown, IconSize.Button));
			buttonBox.PackStart (downButton, false, false, 0);

			//Third column has list (TreeView) in a ScrolledWindow
			ScrolledWindow listScroll = new ScrolledWindow ();
			listScroll.WidthRequest = 200;
			listScroll.HeightRequest = 320;
			hBox.PackStart (listScroll, false, false, 5);
			
			itemTree = new TreeView (itemStore);
			itemTree.Selection.Mode = SelectionMode.Single;
			itemTree.HeadersVisible = false;
			listScroll.AddWithViewport (itemTree);

			//renderers and attribs for TreeView
			CellRenderer rdr = new CellRendererText ();
			itemTree.AppendColumn (new TreeViewColumn ("Index", rdr, "text", 1));
			rdr = new CellRendererText ();
			itemTree.AppendColumn (new TreeViewColumn ("Object", rdr, "text", 2));

			#endregion

			#region Events

			addButton.Clicked += delegate {
				//create the object
				object instance = System.Activator.CreateInstance (types[0]);
				
				//get existing selection and insert after it
				TreeIter oldIter, newIter;
				if (itemTree.Selection.GetSelected (out oldIter))
					newIter = itemStore.InsertAfter (oldIter);
				//or append if no previous selection 
				else
					newIter = itemStore.Append ();
				itemStore.SetValue (newIter, 0, instance);
				
				//select, set name and update all the indices
				itemTree.Selection.SelectIter (newIter);
				UpdateName (itemStore, newIter);
				UpdateIndices (itemStore);
//.........这里部分代码省略.........
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:101,代码来源:CollectionEditor.cs


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