Ejemplo n.º 1
0
        public void LicenseWriter_ReadAgreementStateAgreementTrue_ReadsStateCorrectly()
        {
            var reader = new FakeLicenseReader();

            reader.multiple = true;
            reader.state    = true;

            LicenseWriter writer = new LicenseWriter(reader);

            Assert.IsTrue(writer.ReadAgreementState());
        }
Ejemplo n.º 2
0
        public void LicenseWriter_ReadAgreementStateAgreementTrue_UpdatesStateInManagerCorrectly()
        {
            LicenseManager.LicensesAccepted = false;

            var reader = new FakeLicenseReader();

            reader.multiple = true;
            reader.state    = true;

            LicenseWriter writer = new LicenseWriter(reader);

            writer.ReadAgreementState();

            Assert.IsTrue(LicenseManager.LicensesAccepted);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is the constructor for the MainWindow ViewModel
        /// </summary>
        public MainWindowViewModel(IKeyManager Manager, DataProvider data, IReader reader, IDialogCoordinator dialogCoordinator, bool IsTesting = false)
        {
            AddLicenses();

            //connect delegate commands to icommand handlers
            _changeToHeightCommand            = new DelegateCommand(OnChangeToHeight);
            _changeToLoadCommand              = new DelegateCommand(OnChangeToLoad);
            _changeToAboutCommand             = new DelegateCommand(OnChangeToAbout);
            _changeToAccelerationGraphCommand = new DelegateCommand(OnChangeToAccelerationGraph);
            _changeToAccelerationTimedCommand = new DelegateCommand(OnChangeToAccelerationTimed);
            _changeToAngleGraphCommand        = new DelegateCommand(OnChangeToAngleGraph);
            _changeToAngleTimedCommand        = new DelegateCommand(OnChangeToAngleTimed);
            _changeToMapRouteCommand          = new DelegateCommand(OnChangeToMapRoute);
            _changeToMapTimedCommand          = new DelegateCommand(OnChangeToMapTimed);
            _changeToVelocityGraphCommand     = new DelegateCommand(OnChangeToVelocityGraph);
            _changeToVelocityTimedCommand     = new DelegateCommand(OnChangeToVelocityTimed);
            _changeToHorizonCommand           = new DelegateCommand(OnChangeToHorizonCommand);

            dataProvider = data;

            coordinator = dialogCoordinator;

            manager = Manager;

            MapEnabled    = true;
            _mapAvailable = true;

            if (!reader.FileExists("CIDER.cfg"))
            {
                reader.WriteAllText("", "CIDER.cfg");
            }

            if (!manager.Fetch())
            {
                MapEnabled        = false;
                _mapAvailable     = false;
                displayApiKeyInfo = true;
            }

            if (!IsTesting)
            {
                if (ThemeManager.DetectAppStyle().Item1 == ThemeManager.GetAppTheme("BaseDark"))
                {
                    var theme = ThemeManager.DetectAppStyle();
                    ThemeManager.ChangeAppTheme(App.Current, "BaseDark");
                }
            }

            // Check the license
            try
            {
                LicenseWriter licenseWriter = new LicenseWriter(reader);
                _licenseAccepted = licenseWriter.ReadAgreementState();
                LicenseManager.LicensesAccepted = _licenseAccepted;

                if (_licenseAccepted == false)
                {
                    Licenses licenses = new Licenses();
                    licenses.Show();
                    _licenseAccepted = LicenseManager.LicensesAccepted;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Couldn't configure License State");
                _licenseAccepted = false;
            }

            ButtonState(false);
            MapEnabled = false;

            if (_licenseAccepted)
            {
                ButtonState(true);
            }

            KeyManager.MapKeyChangedEvent     += KeyManager_MapKeyChangedEvent;
            LicenseHolder.LicenseChangedEvent += LicenseHolder_LicenseChangedEvent;
        }