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


C# TreeStore.GetIterFromString方法代码示例

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


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

示例1: FontChooserPanelWidget

		public FontChooserPanelWidget ()
		{
			this.Build ();
			fontStore = new TreeStore (typeof (string), typeof (string), typeof (string));
			treeviewFonts.Model = fontStore;
			
			treeviewFonts.AppendColumn (GettextCatalog.GetString ("Name"), textRenderer, "text", colDisplayName);
			
			comboRenderer.Edited += delegate(object o, Gtk.EditedArgs args) {
				TreeIter iter;
				if (!fontStore.GetIterFromString (out iter, args.Path))
					return;
				string fontName = (string)fontStore.GetValue (iter, colName);
				
				if (args.NewText == GettextCatalog.GetString ("Default")) { 
					SetFont (fontName, FontService.GetFont (fontName).FontDescription);
					fontStore.SetValue (iter, colValue, GettextCatalog.GetString ("Default"));
					return;
				}
				var selectionDialog = new FontSelectionDialog (GettextCatalog.GetString ("Select Font"));
				string fontValue = FontService.FilterFontName (GetFont (fontName));
				selectionDialog.SetFontName (fontValue);
				selectionDialog.OkButton.Clicked += delegate {
					fontValue = selectionDialog.FontName;
					if (fontValue ==  FontService.FilterFontName (FontService.GetFont (fontName).FontDescription))
						fontValue = FontService.GetFont (fontName).FontDescription;
					SetFont (fontName, fontValue);
					fontStore.SetValue (iter, colValue, selectionDialog.FontName);
				};
				MessageService.ShowCustomDialog (selectionDialog);
				selectionDialog.Destroy ();
			};
			
			comboRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
				TreeIter iter;
				if (!fontStore.GetIterFromString (out iter, args.Path))
					return;
				string fontName = (string)fontStore.GetValue (iter, colName);
				string fontValue = GetFont (fontName);
				comboBoxStore.Clear ();
				if (fontValue != FontService.GetFont (fontName).FontDescription) 
					comboBoxStore.AppendValues (fontValue);
				
				comboBoxStore.AppendValues (GettextCatalog.GetString ("Default"));
				comboBoxStore.AppendValues (GettextCatalog.GetString ("Edit..."));
			};
			
			var fontCol = new TreeViewColumn ();
			fontCol.Title = GettextCatalog.GetString ("Font");
			
			comboRenderer.HasEntry = false;
			comboRenderer.Mode = CellRendererMode.Activatable;
			comboRenderer.TextColumn = 0;
			comboRenderer.Editable = true;
			fontCol.PackStart (comboRenderer, true);
			fontCol.SetCellDataFunc (comboRenderer, delegate (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
				string fontValue = (string)fontStore.GetValue (iter, colValue);
				string fontName = (string)fontStore.GetValue (iter, colName);
				var d = FontService.GetFont (fontName);
				if (d == null || d.FontDescription != fontValue) {
					comboRenderer.Text = fontValue;
				} else {
					comboRenderer.Text = GettextCatalog.GetString ("Default");
				}
			});
			
			treeviewFonts.AppendColumn (fontCol);
			
			comboBoxStore = new ListStore (typeof (string));
			
			comboRenderer.Model = comboBoxStore;
			
			LoadFonts ();
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:74,代码来源:FontChooserPanelWidget.cs

示例2: NoteRenameDialog

		public NoteRenameDialog (IList<Note> notes, string oldTitle, Note renamedNote) :
			base (Catalog.GetString ("Rename Note Links?"), renamedNote.Window, 0)
		{
			this.DefaultResponse = ResponseType.Cancel;
			this.BorderWidth = 10;

			var renameButton = (Button)
				AddButton (Catalog.GetString ("_Rename Links"),
				           ResponseType.Yes);
			var dontRenameButton = (Button)
				AddButton (Catalog.GetString ("_Don't Rename Links"),
				           ResponseType.No);

			this.notes = notes;
			notesModel = new Gtk.TreeStore (typeof (bool), typeof (string), typeof (Note));
			foreach (var note in notes)
				notesModel.AppendValues (true, note.Title, note);

			var labelText = Catalog.GetString ("Rename links in other notes from \"<span underline=\"single\">{0}</span>\" " +
			                                   "to \"<span underline=\"single\">{1}</span>\"?\n\n" +
			                                   "If you do not rename the links, " +
			                                   "they will no longer link to anything.");
			var label = new Label ();
			label.UseMarkup = true;
			label.Markup = String.Format (labelText,
			                              GLib.Markup.EscapeText (oldTitle),
			                              GLib.Markup.EscapeText (renamedNote.Title));
			label.LineWrap = true;
			ContentArea.PackStart (label, false, true, 5);

			var notesView = new TreeView (notesModel);
			notesView.SetSizeRequest (-1, 200);
			var toggleCell = new CellRendererToggle ();
			toggleCell.Activatable = true;
			var column = new TreeViewColumn (Catalog.GetString ("Rename Links"),
			                                 toggleCell, "active", 0);
			column.SortColumnId = 0;
			column.Resizable = true;
			notesView.AppendColumn (column);
			toggleCell.Toggled += (o, args) => {
				TreeIter iter;
				if (!notesModel.GetIterFromString (out iter, args.Path))
					return;
				bool val = (bool) notesModel.GetValue (iter, 0);
				notesModel.SetValue (iter, 0, !val);
			};
			column = new TreeViewColumn (Catalog.GetString ("Note Title"),
			                             new CellRendererText (), "text", 1);
			column.SortColumnId = 1;
			column.Resizable = true;
			notesView.AppendColumn (column);

			notesView.RowActivated += (o, args) => {
				TreeIter iter;
				if (!notesModel.GetIter (out iter, args.Path))
					return;
				Note note = (Note) notesModel.GetValue (iter, 2);
				if (note != null) {
					note.Window.Present ();
					NoteFindBar find = note.Window.Find;
					find.ShowAll ();
					find.Visible = true;
					find.SearchText = "\"" + oldTitle + "\"";
				}
			};

			var notesBox = new VBox (false, 5);
			var selectAllButton = new Button ();
			// Translators: This button causes all notes in the list to be selected
			selectAllButton.Label = Catalog.GetString ("Select All");
			selectAllButton.Clicked += (o, e) => {
				notesModel.Foreach ((model, path, iter) => {
					notesModel.SetValue (iter, 0, true);
					return false;
				});
			};
			var selectNoneButton = new Button ();
			// Translators: This button causes all notes in the list to be unselected
			selectNoneButton.Label = Catalog.GetString ("Select None");
			selectNoneButton.Clicked += (o, e) => {
				notesModel.Foreach ((model, path, iter) => {
					notesModel.SetValue (iter, 0, false);
					return false;
				});
			};
			var notesButtonBox = new HButtonBox ();
			notesButtonBox.Add (selectNoneButton);
			notesButtonBox.Add (selectAllButton);
			notesButtonBox.Spacing = 5;
			notesButtonBox.LayoutStyle = ButtonBoxStyle.End;
			var notesScroll = new ScrolledWindow ();
			notesScroll.Add (notesView);
			notesBox.PackStart (notesScroll, true, true, 0);
			notesBox.PackStart (notesButtonBox, false, true, 0);

			var advancedExpander = new Expander (Catalog.GetString ("Ad_vanced"));
			var expandBox = new VBox ();
			expandBox.PackStart (notesBox, true, true, 0);
			alwaysShowDlgRadio = new RadioButton (Catalog.GetString ("Always show this _window"));
			alwaysShowDlgRadio.Clicked += (o, e) => {
//.........这里部分代码省略.........
开发者ID:MatteoNardi,项目名称:Tomboy,代码行数:101,代码来源:NoteRenameDialog.cs


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