Beispiel #1
0
        /// <summary>
        /// Implementation for AddCommand.
        /// Adds a new modification to the modification list.
        /// </summary>
        private void AddImplementation()
        {
            var customModVm = new CustomModificationViewModel(string.Empty, false, this.dialogService);

            if (this.dialogService.OpenCustomModification(customModVm))
            {
                Modification modification = null;
                if (customModVm.FromFormulaChecked)
                {
                    modification = IcParameters.Instance.RegisterModification(
                        customModVm.ModificationName,
                        customModVm.Composition);
                }
                else if (customModVm.FromMassChecked)
                {
                    modification = IcParameters.Instance.RegisterModification(
                        customModVm.ModificationName,
                        customModVm.Mass);
                }

                if (modification != null)
                {
                    this.Modifications.Add(modification);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Implementation for EditCommand.
        /// Edits the selected modification.
        /// </summary>
        private void EditImplementation()
        {
            if (this.SelectedModification == null)
            {
                return;
            }

            // Set the composition or mass for the modification editor
            var customModVm = new CustomModificationViewModel(this.SelectedModification.Name, true, this.dialogService);

            if (this.SelectedModification.Composition is CompositionWithDeltaMass)
            {   // Modification with mass shift
                customModVm.FromFormulaChecked = false;
                customModVm.FromMassChecked    = true;
                customModVm.Mass = this.SelectedModification.Mass;
            }
            else
            {   // Modification with formula
                customModVm.FromMassChecked    = false;
                customModVm.FromFormulaChecked = true;
                customModVm.Composition        = this.SelectedModification.Composition;
            }

            if (this.dialogService.OpenCustomModification(customModVm))
            {
                Modification modification = null;
                if (customModVm.FromFormulaChecked)
                {
                    modification = IcParameters.Instance.UpdateOrRegisterModification(
                        customModVm.ModificationName,
                        customModVm.Composition);
                }
                else if (customModVm.FromMassChecked)
                {
                    modification = IcParameters.Instance.UpdateOrRegisterModification(
                        customModVm.ModificationName,
                        customModVm.Mass);
                }

                if (modification != null)
                {
                    // Replace old modification in the list
                    for (int i = 0; i < this.Modifications.Count; i++)
                    {
                        if (modification.Name == this.Modifications[i].Name)
                        {
                            this.Modifications[i]     = modification;
                            this.SelectedModification = modification;
                        }
                    }
                }
            }
        }