public StatusIconTcVm()
 {
     StatusIconViewModel = new StatusIconViewModel()
     {
         IconState      = StatusIconState.Unlit,
         AdditionalText = "0.5",
     };
 }
Exemple #2
0
        public DashboardViewModel()
        {
            _refreshStopwatch  = Stopwatch.StartNew();
            EngineStatus       = new StatusIconViewModel();
            TransmissionStatus = new StatusIconViewModel();
            SuspensionStatus   = new StatusIconViewModel();
            BodyworkStatus     = new StatusIconViewModel();

            PitLimiterStatus    = new StatusIconViewModel();
            AlternatorStatus    = new StatusIconViewModel();
            TyreDirtStatus      = new StatusIconViewModel();
            DrsStatusIndication = new StatusIconViewModel();
            BoostIndication     = new StatusIconViewModel();
        }
Exemple #3
0
        private static void ApplyDamage(DamageInformation damageInformation, StatusIconViewModel viewModel)
        {
            viewModel.AdditionalText = damageInformation.Damage > 0 ? Math.Ceiling(damageInformation.Damage * 100).ToString("F0") : string.Empty;

            if (damageInformation.Damage < damageInformation.MediumDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Unlit;
                return;
            }

            if (damageInformation.Damage < damageInformation.HeavyDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Warning;
                return;
            }

            viewModel.IconState = StatusIconState.Error;
        }
Exemple #4
0
        private static void ApplyDamage(DamageInformation damageInformation, StatusIconViewModel viewModel)
        {
            viewModel.AdditionalText = damageInformation.Damage < 0.01 ? string.Empty : ((int)(damageInformation.Damage * 100)).ToString(CultureInfo.CurrentCulture);

            if (damageInformation.Damage < damageInformation.MediumDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Unlit;
                return;
            }

            if (damageInformation.Damage < damageInformation.HeavyDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Warning;
                return;
            }

            viewModel.IconState = StatusIconState.Error;
        }
Exemple #5
0
    public MainViewModel()
    {
        ApplyUiConfigWindowSate();

        _dialogScreen = new DialogScreenViewModel();

        _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);

        _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen);

        MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

        NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen);

        _isMainContentEnabled  = true;
        _isDialogScreenEnabled = true;
        _isFullScreenEnabled   = true;

        _statusIcon = new StatusIconViewModel();

        UiServices.Initialize();

        _addWalletPage = new AddWalletPageViewModel();
        _settingsPage  = new SettingsPageViewModel();
        _privacyMode   = new PrivacyModeViewModel();
        _navBar        = new NavBarViewModel(MainScreen);

        NavigationManager.RegisterType(_navBar);
        RegisterViewModels();

        RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

        this.WhenAnyValue(x => x.WindowState)
        .Where(state => state != WindowState.Minimized)
        .ObserveOn(RxApp.MainThreadScheduler)
        .Subscribe(state => Services.UiConfig.WindowState = state.ToString());

        this.WhenAnyValue(
            x => x.DialogScreen !.IsDialogOpen,
            x => x.FullScreen !.IsDialogOpen,
            x => x.CompactDialogScreen !.IsDialogOpen)
        .ObserveOn(RxApp.MainThreadScheduler)
        .Subscribe(tup =>
        {
            var(dialogScreenIsOpen, fullScreenIsOpen, compactDialogScreenIsOpen) = tup;

            IsMainContentEnabled = !(dialogScreenIsOpen || fullScreenIsOpen || compactDialogScreenIsOpen);
        });

        this.WhenAnyValue(
            x => x.DialogScreen.CurrentPage,
            x => x.CompactDialogScreen.CurrentPage,
            x => x.FullScreen.CurrentPage,
            x => x.MainScreen.CurrentPage)
        .ObserveOn(RxApp.MainThreadScheduler)
        .Subscribe(tup =>
        {
            var(dialog, compactDialog, fullscreenDialog, mainsScreen) = tup;

            /*
             * Order is important.
             * Always the topmost content will be the active one.
             */

            if (compactDialog is { })
            {
                compactDialog.SetActive();
                return;
            }

            if (dialog is { })