public CalculatorViewModel(IEventAggregator eventsAggregator,
            RiflesModel riflesModel,
            AmmoModel cartridgeModel,
            ConfigurationModel configurationModel)
            : base(eventsAggregator)
        {
            this.riflesModel = riflesModel;
            this.configurationModel = configurationModel;
            this.cartridgeModel = cartridgeModel;
            selectedRifle = null;
             DisplayName = "Ballistic Calculation";
            configurationModel.Load();
            selectedRifle = configurationModel.CalculatorSettings.CurrentRifle;

            var rifles = Rifles.ToList();
            if (string.IsNullOrWhiteSpace(selectedRifle?.Name) && rifles.Count > 0)
                SelectedRifle = rifles.OrderByDescending(x => x.Name).FirstOrDefault();

            if (selectedRifle != null)
            {
                selectedCartridge = configurationModel.CalculatorSettings.CurrentCartridge;
                if (string.IsNullOrWhiteSpace(selectedCartridge?.Name))
                    selectedCartridge = selectedRifle.Cartridge;
            }
        }
예제 #2
0
 public void Load()
 {
     model.Load();
     view.Workload          = model.Workload;
     view.Tolerance         = model.Tolerance;
     view.Subtract          = model.Subtract;
     view.SubtractCondition = model.SubtractCondition;
     view.SubtractQuantity  = model.SubtractQuantity;
     view.Warn          = model.Warn;
     view.WarnCondition = model.WarnCondition;
     view.Startup       = model.Startup;
 }
예제 #3
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

            ConfigurationModel confModel = ConfigurationModel.Load();

            // Register config
            TinyIoCContainer.Current.Register <IConfigurationModel, ConfigurationModel>(confModel);

            LanguageService languageService = new LanguageService(confModel);

            TinyIoCContainer.Current.Register <ILanguageService, LanguageService>(languageService);

            var viewModel = new MainViewModel();

            var shell = new MainWindow();

            shell.DataContext = viewModel;
            shell.Closing    += new CancelEventHandler(viewModel.OnClosing);
            shell.Show();
        }
 protected override void OnViewReady(object view)
 {
     model.Load();
     NotifyOfPropertyChange(() => Units);
 }