Exemplo n.º 1
0
        private bool SaveScript()
        {
            BaseLanguageGenerator targetLang = this.codeGen.Language;

            this.saveScriptFileDialog.Filter     = targetLang.ToString() + " files (*" + targetLang.FileExt + ")|*" + targetLang.FileExt;
            this.saveScriptFileDialog.DefaultExt = targetLang.FileExt.Remove(0, 1);

            DialogResult answer = this.saveScriptFileDialog.ShowDialog(this);

            if (answer == DialogResult.OK)
            {
                // Save the file.
                String     fileName   = this.saveScriptFileDialog.FileName;
                TextWriter textWriter = new StreamWriter(fileName, false, targetLang.GeneratorEncoding);

                textWriter.Write(this.codeGen.GetAllDecoratedCode());
                textWriter.Close();

                this.saveScriptFileDialog.FileName = "";
                this.isDirty = false;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        private void codeToolStripLanguageCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            BaseLanguageGenerator targetLang = (BaseLanguageGenerator)this.codeToolStripLanguageCombo.SelectedItem;
            bool resetRecorder = ((this.crntLang is WatirGenerator) || (targetLang is WatirGenerator));

            this.crntLang = targetLang;

            if (resetRecorder)
            {
                // Reset the recorder.
                this.codeGen.Reset();
                this.isDirty = false;

                if (targetLang != null)
                {
                    this.codeGen.Language = targetLang;
                }

                this.SetRichEditBoxText("Switching between Twebst <-> Watir is not supported!\nRecording session restarted ...");
            }
            else
            {
                if (targetLang != null)
                {
                    this.codeGen.Language = targetLang;
                }

                this.toolStripStatusLanguageLabel.Text = targetLang.ToString();
                this.codeRichTextBox.Focus();
                this.codeRichTextBox.Select(0, 0);
                this.codeRichTextBox.ScrollToCaret();
            }

            SaveRecorderLanguage(this.codeToolStripLanguageCombo.SelectedIndex);
        }