本文整理汇总了C#中Gtk.ComboBox.SizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.SizeRequest方法的具体用法?C# ComboBox.SizeRequest怎么用?C# ComboBox.SizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ComboBox
的用法示例。
在下文中一共展示了ComboBox.SizeRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize (EditSession session)
{
this.session = session;
//if standard values are supported by the converter, then
//we list them in a combo
if (session.Property.Converter.GetStandardValuesSupported (session))
{
store = new ListStore (typeof(string), typeof(object));
//if converter doesn't allow nonstandard values, or can't convert from strings, don't have an entry
if (session.Property.Converter.GetStandardValuesExclusive (session) || !session.Property.Converter.CanConvertFrom (session, typeof(string))) {
combo = new ComboBox (store);
var crt = new CellRendererText ();
combo.PackStart (crt, true);
combo.AddAttribute (crt, "text", 0);
} else {
combo = new ComboBoxEntry (store, 0);
entry = ((ComboBoxEntry)combo).Entry;
entry.HeightRequest = combo.SizeRequest ().Height;
}
PackStart (combo, true, true, 0);
combo.Changed += TextChanged;
//fill the list
foreach (object stdValue in session.Property.Converter.GetStandardValues (session)) {
store.AppendValues (session.Property.Converter.ConvertToString (session, stdValue), ObjectBox.Box (stdValue));
}
//a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
object[] atts = session.Property.Converter.GetType ()
.GetCustomAttributes (typeof (StandardValuesSeparatorAttribute), true);
if (atts.Length > 0) {
string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
combo.RowSeparatorFunc = (model, iter) => separator == ((string)model.GetValue (iter, 0));
}
}
// no standard values, so just use an entry
else {
entry = new Entry ();
PackStart (entry, true, true, 0);
}
//if we have an entry, fix it up a little
if (entry != null) {
entry.HasFrame = false;
entry.Changed += TextChanged;
entry.FocusOutEvent += FirePendingChangeEvent;
}
if (entry != null && ShouldShowDialogButton ()) {
var button = new Button ("...");
PackStart (button, false, false, 0);
button.Clicked += ButtonClicked;
}
Spacing = 3;
ShowAll ();
}
示例2: ShowIncorretEolMarkers
void ShowIncorretEolMarkers (string fileName, bool multiple)
{
RemoveMessageBar ();
messageOverlayWindow = new OverlayMessageWindow ();
var hbox = new HBox ();
hbox.Spacing = 8;
var image = new HoverCloseButton ();
hbox.PackStart (image, false, false, 0);
var label = new Label (string.Format ("This file has line endings ({0}) which differ from the policy settings ({1}).", GetEolString (DetectedEolMarker), GetEolString (textEditor.Options.DefaultEolMarker)));
var color = (Mono.TextEditor.HslColor)textEditor.ColorStyle.NotificationText.Foreground;
label.ModifyFg (StateType.Normal, color);
int w, h;
label.Layout.GetPixelSize (out w, out h);
label.Ellipsize = Pango.EllipsizeMode.End;
hbox.PackStart (label, true, true, 0);
var okButton = new Button (Gtk.Stock.Ok);
okButton.WidthRequest = 60;
hbox.PackEnd (okButton, false, false, 0);
var list = new List<string> ();
list.Add (string.Format ("Convert to {0} line endings", GetEolString (textEditor.Options.DefaultEolMarker)));
if (multiple)
list.Add (string.Format ("Convert all files to {0} line endings", GetEolString (textEditor.Options.DefaultEolMarker)));
list.Add (string.Format ("Keep {0} line endings", GetEolString (DetectedEolMarker)));
if (multiple)
list.Add (string.Format ("Keep {0} line endings in all files", GetEolString (DetectedEolMarker)));
var combo = new ComboBox (list.ToArray ());
combo.Active = 0;
hbox.PackEnd (combo, false, false, 0);
var container = new HBox ();
const int containerPadding = 8;
container.PackStart (hbox, true, true, containerPadding);
messageOverlayWindow.Child = container;
messageOverlayWindow.ShowOverlay (this.TextEditor);
messageOverlayWindow.SizeFunc = () => {
return okButton.SizeRequest ().Width +
combo.SizeRequest ().Width +
image.SizeRequest ().Width +
w +
hbox.Spacing * 4 +
containerPadding * 2;
};
image.Clicked += delegate {
UseIncorrectMarkers = true;
view.WorkbenchWindow.ShowNotification = false;
RemoveMessageBar ();
};
okButton.Clicked += delegate {
if (multiple) {
switch (combo.Active) {
case 0:
ConvertLineEndings ();
view.WorkbenchWindow.ShowNotification = false;
view.Save (fileName, view.SourceEncoding);
break;
case 1:
FileRegistry.ConvertLineEndingsInAllFiles ();
break;
case 2:
UseIncorrectMarkers = true;
view.WorkbenchWindow.ShowNotification = false;
break;
case 3:
FileRegistry.IgnoreLineEndingsInAllFiles ();
break;
}
} else {
switch (combo.Active) {
case 0:
ConvertLineEndings ();
view.WorkbenchWindow.ShowNotification = false;
view.Save (fileName, view.SourceEncoding);
break;
case 1:
UseIncorrectMarkers = true;
view.WorkbenchWindow.ShowNotification = false;
break;
}
}
RemoveMessageBar ();
};
}
示例3: ShowIncorrectEolMarkers
void ShowIncorrectEolMarkers (string fileName, bool multiple)
{
RemoveMessageBar ();
var hbox = new HBox ();
hbox.Spacing = 8;
var image = new HoverCloseButton ();
hbox.PackStart (image, false, false, 0);
var label = new Label (string.Format ("This file has line endings ({0}) which differ from the policy settings ({1}).", GetEolString (DetectedEolMarker), GetEolString (textEditor.Options.DefaultEolMarker)));
var color = (HslColor)textEditor.ColorStyle.NotificationText.Foreground;
label.ModifyFg (StateType.Normal, color);
int w, h;
label.Layout.GetPixelSize (out w, out h);
label.Ellipsize = Pango.EllipsizeMode.End;
hbox.PackStart (label, true, true, 0);
var okButton = new Button (Gtk.Stock.Ok);
okButton.WidthRequest = 60;
// Small amount of vertical padding for the OK button.
const int verticalPadding = 2;
var vbox = new VBox ();
vbox.PackEnd (okButton, true, true, verticalPadding);
hbox.PackEnd (vbox, false, false, 0);
var list = new List<string> ();
list.Add (string.Format ("Convert to {0} line endings", GetEolString (textEditor.Options.DefaultEolMarker)));
list.Add (string.Format ("Convert all files to {0} line endings", GetEolString (textEditor.Options.DefaultEolMarker)));
list.Add (string.Format ("Keep {0} line endings", GetEolString (DetectedEolMarker)));
list.Add (string.Format ("Keep {0} line endings in all files", GetEolString (DetectedEolMarker)));
var combo = new ComboBox (list.ToArray ());
combo.Active = 0;
hbox.PackEnd (combo, false, false, 0);
incorrectEolMessage = new HBox ();
const int containerPadding = 8;
incorrectEolMessage.PackStart (hbox, true, true, containerPadding);
// This is hacky, but it will ensure that our combo appears with with the correct size.
GLib.Timeout.Add (100, delegate {
combo.QueueResize ();
return false;
});
AddOverlay (incorrectEolMessage, () => {
return okButton.SizeRequest ().Width +
combo.SizeRequest ().Width +
image.SizeRequest ().Width +
w +
hbox.Spacing * 4 +
containerPadding * 2;
});
image.Clicked += delegate {
UseIncorrectMarkers = true;
view.WorkbenchWindow.ShowNotification = false;
RemoveMessageBar ();
};
okButton.Clicked += delegate {
switch (combo.Active) {
case 0:
ConvertLineEndings ();
view.WorkbenchWindow.ShowNotification = false;
view.Save (fileName, view.SourceEncoding);
break;
case 1:
FileRegistry.ConvertLineEndingsInAllFiles ();
break;
case 2:
UseIncorrectMarkers = true;
view.WorkbenchWindow.ShowNotification = false;
break;
case 3:
FileRegistry.IgnoreLineEndingsInAllFiles ();
break;
}
RemoveMessageBar ();
};
}