Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public event EventHandler <CodeGenEventArgs> CodeChanged; // Language changed or last statement deleted.


        public CodeGenerator(BaseLanguageGenerator lg)
        {
            this.languageGenerator = lg;

            Recorder.Instance.ClickAction      += OnClickAction;
            Recorder.Instance.RightClickAction += OnRightClickAction;
            Recorder.Instance.ChangeAction     += OnChangeAction;
            Recorder.Instance.RecStopped       += OnRecordStopped;
            Recorder.Instance.RecStarted       += OnRecordStart;
            Recorder.Instance.ElementSelected  += OnElementSelected;

            //Recorder.Instance.BackAction    += OnRecordBack;
            //Recorder.Instance.ForwardAction += OnRecordForward;
        }