Example #1
1
    public App()
    {
      var vibrateButton = new Button
      {
        Text = "Vibrate"
      };

      var sliderVibrate = new Slider(0, 10000.0, 500.0);

      vibrateButton.Clicked += (sender, args) =>
      {
        Refractored.Xam.Vibrate.CrossVibrate.Current.Vibration((int)sliderVibrate.Value);
      };

      // The root page of your application
      MainPage = new NavigationPage(new ContentPage
      {
        Content = new StackLayout
        {
          VerticalOptions = LayoutOptions.Center,
          Padding = 50,
          Children = {
						sliderVibrate,
            vibrateButton
					}
        }
      });
    }
Example #2
0
        public App()
        {
            var tstButton = new Button
            {
            };
            var slider = new Slider
            {
                Minimum = 0,
                Maximum = 1,
                Value = 1,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            tstButton.SetBinding(VisualElement.OpacityProperty, new Binding("Value", source: slider));
            tstButton.SetBinding(Button.TextProperty, new Binding("Value", source: slider, stringFormat: "Opacity: {0:0.00}"));

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    Padding = new Thickness(10, 10),
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Children = {
                        tstButton,
                        slider
                    }
                }
            };
        }
        public StoreMapPage()
        {
            var map = new Map (
                         MapSpan.FromCenterAndRadius (
                             new Position (30.0219504, -89.8830829), Distance.FromMiles (0.3))) {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // pin first address
            var positionA = new Position (30.517174,-90.463322);

            var pinA = new Pin {
                Type = PinType.Place,
                Position = positionA,
                Label = "Store A (HQ)",
                Address = "100 Janes Lane, \n Hammond, LA, \n 70401"
            };
            map.Pins.Add (pinA);

            // pin second address
            var positionB = new Position (37.42565,-122.13535);

            var pinB = new Pin {
                Type = PinType.Place,
                Position = positionB,
                Label = "Store B",
                Address = "Silicon Valley, Palo Alto, CA, \n 94025"
            };
            map.Pins.Add (pinB);

            // pin third address
            var positionC = new Position (42.360091,-71.09416);

            var pinC = new Pin {
                Type = PinType.Place,
                Position = positionC,
                Label = "Store C",
                Address = "Boston, MA, \n 02481"
            };
            map.Pins.Add (pinC);

            // add the slider
            var slider = new Slider (1, 18, 1);
            slider.ValueChanged += (sender, e) => {
                var zoomLevel = e.NewValue; // between 1 and 18
                var latlongdegrees = 360 / (Math.Pow (2, zoomLevel));
                //Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
                if (map.VisibleRegion != null)
                    map.MoveToRegion (new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
            };

            var stackLayout = new StackLayout { Spacing = 0 };
            stackLayout.Children.Add (map);
            stackLayout.Children.Add (slider);

            Content = stackLayout;
        }
        public App()
        {
            var entry = new CustomEntry {
                Text = "Welcome to Xamarin Forms!",
                BorderWidth = 5,
            };

            var slider = new Slider
            {
                Minimum = 0f,
                Maximum = 20f
            };

            entry.BindingContext = slider;
            entry.SetBinding(CustomEntry.BorderWidthProperty, new Binding("Value", BindingMode.OneWay));

            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        entry,
                        slider
                    }
                }
            };
        }
        //Defining WorkEndHour Slider settings
        private void AddWorkEndHourSlider()
        {
            work_end_hour          = new Label();
            work_end_hour.Text     = "Work End Hour :";
            work_end_hour.FontSize = 15;
            if (Device.OS == TargetPlatform.iOS)
            {
                work_end_hour.TextColor = Color.Black;
            }
            else if (Device.OS == TargetPlatform.Android)
            {
                work_end_hour.TextColor = Color.Black;
            }
            //else if (Device.Idiom == TargetIdiom.Phone && Device.OS == TargetPlatform.Windows)
            //    work_end_hour.TextColor = Color.White;
            else
            {
                work_end_hour.TextColor = Color.Black;
            }

            work_end_label          = new Label();
            work_end_label.Text     = " 18";
            work_end_label.FontSize = 15;

            work_end_slider         = new Xamarin.Forms.Slider();
            work_end_slider.Minimum = 0;
            work_end_slider.Maximum = 24;
            work_end_slider.Value   = 18;
        }
        public BackgroundImageOpacityPage()
        {
            Forms9Patch.Image image = new Forms9Patch.Image();
            image.Source = Forms9Patch.ImageSource.FromMultiResource("FormsGestures.Resources.rocket");
            image.Opacity = 0.3f;
            image.Fill = Forms9Patch.Fill.Fill;

            Slider slider = new Slider
            {
                Minimum = 0.0,
                Maximum = 1.0
            };
            slider.ValueChanged += (sender, e) => image.Opacity = e.NewValue;

            Forms9Patch.StackLayout stack = new Forms9Patch.StackLayout
            {
                Children = {
                    new Label { Text = "Opacity:" },
                    slider
                },
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            // replace between the two lines - in the first the opacity is ok, in the second there is no opacity
            //stack.Children.Add(image);
            stack.BackgroundImage = image;
            Content = stack;
        }
Example #7
0
		public UrhoPage()
		{
			var restartBtn = new Button { Text = "Restart" };
			restartBtn.Clicked += (sender, e) => StartUrhoApp();

			urhoSurface = new UrhoSurface();
			urhoSurface.VerticalOptions = LayoutOptions.FillAndExpand;

			Slider rotationSlider = new Slider(0, 500, 250);
			rotationSlider.ValueChanged += (s, e) => urhoApp?.Rotate((float)(e.NewValue - e.OldValue));

			selectedBarSlider = new Slider(0, 5, 2.5);
			selectedBarSlider.ValueChanged += OnValuesSliderValueChanged;

			Title = " UrhoSharp + Xamarin.Forms";
			Content = new StackLayout {
				Padding = new Thickness (12, 12, 12, 40),
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {
					urhoSurface,
					restartBtn,
					new Label { Text = "ROTATION::" },
					rotationSlider,
					new Label { Text = "SELECTED VALUE:" },
					selectedBarSlider,
				}
			};
		}
Example #8
0
        public InitialPage()
        {
            BindingContext = new InitialPageModel (this.Navigation);

            Title = "Welcome to Peter";

            Label timeLabel = new Label {
                HorizontalOptions = LayoutOptions.Center,
            };
            timeLabel.SetBinding<InitialPageModel> (Label.TextProperty, vm => vm.DrinkingHoursDisplay);

            Slider timeSlider = new Slider (1, 24, 5) {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            timeSlider.SetBinding<InitialPageModel> (Slider.ValueProperty, vm => vm.DrinkingHours, BindingMode.TwoWay);

            Button pressMe = new Button {
                Text = "Help Peter",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                FontSize = 60,
                HeightRequest = 200,
                BackgroundColor = Color.Yellow,
            };
            pressMe.SetBinding<InitialPageModel> (Button.CommandProperty, vm => vm.PressMeCommand);

            Content = new StackLayout {
                Children = {
                    timeLabel,
                    timeSlider,
                    pressMe,
                }
            };
        }
Example #9
0
        public iOSSliderUpdateOnTapPageCS()
        {
            var slider = new Xamarin.Forms.Slider();

            slider.On <iOS>().SetUpdateOnTap(true);

            var button = new Button {
                Text = "Toggle Update on Tap"
            };

            button.Clicked += (sender, e) => slider.On <iOS>().SetUpdateOnTap(!slider.On <iOS>().GetUpdateOnTap());;

            Title   = "Slider Update on Tap";
            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    new Label {
                        Text = "Tap on the Slider bar to move the thumb."
                    },
                    slider,
                    button
                }
            };
        }
        public BindingSourceCodePage()
        {
            Label label = new Label
            {
                Text = "Binding Source Demo",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            Slider slider = new Slider
            {
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Define Binding object with source object and property.
            Binding binding = new Binding
            {
                Source = slider,
                Path = "Value"
            };

            // Bind the Opacity property of the Label to the source.
            label.SetBinding(Label.OpacityProperty, binding);

            // Construct the page.
            Padding = new Thickness(10, 0);
            Content = new StackLayout
            {
                Children = { label, slider }
            };
        }
        public OpacityBindingCodePage()
        {
            Label label = new Label
            {
                Text = "Opacity Binding Demo",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            Slider slider = new Slider
            {
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Set the binding context: target is Label; source is Slider.
            label.BindingContext = slider;

            // Bind the properties: target is Opacity; source is Value.
            label.SetBinding(Label.OpacityProperty, "Value");

            // Construct the page.
            Padding = new Thickness(10, 0);
            Content = new StackLayout
            {
                Children = { label, slider }
            };
        }
 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(MainPage));
     itemQualquer = this.FindByName<Entry>("itemQualquer");
     lblContador = this.FindByName<Label>("lblContador");
     stpContador = this.FindByName<Stepper>("stpContador");
     sldContador = this.FindByName<Slider>("sldContador");
 }
Example #13
0
 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(XamlPage));
     SampleViewModelX = this.FindByName<global::SampleApp.SampleViewModel>("SampleViewModelX");
     LabelMain = this.FindByName<Label>("LabelMain");
     RedSlider = this.FindByName<Slider>("RedSlider");
     GreenSlider = this.FindByName<Slider>("GreenSlider");
     BlueSlider = this.FindByName<Slider>("BlueSlider");
 }
 void OnVolumeSliderChange(object sender, SelectedItemChangedEventArgs args)
 {
     Xamarin.Forms.Slider senderSlider = sender as Xamarin.Forms.Slider;
     if (senderSlider == null)
     {
         return;
     }
     float volume = (float)senderSlider.Value;
     //Media.SetVolume(volume, volume);
 }
		public MapPage ()
		{
			map = new Map { 
				IsShowingUser = true,
				HeightRequest = 100,
				WidthRequest = 960,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			// You can use MapSpan.FromCenterAndRadius 
//			map.MoveToRegion (MapSpan.FromCenterAndRadius (
//				new Position (37, -122), Distance.FromMiles (0.3)));
			// or create a new MapSpan object directly
			map.MoveToRegion (new MapSpan (new Position (0,0), 360, 360) );

			// add the slider
			var slider = new Slider (1, 18, 1);
			slider.ValueChanged += (sender, e) => {
				var zoomLevel = e.NewValue; // between 1 and 18
				var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));
				Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
				if (map.VisibleRegion != null)
					map.MoveToRegion(new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees)); 
			};


			// create map style buttons
			var street = new Button { Text = "Street" };
			var hybrid = new Button { Text = "Hybrid" };
			var satellite = new Button { Text = "Satellite" };
			street.Clicked += HandleClicked;
			hybrid.Clicked += HandleClicked;
			satellite.Clicked += HandleClicked;
			var segments = new StackLayout { Spacing = 30,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				Orientation = StackOrientation.Horizontal, 
				Children = {street, hybrid, satellite}
			};


			// put the page together
			var stack = new StackLayout { Spacing = 0 };
			stack.Children.Add(map);
			stack.Children.Add (slider);
			stack.Children.Add (segments);
			Content = stack;


			// for debugging output only
			map.PropertyChanged += (sender, e) => {
				Debug.WriteLine(e.PropertyName + " just changed!");
				if (e.PropertyName == "VisibleRegion" && map.VisibleRegion != null)
					CalculateBoundingCoordinates (map.VisibleRegion);
			};
		}
        void OnProgressSliderChange(object sender, SelectedItemChangedEventArgs args)
        {
            Xamarin.Forms.Slider senderSlider = sender as Xamarin.Forms.Slider;
            if (senderSlider == null)
            {
                return;
            }
            float progress = (float)senderSlider.Value;

            DependencyService.Get <ISoundPlayer>().Seek(progress);
        }
Example #17
0
        public SliderStepper()
        {
            boxView = new BoxView()
            {
                WidthRequest  = 160,
                HeightRequest = 160,
                Color         = Color.Black,
            };
            Slider1 = new Slider
            {
                Minimum = 0,
                Maximum = 255,
                Value   = 0,
            };
            Slider1.ValueChanged += Slider1_ValueChanged;
            redLabel              = new Label()
            {
            };
            slider2 = new Slider
            {
                Minimum = 0,
                Maximum = 255,
                Value   = 0,
            };

            slider2.ValueChanged += Slider2_ValueChanged;

            greenLabel = new Label()
            {
            };

            Slider3 = new Slider
            {
                Minimum = 0,
                Maximum = 255,
                Value   = 0,
            };

            Slider3.ValueChanged += Slider3_ValueChanged;

            blueLabel = new Label()
            {
            };

            StackLayout stackLayout = new StackLayout()
            {
                Margin   = new Thickness(10),
                Children = { boxView, Slider1, redLabel, slider2, greenLabel, Slider3, blueLabel }
            };

            Content = stackLayout;
        }
		private Slider SyncSlider (double value = 25)
		{
			syncSlider = new Slider () {
				Maximum = 75,
				Minimum = 0,
				Value = value,
			};

			SyncValue = value;

			syncSlider.ValueChanged += HandleSliderChangedEvent;
			return syncSlider;
		}
		public static Page GetMainPage ()
		{	
		
			var contentPage = new ContentPage {
				//Title = "Custom Progress Bar"

			};
		
			var progressBar = new CircularProgress {
				ProgressColor = Color.FromHex("3498DB"),
				ProgressBackgroundColor = Color.FromHex("B4BCBC"),
				WidthRequest = 300,
				HeightRequest = 300
			};

			var increase = new Button { Text = "+5" };
			var decrease = new Button { Text = "-5" };
			var indeterminate = new Button { Text = "Indeterminate" };

			increase.Clicked += (sender, args) => progressBar.Progress += 5;
			decrease.Clicked += (sender, args) => progressBar.Progress -= 5;

			indeterminate.Clicked += (sender, args) => {
				progressBar.Indeterminate = !progressBar.Indeterminate;
			};

			var actionsStack = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Spacing = 10,
				HorizontalOptions = LayoutOptions.Center,
				Children = {increase, decrease, indeterminate}
			};


			var slider = new Slider (50, 150, 100);

			slider.ValueChanged += (sender, args) => progressBar.IndeterminateSpeed = (int)slider.Value;


			var mainStack = new StackLayout {
				Spacing = 10,
				Padding = 10,
				Children = {actionsStack, slider, progressBar }
			};


			contentPage.Content = mainStack;

			return contentPage;
			//return new NavigationPage (contentPage);
		}
Example #20
0
		public LamanPeta ()
		{
			peta = new Map {
				IsShowingUser = true,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			peta.MoveToRegion (new MapSpan (new Position (0, 0), 360, 360));

			var slider = new Slider (1, 18, 2);
			slider.ValueChanged += (sender, e) => {
				var tingkatZoom = e.NewValue;
				var latLongDegree = 360 / (Math.Pow (2, tingkatZoom));
				if (peta.VisibleRegion != null) {
					peta.MoveToRegion (new MapSpan (peta.VisibleRegion.Center, latLongDegree, latLongDegree));
				}
			};

		    var jalan = new Button {Text = "Jalan"};
		    var hibrid = new Button {Text = "Hibrid"};
		    var satelit = new Button {Text = "Satelit"};

		    jalan.Clicked += ClickHandler;
		    hibrid.Clicked += ClickHandler;
		    satelit.Clicked += ClickHandler;

		    var segmen = new StackLayout
		    {
		        Spacing = 30,
		        HorizontalOptions = LayoutOptions.CenterAndExpand,
		        Orientation = StackOrientation.Vertical,
		        Children = {jalan, hibrid, satelit}
		    };

		    var stack = new StackLayout {Spacing = 0};
            stack.Children.Add(peta);
            stack.Children.Add(slider);
            stack.Children.Add(segmen);

		    Content = stack;

		    peta.PropertyChanged += (sender, e) =>
		    {
		        if (e.PropertyName == "VisibleRegion" && peta.VisibleRegion != null)
		        {
                    HitungKoordinat(peta.VisibleRegion);
		        }
		    };
		}
		public MainPage()
		{
			var pos = new Xamarin.Forms.Maps.Position (-15.8046057, -47.896674);
			var Span = MapSpan.FromCenterAndRadius (pos, Distance.FromMiles (0.3));
			map = new Map (Span){ 
				IsShowingUser = true,
				HeightRequest = 100,
				WidthRequest = 960,
				VerticalOptions = LayoutOptions.FillAndExpand
			};


			// add the slider
			var slider = new Slider (1, 18, 1);
			slider.ValueChanged += (sender, e) => {
				var zoomLevel = e.NewValue; // between 1 and 18
				var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));

				Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
				if (map.VisibleRegion != null)
					map.MoveToRegion(new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees)); 
			};


			// create map style buttons
			var street = new Button { Text = "Street" };
			var hybrid = new Button { Text = "Hybrid" };
			var satellite = new Button { Text = "Satellite" };
			street.Clicked += HandleClicked;
			hybrid.Clicked += HandleClicked;
			satellite.Clicked += HandleClicked;
			var segments = new StackLayout { Spacing = 30,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				Orientation = StackOrientation.Horizontal, 
				Children = {street, hybrid, satellite},
			};


			//			if (geoLocator.IsGeolocationAvailable == true) {
			//				geoLocator.PositionChanged
			//			}

			this.Content = new StackLayout
			{
				Children = {map, segments, slider}

			};

		}
Example #22
0
        public SimpleContentPage()
        {
            var labTitulo = new Label
               {
                   Text = "Registro",
                   FontSize = 24
               };
            var entNombre = new Entry
            {
                Placeholder = "Cual es tu problema?"
            };
            var entDesc = new Editor
            {
                Text = "Describe tu problema..."
                //Placeholder = "Describe tu problema..."
               
            };
            var sliCat = new Slider
            {
                Minimum = 1,
                Maximum = 10
            };
            var sliLevel = new Slider
            {
                Minimum = 1,
                Maximum = 10
            };


            var btnEnviar = new Button
            {
                Text = "Enviar"
            };


            Content = new StackLayout
            {
                Padding = 30,
                Spacing = 10,
                Children = { labTitulo, entNombre, entDesc, sliCat, sliLevel, btnEnviar }
            };


        }
        public View SetContent()
        {
            Button btnGo = new Button()
            {
                Text = "Let's Find Out",
                HorizontalOptions = LayoutOptions.Center,
            };
            btnGo.Clicked += btnGo_Clicked;

            Frame frameMap = new Frame() { Padding = 1, VerticalOptions = LayoutOptions.FillAndExpand };
            map = new Map(
                MapSpan.FromCenterAndRadius(
                    viewModel.Location, Distance.FromMiles(2000)))
                    {
                        VerticalOptions = LayoutOptions.FillAndExpand,
                    };
            frameMap.Content = map;

            slider = new Slider(1, 18, 9);
            slider.ValueChanged += slider_ValueChanged;

            StackLayout stackGPS = this.GetGPSLayout();
            StackLayout stackAddr = this.GetAddrLayout();

            StackLayout stack = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding = new Thickness(10, Device.OnPlatform(0, 0, 0), 10, 10),
                Spacing = 5,
                Orientation = StackOrientation.Vertical,
                Children =
                {
                   btnGo,
                   stackGPS,
                   stackAddr,
                   frameMap,
                   slider,
                },

            };

            return stack;
        }
        public NumberSliderInput(string label, double minimum, double maximum)
            : base(label)
        {
            Slider slider = new Slider
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Minimum = minimum,
                Maximum = maximum
            };

            Label sliderValueLabel = new Label
            {
                Text = slider.Value.ToString(),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontSize = 20
            };

            slider.ValueChanged += (o, e) =>
            {
                sliderValueLabel.Text = e.NewValue.ToString();
            };

            View = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    Label,
                    new StackLayout
                    {
                        Orientation = StackOrientation.Vertical,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Children = { slider, sliderValueLabel }
                    }
                }
            };

            ValueRetriever = new Func<object>(() => slider.Value);
        }
        public SliderDemoPage()
        {
            Label header = new Label
            {
                Text = "Slider",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            Slider slider = new Slider
            {
                Minimum = 0,
                Maximum = 100,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            slider.ValueChanged += OnSliderValueChanged;

            label = new Label
            {
                Text = "Slider value is 0",
                Font = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    slider,
                    label
                }
            };
        }
        public SliderDemoPage()
        {
            Label header = new Label
            {
                Text = "Slider",
				FontSize = 50,
				FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            Slider slider = new Slider
            {
                Minimum = 0,
                Maximum = 100,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            slider.ValueChanged += OnSliderValueChanged;

            label = new Label
            {
                Text = "Slider value is 0",
				FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    slider,
                    label
                }
            };
        }
Example #27
0
        void PropertyLayout()
        {
            StackLayout stack = new StackLayout();

            stack.BackgroundColor = Color.White;
            stack.Padding         = 10;
            Label pointer = new Label();

            pointer.Text = "Pointer Value";
            if (Device.OS == TargetPlatform.iOS)
            {
                pointer.FontSize = 15;
            }
            else if (Device.OS == TargetPlatform.Android)
            {
                pointer.FontSize = 15;
            }
            else
            {
                pointer.FontSize = 20;
            }

            pointer.TextColor      = Color.Black;
            pointer.FontAttributes = FontAttributes.Bold;

            Xamarin.Forms.Slider pointerSlider = new Xamarin.Forms.Slider();
            pointerSlider.Maximum = 100;
            if (Device.OS == TargetPlatform.WinPhone)
            {
                pointerSlider.BackgroundColor = Color.Gray;
            }
            pointerSlider.Value         = 60;
            pointerSlider.ValueChanged += pointerSlider_ValueChanged;
            stack.Children.Add(pointer);
            stack.Children.Add(pointerSlider);
            this.PropertyView = stack;
        }
Example #28
0
        public SliderSettingView()
        {
            Caption = new Label()
            {
                FontSize = Font.SystemFontOfSize(18, FontAttributes.Bold).FontSize,
                HorizontalOptions = LayoutOptions.StartAndExpand
            };

            Value = new Label()
            {
                FontSize = Font.SystemFontOfSize(18, FontAttributes.Bold).FontSize,
                TextColor = Color.Accent,
                HorizontalOptions = LayoutOptions.EndAndExpand
            };

            Slider = new Slider()
                    {
                       VerticalOptions = LayoutOptions.CenterAndExpand,
                       HorizontalOptions =  LayoutOptions.FillAndExpand,
                        Minimum =  0,
                        Maximum = 100
                    };

            Padding = new Thickness(30, 30);
            Orientation = StackOrientation.Vertical;
            VerticalOptions = LayoutOptions.Center;

            var header = new StackLayout
                     {
                         Padding = new Thickness(0, 30),
                         Orientation = StackOrientation.Horizontal,
                         Children = {Caption, Value}
                     };
            Children.Add(header);
            Children.Add(Slider);
        }
Example #29
0
        public ButtonCodePage()
        {
            _f9pButton.BackgroundImage = _f9pImage;

            Title       = "StateButtonCodePage";
            IsPresented = true;

            #region Local Elements
            hzOptionSegmentedControl.SelectIndex(3);
            hzOptionSegmentedControl.SegmentTapped += HzOptionSegmentedControl_SegmentTapped;

            vtOptionSegmentedControl.SelectIndex(3);
            vtOptionSegmentedControl.SegmentTapped += VtOptionSegmentedControl_SegmentTapped;


            var heightRequestSlider = new Slider(-1, 300, -1);
            heightRequestSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1));
            heightRequestSlider.ValueChanged += HeightRequestSlider_ValueChanged;

            var fillSegmentedControl = new Forms9Patch.SegmentedControl
            {
                Segments =
                {
                    //new Forms9Patch.Segment("NONE"),
                    new Forms9Patch.Segment("TILE"),
                    new Forms9Patch.Segment("ASPECTFILL"),
                    new Forms9Patch.Segment("ASPECTFIT"),
                    new Forms9Patch.Segment("FILL")
                }
            };
            fillSegmentedControl.SelectIndex(3);
            fillSegmentedControl.SegmentTapped += FillSegmentedControl_SegmentTapped;

            Forms9Patch.SegmentedControl shapesSelector = new Forms9Patch.SegmentedControl
            {
                Segments =
                {
                    new Forms9Patch.Segment {
                        Text = Rectangle
                    },
                    new Forms9Patch.Segment {
                        Text = Square
                    },
                    new Forms9Patch.Segment {
                        Text = Circle
                    },
                    new Forms9Patch.Segment {
                        Text = Ellipse
                    },
                    new Forms9Patch.Segment {
                        Text = "OBROUND"
                    }
                }
            };
            shapesSelector.SelectIndex(0);
            shapesSelector.SegmentTapped += ShapesSelector_SegmentTapped;

            var outlineWidthSlider = new Xamarin.Forms.Slider
            {
                Minimum = 0,
                Maximum = 15,
                Value   = 2
            };
            outlineWidthSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1.0 / Forms9Patch.Display.Scale));
            outlineWidthSlider.ValueChanged += OutlineWidthSlider_ValueChanged;

            outlineRadiusSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1));
            outlineRadiusSlider.ValueChanged += OutlineRadiusSlider_ValueChanged;

            var shapeAttributesSelector = new Forms9Patch.SegmentedControl
            {
                GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect,
                Segments            =
                {
                    new Forms9Patch.Segment("BACKGROUND"),
                    new Forms9Patch.Segment("OUTLINE"),
                    new Forms9Patch.Segment("SHADOW"),
                    new Forms9Patch.Segment("INVERTED")
                }
            };
            shapeAttributesSelector.SegmentTapped += ShapeAttributesSelector_SegmentTapped;

            var seg1 = new Forms9Patch.Segment("");
            var seg2 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.redGridBox");
            var seg3 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.button");
            var seg4 = new Forms9Patch.Segment(null, new Forms9Patch.Image {
                Source = ImageSource.FromFile("cat.jpg"), Fill = Forms9Patch.Fill.AspectFit
            });
            var seg5 = new Forms9Patch.Segment(null, new Forms9Patch.Image {
                Source = ImageSource.FromFile("balloons.jpg"), Fill = Forms9Patch.Fill.AspectFit
            });
            var seg6 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.image");
            var seg7 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.redribbon");
            var seg8 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.bubble");
            var seg9 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.bluebutton");

            var backgroundImageSelector = new Forms9Patch.SegmentedControl
            {
                HeightRequest           = 40,
                HasTightSpacing         = true,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TintIcon = false,
                Segments =
                {
                    seg1,
                    seg2,
                    seg3,
                    seg4,
                    seg5,
                    seg6,
                    seg7,
                    seg8,
                    seg9
                }
            };

            /*
             * backgroundImageSelector.Segments.Add(seg1);
             * backgroundImageSelector.Segments.Add(seg2);
             * backgroundImageSelector.Segments.Add(seg3);
             * backgroundImageSelector.Segments.Add(seg4);
             * backgroundImageSelector.Segments.Add(seg5);
             * backgroundImageSelector.Segments.Add(seg6);
             * backgroundImageSelector.Segments.Add(seg7);
             * backgroundImageSelector.Segments.Add(seg8);
             * backgroundImageSelector.Segments.Add(seg9);
             */
            backgroundImageSelector.SelectIndex(1);
            backgroundImageSelector.SegmentTapped += BackgroundImageSelector_SegmentTapped;

            capsInsetsTopSlider.Effects.Add(capsInsetsTStepSizeEffect);
            capsInsetsTopSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsLeftSlider.Effects.Add(capsInsetsLStepSizeEffect);
            capsInsetsLeftSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsRightSlider.Effects.Add(capsInsetsRStepSizeEffect);
            capsInsetsRightSlider.Rotation      = 180;
            capsInsetsRightSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsBottomSlider.Effects.Add(capsInsetsBStepSizeEffect);
            capsInsetsBottomSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsBottomSlider.Rotation      = 180;

            var outlineGrid = new Xamarin.Forms.Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            outlineGrid.Children.Add(new Forms9Patch.Label("Forms9Patch.Image.OutlineWidth:"), 0, 0);
            outlineGrid.Children.Add(outlineWidthSlider, 0, 1);
            outlineGrid.Children.Add(new Forms9Patch.Label("Forms9Patch.Image.OutlineRadius:"), 1, 0);
            outlineGrid.Children.Add(outlineRadiusSlider, 1, 1);

            //pixelCapsSwitch.Toggled += PixelCapsSwitch_Toggled;

            var capsInsetsGrid = new Xamarin.Forms.Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Top:"), 0, 0);
            capsInsetsGrid.Children.Add(capsInsetsTopSlider, 0, 1);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Bottom:"), 0, 2);
            capsInsetsGrid.Children.Add(capsInsetsBottomSlider, 0, 3);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Left:"), 1, 0);
            capsInsetsGrid.Children.Add(capsInsetsLeftSlider, 1, 1);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Right:"), 1, 2);
            capsInsetsGrid.Children.Add(capsInsetsRightSlider, 1, 3);

            capsUnitsSegmentedControl.SelectIndex(0);
            capsUnitsSegmentedControl.SegmentTapped += CapsUnitsSegmentedControl_SegmentTapped;
            antiAliasSwitch.Toggled += AntiAliasSwitch_Toggled;
            var capsInsetsAndAntiAliasGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("CapsInsets Units:"), 0, 0);
            capsInsetsAndAntiAliasGrid.Children.Add(capsUnitsSegmentedControl, 0, 1);
            capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("AntiAlias:"), 1, 0);
            capsInsetsAndAntiAliasGrid.Children.Add(antiAliasSwitch, 1, 1);

            #endregion

            #region Content
            Master = new ContentPage
            {
                Title           = "Controls",
                BackgroundColor = Color.LightGray,
                Content         = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Padding  = new Thickness(10, 10, 20, 10),
                        Children =
                        {
                            new Forms9Patch.Label("HorizontalOptions:"),
                            hzOptionSegmentedControl,
                            new Forms9Patch.Label("VerticalOptions:"),
                            vtOptionSegmentedControl,
                            new Forms9Patch.Label("Fill / Aspect:"),
                            fillSegmentedControl,
                            new Forms9Patch.Label("ElementShape:"),
                            shapesSelector,
                            new Forms9Patch.Label("Shape attributes:"),
                            shapeAttributesSelector,
                            outlineGrid,

                            new Forms9Patch.Label("ImageSource:"),
                            backgroundImageSelector,

                            capsInsetsAndAntiAliasGrid,
                            capsInsetsGrid,

                            new Forms9Patch.Label("HeightRequest:"),
                            heightRequestSlider,


                            new Xamarin.Forms.Label {
                                Text = "Display.Scale=[" + Forms9Patch.Display.Scale + "]"
                            }
                        },
                    },
                }
            };
            Detail = new ContentPage
            {
                Title = "Images",

                Content = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Children =
                        {
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            new Forms9Patch.Label("Forms9Patch.Button:"),
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            _f9pButton,
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            new Forms9Patch.Label("Xamarin.Forms.Button:"),
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            _xfButton,
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                        }
                    }
                }
            };

            #endregion
        }
		public SvgImageSamplePage ()
		{
			_ViewModel = new SvgImageSamplePageViewModel();
			var insetLabel = new Label();
			insetLabel.SetBinding(Label.TextProperty, nameof(SvgImageSamplePageViewModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
			var resourcePicker = new Picker() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
			};
			foreach (var resourceName in SvgImageSamplePageViewModel.AvailableResourceNames) {
				resourcePicker.Items.Add(resourceName);
			}
			resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(SvgImageSamplePageViewModel.SvgResourceIndex), BindingMode.TwoWay);
			var insetSlider = new Slider() {
				Minimum = 0,
				Maximum = 35,
				Value = _ViewModel.AllSidesInset,
			};
			insetSlider.SetBinding(Slider.ValueProperty, nameof(SvgImageSamplePageViewModel.AllSidesInset), BindingMode.TwoWay);
			var slicingSvg = new SvgImage() {
				SvgAssembly = typeof(App).GetTypeInfo().Assembly,
				WidthRequest = 300,
				HeightRequest = 300,
			};
			slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(SvgImageSamplePageViewModel.SvgInsets));
			slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(SvgImageSamplePageViewModel.SvgResourcePath));
			var svgButton = new Button() {
				WidthRequest = 300,
				HeightRequest = 300,
				BackgroundColor = Color.Transparent,
			};

			// The root page of your application
			Title = "9-Slice SVG Scaling";
			Content = new ScrollView {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Start,
					HorizontalOptions = LayoutOptions.Center,
					Children = {
						insetLabel,
						resourcePicker,
						insetSlider,
						new AbsoluteLayout() {
							WidthRequest = 300,
							HeightRequest = 300,
							Children = {
								slicingSvg,
								svgButton,
							},
						},
						new Label () {
							Text = "Using TwinTechsForms.SvgImage",
						},
						new Label () {
							Text = "Proportional Scaling",
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 50,
							HeightRequest = 50,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 100,
							HeightRequest = 100,
						},
						new Label () {
							Text = "9-Slice Scaling",
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 50,
							HeightRequest = 50,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 100,
							HeightRequest = 100,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 300,
							HeightRequest = 300,
							HorizontalOptions = LayoutOptions.Start,
						},
						new Label () {
							Text = "Using TwinTechsForms.NControl.SvgImageView",
						},
						new Label () {
							Text = "Proportional Scaling",
						},
						new SvgImageView() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 50,
							HeightRequest = 50,
						},
						new SvgImageView() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 100,
							HeightRequest = 100,
						},
						new Label () {
							Text = "9-Slice Scaling",
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 50,
							HeightRequest = 50,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 100,
							HeightRequest = 100,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 300,
							HeightRequest = 300,
							HorizontalOptions = LayoutOptions.Start,
						},
					},
					BindingContext = _ViewModel,
				},
			};
			svgButton.Clicked += (sender, e) => {
				DisplayAlert("Tapped!", "SVG button tapped!", "OK");
			};
		}
        public RadialProgressColorsDemo()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            Title = "Radial progress COLOR demo";
            var headerInfoLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Orientation = StackOrientation.Horizontal,
                Children = 
                        {
                            new Label 
                            {
							    Text = "Radial progress COLOR demo",
                                FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label))
						    }
                        }
            };
            var headerLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                Orientation = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Start,
                Children = 
                {
                   headerInfoLayout
                }
            };
            var slider = new Slider
            {
                Minimum = 0,
                Maximum = 250,
                Value = 128
            };
            #region Init Elements
            radialProgress = new RadialProgress
            {
                Diameter = 200,
                DisplayMode = DisplayModeTypes.ShowProgress,
                Max = 250,
                Progress = 128,
                FillColor = new Color(0, 255, 0, 0.3)
            };
            elementColorPicker = new Picker
            {
                Title = "Select element",
                Items = { "Border color", "Fill color", "Text color", "Max Border color" },
                SelectedIndex = 0
            };

            redSlider = new Slider
            {
                Minimum = 0,
                Maximum = 100,
               
            };
            greenSlider = new Slider
            {
                Minimum = 0,
                Maximum = 100
            };
            blueSlider = new Slider
            {
                Minimum = 0,
                Maximum = 100
            };
            alfaSlider = new Slider
            {
                Minimum = 0,
                Maximum = 100
            };
            SetColorSliders();
            #endregion
            #region EventHandlers
            redSlider.ValueChanged += async (sender, e) =>
            {
                UpdateProgressElementColorColor(
                    e.NewValue / 100
                    , greenSlider.Value / 100
                    , blueSlider.Value / 100
                    , alfaSlider.Value/100);
            };
            greenSlider.ValueChanged += async (sender, e) =>
            {
                UpdateProgressElementColorColor(
                    redSlider.Value / 100
                    , e.NewValue / 100
                    , blueSlider.Value / 100
                    , alfaSlider.Value / 100);
            };
            blueSlider.ValueChanged += async (sender, e) =>
            {
                UpdateProgressElementColorColor(
                    redSlider.Value / 100
                    , greenSlider.Value / 100
                    , e.NewValue / 100
                    , alfaSlider.Value / 100);
            };
            alfaSlider.ValueChanged += async (sender, e) =>
            {
                UpdateProgressElementColorColor(
                    redSlider.Value / 100
                    , greenSlider.Value / 100
                    , blueSlider.Value / 100
                    , e.NewValue / 100);
            };
            slider.ValueChanged += async (sender, e) =>
            {
                radialProgress.Progress = (int)e.NewValue;
            };
            elementColorPicker.SelectedIndexChanged += async (sender, e) =>
            {
                SetColorSliders();
            };
            #endregion
            var contentLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children = 
                {
                    slider,
                    radialProgress,
                    elementColorPicker,
                    new Label 
                    {
						Text = "RED",
                        FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                        TextColor = Color.Red
					},
                    redSlider,
                    new Label 
                    {
						Text = "GREEN",
                        FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                        TextColor = Color.Green
					},
                    greenSlider,
                    new Label 
                    {
						Text = "BLUE",
                        FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                        TextColor = Color.Blue
					},
                    blueSlider,
                    new Label 
                    {
						Text = "ALFA",
                        FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                        TextColor = Color.White
					},
                    alfaSlider
                }
            };
            var footerLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                Orientation = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.End,
                Children = 
                {
                    //radialProgress,
                    new Label 
                    {
							Text = "Made by Jordan Atanasovski 1.0"
					}
                }
            };
            BackgroundImage = "AppBackground.jpg";
            // The root page of your application

            Content = new StackLayout
            {
                // this must be fill and expand in order for this to work
                // VerticalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    // headerLayout,
                    contentLayout,
                    footerLayout
                }
            };

        }
        public UnconstrainedLabelFitPage()
        {
            BackgroundColor = Color.Gray;
            Padding = 0;

            #region Editor
            var editor = new Editor
            {
                //Text = "Żorem ipsum dolor sit amet, consectetur adięiscing ełit",
                Text = text1,
                TextColor = Color.White,
                BackgroundColor = Color.Black,
                HeightRequest = 130,
                FontSize = 15,
            };
            editor.Effects.Add(Effect.Resolve("Forms9Patch.CustomFontEffect"));
            #endregion

            #region Xamarin Forms label
            var xfLabel = new Label
            {
                FontSize = 15,
                TextColor = Color.White,
                BackgroundColor = Color.Black,
                Text = editor.Text
            };
            #endregion

            #region Forms9Patch Label
            var f9pLabel = new Forms9Patch.Label
            {
                //HeightRequest = 50,
                Lines = 3,
                FontSize = 15,
                TextColor = Color.White,
                Fit = Forms9Patch.LabelFit.None,
                BackgroundColor = Color.Black,
                Text = editor.Text
            };
            #endregion

            #region Mode
            var modeSwitch = new Switch
            {
                IsToggled = false,
                HorizontalOptions = LayoutOptions.End,
            };
            modeSwitch.Toggled += (sender, e) =>
            {
                if (modeSwitch.IsToggled)
                    f9pLabel.HtmlText = editor.Text;
                else
                    f9pLabel.Text = editor.Text;
            };
            #endregion

            #region Sync text between Editor and Labels

            editor.TextChanged += (sender, e) =>
            {
                xfLabel.Text = editor.Text;
                f9pLabel.HtmlText = editor.Text;
            };
            #endregion

            #region Font Size selection
            var fontSizeSlider = new Slider
            {
                Maximum = 104,
                Minimum = 4,
                Value = 15
            };

            var fontSizeLabel = new Label
            {
                Text = "Font Size: 15"
            };
            fontSizeSlider.ValueChanged += (sender, e) =>
            {
                fontSizeLabel.Text = "Font Size: " + fontSizeSlider.Value;
                f9pLabel.FontSize = fontSizeSlider.Value;
                if (!rendering)
                {
                    rendering = true;
                    xfLabel.FontSize = fontSizeSlider.Value;
                    Device.StartTimer(TimeSpan.FromMilliseconds(50), () =>
                    {
                        if (Math.Abs(xfLabel.FontSize - lastFontSize) > double.Epsilon * 5)
                        {
                            xfLabel.FontSize = lastFontSize;
                            return true;
                        }
                        rendering = false;
                        return false;
                    });
                }
                lastFontSize = fontSizeSlider.Value;
            };
            var actualFontSizeLabel = new Label
            {
                Text = "Actual Font Size: 15"
            };

            f9pLabel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == Forms9Patch.Label.ActualFontSizeProperty.PropertyName)
                    actualFontSizeLabel.Text = "ActualFontSize: " + f9pLabel.ActualFontSize;
            };
            #endregion

            #region Lines selection
            var linesLabel = new Label
            {
                Text = "Lines: 3"
            };
            var linesSlider = new Slider
            {
                Minimum = 0,
                Maximum = 8,
                Value = 3
            };
            linesSlider.ValueChanged += (sender, e) =>
            {
                linesLabel.Text = "Lines: " + ((int)Math.Round(linesSlider.Value));
                f9pLabel.Lines = ((int)Math.Round(linesSlider.Value));
            };
            #endregion

            #region Fit Selection
            var fitSelector = new Forms9Patch.MaterialSegmentedControl();
            fitSelector.Segments.Add(new Forms9Patch.Segment
            {
                Text = "None",
                Command = new Command(x =>
                {
                    f9pLabel.Fit = Forms9Patch.LabelFit.None;
                })
            });
            var widthSegment = new Forms9Patch.Segment
            {
                Text = "Width",
                Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.Width; }),
                //IsEnabled = f9pLabel.HasImposedSize,
                BindingContext = f9pLabel,
                //IsEnabled = false
            };
            //widthSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize");
            fitSelector.Segments.Add(widthSegment);
            var linesSegment = new Forms9Patch.Segment
            {
                Text = "Lines",
                Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.Lines; }),
                //IsEnabled = f9pLabel.HasImposedSize,
                BindingContext = f9pLabel
            };
            //linesSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize");
            fitSelector.Segments.Add(linesSegment);
            fitSelector.SelectIndex(0);

            #endregion

            #region Alignment Selection
            var hzAlignmentSelector = new Forms9Patch.MaterialSegmentedControl();
            var vtAlignmentSelector = new Forms9Patch.MaterialSegmentedControl();
            hzAlignmentSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Start",
                    Command = new Command(x =>
                    {
                        f9pLabel.HorizontalTextAlignment = TextAlignment.Start;
                        xfLabel.HorizontalTextAlignment = TextAlignment.Start;
                    })
                }
            );
            hzAlignmentSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Center",
                    Command = new Command(x =>
                    {
                        f9pLabel.HorizontalTextAlignment = TextAlignment.Center;
                        xfLabel.HorizontalTextAlignment = TextAlignment.Center;
                    })
                }
            );
            hzAlignmentSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "End",
                    Command = new Command(x =>
                    {
                        f9pLabel.HorizontalTextAlignment = TextAlignment.End;
                        xfLabel.HorizontalTextAlignment = TextAlignment.End;
                    })
                }
            );
            vtAlignmentSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Start",
                    Command = new Command(x =>
                    {
                        f9pLabel.VerticalTextAlignment = TextAlignment.Start;
                        xfLabel.VerticalTextAlignment = TextAlignment.Start;
                    })
                }
            );
            vtAlignmentSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Center",
                    Command = new Command(x =>
                    {
                        f9pLabel.VerticalTextAlignment = TextAlignment.Center;
                        xfLabel.VerticalTextAlignment = TextAlignment.Center;
                    })
                }
            );
            vtAlignmentSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "End",
                    Command = new Command(x =>
                    {
                        f9pLabel.VerticalTextAlignment = TextAlignment.End;
                        xfLabel.VerticalTextAlignment = TextAlignment.End;
                    })
                }
            );
            hzAlignmentSelector.SelectIndex(0);
            vtAlignmentSelector.SelectIndex(0);
            #endregion

            #region BreakMode selection
            var breakModeSelector = new Forms9Patch.MaterialSegmentedControl();
            breakModeSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "NoWrap",
                    Command = new Command(x =>
                    {
                        f9pLabel.LineBreakMode = LineBreakMode.NoWrap;
                        xfLabel.LineBreakMode = LineBreakMode.NoWrap;
                    })
                }
            );
            breakModeSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Char",
                    Command = new Command(x =>
                    {
                        f9pLabel.LineBreakMode = LineBreakMode.CharacterWrap;
                        xfLabel.LineBreakMode = LineBreakMode.CharacterWrap;
                    })
                }
            );
            breakModeSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Word",
                    Command = new Command(x =>
                    {
                        f9pLabel.LineBreakMode = LineBreakMode.WordWrap;
                        xfLabel.LineBreakMode = LineBreakMode.WordWrap;
                    })
                }
            );
            breakModeSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Head",
                    Command = new Command(x =>
                    {
                        f9pLabel.LineBreakMode = LineBreakMode.HeadTruncation;
                        xfLabel.LineBreakMode = LineBreakMode.HeadTruncation;
                    })
                }
            );
            breakModeSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Mid",
                    Command = new Command(x =>
                    {
                        f9pLabel.LineBreakMode = LineBreakMode.MiddleTruncation;
                        xfLabel.LineBreakMode = LineBreakMode.MiddleTruncation;
                    })
                }
            );
            breakModeSelector.Segments.Add(
                new Forms9Patch.Segment
                {
                    Text = "Tail",
                    Command = new Command(x =>
                    {
                        f9pLabel.LineBreakMode = LineBreakMode.TailTruncation;
                        xfLabel.LineBreakMode = LineBreakMode.TailTruncation
                        ;
                    })
                }
            );
            breakModeSelector.SelectIndex(2);
            #endregion

            #region FontSelection
            Picker fontPicker = new Picker
            {
                Title = "Default",
                //HeightRequest = 300,
                //VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.EndAndExpand,

            };
            var fontFamilies = Forms9Patch.FontExtensions.LoadedFontFamilies();
            foreach (var fontFamily in fontFamilies)
                fontPicker.Items.Add(fontFamily);
            fontPicker.SelectedIndexChanged += (sender, e) =>
            {
                string family = null;
                if (fontPicker.SelectedIndex > -1 && fontPicker.SelectedIndex < fontFamilies.Count)
                {
                    f9pLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex];
                    xfLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex];
                    editor.FontFamily = fontFamilies[fontPicker.SelectedIndex];
                }
            };
            #endregion

            Content = new ScrollView
            {
                Padding = 0,
                Content = new StackLayout
                {
                    Padding = 20,
                    Children = {
                        new Label { Text = "Text:" },
                        editor,
                        new StackLayout
                        {
                            Orientation = StackOrientation.Horizontal,
                            Children = {
                                new Label {
                                    Text = "HTML Formatted:",
                                    HorizontalOptions = LayoutOptions.StartAndExpand,
                                },
                                modeSwitch
                            },
                        },
                        new Label { Text = "Forms9Patch.Label:" },
                        f9pLabel,

                        new Label {
                            Text = "Font Family:",
                            HorizontalOptions = LayoutOptions.Start
                        },
                        fontPicker,

                        fontSizeLabel,
                        fontSizeSlider,
                        actualFontSizeLabel,
                        new Label { Text = "Fit:" },
                        fitSelector,
                        linesLabel,
                        linesSlider,

                        new Label { Text = "Horizontal Alignment:" },
                        hzAlignmentSelector,
                        new Label { Text = "Vertical Alignment:" },
                        vtAlignmentSelector,
                        new Label { Text = "Truncation Mode:" },
                        breakModeSelector,

                    }
                }
            };
        }
        void PropertyLayout()
        {

            StackLayout stack = new StackLayout();
            stack.BackgroundColor = Color.White;
            stack.Padding = 10;
            Label pointer = new Label();
            pointer.Text = "Pointer Value";
            if (Device.OS == TargetPlatform.iOS)
            {
                pointer.FontSize = 15;
            }
            else if (Device.OS == TargetPlatform.Android)
            {
                pointer.FontSize = 15;
            }
            else
            {
                pointer.FontSize = 20;
            }

            pointer.TextColor = Color.Black;
            pointer.FontAttributes = FontAttributes.Bold;

            Xamarin.Forms.Slider pointerSlider = new Xamarin.Forms.Slider();
            pointerSlider.Maximum = 100;
            if (Device.OS == TargetPlatform.WinPhone)
            {
                pointerSlider.BackgroundColor = Color.Gray;
            }
            pointerSlider.Value = 60;
            pointerSlider.ValueChanged += pointerSlider_ValueChanged;
            stack.Children.Add(pointer);
            stack.Children.Add(pointerSlider);
            this.PropertyView = stack;
        }
        private void DrawOptionsPage()
        {
            toggleButton                = new Xamarin.Forms.Slider();
            toggleButton.Value          = 4;
            toggleButton2               = new Xamarin.Forms.Slider();
            toggleButton2.Value         = 2;
            toggleButton.Maximum        = 20;
            toggleButton2.Maximum       = 20;
            toggleButton2.ValueChanged += (object sender, ValueChangedEventArgs e) =>
            {
                //groupGap = e.NewValue;
            };
            toggleButton.ValueChanged += (object sender, ValueChangedEventArgs e) => {
                groupPadding = e.NewValue;
                (tree.Levels [0] as TreeMapFlatLevel).GroupPadding = groupPadding;
                tree.Refresh();
            };
            picker1 = new PickerExt();
            picker2 = new PickerExt();
            picker1.Items.Add("Squarified");
            picker1.Items.Add("Slice And Dice Horizontal");
            picker1.Items.Add("Slice And Dice Vertical");
            picker1.Items.Add("Slice And Dice Auto");
            picker1.HeightRequest         = 40;
            picker1.SelectedIndex         = 0;
            picker1.SelectedIndexChanged += picker1_SelectedIndexChanged;


            picker2.Items.Add("RangeColorMapping");
            picker2.Items.Add("DesaturationColorMapping");
            picker2.Items.Add("UniColorMapping");
            picker2.Items.Add("PaletteColorMapping");
            picker2.HeightRequest = 40;
            picker2.SelectedIndex = 0;

            picker2.SelectedIndexChanged += picker2_SelectedIndexChanged;
            picker1.BackgroundColor       = Color.White;
            picker2.BackgroundColor       = Color.White;



            label6 = new Label()
            {
                Text          = " " + "Settings",
                FontSize      = 60,
                HeightRequest = 60,
                YAlign        = TextAlignment.End,
                TextColor     = Color.White
            };
            label3 = new Label()
            {
                Text          = "Layout Type",
                HeightRequest = 20,
                YAlign        = TextAlignment.End,
                TextColor     = Color.Black
            };
            label4 = new Label()
            {
                Text          = "Color Mapping",
                HeightRequest = 20,
                YAlign        = TextAlignment.End,
                TextColor     = Color.Black
            };
            label5 = new Label()
            {
                Text          = "Group Padding",
                HeightRequest = 30,
                YAlign        = TextAlignment.Center,
                TextColor     = Color.Black,
            };
            label9 = new Label()
            {
                Text          = "Group Gap",
                HeightRequest = 20,
                YAlign        = TextAlignment.Center,
                TextColor     = Color.Black
            };


            if (Device.OS == TargetPlatform.Android)
            {
                picker1.BackgroundColor = Color.FromRgb(239, 239, 239);
                picker2.BackgroundColor = Color.FromRgb(239, 239, 239);
                label3.FontSize         = 20;
                label4.FontSize         = 20;
                label5.FontSize         = 20;
            }
            //label10.WidthRequest = tree.Width;
            //label11.WidthRequest = tree.Width;
            label5.WidthRequest = label9.Width;
            if (Device.OS == TargetPlatform.WinPhone)
            {
                label5.WidthRequest = 150;
                label9.WidthRequest = 150;

                picker1.HeightRequest = 60;
                picker2.HeightRequest = 60;

                label3.TextColor     = Color.White;
                label4.TextColor     = Color.White;
                label5.TextColor     = Color.White;
                this.BackgroundColor = Color.Black;


                FileImageSource images = new FileImageSource();
                images.File          = "options.png";
                baritem.Icon         = images;
                label3.Text          = "  " + "Layout Type";
                label3.HeightRequest = 22;
                label4.Text          = "  " + "Color Mapping";
                label4.HeightRequest = 22;
                label5.Text          = "  " + "Group Padding";
                label5.HeightRequest = 22;

                label9.TextColor = Color.White;
            }
            if (Device.OS == TargetPlatform.Windows && Device.Idiom != TargetIdiom.Tablet)
            {
                picker1.BackgroundColor = Color.Gray;
                picker2.BackgroundColor = Color.Gray;
            }
        }
Example #35
0
        public CarouselCodeGallery(ItemsLayoutOrientation orientation)
        {
            On <iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never);

            _scrollInfoLabel.MaxLines      = 1;
            _scrollInfoLabel.LineBreakMode = LineBreakMode.TailTruncation;
            _orientation = orientation;

            Title = $"CarouselView (Code, {orientation})";

            var nItems = 5;
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };
            var itemsLayout =
                new LinearItemsLayout(orientation)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var itemTemplate = ExampleTemplates.CarouselTemplate();

            var carouselView = new CarouselView
            {
                ItemsLayout     = itemsLayout,
                ItemTemplate    = itemTemplate,
                Position        = 2,
                Margin          = new Thickness(0, 10, 0, 10),
                BackgroundColor = Color.LightGray,
                AutomationId    = "TheCarouselView"
            };

            if (orientation == ItemsLayoutOrientation.Horizontal)
            {
                carouselView.PeekAreaInsets = new Thickness(30, 0, 30, 0);
            }
            else
            {
                carouselView.PeekAreaInsets = new Thickness(0, 30, 0, 30);
            }

            carouselView.Scrolled += CarouselView_Scrolled;

            StackLayout stacklayoutInfo = GetReadOnlyInfo(carouselView);

            var generator = new ItemsSourceGenerator(carouselView, initialItems: nItems, itemsSourceType: ItemsSourceType.ObservableCollection);

            layout.Children.Add(generator);

            var positionControl = new PositionControl(carouselView, nItems);

            layout.Children.Add(positionControl);

            var spacingModifier = new SpacingModifier(carouselView.ItemsLayout, "Update Spacing");

            layout.Children.Add(spacingModifier);

            layout.Children.Add(stacklayoutInfo);

            var stckPeek = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckPeek.Children.Add(new Label {
                Text = "Peek"
            });
            var padi = new Xamarin.Forms.Slider
            {
                Maximum         = 100,
                Minimum         = 0,
                Value           = 30,
                WidthRequest    = 100,
                BackgroundColor = Color.Pink
            };

            padi.ValueChanged += (s, e) => {
                var peek = padi.Value;

                if (orientation == ItemsLayoutOrientation.Horizontal)
                {
                    carouselView.PeekAreaInsets = new Thickness(peek, 0, peek, 0);
                }
                else
                {
                    carouselView.PeekAreaInsets = new Thickness(0, peek, 0, peek);
                }
            };

            stckPeek.Children.Add(padi);
            stacklayoutInfo.Children.Add(stckPeek);
            stacklayoutInfo.Children.Add(_scrollInfoLabel);

            var content = new Grid();

            content.Children.Add(carouselView);

#if DEBUG
            // Uncomment this line to add a helper to visualize the center of each element.
            //content.Children.Add(CreateDebuggerLines());
#endif

            layout.Children.Add(content);

            Grid.SetRow(positionControl, 1);
            Grid.SetRow(stacklayoutInfo, 2);
            Grid.SetRow(spacingModifier, 3);
            Grid.SetRow(content, 4);

            Content = layout;
            generator.CollectionChanged += (sender, e) => {
                positionControl.UpdatePositionCount(generator.Count);
            };

            generator.GenerateItems();
        }
Example #36
0
        public App()
        {
            // The root page of your application
            var btn = new Button {
                Text = "Say Hello"
            };
            var queueBtn = new Button {
                Text = "Test Queue"
            };
            var lbl = new Label {
                TextColor = Color.Red
            };

            var volumeSlider = new Xamarin.Forms.Slider(0, 1, 1);

            var volumeSwitch = new Switch();


            queueBtn.Command = new Command(async() =>
            {
                lbl.Text = "";
                try
                {
                    if (cancelSrc == null)
                    {
                        queueBtn.Text = "Cancel Test Queue";
                        cancelSrc     = new CancellationTokenSource();
                        float?vol     = null;
                        if (volumeSwitch.IsToggled)
                        {
                            vol = (float)volumeSlider.Value;
                        }

                        await Task.WhenAll(
                            CrossTextToSpeech.Current.Speak("Queue 1", lang, volume: vol, cancelToken: cancelSrc.Token),
                            CrossTextToSpeech.Current.Speak("Queue 2", lang, volume: vol, cancelToken: cancelSrc.Token),
                            CrossTextToSpeech.Current.Speak("Queue 3", lang, volume: vol, cancelToken: cancelSrc.Token),
                            CrossTextToSpeech.Current.Speak("Queue 4", lang, volume: vol, cancelToken: cancelSrc.Token),
                            CrossTextToSpeech.Current.Speak("Queue 5", lang, volume: vol, cancelToken: cancelSrc.Token)
                            );
                    }
                    else
                    {
                        cancelSrc.Cancel();
                    }
                }
                catch (OperationCanceledException)
                {
                    lbl.Text = "You cancelled it";
                }
                catch (Exception ex)
                {
                    lbl.Text = ex.ToString();
                }
                finally
                {
                    queueBtn.Text = "Test Queue";
                    cancelSrc     = null;
                }
            });



            btn.Command = new Command(async() =>
            {
                lbl.Text = string.Empty;
                btn.Text = "Cancel Speech";
                try
                {
                    if (cancelSrc == null)
                    {
                        cancelSrc = new CancellationTokenSource();
                        float?vol = null;
                        if (volumeSwitch.IsToggled)
                        {
                            vol = (float)volumeSlider.Value;
                        }
                        await CrossTextToSpeech.Current.Speak(MSG, lang, volume: vol, cancelToken: cancelSrc.Token);
                        cancelSrc = null;
                    }
                    else
                    {
                        cancelSrc.Cancel();
                    }
                }
                catch (OperationCanceledException)
                {
                    lbl.Text = "You cancelled it";
                }
                catch (Exception ex)
                {
                    lbl.Text = ex.ToString();
                }
                finally
                {
                    btn.Text  = "Say Hello";
                    cancelSrc = null;
                }
            });



            var language = new Label
            {
                Text = "Default language"
            };



            var pickLanguage = new Button
            {
                Text    = "Pick Language",
                Command = new Command(async() =>
                {
                    var items     = await CrossTextToSpeech.Current.GetInstalledLanguages();
                    var result    = await MainPage.DisplayActionSheet("Pick", "OK", null, items.Select(i => i.DisplayName).ToArray());
                    lang          = items.FirstOrDefault(i => i.DisplayName == result);
                    language.Text = (result == "OK" || string.IsNullOrEmpty(result)) ? "Default" : result;
                })
            };


            var content = new ContentPage
            {
                Title   = "Samples",
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        btn,
                        queueBtn,
                        lbl,
                        language,
                        pickLanguage,
                        new Label {
                            Text = "volume"
                        },
                        volumeSlider,
                        new Label {
                            Text = "use custom volume"
                        },
                        volumeSwitch
                    }
                }
            };

            MainPage = new NavigationPage(content);
        }
Example #37
0
		public ScaleRotate()
		{
			Label label = new Label
			{
				Text = "SCALE AND\nROTATE",
				HorizontalTextAlignment = TextAlignment.Center,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			// Label and Slider for Scale property.
			Label scaleSliderValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(scaleSliderValue, 0);
			Grid.SetColumn(scaleSliderValue, 0);

			Slider scaleSlider = new Slider
			{
				Maximum = 10
			};
			Grid.SetRow(scaleSlider, 0);
			Grid.SetColumn(scaleSlider, 1);

			// Set Bindings.
			scaleSliderValue.BindingContext = scaleSlider;
			scaleSliderValue.SetBinding(Label.TextProperty, 
				new Binding("Value", BindingMode.OneWay, null, null, "Scale = {0:F1}"));

			scaleSlider.BindingContext = label;
			scaleSlider.SetBinding(Slider.ValueProperty,
				new Binding("Scale", BindingMode.TwoWay));

			// Label and Slider for Rotation property.
			Label rotationSliderValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(rotationSliderValue, 1);
			Grid.SetColumn(rotationSliderValue, 0);

			Slider rotationSlider = new Slider
			{
				Maximum = 360
			};
			Grid.SetRow(rotationSlider, 1);
			Grid.SetColumn(rotationSlider, 1);

			// Set Bindings.
			rotationSliderValue.BindingContext = rotationSlider;
			rotationSliderValue.SetBinding(Label.TextProperty,
				new Binding("Value", BindingMode.OneWay, null, null, "Rotation = {0:F0}"));

			rotationSlider.BindingContext = label;
			rotationSlider.SetBinding(Slider.ValueProperty,
				new Binding("Rotation", BindingMode.TwoWay));

			// Label and Slider for AnchorX property.
			Label anchorxStepperValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(anchorxStepperValue, 2);
			Grid.SetColumn(anchorxStepperValue, 0);

			Stepper anchorxStepper = new Stepper
			{
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow(anchorxStepper, 2);
			Grid.SetColumn(anchorxStepper, 1);

			// Set bindings.
			anchorxStepperValue.BindingContext = anchorxStepper;
			anchorxStepperValue.SetBinding(Label.TextProperty,
				new Binding("Value", BindingMode.OneWay, null, null, "AnchorX = {0:F1}"));

			anchorxStepper.BindingContext = label;
			anchorxStepper.SetBinding(Stepper.ValueProperty, 
				new Binding("AnchorX", BindingMode.TwoWay));

			// Label and Slider for AnchorY property.
			Label anchoryStepperValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(anchoryStepperValue, 3);
			Grid.SetColumn(anchoryStepperValue, 0);

			Stepper anchoryStepper = new Stepper
			{
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow(anchoryStepper, 3);
			Grid.SetColumn(anchoryStepper, 1);

			// Set bindings.
			anchoryStepperValue.BindingContext = anchoryStepper;
			anchoryStepperValue.SetBinding(Label.TextProperty,
				new Binding("Value", BindingMode.OneWay, null, null, "AnchorY = {0:F1}"));

			anchoryStepper.BindingContext = label;
			anchoryStepper.SetBinding(Stepper.ValueProperty, 
				new Binding("AnchorY", BindingMode.TwoWay));

			// Assemble the page.
			Content = new StackLayout
			{
				Children =
				{
					label,
					new Grid
					{
						Padding = 10,
						RowDefinitions = 
						{
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
						},
						ColumnDefinitions = 
						{
							new ColumnDefinition { Width = GridLength.Auto },
							new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)}
						},
						Children = 
						{
							scaleSliderValue,
							scaleSlider,
							rotationSliderValue,
							rotationSlider,
							anchorxStepperValue, 
							anchorxStepper,
							anchoryStepperValue,
							anchoryStepper
						}
					}
				}
			};
		}
Example #38
0
        //METHODS

        /**********************************************************************
         *********************************************************************/
        void CreateContent()
        {
            var scrollView = new Xamarin.Forms.ScrollView
            {
                Margin = new Thickness(10)
            };
            var stackLayout = new StackLayout();

            var stackLayout2 = new StackLayout
            {
                Orientation = StackOrientation.Horizontal
            };

            var stackLayout3 = new StackLayout
            {
                Orientation = StackOrientation.Horizontal
            };

            this.Content       = scrollView;
            scrollView.Content = stackLayout;             //Wrap ScrollView around StackLayout to be able to scroll the content

            //define and add elements to stacklayout
            var l_Strategy = new Label {
                Text = "Strategy", FontSize = App._h3FontSize
            };

            p_Strategy = new Xamarin.Forms.Picker()
            {
                FontSize = App._textFontSize
            };
            p_Strategy.Items.Add("Go Back N");
            p_Strategy.Items.Add("Selective Repeat");
            p_Strategy.SelectedIndex = 0;//Go Back N
            var l_Space = new Label {
                Text = "  "
            };

            var l_WindowSize = new Label {
                Text = "Window Size", FontSize = App._h3FontSize
            };

            p_WindowSize = new Xamarin.Forms.Picker()
            {
                FontSize = App._textFontSize
            };
            p_WindowSize.Items.Add("2");
            p_WindowSize.Items.Add("3");
            p_WindowSize.Items.Add("4");
            p_WindowSize.Items.Add("5");
            p_WindowSize.SelectedIndex = 3;//5
            var l_Space2 = new Label {
                Text = "  "
            };

            var l_Timeout = new Label {
                Text = "Timeout =", FontSize = App._h3FontSize
            };

            l_TimeoutValue = new Label {
                Text = "11", VerticalOptions = LayoutOptions.Center, FontSize = App._textFontSize
            };
            s_Timeout = new Xamarin.Forms.Slider(11, 20, 11); //min, max, val
            s_Timeout.HorizontalOptions = LayoutOptions.FillAndExpand;
            s_Timeout.ValueChanged     += S_Timeout_ValueChanged;;
            //s_Timeout.Minimum = 0.0f; //minimum roundtrip time
            //s_Timeout.Maximum = 10.0f; //maximum roundtrip time
            var l_TimeoutMi = new Label {
                VerticalOptions = LayoutOptions.Center,
                FontSize        = App._textFontSize,
                Text            = "11"
            };
            var l_TimeoutMa = new Label {
                VerticalOptions = LayoutOptions.Center,
                FontSize        = App._textFontSize,
                Text            = "20"
            };
            var l_RoundtripTime = new Label {
                FontSize = App._smallTextFontSize,
                Text     = "Round Trip Time: 10"
            };
            var l_Space3 = new Label {
                Text = "  "
            };

            var b_Start = new Button {
                Text            = "Start",
                BackgroundColor = App._buttonBackground,
                TextColor       = App._buttonText,
                CornerRadius    = App._buttonCornerRadius,
                FontSize        = App._buttonFontSize
            };

            b_Start.Clicked += B_Start_Clicked;             //add Click Event(Method)

            stackLayout3.Children.Add(l_Timeout);
            stackLayout3.Children.Add(l_TimeoutValue);

            stackLayout2.Children.Add(l_TimeoutMi);
            stackLayout2.Children.Add(s_Timeout);
            stackLayout2.Children.Add(l_TimeoutMa);

            stackLayout.Children.Add(l_Strategy);
            stackLayout.Children.Add(p_Strategy);
            stackLayout.Children.Add(l_Space);
            stackLayout.Children.Add(l_WindowSize);
            stackLayout.Children.Add(p_WindowSize);
            stackLayout.Children.Add(l_Space2);
            stackLayout.Children.Add(stackLayout3);
            stackLayout.Children.Add(stackLayout2);
            stackLayout.Children.Add(l_RoundtripTime);
            stackLayout.Children.Add(l_Space3);
            stackLayout.Children.Add(b_Start);
        }
Example #39
0
        public MainPage()
        {
            Xamarin.Forms.NavigationPage.SetHasNavigationBar(this, false);
            On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

            BackgroundColor = Color.Black;

            var grid = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition(),
                    new ColumnDefinition()
                },
                RowSpacing = 0
            };

            _captionLabel = new Label()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.Silver,
                Text    = "Tap Start To Run",
                Padding = new Thickness(5),
                HorizontalTextAlignment = TextAlignment.Center
            };

            Grid.SetColumnSpan(_captionLabel, 2);
            grid.Children.Add(_captionLabel);


            _absoluteLayout = new AbsoluteLayout()
            {
                BackgroundColor = Color.Black, IsClippedToBounds = true
            };

            Grid.SetRow(_absoluteLayout, 1);
            Grid.SetColumnSpan(_absoluteLayout, 2);
            grid.Children.Add(_absoluteLayout);

            _startButton = new Button()
            {
                Text = "Start", Margin = new Thickness(10), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
            };
            _startButton.Clicked += StartButton_Clicked;
            Grid.SetRow(_startButton, 2);
            Grid.SetColumn(_startButton, 0);

            _stopButton = new Button()
            {
                Text = "Stop", Margin = new Thickness(10), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center
            };
            _stopButton.Clicked += StopButton_Clicked;
            Grid.SetRow(_stopButton, 2);
            Grid.SetColumn(_stopButton, 1);

            _theshholdLabel = new Label()
            {
                Text                    = $"Threshold: {Threshold}",
                TextColor               = Color.Orange,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            Grid.SetRow(_theshholdLabel, 2);
            Grid.SetColumnSpan(_theshholdLabel, 2);

            var stackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = Color.Orange,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End,
            };

            _checkReuseChildren = new CheckBox()
            {
                IsChecked = true
            };
            stackLayout.Children.Add(_checkReuseChildren);
            stackLayout.Children.Add(new Label {
                Text = "Re-Use Children on Threshold", TextColor = Color.White, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, 10, 0)
            });

            Grid.SetRow(stackLayout, 2);
            Grid.SetColumnSpan(stackLayout, 2);

            grid.Children.Add(_startButton);
            grid.Children.Add(_stopButton);
            grid.Children.Add(_theshholdLabel);
            grid.Children.Add(stackLayout);

            var slider = new Xamarin.Forms.Slider
            {
                Maximum = ThresholdMax,
                Minimum = ThresholdMin,
                Value   = Threshold
            };

            slider.ValueChanged += Slider_ValueChanged;
            Grid.SetRow(slider, 3);
            Grid.SetColumnSpan(slider, 2);

            grid.Children.Add(slider);

            Content = grid;

            _random    = new Random(1);
            _stopWatch = new Stopwatch();
        }
        public App() {
            var resourcePicker = new Picker() {
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            foreach (var resourceName in TestModel.AvailableResourceNames) {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider() {
                Minimum = 0,
                Maximum = 35,
                Value = _ViewModel.AllSidesInset,
            };
            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImageView() {
                SvgAssembly = typeof(App).GetTypeInfo().Assembly,
                SvgPath = _ViewModel.SvgResourcePath,
                WidthRequest = 300,
                HeightRequest = 300,
            };
            slicingSvg.SetBinding(SvgImageView.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImageView.SvgPathProperty, nameof(TestModel.SvgResourcePath));

            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        resourcePicker,
                        insetSlider,
                        slicingSvg,
                    },
                    BindingContext = _ViewModel,
                },
            };
        }
Example #41
0
        private void DrawOptionsPage()
        {
            toggleButton = new Xamarin.Forms.Slider();
            toggleButton.MinimumTrackColor = Color.FromHex("#177CE7");
            toggleButton.MaximumTrackColor = Color.DarkGray;
            toggleButton.ThumbColor        = Color.FromHex("#1a1aff");
            toggleButton.Value             = 2;
            toggleButton2               = new Xamarin.Forms.Slider();
            toggleButton2.Value         = 2;
            toggleButton.Maximum        = 20;
            toggleButton2.Maximum       = 20;
            toggleButton2.ValueChanged += (object sender, ValueChangedEventArgs e) =>
            {
                //groupGap = e.NewValue;
            };
            toggleButton.ValueChanged += (object sender, ValueChangedEventArgs e) => {
                groupPadding = e.NewValue;
                ApplyChanges();
            };
            picker1 = new Picker();
            picker2 = new Picker();
            picker1.Items.Add("Squarified");
            picker1.Items.Add("Slice And Dice Horizontal");
            picker1.Items.Add("Slice And Dice Vertical");
            picker1.Items.Add("Slice And Dice Auto");
            picker1.HeightRequest         = 40;
            picker1.SelectedIndex         = 0;
            picker1.SelectedIndexChanged += picker1_SelectedIndexChanged;


            picker2.Items.Add("RangeColorMapping");
            picker2.Items.Add("DesaturationColorMapping");
            picker2.Items.Add("UniColorMapping");
            picker2.Items.Add("PaletteColorMapping");
            picker2.HeightRequest = 40;
            picker2.SelectedIndex = 0;

            picker2.SelectedIndexChanged += picker2_SelectedIndexChanged;



            label6 = new Label()
            {
                Text                  = " " + "Settings",
                FontSize              = 60,
                HeightRequest         = 60,
                VerticalTextAlignment = TextAlignment.End,
            };
            label3 = new Label()
            {
                Text                  = "Layout Type",
                HeightRequest         = 20,
                VerticalTextAlignment = TextAlignment.End,
            };
            label4 = new Label()
            {
                Text                  = "Color Mapping",
                HeightRequest         = 20,
                VerticalTextAlignment = TextAlignment.End,
            };
            label5 = new Label()
            {
                Text                  = "Group Padding",
                HeightRequest         = 30,
                VerticalTextAlignment = TextAlignment.Center,
            };
            label9 = new Label()
            {
                Text                  = "Group Gap",
                HeightRequest         = 20,
                VerticalTextAlignment = TextAlignment.Center,
            };


            if (Device.RuntimePlatform == Device.Android)
            {
                picker1.BackgroundColor = Color.FromRgb(239, 239, 239);
                picker2.BackgroundColor = Color.FromRgb(239, 239, 239);
                label3.FontSize         = 20;
                label4.FontSize         = 20;
                label5.FontSize         = 20;
            }
            //label10.WidthRequest = tree.Width;
            //label11.WidthRequest = tree.Width;
            label5.WidthRequest = label9.Width;
            if (Device.RuntimePlatform == Device.UWP && Device.Idiom == TargetIdiom.Phone)
            {
                label5.WidthRequest = 150;
                label9.WidthRequest = 150;

                picker1.HeightRequest = 60;
                picker2.HeightRequest = 60;



                FileImageSource images = new FileImageSource();
                images.File          = "options.png";
                baritem.Icon         = images;
                label3.Text          = "  " + "Layout Type";
                label3.HeightRequest = 22;
                label4.Text          = "  " + "Color Mapping";
                label4.HeightRequest = 22;
                label5.Text          = "  " + "Group Padding";
                label5.HeightRequest = 22;

                label9.TextColor = Color.White;
            }
            if (Device.RuntimePlatform == Device.iOS)
            {
                picker1.HeightRequest = 0;
                label3.Text           = "";
            }
        }
Example #42
0
        public IndicatorCodeGallery()
        {
            Title = "IndicatorView Gallery";

            On <iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never);

            var nItems = 10;

            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            var itemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var itemTemplate = ExampleTemplates.CarouselTemplate();

            var carouselView = new CarouselView
            {
                ItemsLayout     = itemsLayout,
                ItemTemplate    = itemTemplate,
                BackgroundColor = Color.LightGray,
                AutomationId    = "TheCarouselView"
            };

            layout.Children.Add(carouselView);

            var generator = new ItemsSourceGenerator(carouselView, nItems, ItemsSourceType.ObservableCollection);

            layout.Children.Add(generator);

            generator.GenerateItems();

            var indicatorView = new IndicatorView
            {
                HorizontalOptions      = LayoutOptions.Center,
                Margin                 = new Thickness(12, 6, 12, 12),
                IndicatorColor         = Color.Gray,
                SelectedIndicatorColor = Color.Black,
                IndicatorsShape        = IndicatorShape.Square,
                AutomationId           = "TheIndicatorView"
            };

            carouselView.IndicatorView = indicatorView;

            layout.Children.Add(indicatorView);

            var stckColors = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckColors.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorColor"
            });

            var colors = new List <string>
            {
                "Black",
                "Blue",
                "Red"
            };

            var colorsPicker = new Xamarin.Forms.Picker
            {
                ItemsSource  = colors,
                WidthRequest = 150
            };

            colorsPicker.SelectedIndex = 0;

            colorsPicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = colorsPicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorColor = Color.Black;
                    break;

                case 1:
                    indicatorView.IndicatorColor = Color.Blue;
                    break;

                case 2:
                    indicatorView.IndicatorColor = Color.Red;
                    break;
                }
            };

            stckColors.Children.Add(colorsPicker);

            layout.Children.Add(stckColors);

            var stckTemplate = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckTemplate.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorTemplate"
            });

            var templates = new List <string>
            {
                "Circle",
                "Square",
                "Template"
            };

            var templatePicker = new Xamarin.Forms.Picker
            {
                ItemsSource  = templates,
                WidthRequest = 150,
                TextColor    = Color.Black
            };

            templatePicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = templatePicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Circle;
                    break;

                case 1:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Square;
                    break;

                case 2:
                    indicatorView.IndicatorTemplate = ExampleTemplates.IndicatorTemplate();
                    break;
                }
            };

            templatePicker.SelectedIndex = 0;

            stckTemplate.Children.Add(templatePicker);

            layout.Children.Add(stckTemplate);

            var stckSize = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckSize.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "Indicator Size"
            });

            indicatorView.IndicatorSize = 10;

            var sizeSlider = new Xamarin.Forms.Slider
            {
                WidthRequest      = 150,
                Value             = indicatorView.IndicatorSize,
                MaximumTrackColor = Color.Gray,
                Maximum           = 20,
                MinimumTrackColor = Color.LightGray,
                Minimum           = 1
            };

            sizeSlider.ValueChanged += (s, e) =>
            {
                var indicatorSize = sizeSlider.Value;
                indicatorView.IndicatorSize = indicatorSize;
            };

            stckSize.Children.Add(sizeSlider);

            layout.Children.Add(stckSize);

            Grid.SetRow(generator, 0);
            Grid.SetRow(stckColors, 1);
            Grid.SetRow(stckTemplate, 2);
            Grid.SetRow(stckSize, 3);
            Grid.SetRow(carouselView, 4);
            Grid.SetRow(indicatorView, 5);

            Content = layout;
        }
Example #43
0
        public PlayerView()
        {
            var clipTitleLabel = new Label()
            {
                Text = "CLIP TITLE",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                TextColor = Color.White,
                BackgroundColor = Color.Black,
                XAlign = TextAlignment.Center
            };

            var currentStateLabel = new Label() { TextColor = Color.Red, BackgroundColor = Color.Black };

            var playPauseBtn = new Button() { Text = "Pause" };
            var nextBtn = new Button() { Text = "Next" };
            var prevBtn = new Button() { Text = "Prev" };

            var informLayout = new StackLayout
            {
                Spacing = 20,
                Orientation = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                IsVisible = false,
                Children = { clipTitleLabel, currentStateLabel, playPauseBtn, nextBtn, prevBtn }
            };

            var button = new Button()
            {
                Text = "Load playlist and play",
                TextColor = Color.White,
                BackgroundColor = Color.Gray,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            button.Clicked += OnButtonClicked;

            var buttonLargeList = new Button()
            {
                Text = "Load large playlist and play",
                TextColor = Color.White,
                BackgroundColor = Color.Gray,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonLargeList.Clicked += OnButtonLargeListClicked;

            var buttonWMV = new Button()
            {
                Text = "Load WMV file and play",
                TextColor = Color.White,
                BackgroundColor = Color.Gray,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonWMV.Clicked += OnButtonWMVListClicked;

            playerSlider = new Slider()
            {
                VerticalOptions = LayoutOptions.End,
                BackgroundColor = Color.Black,
                Value = 0
            };

            mediaPlayer = new Player();

            playerSlider.BindingContext = mediaPlayer;
            playerSlider.SetBinding(Slider.MaximumProperty, "CurrentVideoDuration", BindingMode.Default, new TimeConverter());
            //playerSlider.SetBinding(Slider.ValueProperty, "Position", BindingMode.TwoWay, new TimeConverter());

            mediaPlayer.CurrentStateChanged += delegate(object sender, StateChangedEventArgs e)
            {
                if (e.NewAction == HyperMediaStateAction.PlayerPlayedToEndOfVideo)
                {
                    mediaPlayer.Next();
                }
                currentStateLabel.Text = mediaPlayer.CurrentPlayerState.ToString();
                playPauseBtn.Text = mediaPlayer.CurrentPlayerState == HyperMediaPlayerState.Playing ? "Pause" : "Play"; ;
            };

            mediaPlayer.PlaylistItemLoaded += delegate(object sender, EventArgs e)
            {
                if (!informLayout.IsVisible) informLayout.IsVisible = true;
                if (mediaPlayer.CurrentItem == null) return;
                clipTitleLabel.Text = mediaPlayer.CurrentItem.Title;
            };

            mediaPlayer.PositionChanged += delegate(object sender, PositionChangedArgs e)
            {
                lockPlayerSliderChangeValueEvent = true;
                playerSlider.Value = e.NewPosition.TotalMilliseconds;
                lockPlayerSliderChangeValueEvent = false;
            };

            /*playerSlider.ValueChanged += delegate(object sender, ValueChangedEventArgs e)
            {
                if (lockPlayerSliderChangeValueEvent) return;
                var delta = e.NewValue - e.OldValue;
                mediaPlayer.SeekBy(new TimeSpan(0, 0, 0, 0, (int)delta));
            };*/

            nextBtn.Clicked += delegate(object sender, EventArgs e)
            {
                mediaPlayer.Next();
            };
            prevBtn.Clicked += delegate(object sender, EventArgs e)
            {
                mediaPlayer.Prev();
            };

            playPauseBtn.Clicked += delegate(object sender, EventArgs e)
            {
                if (mediaPlayer.CurrentPlayerState == HyperMediaPlayerState.Playing)
                    mediaPlayer.Pause();
                else mediaPlayer.Play();
            };

            Content = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    informLayout,
                    button,
                    buttonLargeList,
                    buttonWMV,
                    playerSlider,
                    mediaPlayer,
                }
            };
            Padding = new Thickness(0, 20, 0, 0);
        }
        public SliderHandler(NativeComponentRenderer renderer, XF.Slider sliderControl) : base(renderer, sliderControl)
        {
            SliderControl = sliderControl ?? throw new ArgumentNullException(nameof(sliderControl));

            Initialize(renderer);
        }
Example #45
0
        public MapPage()
        {
            GetPositions();
            map = new Map
            {
                HeightRequest   = 100,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            var position = new Position(Lattitude, Longitude);
            var pin      = new Pin
            {
                Position = position,
                Address  = "TEK-UP Adress",
                Label    = "TEK-UP",
                Type     = PinType.Place
            };
            var pos2 = new Position(36.9029481, 10.1452774);
            var pos3 = new Position(36.8608634, 10.1644176);
            var pos4 = new Position(36.8678495, 10.1712841);
            var pin2 = new Pin
            {
                Position = pos2,
                Address  = "Location 2",
                Label    = "TEK-UP",
                Type     = PinType.Generic
            };
            var pin3 = new Pin
            {
                Position = pos3,
                Address  = "Location 3",
                Label    = "TEK-UP",
                Type     = PinType.SavedPin
            };
            var pin4 = new Pin
            {
                Position = pos4,
                Address  = "Location 4",
                Label    = "TEK-UP",
                Type     = PinType.SearchResult
            };

            map.Pins.Add(pin);
            map.Pins.Add(pin2);
            map.Pins.Add(pin3);
            map.Pins.Add(pin4);
            map.MoveToRegion(new MapSpan(position, 360, 360));
            var slider = new Xamarin.Forms.Slider(1, 18, 1);

            slider.ValueChanged += (sender, e) =>
            {
                var zoomLevel = e.NewValue;
                var degree    = 360 / (Math.Pow(2, zoomLevel));
                if (map.VisibleRegion != null)
                {
                    map.MoveToRegion(new MapSpan(map.VisibleRegion.Center, degree, degree));
                }
            };

            var streetBtn = new Button {
                Text = "Street"
            };

            var hybridBtn = new Button {
                Text = "Hybrid"
            };

            var steliteBtn = new Button {
                Text = "Satellite"
            };

            streetBtn.Clicked  += ChangeViewMap;
            hybridBtn.Clicked  += ChangeViewMap;
            steliteBtn.Clicked += ChangeViewMap;

            var stackBtn = new StackLayout
            {
                Spacing           = 30,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Children          = { streetBtn, hybridBtn, steliteBtn }
            };
            var stackPage = new StackLayout {
                Spacing = 0
            };

            stackPage.Children.Add(map);
            stackPage.Children.Add(slider);
            stackPage.Children.Add(stackBtn);
            Content = stackPage;
        }
Example #46
0
        public override View GetView(int index)
        {
            string tipText = "  Please select a value below.";

            if (base.GetView(index) == null && _maximum > _minimum)
            {
                _slider = new Slider
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Minimum = double.MinValue,
                    Maximum = double.MaxValue

                    // set the style ID on the view so that we can retrieve it when unit testing
                    #if UNIT_TESTING
                    , StyleId = Name
                    #endif
                };

                _slider.Minimum = _minimum;
                _slider.Maximum = _maximum;
                _slider.Value = _incrementalValue = GetIncrementalValue((_maximum - _minimum) / 2d);
                _incrementalValueHasChanged = false;

                _sliderLabel = CreateLabel(index);
                _sliderLabel.Text += tipText;

                _slider.ValueChanged += (o, e) =>
                {
                    double newIncrementalValue = GetIncrementalValue(_slider.Value);

                    if (newIncrementalValue != _incrementalValue)
                    {
                        _incrementalValue = newIncrementalValue;
                        _incrementalValueHasChanged = true;
                        _sliderLabel.Text = GetLabelText(index) + "  " + _incrementalValue;
                        Complete = Value != null;
                    }
                };

                base.SetView(new StackLayout
                    {
                        Orientation = StackOrientation.Vertical,
                        VerticalOptions = LayoutOptions.Start,
                        Children =
                        { 
                            _sliderLabel,
                            new StackLayout
                            {
                                Orientation = StackOrientation.Horizontal,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                                Children =
                                {
                                    new Label
                                    {
                                        Text = _minimum.ToString(),
                                        FontSize = 20,
                                        HorizontalOptions = LayoutOptions.Fill
                                    },
                                    _slider,
                                    new Label
                                    {
                                        Text = _maximum.ToString(),
                                        FontSize = 20,
                                        HorizontalOptions = LayoutOptions.Fill
                                    }
                                }
                            }
                        }
                    });
            }
            else
            {
                if (Enabled)
                {
                    // if the view was already initialized and is enabled, just update the label since the index might have changed.
                    _sliderLabel.Text = GetLabelText(index) + "  " + (_incrementalValueHasChanged ? _incrementalValue.ToString() : tipText);
                }
                else
                {
                    // if the view was already initialized but is not enabled and has never been interacted with, there should be no tip text since the user can't do anything with the slider.
                    if (!_incrementalValueHasChanged)
                    {
                        _slider.Value = _minimum;
                        _sliderLabel.Text = GetLabelText(index) + "  No value selected.";
                    }
                }                
            }

            return base.GetView(index);
        }