public ScriptManager(string varFilePath, TabPage tabPage, WatchVariableFlowLayoutPanel watchVariablePanel) : base(varFilePath, watchVariablePanel) { SplitContainer splitContainer = tabPage.Controls["splitContainerScript"] as SplitContainer; SplitContainer splitContainerLeft = splitContainer.Panel1.Controls["splitContainerScriptLeft"] as SplitContainer; _checkBoxScriptRunContinuously = splitContainerLeft.Panel1.Controls["checkBoxScriptRunContinuously"] as CheckBox; _buttonScriptRunOnce = splitContainerLeft.Panel1.Controls["buttonScriptRunOnce"] as Button; _buttonScriptInstructions = splitContainerLeft.Panel1.Controls["buttonScriptInstructions"] as Button; _buttonScriptExamples = splitContainerLeft.Panel1.Controls["buttonScriptExamples"] as Button; _richTextBoxScript = splitContainerLeft.Panel2.Controls["richTextBoxScript"] as RichTextBoxEx; _script = new TokenScript(); _checkBoxScriptRunContinuously.Click += (sender, e) => { if (_checkBoxScriptRunContinuously.Checked) { _script.SetScript(_richTextBoxScript.Text); } _script.SetIsEnabled(_checkBoxScriptRunContinuously.Checked); _richTextBoxScript.ReadOnly = _checkBoxScriptRunContinuously.Checked; }; _buttonScriptRunOnce.Click += (sender, e) => { _script.SetScript(_richTextBoxScript.Text); _script.Run(); }; _buttonScriptInstructions.Click += (sender, e) => { InfoForm.ShowValue( string.Join("\r\n", _instructions), "Instructions", "Instructions"); }; _buttonScriptExamples.ContextMenuStrip = new ContextMenuStrip(); for (int i = 0; i < _exampleNames.Count; i++) { ToolStripMenuItem item = new ToolStripMenuItem(_exampleNames[i]); string text = string.Join("\r\n", _exampleLines[i]); item.Click += (sender, e) => _richTextBoxScript.Text = text; _buttonScriptExamples.ContextMenuStrip.Items.Add(item); } _buttonScriptExamples.Click += (sender, e) => _buttonScriptExamples.ContextMenuStrip.Show(Cursor.Position); }
public override void InitializeTab() { base.InitializeTab(); checkBoxScriptRunContinuously.Click += (sender, e) => { if (checkBoxScriptRunContinuously.Checked) { _script.SetScript(richTextBoxScript.Text); } _script.SetIsEnabled(checkBoxScriptRunContinuously.Checked); richTextBoxScript.ReadOnly = checkBoxScriptRunContinuously.Checked; }; buttonScriptRunOnce.Click += (sender, e) => { _script.SetScript(richTextBoxScript.Text); _script.Run(); }; buttonScriptInstructions.Click += (sender, e) => { InfoForm.ShowValue( string.Join("\r\n", _instructions), "Instructions", "Instructions"); }; buttonScriptExamples.ContextMenuStrip = new ContextMenuStrip(); for (int i = 0; i < _exampleNames.Count; i++) { ToolStripMenuItem item = new ToolStripMenuItem(_exampleNames[i]); string text = string.Join("\r\n", _exampleLines[i]); item.Click += (sender, e) => richTextBoxScript.Text = text; buttonScriptExamples.ContextMenuStrip.Items.Add(item); } buttonScriptExamples.Click += (sender, e) => buttonScriptExamples.ContextMenuStrip.Show(Cursor.Position); }