本文整理汇总了C#中Gtk.Label.SizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Label.SizeRequest方法的具体用法?C# Label.SizeRequest怎么用?C# Label.SizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Label
的用法示例。
在下文中一共展示了Label.SizeRequest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVisualizerWidget
public override Control GetVisualizerWidget (ObjectValue val)
{
string value = val.Value;
Gdk.Color col = new Gdk.Color (85, 85, 85);
if (!val.IsNull && (val.TypeName == "string" || val.TypeName == "char[]"))
value = '"' + GetString (val) + '"';
if (DebuggingService.HasInlineVisualizer (val))
value = DebuggingService.GetInlineVisualizer (val).InlineVisualize (val);
var label = new Gtk.Label ();
label.Text = value;
var font = label.Style.FontDescription.Copy ();
if (font.SizeIsAbsolute) {
font.AbsoluteSize = font.Size - 1;
} else {
font.Size -= (int)(Pango.Scale.PangoScale);
}
label.ModifyFont (font);
label.ModifyFg (StateType.Normal, col);
label.SetPadding (4, 4);
if (label.SizeRequest ().Width > 500) {
label.WidthRequest = 500;
label.Wrap = true;
label.LineWrapMode = Pango.WrapMode.WordChar;
} else {
label.Justify = Gtk.Justification.Center;
}
if (label.Layout.GetLine (1) != null) {
label.Justify = Gtk.Justification.Left;
var line15 = label.Layout.GetLine (15);
if (line15 != null) {
label.Text = value.Substring (0, line15.StartIndex).TrimEnd ('\r', '\n') + "\n…";
}
}
label.Show ();
return label;
}
示例2: GetVisualizerWidget
public override Control GetVisualizerWidget (ObjectValue val)
{
var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
ops.AllowTargetInvoke = true;
ops.ChunkRawStrings = true;
ops.EllipsizedLength = 5000;//Preview window can hold aprox. 4700 chars
val.Refresh (ops);//Refresh DebuggerDisplay/String value with full length instead of ellipsized
string value = val.Value;
Gdk.Color col = Styles.PreviewVisualizerTextColor.ToGdkColor ();
if (DebuggingService.HasInlineVisualizer (val))
value = DebuggingService.GetInlineVisualizer (val).InlineVisualize (val);
var label = new Gtk.Label ();
label.Text = value;
label.ModifyFont (FontService.SansFont.CopyModified (Ide.Gui.Styles.FontScale11));
label.ModifyFg (StateType.Normal, col);
label.SetPadding (4, 4);
if (label.SizeRequest ().Width > 500) {
label.WidthRequest = 500;
label.Wrap = true;
label.LineWrapMode = Pango.WrapMode.WordChar;
} else {
label.Justify = Gtk.Justification.Center;
}
if (label.Layout.GetLine (1) != null) {
label.Justify = Gtk.Justification.Left;
var trimmedLine = label.Layout.GetLine (50);
if (trimmedLine != null) {
label.Text = value.Substring (0, trimmedLine.StartIndex).TrimEnd ('\r', '\n') + "\n…";
}
}
label.Show ();
return label;
}
示例3: LevelRangeWidget
public LevelRangeWidget(string label, int low, int high)
{
IConfigSource config = new DotNetConfigSource(DotNetConfigSource.GetFullConfigPath());
int entrySize = config.Configs["defaults"].GetInt("entrySize");
int entryWidth = config.Configs["defaults"].GetInt("entryWidth");
Low = new Entry(entrySize);
Low.SetSizeRequest(entryWidth, Low.SizeRequest().Height);
Low.WidthChars = entrySize;
Low.IsEditable = false;
Low.CanFocus = false;
Label = new Label(label);
Label.Justify = Justification.Center;
Label.SetSizeRequest(150, Label.SizeRequest().Height);
High = new Entry(entrySize);
High.SetSizeRequest(entryWidth, High.SizeRequest().Height);
High.WidthChars = entrySize;
High.IsEditable = false;
High.CanFocus = false;
}
示例4: GetVisualizerWidget
public override Control GetVisualizerWidget (ObjectValue val)
{
string value = val.Value;
Gdk.Color col = Styles.PreviewVisualizerTextColor.ToGdkColor ();
if (!val.IsNull && (val.TypeName == "string" || val.TypeName == "char[]"))
value = '"' + GetString (val) + '"';
if (DebuggingService.HasInlineVisualizer (val))
value = DebuggingService.GetInlineVisualizer (val).InlineVisualize (val);
var label = new Gtk.Label ();
label.Text = value;
label.ModifyFont (FontService.SansFont.CopyModified (Ide.Gui.Styles.FontScale11));
label.ModifyFg (StateType.Normal, col);
label.SetPadding (4, 4);
if (label.SizeRequest ().Width > 500) {
label.WidthRequest = 500;
label.Wrap = true;
label.LineWrapMode = Pango.WrapMode.WordChar;
} else {
label.Justify = Gtk.Justification.Center;
}
if (label.Layout.GetLine (1) != null) {
label.Justify = Gtk.Justification.Left;
var line15 = label.Layout.GetLine (15);
if (line15 != null) {
label.Text = value.Substring (0, line15.StartIndex).TrimEnd ('\r', '\n') + "\n…";
}
}
label.Show ();
return label;
}
示例5: GridRow
public GridRow(PropertyGrid parentGrid, PropertyDescriptor descriptor)
{
this.parent = parentGrid;
this.propertyDescriptor = descriptor;
// TODO: Need a better way to check if the property has no get accessor.
// Write-only? Don't add this to the list.
try {object propertyValue = descriptor.GetValue (parent.CurrentObject);}
catch (Exception) {
isValidProperty = false;
return;
}
#region Name label
string name = descriptor.DisplayName;
ParenthesizePropertyNameAttribute paren = descriptor.Attributes[typeof (ParenthesizePropertyNameAttribute)] as ParenthesizePropertyNameAttribute;
if (paren != null && paren.NeedParenthesis)
name = "(" + name + ")";
propertyNameLabel = new Label (name);
propertyNameLabel.Xalign = 0;
propertyNameLabel.Xpad = 3;
propertyNameLabel.HeightRequest = 20;
propertyNameEventBox = new EventBox ();
propertyNameEventBox.ModifyBg (StateType.Normal, parent.Style.White);
propertyNameEventBox.Add (propertyNameLabel);
propertyNameEventBox.ButtonReleaseEvent += on_label_ButtonRelease;
if (propertyNameLabel.SizeRequest ().Width > 100) {
propertyNameLabel.WidthRequest = 100;
//TODO: Display tooltip of full name when truncated
//parent.tooltips.SetTip (propertyNameLabel, descriptor.DisplayName, descriptor.DisplayName);
}
#endregion
editor = parent.EditorManager.GetEditor(propertyDescriptor, this);
propertyValueHBox = new HBox();
//check if it needs a button. Note arrays are read-only but have buttons
if (editor.DialogueEdit && (!propertyDescriptor.IsReadOnly || editor.EditsReadOnlyObject)) {
Label buttonLabel = new Label ();
buttonLabel.UseMarkup = true;
buttonLabel.Xpad = 0; buttonLabel.Ypad = 0;
buttonLabel.Markup = "<span size=\"small\">...</span>";
Button dialogueButton = new Button (buttonLabel);
dialogueButton.Clicked += new EventHandler (dialogueButton_Clicked);
propertyValueHBox.PackEnd (dialogueButton, false, false, 0);
}
propertyValueEventBox = new EventBox ();
propertyValueEventBox.ModifyBg (StateType.Normal, parent.Style.White);
propertyValueEventBox.CanFocus = true;
propertyValueEventBox.ButtonReleaseEvent += on_value_ButtonRelease;
propertyValueEventBox.Focused += on_value_ButtonRelease;
propertyValueHBox.PackStart (propertyValueEventBox, true, true, 0);
valueBeforeEdit = propertyDescriptor.GetValue (parentGrid.CurrentObject);
DisplayRenderWidget ();
}
示例6: CreateWidgets
private Widget CreateWidgets()
{
table = new Table(1, 2, false);
table.ColumnSpacing = 12;
table.BorderWidth = 4;
image = new Image(normalPixbuf);
table.Attach(image,
0, 1,
0, 1,
AttachOptions.Shrink,
0, 0, 0);
VBox vbox = new VBox(false, 0);
table.Attach(vbox,
1, 2,
0, 1,
AttachOptions.Expand | AttachOptions.Fill,
0, 0, 0);
widthForLabels = (int)maxWidth - (int)normalPixbuf.Width
- (int)table.ColumnSpacing - (int)(table.BorderWidth * 2);
nameLabel = new Label("<span size=\"large\"></span>");
vbox.PackStart(nameLabel, false, false, 0);
nameLabel.UseMarkup = true;
nameLabel.UseUnderline = false;
nameLabel.Xalign = 0;
Requisition req = nameLabel.SizeRequest();
nameLabel.SetSizeRequest(widthForLabels, -1);
Util.GtkLabelSetMaxWidthChars(nameLabel, widthForLabels);
Util.GtkLabelSetEllipsize(nameLabel, true);
locationLabel = new Label("<span size=\"small\"></span>");
vbox.PackStart(locationLabel, false, false, 0);
locationLabel.UseMarkup = true;
locationLabel.UseUnderline = false;
locationLabel.ModifyFg(StateType.Normal, this.Style.Base(StateType.Active));
locationLabel.Xalign = 0;
req = locationLabel.SizeRequest();
locationLabel.SetSizeRequest(widthForLabels, req.Height);
Util.GtkLabelSetMaxWidthChars(locationLabel, widthForLabels);
Util.GtkLabelSetEllipsize(locationLabel, true);
statusLabel = new Label("<span size=\"small\"></span>");
vbox.PackStart(statusLabel, false, false, 0);
statusLabel.UseMarkup = true;
statusLabel.UseUnderline = false;
statusLabel.ModifyFg(StateType.Normal, this.Style.Base(StateType.Active));
statusLabel.Xalign = 0;
req = statusLabel.SizeRequest();
statusLabel.SetSizeRequest(widthForLabels, req.Height);
Util.GtkLabelSetMaxWidthChars(statusLabel, widthForLabels);
Util.GtkLabelSetEllipsize(statusLabel, true);
return table;
}