本文整理汇总了C#中MonoMac.AppKit.NSButton.SetFrameSize方法的典型用法代码示例。如果您正苦于以下问题:C# NSButton.SetFrameSize方法的具体用法?C# NSButton.SetFrameSize怎么用?C# NSButton.SetFrameSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.AppKit.NSButton
的用法示例。
在下文中一共展示了NSButton.SetFrameSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public bool Run (ExceptionDialogData data)
{
using (var alert = new NSAlert { AlertStyle = NSAlertStyle.Critical }) {
alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
alert.MessageText = data.Title ?? GettextCatalog.GetString ("Error");
if (!string.IsNullOrEmpty (data.Message)) {
alert.InformativeText = data.Message;
}
List<AlertButton> buttons = null;
if (data.Buttons != null && data.Buttons.Length > 0)
buttons = data.Buttons.Reverse ().ToList ();
if (buttons != null) {
foreach (var button in buttons) {
var label = button.Label;
if (button.IsStockButton)
label = Gtk.Stock.Lookup (label).Label;
label = label.Replace ("_", "");
//this message seems to be a standard Mac message since alert handles it specially
if (button == AlertButton.CloseWithoutSave)
label = GettextCatalog.GetString ("Don't Save");
alert.AddButton (label);
}
}
if (data.Exception != null) {
var scrollSize = new SizeF (400, 130);
float spacing = 4;
string title = GettextCatalog.GetString ("View details");
string altTitle = GettextCatalog.GetString ("Hide details");
var buttonFrame = new RectangleF (0, 0, 0, 0);
var button = new NSButton (buttonFrame) {
BezelStyle = NSBezelStyle.Disclosure,
Title = "",
AlternateTitle = "",
};
button.SetButtonType (NSButtonType.OnOff);
button.SizeToFit ();
var label = new MDClickableLabel (title) {
Alignment = NSTextAlignment.Left,
};
label.SizeToFit ();
button.SetFrameSize (new SizeF (button.Frame.Width, Math.Max (button.Frame.Height, label.Frame.Height)));
label.SetFrameOrigin (new PointF (button.Frame.Width + 5, button.Frame.Y));
var text = new MyTextView (new RectangleF (0, 0, float.MaxValue, float.MaxValue)) {
HorizontallyResizable = true,
};
text.TextContainer.ContainerSize = new SizeF (float.MaxValue, float.MaxValue);
text.TextContainer.WidthTracksTextView = true;
text.InsertText (new NSString (data.Exception.ToString ()));
text.Editable = false;
var scrollView = new NSScrollView (new RectangleF (PointF.Empty, SizeF.Empty)) {
HasHorizontalScroller = true,
HasVerticalScroller = true,
};
var accessory = new NSView (new RectangleF (0, 0, scrollSize.Width, button.Frame.Height));
accessory.AddSubview (scrollView);
accessory.AddSubview (button);
accessory.AddSubview (label);
alert.AccessoryView = accessory;
button.Activated += delegate {
float change;
if (button.State == NSCellStateValue.On) {
change = scrollSize.Height + spacing;
label.StringValue = altTitle;
scrollView.Hidden = false;
scrollView.Frame = new RectangleF (PointF.Empty, scrollSize);
scrollView.DocumentView = text;
} else {
change = -(scrollSize.Height + spacing);
label.StringValue = title;
scrollView.Hidden = true;
scrollView.Frame = new RectangleF (PointF.Empty, SizeF.Empty);
}
var f = accessory.Frame;
f.Height += change;
accessory.Frame = f;
var lf = label.Frame;
lf.Y += change;
label.Frame = lf;
var bf = button.Frame;
bf.Y += change;
button.Frame = bf;
label.SizeToFit ();
var panel = (NSPanel) alert.Window;
var pf = panel.Frame;
//.........这里部分代码省略.........