Beispiel #1
0
 /// <summary>
 /// Sends each command to the Port.
 /// </summary>
 /// <param name="m"></param>
 private void ExecuteMacro(MacroItem m)
 {
     foreach (string s in m.CommandList)
     {
         SendCommandToPort(s);
     }
 }
Beispiel #2
0
        private void btnMacro_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(typeof(pr_M503orM501_Config)))
                {
                    pr_M503orM501_Config o             = e.Data.GetData(typeof(pr_M503orM501_Config)) as pr_M503orM501_Config;
                    MacroItem            _macroForEdit = new MacroItem(GetMacroFromButton(sender).Label, o.CommandList);          //The macro object will sanitize the command list.
                    if (_macroForEdit.Label == string.Empty)
                    {
                        _macroForEdit.Label = "M503 or M501 Config";
                    }
                    EditMacro((Button)sender, _macroForEdit);
                }
                else if (e.Data.GetDataPresent(DataFormats.Text))
                {
                    string s = (string)e.Data.GetData(DataFormats.Text);

                    // Strip off any non-command stuff in case the user is drag-dropping echo'ed commands.
                    s = MarlinStringHelpers.CleanMarlinResponseAndRemoveTextAndLinesNotNeededForCommands(s).Item2;

                    // Take the label from the existing button and the command text from the drag/drop.
                    MacroItem _macroForEdit = new MacroItem(GetMacroFromButton(sender).Label, s);                     //The macro object will sanitize the command string.
                    EditMacro((Button)sender, _macroForEdit);
                }
            }
            catch { }
        }
Beispiel #3
0
        private void EditMacro(Button macroButton, MacroItem macroForEdit)
        {
            MacroEditWindow _win = new MacroEditWindow(macroForEdit, 1);

            if (_win.ShowDialog() == true)
            {
                MacroItem updatedMacro = _win.GetUpdatedMacro();
                macroButton.DataContext = updatedMacro;
                SaveCurrentMacrosToUserSettings();
            }
        }
Beispiel #4
0
        private void btnMacro_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            MacroItem _macroForEdit = GetMacroFromButton(sender).ShallowClone();

            EditMacro((Button)sender, _macroForEdit);
        }
Beispiel #5
0
 public MacroEditWindow(MacroItem m, int Number)
 {
     InitializeComponent();
     Macro            = m;
     this.DataContext = this;
 }