Exemplo n.º 1
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 { }
        }
Exemplo n.º 2
0
		public MacroItem(string settingString)
		{
			Label = "";
			string[] s = settingString.Split(ListSeparator);

			List<string> _list = new List<string>(s);

			if (_list.Count == 0) { return; } // Empty list, nothing to do - leave defaults from above.

			// If we get here, we have at least 1 element. That's our label.
			Label = _list[0];
			_list.RemoveAt(0);

			CommandList = MarlinStringHelpers.SanitizeCommandList(_list);
		}
Exemplo n.º 3
0
 private void SendTextboxContentsAsCommand()
 {
     try
     {
         string s = MarlinStringHelpers.CleanCommandString(txtCommandToSend.Text);
         SendCommandToPort(s);
         if (_oldCommandIndex == 0 || !DoesCommandMatchScrolledCommand(s))                 // New Command, not one from the history
         {
             AddCommandToOldCommandQueue(s);
         }
         _oldCommandIndex = 0;
     }
     catch (Exception err)
     {
         AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message));
     }
 }
Exemplo n.º 4
0
		public MacroItem(string label, List<String> commandList)
		{
			Label = label;
			CommandList = MarlinStringHelpers.SanitizeCommandList(commandList);
		}