Ejemplo n.º 1
0
        /// <summary>
        /// Constructor of the class. Sets up commands and initializes variables.
        /// </summary>
        public NewMeasurementViewModel()
        {
            Database = MyGlobals.Database;

            NewSampleCommand = new RelayCommand(() => _NewSampleCommand(), () => true);

            StartMeasurementCommand = new RelayCommand(() => _StartMeasurementCommand(), () => true);
            CancelCommand = new RelayCommand(() => _CancelCommand(), () => true);

            Channels_10 = new ObservableCollection<CheckedListItem<int>> { new CheckedListItem<int>(0), new CheckedListItem<int>(1), new CheckedListItem<int>(2), new CheckedListItem<int>(3) };
            Channels_30 = new ObservableCollection<CheckedListItem<int>> { new CheckedListItem<int>(4), new CheckedListItem<int>(5) };

            Channels_10[0].IsChecked = true;
            Channels_30[0].IsChecked = true;

            Orientations = new ObservableCollection<string> { "(undefined)", "random", "aligned" };
            Chambers = new ObservableCollection<string> { "(undefined)", "-10°", "-30°" };
            StopTypes = new ObservableCollection<string> { "Manual", "Duration (min)", "Charge (µC)", "Counts", "ChopperCounts" };
            Ions = new ObservableCollection<Isotope>(Database.Elements.Where(x => x.AtomicNumber <= 3).SelectMany(y => y.Isotopes).Where(z => z.MassNumber > 0).ToList());

            Samples = new ObservableCollection<Sample>(Database.Samples.ToList());

            NewMeasurement = Database.Measurements.Where(y => y.MeasurementName != "TestMeasurement").OrderByDescending(x => x.StartTime).First();

            VariableParameters = new ObservableCollection<string> { "x", "y", "Theta", "Phi", "Energy", "Charge" };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor of the class. Sets up the commands and initiates <see cref="MeasurementInfo"/>.
        /// </summary>
        /// <param name="MeasurementID"></param>
        public MeasurementInfoViewModel(int MeasurementID)
        {
            SaveCommand = new RelayCommand(() => _SaveCommand(), () => true);
            CancelCommand = new RelayCommand(() => _CancelCommand(), () => true);

            Database = MyGlobals.Database;
            MeasurementInfo = new MeasurementInfoClass(Database);
            MeasurementInfo.Measurement = Database.Measurements.FirstOrDefault(x => x.MeasurementID == MeasurementID);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor of the class, storing the handled instance of <see cref="DatabaseDataContext"/> and initializing the collections for the Comboboxes.
        /// </summary>
        /// <param name="database"></param>
        public MeasurementInfoClass(DatabaseDataContext database)
        {
            Database = database;
            Samples = new ObservableCollection<Sample>(Database.Samples.ToList());

            NewSampleCommand = new RelayCommand(() => _NewSampleCommand(), () => true);

            Orientations = new ObservableCollection<string> { "(undefined)", "random", "aligned" };
            Chambers = new ObservableCollection<string> { "(undefined)", "-10°", "-30°" };
            StopTypes = new ObservableCollection<string> { "Manual", "Duration (min)", "Charge (µC)", "Counts", "ChopperCounts" };
            Ions = new ObservableCollection<Isotope>(Database.Elements.Where(x => x.AtomicNumber <= 3).SelectMany(y => y.Isotopes).Where(z=>z.MassNumber>0).ToList());
        }
Ejemplo n.º 4
0
        public LayerElementListItem(DatabaseDataContext database, LayerElement layerElement)
        {
            Isotope initialIsotope = layerElement.Isotope;
            LayerElement = layerElement;

            Elements = new ObservableCollection<Element>(database.Elements.ToList());
            Isotopes = new ObservableCollection<Isotope>();

            if (layerElement.Isotope!=null)
                SelectedElement = layerElement.Isotope.Element;

            SelectedIsotope = initialIsotope;
        }
        /// <summary>
        /// Constructor of the class. Sets up the commands an initializes the variables.
        /// </summary>
        /// <param name="FileName">The name of the file containing the <see cref="Measurement"/>s to import.</param>
        public MeasurementImportViewModel(string FileName)
        {
            AddCurrentMeasurementCommand = new RelayCommand(() => _AddCurrentMeasurementCommand(), () => true);
            AddAllMeasurementsCommand = new RelayCommand(() => _AddAllMeasurementsCommand(), () => true);
            CancelCommand = new RelayCommand(() => _CancelCommand(), () => true);

            newMeausurements = new ObservableCollection<Measurement>();

            UpdatePlot = new ObservableCollection<int>();

            Database = MyGlobals.Database;
            //Database.Log = Console.Out;

            MeasurementInfo = new MeasurementInfoClass(Database);

            LoadMeasurements(FileName);
        }
        /// <summary>
        /// Constructor of the class. Sets up the commands, collections and selected items of the view.
        /// </summary>
        public EnergyCalibrationViewModel(List<int> SelectedMeasurementIDs)
        {
            AddToListCommand = new RelayCommand(() => _AddToListCommand(), () => true);
            ClearListCommand = new RelayCommand(() => _ClearListCommand(), () => true);

            CalculateEnergyCalCommand = new RelayCommand(() => _CalculateEnergyCalCommand(), () => true);

            SaveEnergyCalCommand = new RelayCommand(() => _SaveEnergyCalCommand(), () => true);
            CancelCalCommand = new RelayCommand(() => _CancelCalCommand(), () => true);

            Database = MyGlobals.Database;

            IsotopeList = new ObservableCollection<Isotope>();

            ElementList = new ObservableCollection<Database.Element>(Database.Elements);

            SelectedElement = ElementList.FirstOrDefault();

            selectedMeasurements = Database.Measurements.Where(x=> SelectedMeasurementIDs.Contains(x.MeasurementID)).ToList();

            EnergyCalList = new ObservableCollection<EnergyCalListItem>();

            FitType = new ObservableCollection<string> { "linear", "quadratic" };

            LineColors = new List<OxyColor>
            {
                OxyColor.FromRgb(0x4E, 0x9A, 0x06),
                OxyColor.FromRgb(0xC8, 0x8D, 0x00),
                OxyColor.FromRgb(0xCC, 0x00, 0x00),
                OxyColor.FromRgb(0x20, 0x4A, 0x87),
                OxyColors.Red,
                OxyColors.Orange,
                OxyColors.Yellow,
                OxyColors.Green,
                OxyColors.Blue,
                OxyColors.Indigo,
                OxyColors.Violet
            };

            SelectedMeasurementsPlot = new PlotModel();

            SetUpModel();

            PlotMeasurements();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor of the class. Sets up commands, initializes variables and checks whether a <see cref="Sample"/> and <see cref="Material"/> belongs to the <see cref="SelectedMeasurement"/>.
        /// </summary>
        /// <param name="MeasurementID"></param>
        public SimulateSpectrumViewModel(int MeasurementID)
        {
            StartSimulationCommand = new RelayCommand(() => _StartSimulationCommand(), () => true);
            CancelCommand = new RelayCommand(() => _CancelCommand(), () => true);

            Database = MyGlobals.Database;

            SelectedMeasurement = Database.Measurements.FirstOrDefault(x => x.MeasurementID == MeasurementID);
            SelectedSample = SelectedMeasurement.Sample;
            SelectedMaterial = SelectedSample.Material;

            if (SelectedSample.SampleName == "(undefined)" || SelectedMaterial.MaterialName == "(undefined)")
            {
                MessageBox.Show("A sample (with a material) must be assigned to the measurement!", "Error");
                DialogResult = false;
            }

            IonFluence = 1E14;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructor of the class. Sets up commands and initializes variables.
        /// </summary>
        public SampleEditorViewModel()
        {
            Database = MyGlobals.Database;

            AddSampleCommand = new RelayCommand(() => _AddSampleCommand(), () => true);
            RemoveSampleCommand = new RelayCommand(() => _RemoveSampleCommand(), () => true);
            RenameSampleCommand = new RelayCommand(() => _RenameSampleCommand(), () => true);

            SaveCommand = new RelayCommand(() => _SaveCommand(), () => true);
            CancelCommand = new RelayCommand(() => _CancelCommand(), () => true);

            Layers = new ObservableCollection<string>();

            Materials = new ObservableCollection<Material>(Database.Materials.ToList());
            SelectedMaterial = new Material();

            Samples = new ObservableCollection<Sample>(Database.Samples.ToList());
            Samples.Remove(Samples.First(x => x.SampleName == "(undefined)"));
            SelectedSample = Samples.FirstOrDefault();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Function that gets an database admin login and starts a new <see cref="UserEditorViewModel"/> instance and binds it to a <see cref="Views.UserEditorView"/> instance.
        /// </summary>
        public void _UserEditorCommand()
        {
            Views.Utils.LogInDialog logInDialog = new Views.Utils.LogInDialog("Please enter the admin login data and the connection settings!");

            if (logInDialog.ShowDialog() == true)
            {
                string ConString = "Data Source = " + logInDialog.logIn.IPAdress + "," + logInDialog.logIn.Port + "; Network Library=DBMSSOCN; User ID = " + logInDialog.logIn.UserName + "; Password = "******"; Initial Catalog = " + logInDialog.logIn.UserName + "_db";
                var newConnection = new DatabaseDataContext(ConString);
                newConnection.CommandTimeout = 10;

                if (newConnection.DatabaseExists())
                {
                    UserEditorViewModel userEditorViewModel = new UserEditorViewModel(logInDialog.logIn);
                    Views.UserEditorView userEditorView = new Views.UserEditorView();
                    userEditorView.DataContext = userEditorViewModel;
                    userEditorView.ShowDialog();
                }
                else
                    trace.Value.TraceEvent(TraceEventType.Information, 0, "Database connection problem");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Constructor of the class.
        /// </summary>
        public MaterialEditorViewModel()
        {
            Database = MyGlobals.Database;

            Materials = new ObservableCollection<Material>(Database.Materials.Where(x => x.MaterialName != "(undefined)").ToList());
            Layers = new ObservableCollection<Layer>();
            LayerElements = new ObservableCollection<LayerElementListItem>();

            AddMaterialCommand = new RelayCommand(() => _AddMaterialCommand(), () => true);
            RemoveMaterialCommand = new RelayCommand(() => _RemoveMaterialCommand(), () => true);
            RenameMaterialCommand = new RelayCommand(() => _RenameMaterialCommand(), () => true);

            AddLayerCommand = new RelayCommand(() => _AddLayerCommand(), () => true);
            RemoveLayerCommand = new RelayCommand(() => _RemoveLayerCommand(), () => true);
            MoveLayerUpCommand = new RelayCommand(() => _MoveLayerUpCommand(), () => true);
            MoveLayerDownCommand = new RelayCommand(() => _MoveLayerDownCommand(), () => true);

            AddElementCommand = new RelayCommand(() => _AddLayerElementCommand(), () => true);
            RemoveElementCommand = new RelayCommand(() => _RemoveLayerElementCommand(), () => true);

            SaveCommand = new RelayCommand(() => _SaveCommand(), () => true);
            CancelCommand = new RelayCommand(() => _CancelCommand(), () => true);

            LayersViewSource = new CollectionViewSource();
            LayersViewSource.Source = Layers;
            LayersViewSource.SortDescriptions.Add(new SortDescription("LayerIndex", ListSortDirection.Ascending));
        }