Esempio n. 1
0
        private async void CreateExperimentAction()
        {
            var dialog = (BaseMetroDialog)Application.Current.Windows.OfType <MainWindow>().First().Resources["ExperimentDialog"];
            var experimentDialogViewModel = new ExperimentDialogViewModel
            {
                DialogCloseAction = async(vm) =>
                {
                    await MetroDialogCoordinator.HideMetroDialogAsync(this, dialog);
                },
                DialogAddAction = async(vm) =>
                {
                    var newExperimentVm = new ExperimentViewModel();
                    newExperimentVm.InitFieldsFrom(vm);
                    ExperimentListViewModel.ExperimentTileCollection.Add(newExperimentVm);
                    EntityDataProvider <ExperimentEntity> .Instance.SaveManager.Map(newExperimentVm);

                    Logger.Info(StringResourceProvider.Instance[StringResourceProvider.Keys.Experiment_PLACE_WasAdded].Value, newExperimentVm.Name);
                    //todo save previous selected item data

                    ExperimentListViewModel.SelectedExperimentTile = null;
                    await Task.Delay(300);

                    ExperimentListViewModel.SelectedExperimentTile = newExperimentVm;
                    await MetroDialogCoordinator.HideMetroDialogAsync(this, dialog);
                },
                Name             = "Experiment #" + DateTime.Now.ToString("yyyy MMMM dd HH:mm"),
                DateTime         = DateTime.Now,
                Category         = "Spectrum",
                WaveMax          = 720,
                WaveMin          = 430,
                ExperimentStatus = ExperimentStatus.Unknown,
                //DistanceRange = new ObservableCollection<double>() { 1.25, 1.5, 1.75, 2, 2.5 },
                DistanceRange = new ObservableCollection <double>()
                {
                    1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2, 2.25, 2.5
                },
                SpectrometerName = "LOTIS CMS-400",

                BaseDistance  = 1.25,
                DistanceToAdd = 2
            };

            //dialog.Content = experimentDialogViewModel;
            dialog.DataContext = experimentDialogViewModel;
            experimentDialogViewModel.PhysicModel = ParamsRetrieverManager.GetParamsRetrievers().FirstOrDefault();
            await MetroDialogCoordinator.ShowMetroDialogAsync(this, dialog);
        }
Esempio n. 2
0
        private async void SettingsAction()
        {
            var dialog            = (BaseMetroDialog)Application.Current.Windows.OfType <MainWindow>().First().Resources["SettingsDialog"];
            var settingsViewModel = new SettingsViewModel
            {
                DialogCloseAction = async(vm) =>
                {
                    await MetroDialogCoordinator.HideMetroDialogAsync(this, dialog);
                },
                DialogSaveAction = async(vm) =>
                {
                    try
                    {
                        var lang = ((SettingsViewModel)vm).Language;
                        var path = ((SettingsViewModel)vm).SavePath;
                        if (lang != "En")
                        {
                            var xml = XElement.Load($"Language/{lang}.xml");
                            StringResourceProvider.Instance.PopulateStringResources(xml.Elements().ToDictionary(x => x.Attribute("ElementID")?.Value, x => x.Value));
                        }
                        else
                        {
                            StringResourceProvider.Instance.SetToDefaultStringResources();
                        }
                        //Logger.Info("");
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e);
                    }
                    await MetroDialogCoordinator.HideMetroDialogAsync(this, dialog);
                },
            };

            //dialog.Content = experimentDialogViewModel;
            dialog.DataContext = settingsViewModel;
            await MetroDialogCoordinator.ShowMetroDialogAsync(this, dialog);
        }