Ejemplo n.º 1
0
		public override CGSize SizeThatFits(CGSize size)
		{
			var dec = DecrementButton.SizeThatFits(CGSize.Empty);
			var inc = IncrementButton.SizeThatFits(CGSize.Empty);
			var btn = new CGSize(
				Math.Max(dec.Width, inc.Width),
				Math.Max(dec.Height, inc.Height));
			return new CGSize(btn.Width * 2 + DefaultButtonSpacing, btn.Height);
		}
Ejemplo n.º 2
0
        public CounterPage()
        {
            InitializeComponent();

            // Observe changes on state
            Store.Select(SelectCount)
            .UntilDestroyed(this)
            .Subscribe(count =>
            {
                CounterValueTextBlock.Text = count.ToString();
            });

            // Observe UI events
            IncrementButton.Events().Click
            .Subscribe(_ => Store.Dispatch(new IncrementAction()));

            DecrementButton.Events().Click
            .Subscribe(_ => Store.Dispatch(new DecrementAction()));

            // Initialize Documentation
            DocumentationComponent.LoadMarkdownFilesAsync("Counter");

            GoToGitHubButton.Events().Click
            .Subscribe(async _ =>
            {
                var uri = new Uri("https://github.com/Odonno/ReduxSimple/tree/master/ReduxSimple.Samples/Counter");
                await Launcher.LaunchUriAsync(uri);
            });

            OpenDevToolsButton.Events().Click
            .Subscribe(async _ =>
            {
                await Store.OpenDevToolsAsync();
            });

            ContentGrid.Events().Tapped
            .Subscribe(_ => DocumentationComponent.Collapse());
            DocumentationComponent.ObserveOnExpanded()
            .Subscribe(_ => ContentGrid.Blur(5).Start());
            DocumentationComponent.ObserveOnCollapsed()
            .Subscribe(_ => ContentGrid.Blur(0).Start());
        }
Ejemplo n.º 3
0
        void ReleaseDesignerOutlets()
        {
            if (Count != null)
            {
                Count.Dispose();
                Count = null;
            }

            if (IncrementButton != null)
            {
                IncrementButton.Dispose();
                IncrementButton = null;
            }

            if (DecrementButton != null)
            {
                DecrementButton.Dispose();
                DecrementButton = null;
            }
        }
Ejemplo n.º 4
0
        private void WireEvents(Action<string> returnString, Action<double> returnDouble) 
        {

            OKButton.Events().Clicked
                .Subscribe(x => PopupNavigation.Instance.PopAsync());

            IncrementButton.Events().Clicked
                .Subscribe(x =>
                {
                    if (StepMode == StepMode.Discrete)
                    {
                        if (slider.Value < Items.Count) slider.Value++;
                    } 
                    else if (StepMode == StepMode.Normal)
                    {
                        if (slider.Value + Step <= slider.Maximum) slider.Value += Step;
                    } else
                    {
                        // change by .1 percent
                        var increment = GetFriendlyIncrement();
                        var newValue = slider.Value + increment;
                        slider.Value = Math.Round(newValue / increment) * increment;
                    }
                });


            DecrementButton.Events().Clicked
                .Subscribe(x =>
                {
                    if (StepMode == StepMode.Discrete)
                    {
                        if (slider.Value < Items.Count) slider.Value--;
                    } 
                    else if (StepMode == StepMode.Normal)
                    {
                        if (slider.Value - Step >= slider.Minimum) slider.Value -= Step;
                    } else
                    {
                        // change by .1 percent
                        var increment = GetFriendlyIncrement();
                        var newValue = slider.Value - increment;
                        slider.Value = Math.Round(newValue / increment) * increment;
                    }
                });

            slider.Events().ValueChanged
                .SubscribeOnUI()
                //.Throttle(TimeSpan.FromMilliseconds(1))
                .Subscribe(X => 
                {
                    SetToNearestStep();
                    DrawSliderLabel();
                    if (returnDouble != null)
                    {
                        if (StepMode == StepMode.Discrete && double.TryParse(SelectedItem, out var dbl))
                        {
                            returnDouble(dbl);
                        }
                        else
                        {
                            returnDouble(slider.Value);
                        }
                    }
                    else if (returnString != null)
                    {
                        returnString((string)SelectedItem);
                    }
                });

            this.Events().LayoutChanged
                .SubscribeOnUI()
                .Subscribe(x => {
                    if (slider.Width > 0)
                    {
                        DrawTicks();
                        DrawSliderLabel();
                    }
                });
        }