本文整理汇总了C#中Gtk.TreeView.SetSizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.SetSizeRequest方法的具体用法?C# TreeView.SetSizeRequest怎么用?C# TreeView.SetSizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.TreeView
的用法示例。
在下文中一共展示了TreeView.SetSizeRequest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeComponent
private void InitializeComponent()
{
this.Title = "Search Errors";
this.Modal = false;
this.WindowPosition = Gtk.WindowPosition.CenterOnParent;
this.Resizable = true;
this.SetDefaultSize(480, 320);
this.IconName = Stock.DialogError;
this.AddButton(Stock.Close, Gtk.ResponseType.Close);
Gtk.Frame treeFrame = new Gtk.Frame();
treeFrame.Shadow = ShadowType.In;
Gtk.ScrolledWindow treeWin = new Gtk.ScrolledWindow();
tvErrors = new Gtk.TreeView ();
tvErrors.SetSizeRequest(480,200);
tvErrors.Selection.Mode = SelectionMode.Single;
tvErrors.AppendColumn(CreateTreeViewColumn("Name", 60, 0));
tvErrors.AppendColumn(CreateTreeViewColumn("Located In", 200, 1));
lsErrors = new Gtk.ListStore(typeof (string), typeof (string), typeof(string));
tvErrors.Model = lsErrors;
tvErrors.Selection.Changed += new EventHandler(tvErrors_Selection_Changed);
treeWin.Add(tvErrors);
treeFrame.BorderWidth = 0;
treeFrame.Add(treeWin);
for (int i=0; i< alErrors.Count; i++)
{
MessageEventArgs args = (MessageEventArgs)alErrors[i];
if (args.ErrorFile == null)
lsErrors.AppendValues("General Error", string.Empty, args.Message);
else
lsErrors.AppendValues(args.ErrorFile.Name, args.ErrorFile.DirectoryName, args.Message);
}
Gtk.Frame txtFrame = new Gtk.Frame();
txtFrame.Shadow = ShadowType.In;
Gtk.ScrolledWindow txtScrollWin = new Gtk.ScrolledWindow();
txtErrorDetails = new TextView();
txtErrorDetails.WrapMode = Gtk.WrapMode.WordChar;
txtErrorDetails.Editable = false;
txtScrollWin.Add(txtErrorDetails);
txtFrame.BorderWidth = 0;
txtFrame.Add(txtScrollWin);
this.VBox.PackStart(treeFrame, true, true, 3);
this.VBox.PackEnd(txtFrame, true, true, 3);
this.VBox.ShowAll();
}
示例2: CreateTree
private TreeView CreateTree ()
{
TreeView view = new TreeView ();
view.Model = FillTree ();
CellRendererText cr = new CellRendererText ();
TreeViewColumn column = new TreeViewColumn ("Widget (double click for demo)", cr, "text", 0);
column.AddAttribute (cr, "style" , 2);
view.AppendColumn (column);
view.Selection.Changed += new EventHandler (TreeChanged);
view.RowActivated += new RowActivatedHandler (RowActivated);
view.ExpandAll ();
view.SetSizeRequest (200, -1);
view.Selection.Mode = Gtk.SelectionMode.Browse;
return view;
}
示例3: CreateTree
void CreateTree()
{
_treeView = new Gtk.TreeView ();
_treeView.SetSizeRequest (500, 600);
//name
var nameColumn = new Gtk.TreeViewColumn ();
nameColumn.Title = "Name";
nameColumn.MaxWidth = 500;
var nameCell = new Gtk.CellRendererText ();
nameColumn.PackStart (nameCell, true);
_treeView.AppendColumn (nameColumn);
nameColumn.AddAttribute (nameCell, "text", 0);
_treeView.Selection.Mode = Gtk.SelectionMode.Single;
_treeView.Selection.Changed += _treeView_Selection_Changed;
_treeView.KeyPressEvent += HandleKeyPressEvent;
_treeView.KeyReleaseEvent += HandleKeyReleaseEvent;
_treeView.ButtonReleaseEvent += (o, args) => {
if (_selectedDocument != null) {
CloseWindow (true);
}
};
}
示例4: CreateTree
void CreateTree()
{
_treeView = new Gtk.TreeView ();
_treeView.SetSizeRequest (500, 600);
//type
var typeColumn = new Gtk.TreeViewColumn ();
typeColumn.Title = "Type";
typeColumn.MaxWidth = 50;
// Do the same for the song title column
var typeCell = new CellRendererImage ();
typeColumn.PackStart (typeCell, true);
typeColumn.SetCellDataFunc (typeCell, ResultTypeIconFunc);
//name
var nameColumn = new Gtk.TreeViewColumn ();
nameColumn.Title = "Name";
nameColumn.MaxWidth = 300;
var nameCell = new Gtk.CellRendererText ();
nameColumn.PackStart (nameCell, true);
// Add the columns to the TreeView
_treeView.AppendColumn (typeColumn);
_treeView.AppendColumn (nameColumn);
typeColumn.AddAttribute (typeCell, "text", 0);
nameColumn.AddAttribute (nameCell, "text", 1);
_treeView.Selection.Mode = Gtk.SelectionMode.Single;
_treeView.Selection.Changed += _treeView_Selection_Changed;
_treeView.KeyPressEvent += HandleKeyPressEvent;
_treeView.KeyReleaseEvent += HandleKeyReleaseEvent;
_treeView.ButtonReleaseEvent += (o, args) => {
if (_selectedEntry != null) {
CloseWindow (true);
}
};
}
示例5: BuildInterface
private void BuildInterface()
{
VBox usersPane = new VBox ();
VBox photosPane = new VBox ();
HBox panes = new HBox ();
#region Users pane
usersLabel = new Label ("Users");
usersView = new TreeView ();
usersView.SetSizeRequest (320, 240);
TreeViewColumn userIdColumn = new TreeViewColumn ();
TreeViewColumn userUidColumn = new TreeViewColumn ();
TreeViewColumn userNameColumn = new TreeViewColumn ();
userIdColumn.Title = "ID";
userUidColumn.Title = "UID";
userNameColumn.Title = "Name";
CellRendererText idRenderer = new CellRendererText ();
CellRendererText uidRenderer = new CellRendererText ();
CellRendererText nameRenderer = new CellRendererText ();
userIdColumn.PackStart (idRenderer, true);
userUidColumn.PackStart (uidRenderer, true);
userNameColumn.PackStart (nameRenderer, true);
userIdColumn.SetCellDataFunc (idRenderer, new TreeCellDataFunc (RenderUserId));
userUidColumn.SetCellDataFunc (uidRenderer, new TreeCellDataFunc (RenderUserUid));
userNameColumn.SetCellDataFunc (nameRenderer, new TreeCellDataFunc (RenderUserName));
usersView.AppendColumn (userIdColumn);
usersView.AppendColumn (userUidColumn);
usersView.AppendColumn (userNameColumn);
usersPane.PackStart (usersLabel, false, false, 8);
usersPane.PackStart (usersView);
#endregion
#region Photos pane
photosLabel = new Label ("Photos");
addPhotoButton = new Button ("Add photo");
deletePhotoButton = new Button ("Delete photo");
addPhotoButton.Sensitive = false;
deletePhotoButton.Sensitive = false;
photoManagementButtons = new HButtonBox ();
photoManagementButtons.LayoutStyle = ButtonBoxStyle.Start;
photoManagementButtons.PackStart (addPhotoButton);
photoManagementButtons.PackStart (deletePhotoButton);
photosView = new TreeView ();
photosView.SetSizeRequest (320, 240);
TreeViewColumn photoIdColumn = new TreeViewColumn ();
photoIdColumn.Title = "ID";
TreeViewColumn photoImageColumn = new TreeViewColumn();
photoImageColumn.Title = "Image";
CellRendererText photoIdRenderer = new CellRendererText();
CellRendererPixbuf imageRenderer = new CellRendererPixbuf();
photoIdColumn.PackStart(photoIdRenderer, true);
photoImageColumn.PackStart(imageRenderer, true);
photoIdColumn.SetCellDataFunc(photoIdRenderer, new TreeCellDataFunc(RenderPhotoId));
photoImageColumn.SetCellDataFunc(imageRenderer, new TreeCellDataFunc(RenderPhotoImage));
photosView.AppendColumn (photoIdColumn);
photosView.AppendColumn (photoImageColumn);
ListStore photosStore = new ListStore (typeof(Photo));
photosView.Model = photosStore;
photosPane.PackStart (photosLabel, false, false, 8);
photosPane.PackStart (photosView);
photosPane.PackStart (photoManagementButtons);
#endregion
panes.PackStart (usersPane);
panes.PackStart (photosPane);
#region Control buttons
controlButtons = new HButtonBox ();
saveButton = new Button ("Save");
cancelButton = new Button ("Cancel");
controlButtons.PackStart (saveButton, false, false, 8);
controlButtons.PackStart (cancelButton, false, false, 8);
controlButtons.LayoutStyle = ButtonBoxStyle.End;
#endregion
VBox rows = new VBox ();
rows.PackStart (panes);
rows.PackStart (controlButtons);
this.Add (rows);
this.ShowAll ();
#region Event Handlers Setup
this.DeleteEvent += new DeleteEventHandler (OnDelete);
usersView.CursorChanged += new EventHandler (UsersViewCursorChanged);
//.........这里部分代码省略.........
示例6: 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) => {
//.........这里部分代码省略.........