Exemple #1
0
        /// <summary>
        /// Removes the substitution.
        /// </summary>
        /// <param name="substitutionToRemove">The substitution to remove.</param>
        public void RemoveSubstitution([NotNull] SubstitutionViewModel substitutionToRemove)
        {
            Assert.ArgumentNotNull(substitutionToRemove, "substitutionToRemove");

            Group.Substitutions.Remove(substitutionToRemove.Substitution);
            _substitutions.Remove(substitutionToRemove);
        }
        private void AddSubstitutionCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            var substitutionToAdd      = new SubstitutionViewModel(Groups, Groups.First(g => g.IsBuildIn), new Substitution());
            var substitutionEditDialog = new SubstitutionEditDialog {
                DataContext = substitutionToAdd, Owner = (Window)obj
            };

            substitutionEditDialog.Show();
            substitutionEditDialog.Closed += (s, e) =>
            {
                if (substitutionEditDialog.Save)
                {
                    substitutionToAdd.SubstitutionGroup.AddSubstitution(substitutionToAdd);
                }
            };
        }
        private void EditSubstitutionCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            if (SelectedSubstitution == null)
            {
                return;
            }

            var originalSubstitution   = SelectedSubstitution;
            var substitutionEditDialog = new SubstitutionEditDialog {
                DataContext = originalSubstitution.Clone(), Owner = (Window)obj
            };

            substitutionEditDialog.Show();
            substitutionEditDialog.Closed += (object sender, System.EventArgs e) =>
            {
                if (!substitutionEditDialog.Save)
                {
                    return;
                }

                var changedSubstitution = (SubstitutionViewModel)substitutionEditDialog.DataContext;
                if (originalSubstitution.SubstitutionGroup == changedSubstitution.SubstitutionGroup)
                {
                    var originalIndex = originalSubstitution.SubstitutionGroup.Substitutions.IndexOf(originalSubstitution);
                    originalSubstitution.SubstitutionGroup.InsertSubstitution(originalIndex, (SubstitutionViewModel)substitutionEditDialog.DataContext);
                }
                else
                {
                    changedSubstitution.SubstitutionGroup.AddSubstitution(changedSubstitution);
                }

                originalSubstitution.SubstitutionGroup.RemoveSubstitution(originalSubstitution);
                SelectedSubstitution = (SubstitutionViewModel)substitutionEditDialog.DataContext;
            };
        }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="index"></param>
 /// <param name="substitutionToAdd"></param>
 public void InsertSubstitution(int index, [NotNull] SubstitutionViewModel substitutionToAdd)
 {
     Assert.ArgumentNotNull(substitutionToAdd, "substitutionToAdd");
     Group.Substitutions.Insert(index, substitutionToAdd.Substitution);
     _substitutions.Insert(index, substitutionToAdd);
 }
Exemple #5
0
 /// <summary>
 /// Adds the substitution.
 /// </summary>
 /// <param name="substitutionToAdd">The substitution to add.</param>
 public void AddSubstitution([NotNull] SubstitutionViewModel substitutionToAdd)
 {
     Assert.ArgumentNotNull(substitutionToAdd, "substitutionToAdd");
     Group.Substitutions.Add(substitutionToAdd.Substitution);
     _substitutions.Add(substitutionToAdd);
 }