static ButtonHandler() { // store the normal size for a rounded button, so we can determine what style to give it based on actual size var b = new EtoButton(NSButtonType.MomentaryPushIn); originalSize = b.GetAlignmentRectForFrame(new CGRect(CGPoint.Empty, b.FittingSize)).Size.ToEtoSize(); }
static ToggleButtonHandler() { // store the normal size for a rounded button, so we can determine what style to give it based on actual size var b = new EtoButton(NSButtonType.PushOnPushOff); s_defaultMinimumSize = b.GetAlignmentRectForFrame(new CGRect(CGPoint.Empty, b.FittingSize)).Size.ToEtoSize(); }
public ButtonHandler() { Control = new EtoButton { AutoSizeMode = swf.AutoSizeMode.GrowAndShrink, TextImageRelation = swf.TextImageRelation.ImageBeforeText, AutoSize = true }; Control.Click += delegate { Callback.OnClick(Widget, EventArgs.Empty); }; }
public ButtonHandler() { Control = new EtoButton { Handler = this, Cell = new EtoButtonCell(), Title = string.Empty, BezelStyle = NSBezelStyle.Rounded, ImagePosition = NSCellImagePosition.ImageLeft }; Control.SetButtonType(NSButtonType.MomentaryPushIn); Control.Activated += HandleActivated; }
public ButtonHandler() { Control = new EtoButton { Handler = this }; Control.Cell = new MyButtonCell(); Control.Title = string.Empty; Control.SetButtonType(NSButtonType.MomentaryPushIn); Control.BezelStyle = NSBezelStyle.Rounded; Control.SetFrameSize(Generator.ConvertF(Button.DefaultSize)); Control.Activated += delegate { Widget.OnClick(EventArgs.Empty); }; }
public ButtonHandler() { Control = new EtoButton { Handler = this, Cell = new EtoButtonCell(), Title = string.Empty, BezelStyle = NSBezelStyle.Rounded, ImagePosition = NSCellImagePosition.ImageLeft }; defaultSize = Button.DefaultSize; Control.SetButtonType(NSButtonType.MomentaryPushIn); Control.SetFrameSize(defaultSize.ToSDSizeF()); Control.Activated += HandleActivated; SetBezel(); }
public ButtonHandler() { Control = new EtoButton { Handler = this }; Control.Click += (sender, e) => Callback.OnClick(Widget, EventArgs.Empty); label = new WpfLabel { IsHitTestVisible = false, VerticalAlignment = sw.VerticalAlignment.Center, HorizontalAlignment = sw.HorizontalAlignment.Center, Padding = new sw.Thickness(3, 0, 3, 0), Visibility = sw.Visibility.Collapsed }; swc.Grid.SetColumn(label, 1); swc.Grid.SetRow(label, 1); swcimage = new swc.Image(); var grid = new swc.Grid(); grid.ColumnDefinitions.Add(new swc.ColumnDefinition { Width = sw.GridLength.Auto }); grid.ColumnDefinitions.Add(new swc.ColumnDefinition { Width = new sw.GridLength(1, sw.GridUnitType.Star) }); grid.ColumnDefinitions.Add(new swc.ColumnDefinition { Width = sw.GridLength.Auto }); grid.RowDefinitions.Add(new swc.RowDefinition { Height = sw.GridLength.Auto }); grid.RowDefinitions.Add(new swc.RowDefinition { Height = new sw.GridLength(1, sw.GridUnitType.Star) }); grid.RowDefinitions.Add(new swc.RowDefinition { Height = sw.GridLength.Auto }); grid.Children.Add(swcimage); grid.Children.Add(label); Control.Content = grid; }
public void ButtonNaturalSizeShouldBeConsistent() { Exception exception = null; Button button = null; Panel panel = null; Form(form => { button = new Button(); button.Text = "Click Me"; panel = new Panel { Content = button }; form.Content = TableLayout.AutoSized(panel); form.ClientSize = new Size(200, 200); var handler = button?.Handler as ButtonHandler; Assert.IsNotNull(handler, "#1.1"); var b = new EtoButton(NSButtonType.MomentaryPushIn); var originalSize = b.GetAlignmentRectForFrame(new CGRect(CGPoint.Empty, b.FittingSize)).Size; Assert.AreEqual(21, originalSize.Height, "#2.1"); var preferred = handler.GetPreferredSize(SizeF.PositiveInfinity); Assert.AreEqual(originalSize.Height, preferred.Height, "#2.1"); Assert.AreEqual(NSBezelStyle.Rounded, handler.Control.BezelStyle, "#2.2"); form.Shown += async(sender, e) => { try { // need to use invokes to wait for the layout pass to complete panel.Size = new Size(-1, 22); await Task.Delay(1000); await Application.Instance.InvokeAsync(() => { Assert.AreEqual(NSBezelStyle.RegularSquare, handler.Control.BezelStyle, "#3.1"); Assert.AreEqual(22, handler.Widget.Height, "#3.2"); }); panel.Size = new Size(-1, -1); await Application.Instance.InvokeAsync(() => { Assert.AreEqual(NSBezelStyle.Rounded, handler.Control.BezelStyle, "#4.1"); Assert.AreEqual(21, handler.Widget.Height, "#4.2"); }); panel.Size = new Size(-1, 20); await Task.Delay(1000); await Application.Instance.InvokeAsync(() => { Assert.AreEqual(NSBezelStyle.SmallSquare, handler.Control.BezelStyle, "#5.1"); Assert.AreEqual(20, handler.Widget.Height, "#5.2"); }); panel.Size = new Size(-1, -1); await Application.Instance.InvokeAsync(() => { Assert.AreEqual(NSBezelStyle.Rounded, handler.Control.BezelStyle, "#6.1"); Assert.AreEqual(21, handler.Widget.Height, "#6.2"); }); } catch (Exception ex) { exception = ex; } finally { form.Close(); } }; }, -1); if (exception != null) { ExceptionDispatchInfo.Capture(exception).Throw(); } }