Пример #1
0
        private void InsertInstruction(VisualLine.LocalToInsertInstruction localToInsertInstruction, params OperationCode[] opCodes)
        {
            if (!IsLadderFormOpen())
            {
                return;
            }

            if (projectForm.LadderForm.VisualInstruction.IsDisposed)
            {
                return;
            }

            if (btnSimulateLadder.Checked)
            {
                btnSimulateLadder.Checked = false;
                Thread.Sleep(100);
            }

            VisualInstructionUserControl visualInstruction = projectForm.LadderForm.VisualInstruction;
            VisualLine visualLine = projectForm.LadderForm.SelectedVisualLine;

            visualInstruction = visualLine.InsertInstruction(localToInsertInstruction, visualInstruction, opCodes);

            projectForm.LadderForm.ReorganizeLines();

            visualInstruction.Select();
        }
Пример #2
0
        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLadderFormOpen())
            {
                if (projectForm.LadderForm.VisualInstruction != null)
                {
                    if (!projectForm.LadderForm.VisualInstruction.IsDisposed)
                    {
                        DataFormats.Format myFormat                = DataFormats.GetFormat("List<SimboloBasico>");
                        Object             returnObject            = null;
                        List <Instruction> instructionsSource      = new List <Instruction>();
                        InstructionList    instructionsDestination = new InstructionList();

                        IDataObject iData = Clipboard.GetDataObject();

                        // Determines whether the data is in a format you can use.
                        if (iData.GetDataPresent(myFormat.Name))
                        {
                            try
                            {
                                returnObject = iData.GetData(myFormat.Name);
                            }
                            catch
                            {
                                MessageBox.Show("Error");
                            }
                        }

                        instructionsSource = (List <Instruction>)returnObject;

                        instructionsDestination.InsertAllWithClearBefore(instructionsSource);

                        VisualInstructionUserControl visualInstruction = projectForm.LadderForm.SelectedVisualLine.InsertInstructionAtLocalToBeDefined(true, projectForm.LadderForm.VisualInstruction, instructionsDestination);
                        projectForm.LadderForm.ReorganizeLines();
                        visualInstruction.Select();
                    }
                }
            }
        }