Example #1
0
 public PromptSmartButtonEdit(SmartButton SmartIn)
 {
     InitializeComponent();
     this.SmartButtonToEdit = SmartIn;
     populateCurrentAttributes();
     this.Show();
 }
Example #2
0
        int timeSelectedIndex = 1; //min

        #endregion Fields

        #region Constructors

        public PromptScriptEdit(SmartButton SmartIn)
        {
            InitializeComponent();
            this.SmartButtonToEdit = SmartIn;
            this.ScriptToEdit = SmartIn.storedScript;
            populateCurrentAttributes();
            this.Show();
        }
Example #3
0
        private void loadSmartButtons(string[] dataIn)
        {
            String[] recalledData = dataIn;
            string[] stringSeparator = new string[] { "\t" };
            int buttonStyle = 0;
            //variable to set wheter a script button is being created
            Boolean scriptbutton = false;
            SmartButton tempButton = new SmartButton();
            try
            {
                if (!(recalledData == null || recalledData.Length == 0))
                {
                    for (int i = 0; i < recalledData.Length; i++)
                    {
                        String[] parsed = recalledData[i].Split(stringSeparator, StringSplitOptions.RemoveEmptyEntries);
                        //parse out the data
                        //when encountering an empty line, change the button style
                        //this allows for grouping button appeareance by function
                        if (parsed.Length == 0)
                        {
                            buttonStyle++;
                            buttonStyle = buttonStyle % 2;
                        }
                        //make sure there is data on the line
                        if (!(parsed == null || parsed.Length == 0))
                        {
                            if (parsed[0].Length > 0)
                            {
                                String command = parsed[0];
                                String description = parsed[0];

                                //find out if there is a special command
                                if (command.Trim().StartsWith("**"))
                                {

                                    if (command.ToLower().Contains("**script"))
                                    {
                                        //toggle script creation on and off
                                        scriptbutton = !scriptbutton;
                                        //for the first time, create a script button
                                        if (scriptbutton)
                                        {
                                            if ((parsed.Length > 1) && parsed[1].Length > 0)
                                            {
                                                description = parsed[1];
                                            }
                                            tempButton = createScriptButton(description, description, showCMD, 2);
                                            //create a new script
                                            loadScript(false);
                                        }
                                        else
                                        {
                                            //when the script is done populating, add the script to the button
                                            tempButton.addScript(serialScript);
                                        }
                                    }
                                }
                                if (!(command.ToLower().Contains("**script")))
                                {
                                    if (scriptbutton)
                                    {
                                        //add to the script - but only if it is not a command
                                        serialScript.addCommandIntoCurrentScript(recalledData[i]);
                                    }
                                    else
                                    {
                                        //the usual case - not a scripted command or function
                                        if ((parsed.Length > 1) && parsed[1].Length > 0)
                                        {
                                            description = parsed[1];
                                        }
                                        createHistoryButton(command, description, showCMD, buttonStyle);
                                    }
                                }
                            }
                        }
                    }
                }

                //if everything loaded correctly, display the descriptions
                showCMD = !showCMD;
                changeHistoryButtonDisplay(showCMD);
            }
            catch (Exception)
            {
                Console.WriteLine("Error opening / parsing saved data");
            }
        }
Example #4
0
        private SmartButton createScriptButton(String buttonCommandText, String buttonDescriptionText, Boolean displayCMD, int buttonStyle)
        {
            var newbutton = new SmartButton(SmartButton.buttonTypes.ScriptRunner, buttonCommandText, buttonDescriptionText, displayCMD);

            if (displayCMD)
            {
                this.toolTip1.SetToolTip(newbutton, newbutton.CommandDescription);
            }
            else
            {
                this.toolTip1.SetToolTip(newbutton, newbutton.CommandToSend);
            }

            setButtonStyle(newbutton, buttonStyle);
            setButtonLocation(newbutton);
            setButtonEventHandlers(newbutton);

            return newbutton;
        }
Example #5
0
        private void setButtonLocation(SmartButton newbutton)
        {
            newbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

            //find the relative relative location
            Point basePoint = lastButtonForLocation.Location;
            Point offsetPoint = new Point(0, -29);
            basePoint.Offset(offsetPoint);
            newbutton.Location = basePoint;
            newbutton.Size = lastButtonForLocation.Size;
            lastButtonForLocation = newbutton;
            //set the size
        }
Example #6
0
        private void setButtonEventHandlers(SmartButton newbutton)
        {
            //add the event handlers

            //clicking the button sends its history data to the terminal
            if (newbutton.buttonType == SmartButton.buttonTypes.SerialCommand)
            {
                newbutton.Click += new System.EventHandler(this.SmartButton_SendSerial);
            }
            if (newbutton.buttonType == SmartButton.buttonTypes.ScriptRunner)
            {
                newbutton.Click += new System.EventHandler(this.SmartButton_RunScript);
            }
            newbutton.ContextMenuStrip = setupToolStripMenu(true);
            newbutton.MouseHover += new System.EventHandler(this.newbutton_MouseHover);
            newbutton.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxTerminal_KeyPress);
            //add the context menu
            newbutton.ContextMenuStrip = contextMenuSmartButton;
            this.panelHistory.Controls.Add(newbutton);
        }