/// <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();
        }
 partial void DeleteMaterial(Material instance);
 partial void UpdateMaterial(Material instance);
 partial void InsertMaterial(Material instance);
        /// <summary>
        /// Function that removes the selected <see cref="Material"/>.
        /// </summary>
        public void _RemoveMaterialCommand()
        {
            if (SelectedMaterial == null) return;

            Database.LayerElements.DeleteAllOnSubmit(Database.LayerElements.Where(x => x.MaterialID == SelectedMaterial.MaterialID));
            Database.Layers.DeleteAllOnSubmit(Database.Layers.Where(x => x.MaterialID == SelectedMaterial.MaterialID));
            Database.Materials.DeleteOnSubmit(SelectedMaterial);
            Materials.Remove(SelectedMaterial);

            SelectedMaterial = null;
        }
        /// <summary>
        /// Function that adds a new <see cref="Material"/>.
        /// </summary>
        public void _AddMaterialCommand()
        {
            Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new material name:", "new Material");
            if (inputDialog.ShowDialog() == true)
            {
                Material newMaterial = new Material { MaterialName = inputDialog.Answer };

                Database.Materials.InsertOnSubmit(newMaterial);

                Materials.Add(newMaterial);
            }
        }