コード例 #1
0
        private void btnAddCommand_Click(object sender, EventArgs e)
        {
            string sSpeed = AppUtils.CorrectDecDelimiter(this.tbSpeedPC.Text);
            string sPos = AppUtils.CorrectDecDelimiter(this.tbPositionPC.Text);

            float speed = 0.0f;
            float position = 0.0f;

            float.TryParse(sSpeed, out speed);
            float.TryParse(sPos, out position);

            MotionCommand command = new MotionCommand(position, speed);

            this.programControl.Commands.Add(command);
            this.lstCommands.Items.Add(command.ToString());
        }
コード例 #2
0
        private void LoadProgram()
        {
            // Create an instance of the open file dialog box.
            OpenFileDialog fileDialog = new OpenFileDialog();

            // Set filter options and filter index.
            fileDialog.Filter = "XML Files (.xml)|*.xml|All Files (*.*)|*.*";
            fileDialog.FilterIndex = 1;
            fileDialog.Multiselect = false;

            // Show the dialog and get result.
            DialogResult result = fileDialog.ShowDialog();

            if (result == DialogResult.OK) // Test result.
            {
                string path = fileDialog.FileName;
                MotionCommands commands = CommandsStore.Load(path);

                if (commands != null && commands.Count > 0)
                {

                    this.programControl.Commands = commands;

                    this.lstCommands.Items.Clear();
                    MotionCommand[] test = new MotionCommand[this.programControl.Commands.Count];
                    this.programControl.Commands.CopyTo(test, 0);
                    this.lstCommands.Items.AddRange(test);
                }

                this.programName = Path.GetFileNameWithoutExtension(path);

                this.lblProgramName.Text = String.Format("Program: {0}", this.programName);
            }
        }