// this method uses Tags defined in UI for some controls!!! private void MainForm_Load(object sender, EventArgs e) { label1.Text = ""; label12.Text = ResGUIStr.LABEL_CONFIG_FILE; // set UI elements from Tags cbCaseFixingValidation.Checked = cbCaseFixingValidation.Tag.ToString().Contains(":true"); cbCreateProcedureInOutput.Checked = cbCreateProcedureInOutput.Tag.ToString().Contains(":true"); cbFormatOutput.Checked = cbFormatOutput.Tag.ToString().Contains(":true"); cbGenerateConversionComments.Checked = cbGenerateConversionComments.Tag.ToString().Contains(":false"); configFileControl.OpenDialogFilter = "Text Files|*.txt|All Files|*.*"; configFileControl.OpenDialogTitle = ResGUIStr.TITLE_SELECT_CONFIG_FILE; inputFileControl.OpenDialogFilter = "Sql Files|*.sql|All Files|*.*"; inputFileControl.OpenDialogTitle = ResGUIStr.TITLE_SELECT_INPUT_FILE; outputFileControl.OpenDialogFilter = "Sql Files|*.sql|All Files|*.*"; outputFileControl.OpenDialogTitle = ResGUIStr.TITLE_SELECT_OUTPUT_FILE; controlsList = new List <Control>(); controlsList.Add(cbCaseFixingValidation); controlsList.Add(cbCreateProcedureInOutput); controlsList.Add(cbFormatOutput); controlsList.Add(cbGenerateConversionComments); controlsList.Add(tbHANAHostname); controlsList.Add(tbHANAPassword); controlsList.Add(tbHANASchema); controlsList.Add(tbHANAUser); /*controlsList.Add(tbMSDatabase); * controlsList.Add(tbMSHostname); * controlsList.Add(tbMSPassword); * controlsList.Add(tbMSUser); */ controlsList.Add(tbHANAPort); controlsList.Add(tbMSPort); controlsList.Add(inputFileControl); controlsList.Add(outputFileControl); TranslatorTool tool = new TranslatorTool(); Config.Initialize(null); PrepareForm(); if (Config.InputFile.Length == 0) { outputFileControl.FileName = ""; } if (Config.isInitialized) { configFileControl.FileName = Config.configFileName; } tool.Close(); }
// this method uses Tags defined in UI for some controls!!! private void Run() { string input = ""; string output = ""; // this runs on the UI thread, otherwise it would be not thread safe // and we would get errors while debugging btnRun... and label1... this.Invoke((MethodInvoker) delegate { btnRun.Enabled = false; label1.Text = ResStr.INF_TRANSLATOR_RUNNING; input = sourceLeft.Text; }); tool = new TranslatorTool(); StringBuilder stringBuilder = GenerateCommandLine(); string[] strings = stringBuilder.ToString().TrimEnd(' ').Split(' '); int numOfStatements; int numOfErrors; try { tool.ApplyLocalSettings(); output = tool.RunConversion(strings, input, out lastResult, out numOfStatements, out numOfErrors); } catch { output = ResStr.ERR_CRITICAL_SYNTAX_ERROR; } //MessageBox.Show(lastResult); tool.Close(); this.Invoke((MethodInvoker) delegate { btnRun.Enabled = true; label1.Text = ""; sourceRight.Clear(); sourceRight.AppendText(output, Color.Black); HighlightText(sourceLeft); HighlightText(sourceRight); ShowResults(); }); }
private void configFileControl_OpenButtonClicked() { tool = new TranslatorTool(configFileControl.OpenDialogFileName); PrepareForm(); tool.Close(); }