From df24f5df73a2d5fe95ebeee4c1ecd0fc0a581039 Mon Sep 17 00:00:00 2001 From: John Rennemeyer Date: Wed, 12 Apr 2017 08:27:13 -0600 Subject: [PATCH 1/2] Added ButtonIconFontSize and ButtonIconFontSizeAuto to ActionButton --- .../NControl.Controls/ActionButton.cs | 87 +++++++++++++++++-- .../ActionButtonPage.cs | 4 +- 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/NControl.Controls/NControl.Controls/ActionButton.cs b/NControl.Controls/NControl.Controls/ActionButton.cs index a0fe814..6757f8c 100644 --- a/NControl.Controls/NControl.Controls/ActionButton.cs +++ b/NControl.Controls/NControl.Controls/ActionButton.cs @@ -213,9 +213,9 @@ public Color ButtonColor }); /// - /// Gets or sets the color of the buton. + /// Gets or sets the button font family. /// - /// The color of the buton. + /// The button font family. public string ButtonFontFamily { get { return (string)GetValue (ButtonFontFamilyProperty);} @@ -249,9 +249,58 @@ public string ButtonIcon } /// - /// The button icon property. + /// The button icon font size property. + /// + public static BindableProperty ButtonIconFontSizeProperty = + BindableProperty.Create(nameof(ButtonIconFontSize), typeof(double), typeof(ActionButton), (double)14, + BindingMode.TwoWay, null, (bindable, oldValue, newValue) => + { + var ctrl = (ActionButton)bindable; + ctrl.ButtonIconFontSize = (double)newValue; + }); + + /// + /// Gets or sets the size of the button icon font. + /// + /// The size of the button icon font. + public double ButtonIconFontSize + { + get { return (double)GetValue(ButtonIconFontSizeProperty); } + set + { + SetValue(ButtonIconFontSizeProperty, value); + ButtonIconLabel.FontSize = (double)value; + } + } + + /// + /// The button icon font size auto property. + /// + public static BindableProperty ButtonIconFontSizeAutoProperty = + BindableProperty.Create(nameof(ButtonIconFontSizeAuto), typeof(bool), typeof(ActionButton), (bool)false, + BindingMode.TwoWay, null, (bindable, oldValue, newValue) => + { + var ctrl = (ActionButton)bindable; + ctrl.ButtonIconFontSizeAuto = (bool)newValue; + }); + + /// + /// Gets or sets the automatic sizing of the button icon font size. + /// + /// The size of the button icon auto font. + public bool ButtonIconFontSizeAuto + { + get { return (bool)GetValue(ButtonIconFontSizeAutoProperty); } + set + { + SetValue(ButtonIconFontSizeAutoProperty, value); + } + } + + /// + /// The has shadow property. /// - public static BindableProperty HasShadowProperty = + public static BindableProperty HasShadowProperty = BindableProperty.Create(nameof(HasShadow), typeof(bool), typeof(ActionButton), true, BindingMode.TwoWay, null, (bindable, oldValue, newValue) => { var ctrl = (ActionButton)bindable; @@ -391,7 +440,35 @@ public override bool TouchesEnded (System.Collections.Generic.IEnumerable + /// + /// Lays out the children. + /// + /// The children. + /// The x coordinate. + /// The y coordinate. + /// Width. + /// Height. + protected override void LayoutChildren(double x, double y, double width, double height) + { + base.LayoutChildren(x, y, width, height); + + if (ButtonIconFontSizeAuto) + { + //TODO: Improve the calculations for Auto FontSizing ratios + if (width > 0 && width < 32) + ButtonIconFontSize = width / 4; + if (width >= 32 && width < 64) + ButtonIconFontSize = width / 3.5; + if (width > 64 && width < 96) + ButtonIconFontSize = width / 3; + if (width >= 96 && width < 128) + ButtonIconFontSize = width / 2.5; + if (width >= 128) + ButtonIconFontSize = width / 2; + } + } + + /// /// On Measure /// /// diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/ActionButtonPage.cs b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/ActionButtonPage.cs index f99cf03..55db77e 100644 --- a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/ActionButtonPage.cs +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/ActionButtonPage.cs @@ -23,15 +23,17 @@ protected override void OnAppearing () var ab = new ActionButton { ButtonColor = Color.FromHex("#E91E63"), ButtonIcon = FontAwesomeLabel.FAThumbsUp, + ButtonIconFontSize = 18, }; layout.Children.Add(ab, () => new Rectangle((layout.Width/4)-(56/2), (layout.Height/2)-(56/2), 56, 56)); var abtgl = new ToggleActionButton { ButtonColor = Color.FromHex("#FF5722"), ButtonIcon = FontAwesomeLabel.FAPlus, + ButtonIconFontSizeAuto = true, }; abtgl.SetBinding (IsToggledProperty, "IsToggled"); - layout.Children.Add(abtgl, () => new Rectangle((layout.Width/2)-(56/2), (layout.Height/2)-(56/2), 56, 56)); + layout.Children.Add(abtgl, () => new Rectangle((layout.Width / 2) - (56 / 2), (layout.Height / 2) - (56 / 2), 84, 84)); _command = new Command ((obj) => {}, (obj) => abtgl.IsToggled); From b5d85c42ca6f30e7c106c46f2e4982f127a864eb Mon Sep 17 00:00:00 2001 From: John Rennemeyer Date: Wed, 12 Apr 2017 13:41:01 -0600 Subject: [PATCH 2/2] Fix WizardPageXaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WizardPageXaml didn’t have any events and had same text for the two pages that were in it. I modified it to match WizardPage.cs Update paging numbers on WizardPage.cs (started at 2, should start at 1). --- .../WizardPage.cs | 6 +++--- .../WizardPageXaml.xaml | 18 ++++++++---------- .../WizardPageXaml.xaml.cs | 5 +++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs index 0d20eae..e962f96 100644 --- a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs @@ -19,17 +19,17 @@ protected override void OnAppearing () Pages = { new Button { Command = new Command((obj)=>wizard.Page++), - Text = "Page 2", + Text = "Page 1", }, new Button { Command = new Command((obj)=>wizard.Page++), - Text = "Page 3", + Text = "Page 2", }, new Button { Command = new Command((obj)=>wizard.Page++), - Text = "Page 4", + Text = "Page 3", }, new Button { diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml index 119a76c..274c887 100644 --- a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml @@ -1,15 +1,13 @@ - - + + - + - - +