using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using SU = Laj.StringUtils;
using BE = Laj.BabbelFisken.Backend;
namespace Laj.BabbelFisken
{
// Last modified: 2002-10-05
// Version: 0.55 ID:LAJ44004
// Compiles with Microsoft Visual C# .NET 7.0.9466 on Windows 95.
// The source code is free. It is not under any kind of license.
// If this code works, it was written by Lars Johansson, Göteborg.
// If not, I don't know who wrote it.
// Changes:
// Version: 0.43
// ref changed to out for Delphi functions/procedures.
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemFile;
private System.Windows.Forms.MenuItem menuItemNew;
private System.Windows.Forms.MenuItem menuItemSaveAs;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItemExit;
private System.Windows.Forms.MenuItem menuItemEdit;
private System.Windows.Forms.MenuItem menuItemClearAll;
private System.Windows.Forms.MenuItem menuItemHelp;
private System.Windows.Forms.MenuItem menuItemHelpTopics;
private System.Windows.Forms.MenuItem menuItem37;
private System.Windows.Forms.MenuItem menuItemAbout;
private System.Windows.Forms.Panel panelLeft;
private System.Windows.Forms.Panel panelTop;
private System.Windows.Forms.Panel panelLeftTop;
private System.Windows.Forms.Panel panelLeftBottom;
private System.Windows.Forms.TextBox textBoxLegacyFile;
private System.Windows.Forms.TextBox textBoxResultFile;
private System.Windows.Forms.Panel panelRight;
private System.Windows.Forms.Panel panelRightTop;
private System.Windows.Forms.Panel panelRightBottom;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBoxChoseLegacyLanguage;
private System.Windows.Forms.MenuItem menuItemTranslateMain;
private System.Windows.Forms.MenuItem menuItemTranslate;
private System.Windows.Forms.Button buttonNew;
private System.Windows.Forms.Button buttonOpen;
private System.Windows.Forms.Button buttonSave;
private System.Windows.Forms.Button buttonTranslate;
private System.Windows.Forms.Button buttonHelp;
private System.Windows.Forms.MenuItem menuItemOpenDelphi;
private System.Windows.Forms.MenuItem menuItemOpenVBNET;
private System.Windows.Forms.MenuItem menuItemOpenVB6;
private System.Windows.Forms.MenuItem menuItemOpen;
private System.ComponentModel.IContainer components;
public Form1()
{
InitializeComponent();
toolTip = new System.Windows.Forms.ToolTip (this.components);
toolTip.SetToolTip (this.buttonNew, "New Blank Legacy Source Code Document (Ctrl+N)");
toolTip.SetToolTip (this.buttonOpen, "Open Legacy Source Code (Ctrl+O)");
toolTip.SetToolTip (this.buttonSave, "Save Translated Code As (Ctrl+S)");
toolTip.SetToolTip (this.comboBoxChoseLegacyLanguage, "Choose translation");
toolTip.SetToolTip (this.buttonTranslate, "Execute Translation (Ctrl+T)");
toolTip.SetToolTip (this.buttonHelp, "Help (F1)");
toolTip.Active = true;
this.Text = Application.ProductName;
menuItemAbout.Text = "About " + Application.ProductName;
comboBoxChoseLegacyLanguage.SelectedIndex = 0;
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItemFile = new System.Windows.Forms.MenuItem();
this.menuItemNew = new System.Windows.Forms.MenuItem();
this.menuItemOpenDelphi = new System.Windows.Forms.MenuItem();
this.menuItemOpenVBNET = new System.Windows.Forms.MenuItem();
this.menuItemOpenVB6 = new System.Windows.Forms.MenuItem();
this.menuItemOpen = new System.Windows.Forms.MenuItem();
this.menuItemSaveAs = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItemExit = new System.Windows.Forms.MenuItem();
this.menuItemEdit = new System.Windows.Forms.MenuItem();
this.menuItemClearAll = new System.Windows.Forms.MenuItem();
this.menuItemTranslateMain = new System.Windows.Forms.MenuItem();
this.menuItemTranslate = new System.Windows.Forms.MenuItem();
this.menuItemHelp = new System.Windows.Forms.MenuItem();
this.menuItemHelpTopics = new System.Windows.Forms.MenuItem();
this.menuItem37 = new System.Windows.Forms.MenuItem();
this.menuItemAbout = new System.Windows.Forms.MenuItem();
this.panelLeft = new System.Windows.Forms.Panel();
this.panelLeftBottom = new System.Windows.Forms.Panel();
this.textBoxLegacyFile = new System.Windows.Forms.TextBox();
this.panelLeftTop = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panelTop = new System.Windows.Forms.Panel();
this.buttonHelp = new System.Windows.Forms.Button();
this.buttonTranslate = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonOpen = new System.Windows.Forms.Button();
this.buttonNew = new System.Windows.Forms.Button();
this.comboBoxChoseLegacyLanguage = new System.Windows.Forms.ComboBox();
this.panelRight = new System.Windows.Forms.Panel();
this.panelRightBottom = new System.Windows.Forms.Panel();
this.textBoxResultFile = new System.Windows.Forms.TextBox();
this.panelRightTop = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panelLeft.SuspendLayout();
this.panelLeftBottom.SuspendLayout();
this.panelLeftTop.SuspendLayout();
this.panelTop.SuspendLayout();
this.panelRight.SuspendLayout();
this.panelRightBottom.SuspendLayout();
this.panelRightTop.SuspendLayout();
this.SuspendLayout();
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemFile,
this.menuItemEdit,
this.menuItemTranslateMain,
this.menuItemHelp});
//
// menuItemFile
//
this.menuItemFile.Index = 0;
this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemNew,
this.menuItemOpenDelphi,
this.menuItemOpenVBNET,
this.menuItemOpenVB6,
this.menuItemOpen,
this.menuItemSaveAs,
this.menuItem12,
this.menuItemExit});
this.menuItemFile.Text = "File";
//
// menuItemNew
//
this.menuItemNew.Index = 0;
this.menuItemNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
this.menuItemNew.Text = "&New Blank Legacy Source Code Document";
this.menuItemNew.Click += new System.EventHandler(this.menuItemNew_Click);
//
// menuItemOpenDelphi
//
this.menuItemOpenDelphi.Index = 1;
this.menuItemOpenDelphi.Shortcut = System.Windows.Forms.Shortcut.CtrlD;
this.menuItemOpenDelphi.Text = "Open &Delphi Source Code...";
this.menuItemOpenDelphi.Click += new System.EventHandler(this.menuItemOpen_Click);
//
// menuItemOpenVBNET
//
this.menuItemOpenVBNET.Index = 2;
this.menuItemOpenVBNET.Shortcut = System.Windows.Forms.Shortcut.CtrlB;
this.menuItemOpenVBNET.Text = "Open V&B.NET Source Code...";
this.menuItemOpenVBNET.Click += new System.EventHandler(this.menuItemOpen_Click);
//
// menuItemOpenVB6
//
this.menuItemOpenVB6.Index = 3;
this.menuItemOpenVB6.Shortcut = System.Windows.Forms.Shortcut.Ctrl6;
this.menuItemOpenVB6.Text = "Open VB&6 Source Code...";
this.menuItemOpenVB6.Click += new System.EventHandler(this.menuItemOpen_Click);
//
// menuItemOpen
//
this.menuItemOpen.Index = 4;
this.menuItemOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
this.menuItemOpen.Text = "Open File...";
this.menuItemOpen.Visible = false;
this.menuItemOpen.Click += new System.EventHandler(this.menuItemOpen_Click);
//
// menuItemSaveAs
//
this.menuItemSaveAs.Index = 5;
this.menuItemSaveAs.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
this.menuItemSaveAs.Text = "&Save Translated Code As...";
this.menuItemSaveAs.Click += new System.EventHandler(this.menuItemSave_Click);
//
// menuItem12
//
this.menuItem12.Index = 6;
this.menuItem12.Text = "-";
//
// menuItemExit
//
this.menuItemExit.Index = 7;
this.menuItemExit.Text = "E&xit";
this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
//
// menuItemEdit
//
this.menuItemEdit.Index = 1;
this.menuItemEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemClearAll});
this.menuItemEdit.Text = "Edit";
//
// menuItemClearAll
//
this.menuItemClearAll.Index = 0;
this.menuItemClearAll.Text = "C&lear All";
this.menuItemClearAll.Click += new System.EventHandler(this.menuItemClearAll_Click);
//
// menuItemTranslateMain
//
this.menuItemTranslateMain.Index = 2;
this.menuItemTranslateMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemTranslate});
this.menuItemTranslateMain.Text = "Translate";
//
// menuItemTranslate
//
this.menuItemTranslate.Index = 0;
this.menuItemTranslate.Shortcut = System.Windows.Forms.Shortcut.CtrlT;
this.menuItemTranslate.Text = "&Translate";
this.menuItemTranslate.Click += new System.EventHandler(this.menuItemTranslate_Click);
//
// menuItemHelp
//
this.menuItemHelp.Index = 3;
this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemHelpTopics,
this.menuItem37,
this.menuItemAbout});
this.menuItemHelp.Text = "Help";
//
// menuItemHelpTopics
//
this.menuItemHelpTopics.Index = 0;
this.menuItemHelpTopics.Shortcut = System.Windows.Forms.Shortcut.F1;
this.menuItemHelpTopics.Text = "&Help Topics";
this.menuItemHelpTopics.Click += new System.EventHandler(this.menuItemHelpTopics_Click);
//
// menuItem37
//
this.menuItem37.Index = 1;
this.menuItem37.Text = "-";
//
// menuItemAbout
//
this.menuItemAbout.Index = 2;
this.menuItemAbout.Text = "&About BabbelFisken";
this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
//
// panelLeft
//
this.panelLeft.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelLeft.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panelLeftBottom,
this.panelLeftTop});
this.panelLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.panelLeft.Location = new System.Drawing.Point(0, 28);
this.panelLeft.Name = "panelLeft";
this.panelLeft.Size = new System.Drawing.Size(390, 525);
this.panelLeft.TabIndex = 0;
//
// panelLeftBottom
//
this.panelLeftBottom.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBoxLegacyFile});
this.panelLeftBottom.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelLeftBottom.Location = new System.Drawing.Point(0, 23);
this.panelLeftBottom.Name = "panelLeftBottom";
this.panelLeftBottom.Size = new System.Drawing.Size(388, 500);
this.panelLeftBottom.TabIndex = 1;
//
// textBoxLegacyFile
//
this.textBoxLegacyFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBoxLegacyFile.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBoxLegacyFile.Multiline = true;
this.textBoxLegacyFile.Name = "textBoxLegacyFile";
this.textBoxLegacyFile.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBoxLegacyFile.Size = new System.Drawing.Size(388, 500);
this.textBoxLegacyFile.TabIndex = 6;
this.textBoxLegacyFile.Text = "";
this.textBoxLegacyFile.WordWrap = false;
//
// panelLeftTop
//
this.panelLeftTop.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1});
this.panelLeftTop.Dock = System.Windows.Forms.DockStyle.Top;
this.panelLeftTop.Name = "panelLeftTop";
this.panelLeftTop.Size = new System.Drawing.Size(388, 23);
this.panelLeftTop.TabIndex = 0;
//
// label1
//
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Legacy Source Code";
//
// panelTop
//
this.panelTop.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelTop.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonHelp,
this.buttonTranslate,
this.buttonSave,
this.buttonOpen,
this.buttonNew,
this.comboBoxChoseLegacyLanguage});
this.panelTop.Dock = System.Windows.Forms.DockStyle.Top;
this.panelTop.Name = "panelTop";
this.panelTop.Size = new System.Drawing.Size(792, 28);
this.panelTop.TabIndex = 2;
//
// buttonHelp
//
this.buttonHelp.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonHelp.Image")));
this.buttonHelp.ImageIndex = 4;
this.buttonHelp.ImageList = this.imageList1;
this.buttonHelp.Location = new System.Drawing.Point(264, 0);
this.buttonHelp.Name = "buttonHelp";
this.buttonHelp.Size = new System.Drawing.Size(25, 25);
this.buttonHelp.TabIndex = 5;
this.buttonHelp.Click += new System.EventHandler(this.menuItemHelpTopics_Click);
//
// buttonTranslate
//
this.buttonTranslate.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonTranslate.Image")));
this.buttonTranslate.ImageIndex = 3;
this.buttonTranslate.ImageList = this.imageList1;
this.buttonTranslate.Location = new System.Drawing.Point(232, 0);
this.buttonTranslate.Name = "buttonTranslate";
this.buttonTranslate.Size = new System.Drawing.Size(25, 25);
this.buttonTranslate.TabIndex = 4;
this.buttonTranslate.Click += new System.EventHandler(this.menuItemTranslate_Click);
//
// buttonSave
//
this.buttonSave.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonSave.Image")));
this.buttonSave.ImageIndex = 2;
this.buttonSave.ImageList = this.imageList1;
this.buttonSave.Location = new System.Drawing.Point(48, 0);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(25, 25);
this.buttonSave.TabIndex = 2;
this.buttonSave.Click += new System.EventHandler(this.menuItemSave_Click);
//
// buttonOpen
//
this.buttonOpen.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonOpen.Image")));
this.buttonOpen.ImageIndex = 1;
this.buttonOpen.ImageList = this.imageList1;
this.buttonOpen.Location = new System.Drawing.Point(24, 0);
this.buttonOpen.Name = "buttonOpen";
this.buttonOpen.Size = new System.Drawing.Size(25, 25);
this.buttonOpen.TabIndex = 1;
this.buttonOpen.Click += new System.EventHandler(this.menuItemOpen_Click);
//
// buttonNew
//
this.buttonNew.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonNew.Image")));
this.buttonNew.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.buttonNew.ImageIndex = 0;
this.buttonNew.ImageList = this.imageList1;
this.buttonNew.Name = "buttonNew";
this.buttonNew.Size = new System.Drawing.Size(25, 25);
this.buttonNew.TabIndex = 0;
this.buttonNew.Click += new System.EventHandler(this.menuItemNew_Click);
//
// comboBoxChoseLegacyLanguage
//
this.comboBoxChoseLegacyLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxChoseLegacyLanguage.Items.AddRange(new object[] {
"Delphi => C#",
"VB.NET => C#",
"VB6 => C#",
"VB6 Option Explicit => C#"});
this.comboBoxChoseLegacyLanguage.Location = new System.Drawing.Point(80, 2);
this.comboBoxChoseLegacyLanguage.Name = "comboBoxChoseLegacyLanguage";
this.comboBoxChoseLegacyLanguage.Size = new System.Drawing.Size(152, 21);
this.comboBoxChoseLegacyLanguage.TabIndex = 3;
//
// panelRight
//
this.panelRight.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelRight.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panelRightBottom,
this.panelRightTop});
this.panelRight.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelRight.Location = new System.Drawing.Point(393, 28);
this.panelRight.Name = "panelRight";
this.panelRight.Size = new System.Drawing.Size(399, 525);
this.panelRight.TabIndex = 1;
//
// panelRightBottom
//
this.panelRightBottom.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBoxResultFile});
this.panelRightBottom.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelRightBottom.Location = new System.Drawing.Point(0, 23);
this.panelRightBottom.Name = "panelRightBottom";
this.panelRightBottom.Size = new System.Drawing.Size(397, 500);
this.panelRightBottom.TabIndex = 1;
//
// textBoxResultFile
//
this.textBoxResultFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBoxResultFile.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBoxResultFile.Multiline = true;
this.textBoxResultFile.Name = "textBoxResultFile";
this.textBoxResultFile.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBoxResultFile.Size = new System.Drawing.Size(397, 500);
this.textBoxResultFile.TabIndex = 7;
this.textBoxResultFile.Text = "";
this.textBoxResultFile.WordWrap = false;
//
// panelRightTop
//
this.panelRightTop.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label2});
this.panelRightTop.Dock = System.Windows.Forms.DockStyle.Top;
this.panelRightTop.Name = "panelRightTop";
this.panelRightTop.Size = new System.Drawing.Size(397, 23);
this.panelRightTop.TabIndex = 0;
//
// label2
//
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 23);
this.label2.TabIndex = 1;
this.label2.Text = "Translated Source Code";
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(390, 28);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 525);
this.splitter1.TabIndex = 6;
this.splitter1.TabStop = false;
//
// Form1
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(792, 553);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panelRight,
this.splitter1,
this.panelLeft,
this.panelTop});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
this.panelLeft.ResumeLayout(false);
this.panelLeftBottom.ResumeLayout(false);
this.panelLeftTop.ResumeLayout(false);
this.panelTop.ResumeLayout(false);
this.panelRight.ResumeLayout(false);
this.panelRightBottom.ResumeLayout(false);
this.panelRightTop.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
System.Windows.Forms.ToolTip toolTip;
ReplaceTable rt = new ReplaceTable();
private void translateDelphi()
{
string[] stringArray = new string [textBoxLegacyFile.Lines.Length];
stringArray = textBoxLegacyFile.Lines;
textBoxResultFile.Text = "";
Delphi.FixCommentsUndSoWeiter(stringArray);
for (int k = rt.LineNumberStartReplace+1; k < rt.LineNumberEndParsing; k++)
{
if (k == rt.LineNumberDoSpecialOperations)
{
Delphi.DoSpecialOperations(stringArray);
}
else
{
string[] findReplacePair = rt.TheFileAsRows[k].Split('Ö');
if (findReplacePair.Length == 2)
{
for (int j = 0; j < stringArray.Length; j++)
{
stringArray[j] = SU.ReplaceStringMatchWholeWord(stringArray[j], false, findReplacePair[0], findReplacePair[1]);
}
}
}
}
textBoxResultFile.Lines = stringArray;
}
private void translateVBNET(bool optionExplicit)
{
string[] stringArray = VBNET.DeleteSpaceUnderscoreAndSplit(textBoxLegacyFile.Text);
textBoxResultFile.Text = "";
for (int k = rt.LineNumberStartReplace+1; k < rt.LineNumberEndParsing; k++)
{
if (k == rt.LineNumberDoSpecialOperations)
{
VBNET.AppendSemiColonUndSoWeiter(stringArray, rt);
VBNET.DoSpecialOperations(stringArray, optionExplicit);
}
else
{
string[] findReplacePair = rt.TheFileAsRows[k].Split('Ö');
if (findReplacePair.Length == 2)
{
for (int j = 0; j < stringArray.Length; j++)
{
stringArray[j] = SU.ReplaceStringMatchWholeWord(stringArray[j], true, findReplacePair[0], findReplacePair[1]);
}
}
}
}
VBNET.FixTheRest(stringArray);
textBoxResultFile.Lines = stringArray;
}
private void translateVB6(bool optionExplicit)
{
translateVBNET(optionExplicit);
}
private void menuItemTranslate_Click(object sender, System.EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
rt.LoadFile(comboBoxChoseLegacyLanguage.SelectedIndex);
switch(comboBoxChoseLegacyLanguage.SelectedIndex)
{
case 0:
translateDelphi();
break;
case 1:
translateVBNET(true);
break;
case 2:
translateVB6(false);
break;
case 3:
translateVB6(true);
break;
}
Cursor.Current = Cursors.Default;
}
void clearTextBoxLegacyFile()
{
this.Text = Application.ProductName;
textBoxLegacyFile.Text = "";
textBoxLegacyFile.Focus();
}
private void menuItemNew_Click(object sender, System.EventArgs e)
{
clearTextBoxLegacyFile();
}
void openFile(string fileName)
{
string[] theFileAsRows;
BE.OpenFile(fileName, out theFileAsRows);
this.Text = Application.ProductName + " - " + fileName;
textBoxLegacyFile.Lines = theFileAsRows;
textBoxLegacyFile.SelectionStart = 0;
textBoxLegacyFile.SelectionLength = 0;
textBoxLegacyFile.Modified = false;
textBoxLegacyFile.ClearUndo();
switch (BE.CurrentLegacyCode)
{
case BE.KindOfLegacyCode.Delphi:
case BE.KindOfLegacyCode.VBNET:
case BE.KindOfLegacyCode.VB6:
comboBoxChoseLegacyLanguage.SelectedIndex = (int)BE.CurrentLegacyCode;
break;
case BE.KindOfLegacyCode.VB6Form:
case BE.KindOfLegacyCode.VB6Class:
comboBoxChoseLegacyLanguage.SelectedIndex = 2;
break;
}
textBoxLegacyFile.Focus();
}
private void menuItemOpen_Click(object sender, System.EventArgs e)
{
if (sender == menuItemOpenDelphi)
BE.CurrentLegacyCode = BE.KindOfLegacyCode.Delphi;
else if (sender == menuItemOpenVBNET)
BE.CurrentLegacyCode = BE.KindOfLegacyCode.VBNET;
else if (sender == menuItemOpenVB6)
BE.CurrentLegacyCode = BE.KindOfLegacyCode.VB6;
string fileName;
if (BE.ShowOpenFileDialog(out fileName) ) openFile(fileName);
}
private void menuItemSave_Click(object sender, System.EventArgs e)
{
BE.ShowSaveFileDialog(textBoxResultFile.Text);
}
private void menuItemExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void menuItemClearAll_Click(object sender, System.EventArgs e)
{
clearTextBoxLegacyFile();
textBoxResultFile.Text = "";
}
private void menuItemHelpTopics_Click(object sender, System.EventArgs e)
{
try
{
Help.ShowHelp(this, "babbelfisken.htm");
}
catch
{
MessageBox.Show("babbelfisken.htm is missing...");
}
}
private void menuItemAbout_Click(object sender, System.EventArgs e)
{
Laj.DlgArchetype.DlgAbout about = new Laj.DlgArchetype.DlgAbout();
about.ShowDialog();
}
private void Form1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) )
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
string[] files = (string[])e.Data.GetData("FileDrop", false);
string fileName = files[0]; //We can only open one file..., select the first
BE.CurrentLegacyCode = BE.KindOfLegacyCode.All;
openFile(fileName);
}
}
}