Esempio n. 1
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);
                }
            };
        }
Esempio n. 2
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;
            };
        }