public override void ViewDidLoad()
        {
            System.Diagnostics.Debug.WriteLine("ModeAstroStatusViewController ViewDidLoad");

            Vm = (ModeAstroViewModel)NavigationParameter;

            CancelButton.Clicked += (sender, e) =>
            {
                PauseResumeButton.Enabled = false;
                CancelButton.Enabled = false;

                _canceled = true;
                Vm.StopProgramCommand.Execute(null);
            };

            PauseResumeButton.Clicked += (sender, e) =>
            {
                PauseResumeButton.Enabled = false;
                CancelButton.Enabled = false;

                switch (DeviceVm.RunStatus)
                {
                    case MoCoBusRunStatus.Paused:
                        Vm.StartProgramCommand.Execute(null);
                        break;
                    case MoCoBusRunStatus.Running:
                        Vm.PauseProgramCommand.Execute(null);
                        break;
                }
            };

            SetupBindings();

            base.ViewDidLoad();
        }
Пример #2
0
        public DeviceViewModel(IDispatcherHelper dispatcherHelper, 
                               INavigationService navigationService, 
                               IDevice device, 
                               Func<IDevice, IMoCoBusCommService> moCoBusCommServiceFactory, 
                               Func<IMoCoBusCommService, byte, IMoCoBusProtocolService> moCoBusProtocolServiceFactory)
        {
            _dispatcherHelper = dispatcherHelper;
            _navigationService = navigationService;

            _commService = moCoBusCommServiceFactory(device);
            _commService.ConnectionChanged += CommServiceOnConnectionChanged;

            _protocolService = moCoBusProtocolServiceFactory(_commService, 3);

            ModeAstroViewModel = new ModeAstroViewModel(_dispatcherHelper, this, _protocolService);
            ModePanoViewModel = new ModePanoViewModel(_dispatcherHelper, this, _protocolService);
            ModeSmsViewModel = new ModeSmsViewModel(_dispatcherHelper, this, _protocolService);

            JoystickViewModel = new JoystickViewModel(this, _protocolService);
        }
        public override void ViewDidLoad()
        {
            System.Diagnostics.Debug.WriteLine("ModeAstroViewController ViewDidLoad");

            Vm = (ModeAstroViewModel)NavigationParameter;

            Vm.PropertyChanged += (s, e) =>
            {
            };

            var tableView = (UITableView)View;
            tableView.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
            tableView.BackgroundView = null;
            tableView.AllowsSelection = true;

            _hemispherePickerViewModel = new ListPickerViewModel<string>(new[] { "North", "South" });
            _hemispherePickerViewModel.ValueChanged += (sender, e) =>
                {
                    var t = (AstroDirection)_hemispherePickerViewModel.SelectedIndex;
                    if (Vm.Direction != t)
                        Vm.Direction = t;
                };
            HemisphereValuePickerView.Model = _hemispherePickerViewModel;

            _speedPickerViewModel = new ListPickerViewModel<string>(new[] { "Sidereal/Stars", "Lunar" });
            _speedPickerViewModel.ValueChanged += (sender, e) =>
                {
                    var t = (AstroSpeed)_speedPickerViewModel.SelectedIndex;
                    if (Vm.Speed != t)
                        Vm.Speed = t;
                };
            SpeedValuePickerView.Model = _speedPickerViewModel;

            StartButton.Clicked += (sender, e) =>
                {
                    _navigatedToStatusView = true;
                    Vm.StartProgramCommand.Execute(null);
                    ServiceLocator.Current.GetInstance<INavigationService>().NavigateTo(AppDelegate.ModeAstroStatusViewKey, Vm);
                };

            SetupBindings();

            base.ViewDidLoad();
        }