Exemplo n.º 1
0
        private void AddClick([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var macro = new Macro(new Rule(), Rocks.Resources.MacroOrganizer_AddClick_New_Macro);

            var d = new MacroDesigner();
            d.Initialize(macro, null);

            if (AppHost.Shell.ShowDialog(d) != true)
            {
                return;
            }

            MacroManager.Add(macro);
            MacroList.SelectedIndex = LoadMacro(macro);

            EnableButtons();
        }
Exemplo n.º 2
0
        private void EditClick([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var selectedItem = MacroList.SelectedItem as ListBoxItem;
            if (selectedItem == null)
            {
                return;
            }

            var macro = selectedItem.Tag as Macro;
            if (macro == null)
            {
                Trace.Expected(typeof(Macro));
                return;
            }

            var oldName = macro.Text;

            var d = new MacroDesigner();
            d.Initialize(macro, null);

            if (AppHost.Shell.ShowDialog(d) != true)
            {
                return;
            }

            MacroManager.Save();
            selectedItem.Content = macro.Text;

            if (GetPostSaveMacroName() == oldName)
            {
                SetPostSaveMacroName(macro.Text);
                LoadPostSaveMacro(macro.Text);
            }

            EnableButtons();
        }