Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="index"></param>
 /// <param name="aliasToAdd"></param>
 public void InsertAlias(int index, [NotNull] AliasViewModel aliasToAdd)
 {
     Assert.ArgumentNotNull(aliasToAdd, "aliasToAdd");
     _aliases.Add(aliasToAdd);
     Group.Aliases.Insert(index, aliasToAdd.CommandAlias);
     _aliases.Insert(index, aliasToAdd);
 }
Пример #2
0
        /// <summary>
        /// Adds the alias.
        /// </summary>
        /// <param name="aliasToAdd">The alias to add.</param>
        public void AddAlias([NotNull] AliasViewModel aliasToAdd)
        {
            Assert.ArgumentNotNull(aliasToAdd, "aliasToAdd");

            _aliases.Add(aliasToAdd);
            Group.Aliases.Add(aliasToAdd.CommandAlias);
        }
Пример #3
0
        private void AddAliasCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            var commandAlias = new CommandAlias();

            commandAlias.Actions.Add(new SendTextAction());
            var aliasToAdd      = new AliasViewModel(Groups, Groups.First(g => g.IsBuildIn), commandAlias, _actionDescriptions);
            var aliasEditDialog = new AliasEditDialog {
                DataContext = aliasToAdd, Owner = (Window)obj
            };

            aliasEditDialog.Show();
            aliasEditDialog.Closed += (s, e) =>
            {
                if (aliasEditDialog.Save)
                {
                    aliasToAdd.AliasGroup.AddAlias(aliasToAdd);
                }
            };
        }
Пример #4
0
        private void EditAliasCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            if (SelectedAlias == null)
            {
                return;
            }

            var originalAlias   = SelectedAlias;
            var aliasEditDialog = new AliasEditDialog {
                DataContext = originalAlias.Clone(), Owner = (Window)obj
            };

            aliasEditDialog.Show();
            aliasEditDialog.Closed += (s, e) =>
            {
                if (!aliasEditDialog.Save)
                {
                    return;
                }

                var changedAlias = (AliasViewModel)aliasEditDialog.DataContext;
                if (originalAlias.AliasGroup == changedAlias.AliasGroup)
                {
                    var originalIndex = originalAlias.AliasGroup.Aliases.IndexOf(originalAlias);
                    originalAlias.AliasGroup.InsertAlias(originalIndex, (AliasViewModel)aliasEditDialog.DataContext);
                }
                else
                {
                    changedAlias.AliasGroup.AddAlias(changedAlias);
                }

                originalAlias.AliasGroup.RemoveAlias(originalAlias);
                SelectedAlias = (AliasViewModel)aliasEditDialog.DataContext;
            };
        }
Пример #5
0
 /// <summary>
 /// Removes the alias.
 /// </summary>
 /// <param name="aliasToRemove">The alias to remove.</param>
 public void RemoveAlias([NotNull] AliasViewModel aliasToRemove)
 {
     Assert.ArgumentNotNull(aliasToRemove, "aliasToRemove");
     Group.Aliases.Remove(aliasToRemove.CommandAlias);
     _aliases.Remove(aliasToRemove);
 }