public SVG_ButtonBackgroundImage() { Padding = 40; var stateButton = new Forms9Patch.StateButton { ToggleBehavior = true }; stateButton.DefaultState.BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.redWhiteGradient.svg"); stateButton.DefaultState.Text = "Forms9Patch.StateButton.DefaultState"; // only the default state is created by default. So have to create a pressing state stateButton.SelectedState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.blueWhiteGradient.svg"), Text = "Forms9Patch.StateButton.SelectedState" }; var button = new Forms9Patch.Button { Text = "Forms9Patch.Button", BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.greenWhiteGradient.svg") }; Content = new StackLayout { Children = { new Label { Text = "SVG Button.BackgroundImage demo" }, stateButton, button, } }; }
public SVG_ButtonBackgroundImage() { Padding = 40; var stateButton = new Forms9Patch.StateButton { ToggleBehavior = true }; stateButton.DefaultState.BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.redWhiteGradient.svg"); stateButton.DefaultState.Text = "Forms9Patch.StateButton.DefaultState"; // only the default state is created by default. So have to create a pressing state stateButton.SelectedState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.blueWhiteGradient.svg"), Text = "Forms9Patch.StateButton.SelectedState" }; var button = new Forms9Patch.Button { Text = "Forms9Patch.Button", BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.greenWhiteGradient.svg") }; var svgString = $@" <svg xmlns=""http://www.w3.org/2000/svg"" viewBox=""0 0 96 105""> <g fill=""#97C024"" stroke=""#97C024"" stroke-linejoin=""round"" stroke-linecap=""round""> <path d=""M14,40v24M81,40v24M38,68v24M57,68v24M28,42v31h39v-31z"" stroke-width=""12""/> <path d=""M32,5l5,10M64,5l-6,10"" stroke-width=""2""/> </g> <path d=""M22,35h51v10h-51zM22,33c0-31,51-31,51,0"" fill=""#97C024""/> <g fill=""#FFF""> <circle cx=""36"" cy=""22"" r=""2""/> <circle cx=""59"" cy=""22"" r=""2""/> </g> </svg> "; var image = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromSvgText(svgString), HeightRequest = 200, WidthRequest = 200, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; Content = new StackLayout { Children = { image, } }; }
public ZenmekPage() { ibStartStop = new Forms9Patch.StateButton { DefaultState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromResource(BaseResource + ".Resources.button_01_default.png"), }, TextColor = Color.Black, Text = "Start", }, PressingState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromResource(BaseResource + ".Resources.button_01_pressing.png"), }, }, ToggleBehavior = true, HeightRequest = 50, HorizontalTextAlignment = TextAlignment.Center, }; StackLayout slMain = new StackLayout() { Orientation = StackOrientation.Vertical, Children = { ibStartStop } }; //ContentView fnpcvMain = new ContentView Forms9Patch.Frame fnpcvMain = new Forms9Patch.Frame { Content = slMain, }; //Issue happens with this: Content = fnpcvMain; //It works fine with this: //Content = slMain; }
public StateButton() { var button = new Forms9Patch.StateButton { Text = "Click me", ToggleBehavior = true, BackgroundColor = Color.NavajoWhite, OutlineRadius = 5, BackgroundImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.button"), }; var hasShadowSwitch = new Switch(); hasShadowSwitch.Toggled += (sender, e) => button.HasShadow = e.Value; var hasOutlineSwitch = new Switch(); hasOutlineSwitch.Toggled += (sender, e) => button.OutlineWidth = e.Value ? 1 : 0; Padding = 20; Content = new StackLayout { Children = { new Label { Text = "HasShadow" }, hasShadowSwitch, new Label { Text = "HasOutline" }, hasOutlineSwitch, button, } }; }
public ImageButtonCodePage() { #region ImageButtons var b2 = new Forms9Patch.StateButton { DefaultState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.button"), }, IconImage = new Forms9Patch.Image { Source = ImageSource.FromFile("five.png"), }, TextColor = Color.White, Text = "Sticky w/ SelectedState", }, SelectedState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.image"), }, TextColor = Color.Red, Text = "Selected", }, ToggleBehavior = true, HeightRequest = 50, HorizontalTextAlignment = TextAlignment.Start, }; b2.Tapped += OnImageButtonTapped; b2.Selected += OnImageButtonSelected; b2.LongPressing += OnImageButtonLongPressing; b2.LongPressed += OnImageButtonLongPressed; var b3 = new Forms9Patch.StateButton { DefaultState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.button"), }, IconImage = new Forms9Patch.Image { Source = ImageSource.FromFile("five.png"), }, TextColor = Color.FromRgb(0.0, 0.0, 0.8), Text = "Sticky w/o SelectedState", }, PressingState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.redButton"), }, }, ToggleBehavior = true, HeightRequest = 50, HorizontalTextAlignment = TextAlignment.Center, }; b3.Tapped += OnImageButtonTapped; b3.Selected += OnImageButtonSelected; b3.LongPressing += OnImageButtonLongPressing; b3.LongPressed += OnImageButtonLongPressed; var b4 = new Forms9Patch.StateButton { DefaultState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.button"), }, IconImage = new Forms9Patch.Image { Source = ImageSource.FromFile("five.png"), }, TextColor = Color.White, Text = "Not toggle", }, //ToggleBehavior = true, HeightRequest = 50, HorizontalTextAlignment = TextAlignment.End, }; b4.Tapped += OnImageButtonTapped; b4.Selected += OnImageButtonSelected; b4.LongPressing += OnImageButtonLongPressing; b4.LongPressed += OnImageButtonLongPressed; #endregion Content = new StackLayout { Children = { new Label { Text = "Buttons Page" }, b2, b3, b4, } }; }
public HtmlButtonsPage() { Padding = 20; BackgroundColor = Color.White; #region Material Button mb1.Tapped += (sender, e) => System.Diagnostics.Debug.WriteLine("Tapped"); mb1.Selected += (sender, e) => System.Diagnostics.Debug.WriteLine("Selected"); mb1.LongPressing += (sender, e) => System.Diagnostics.Debug.WriteLine("Long Pressing"); mb1.LongPressed += (sender, e) => System.Diagnostics.Debug.WriteLine("Long Pressed"); #endregion #region Segmented Button var sc1 = new Forms9Patch.SegmentedControl { HasShadow = true, BackgroundColor = Color.FromRgb(200, 200, 200), FontSize = 15, Padding = 5, //TextColor = Color.Blue, Segments = { new Forms9Patch.Segment { Text = "Cart", IconText = "<font size=\"4\" face=\"Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf\"></font>", }, new Forms9Patch.Segment { Text = "Pay", IconText = "<font size=\"4\" face=\"Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf\"></font>", }, new Forms9Patch.Segment { Text = "Ship", IconText = "<font size=\"4\" face=\"Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf\"></font>", }, new Forms9Patch.Segment { Text = "Email", IconText = "<font size=\"4\" face=\"Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf\"></font>", }, }, HasTightSpacing = true, IntraSegmentSpacing = 10 }; sc1.SegmentSelected += OnSegmentSelected; sc1.SegmentTapped += OnSegmentTapped; sc1.SegmentLongPressing += OnSegmentLongPressing; sc1.SegmentLongPressed += OnSegmentLongPressed; #endregion #region Image Button var ib1 = new Forms9Patch.StateButton { DefaultState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.button"), }, IconImage = new Forms9Patch.Image { Source = ImageSource.FromFile("five.png"), }, TextColor = Color.White, //Text = "Toggle w/ SelectedState", HtmlText = "<b>Toggle</b> with <i>SelectedState</i>", }, SelectedState = new Forms9Patch.ButtonState { BackgroundImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.image"), }, TextColor = Color.Red, //Text = "Selected", HtmlText = "<b><i>Selected</i></b>", }, ToggleBehavior = true, HeightRequest = 50, HorizontalTextAlignment = TextAlignment.Start, }; ib1.Tapped += OnImageButtonTapped; ib1.Selected += OnImageButtonSelected; ib1.LongPressing += OnImageButtonLongPressing; ib1.LongPressed += OnImageButtonLongPressed; #endregion Content = new StackLayout { Children = { new Forms9Patch.Label { HtmlText = "<b>HTML Buttons</b>" }, mb1, sc1, ib1, } }; }