Пример #1
0
 private void inputTexBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         IncrementButton.PerformClick();
         e.SuppressKeyPress = true;
         e.Handled          = true;
     }
 }
Пример #2
0
        void ReleaseDesignerOutlets()
        {
            if (TestView != null)
            {
                TestView.Dispose();
                TestView = null;
            }

            if (IncrementButton != null)
            {
                IncrementButton.Dispose();
                IncrementButton = null;
            }
        }
Пример #3
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());
        }
Пример #4
0
 void ReleaseDesignerOutlets()
 {
     if (ClockText != null)
     {
         ClockText.Dispose();
         ClockText = null;
     }
     if (DialogNavText != null)
     {
         DialogNavText.Dispose();
         DialogNavText = null;
     }
     if (IncrementButton != null)
     {
         IncrementButton.Dispose();
         IncrementButton = null;
     }
     if (NavigateButton != null)
     {
         NavigateButton.Dispose();
         NavigateButton = null;
     }
     if (SendMessageButton != null)
     {
         SendMessageButton.Dispose();
         SendMessageButton = null;
     }
     if (ShowDialogButton != null)
     {
         ShowDialogButton.Dispose();
         ShowDialogButton = null;
     }
     if (WelcomeText != null)
     {
         WelcomeText.Dispose();
         WelcomeText = null;
     }
 }
Пример #5
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();
                    }
                });
        }
Пример #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Illustrates how to use the Messenger by receiving a message
            // and sending a message back.
            Messenger.Default.Register <NotificationMessageAction <string> >(
                this,
                HandleNotificationMessage);

            // Binding and commanding

            // Binding between the first TextView and the WelcomeTitle property on the VM.
            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(
                this.SetBinding(
                    () => Vm.WelcomeTitle,
                    () => WelcomeText.Text));

            // Actuate the IncrementCommand on the VM.
            IncrementButton.SetCommand(
                "Click",
                Vm.IncrementCommand);

            // Create a binding that fires every time that the EditingChanged event is called
            var dialogNavBinding = this.SetBinding(
                () => DialogNavText.Text);

            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(dialogNavBinding);

            // Actuate the NavigateCommand on the VM.
            // This command needs a CommandParameter of type string.
            // This is what the dialogNavBinding provides.
            TapText.SetCommand(
                "Click",
                Vm.NavigateCommand,
                dialogNavBinding);

            // Actuate the ShowDialogCommand on the VM.
            // This command needs a CommandParameter of type string.
            // This is what the dialogNavBinding provides.
            // This button will be disabled when the content of DialogNavText
            // is empty (see ShowDialogCommand on the MainViewModel class).
            ShowDialogButton.SetCommand(
                "Click",
                Vm.ShowDialogCommand,
                dialogNavBinding);

            // Create a binding between the Clock property of the VM
            // and the ClockText TextView.
            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(this.SetBinding(
                              () => Vm.Clock,
                              () => ClockText.Text));

            // Actuate the SendMessageCommand on the VM.
            SendMessageButton.SetCommand(
                "Click",
                Vm.SendMessageCommand);
        }
Пример #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Dismiss the keyboard
            DialogNavText.ShouldReturn += t =>
            {
                t.ResignFirstResponder();
                return(true);
            };

            // Binding and commanding

            // Binding between the first UILabel and the WelcomeTitle property on the VM.
            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(
                this.SetBinding(
                    () => Vm.WelcomeTitle,
                    () => WelcomeText.Text));

            // Actuate the IncrementCommand on the VM.
            IncrementButton.SetCommand(
                "TouchUpInside",
                Vm.IncrementCommand);

            // Create a binding that fires every time that the EditingChanged event is called
            var dialogNavBinding = this.SetBinding(
                () => DialogNavText.Text)
                                   .UpdateSourceTrigger("EditingChanged");

            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(dialogNavBinding);

            // Actuate the NavigateCommand on the VM.
            // This command needs a CommandParameter of type string.
            // This is what the dialogNavBinding provides.
            NavigateButton.SetCommand(
                "TouchUpInside",
                Vm.NavigateCommand,
                dialogNavBinding);

            // Actuate the ShowDialogCommand on the VM.
            // This command needs a CommandParameter of type string.
            // This is what the dialogNavBinding provides.
            // This button will be disabled when the content of DialogNavText
            // is empty (see ShowDialogCommand on the MainViewModel class).
            ShowDialogButton.SetCommand(
                "TouchUpInside",
                Vm.ShowDialogCommand,
                dialogNavBinding);

            // Create a binding between the Clock property of the VM
            // and the ClockText UILabel.
            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(
                this.SetBinding(
                    () => Vm.Clock,
                    () => ClockText.Text));

            // Actuate the SendMessageCommand on the VM.
            SendMessageButton.SetCommand(
                "TouchUpInside",
                Vm.SendMessageCommand);
        }