Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include once "aulib/file/AuFile.bas"
- #include once "aulib/collection/AuList.bas"
- using AuLib
- type control
- as string objectName
- as string objectType
- as string controlType
- end type
- type font
- as string fontName = "Arial"
- as single size = 9
- end type
- type form
- as string objectName
- as string text
- as integer wdth
- as integer hght
- as ubyte backColorR
- as ubyte backColorG
- as ubyte backColorB
- as font fnt
- end type
- type label
- as string objectName
- as string text
- as boolean autoSize
- as integer tabIndex
- as integer wdth
- as integer hght
- as integer px
- as integer py
- as font fnt
- end type
- type textBox
- as string objectName
- as string text
- as string passwordChar
- as integer maxLength = 32767
- as integer tabIndex
- as integer wdth
- as integer hght
- as integer px
- as integer py
- as boolean multiLine
- as font fnt
- end type
- type button
- as string objectName
- as string text
- as boolean autoSize
- as integer tabIndex
- as integer wdth
- as integer hght
- as integer px
- as integer py
- as font fnt
- end type
- type spinner
- as string objectName
- as integer tabIndex
- as integer wdth
- as integer hght
- as integer px
- as integer py
- end type
- type grid
- as string objectName
- as integer tabIndex
- as integer wdth
- as integer hght
- as integer px
- as integer py
- end type
- function parseObjectTag(tag as string) as string
- tag = trim(tag, "<")
- tag = trim(tag, ">")
- return tag
- end function
- function trimNewLine(content as string) as string
- return rTrim(content, !"\n")
- '= left(frm.VFP_properties, len(frm.VFP_properties)-1)
- end function
- dim as AuFile file
- dim as boolean inObject = false
- dim as string currentObject
- dim as form frm
- DeclareList(control)
- dim as controlList controls
- dim as control ptr cnt
- DeclareList(label)
- dim as labelList labels
- dim as label ptr lbl
- DeclareList(textbox)
- dim as textboxList textboxes
- dim as textbox ptr txt
- DeclareList(button)
- dim as buttonList buttons
- dim as button ptr btn
- DeclareList(spinner)
- dim as spinnerList spinners
- dim as spinner ptr spn
- DeclareList(grid)
- dim as gridList grids
- dim as grid ptr grd
- file.openRead("Properties_Output.txt")
- do
- 'Read line
- dim as string curLine = file.readLine()
- if(NOT inObject) then
- 'Expect the start of an object
- inObject = true
- select case curLine
- case "<FORM>"
- currentObject = parseObjectTag(curLine)
- case "<LABEL>"
- currentObject = parseObjectTag(curLine)
- lbl = new label
- cnt = new control
- cnt->objectType = currentObject
- cnt->controlType = "Label"
- case "<TEXTBOX>", "<EDITBOX>"
- currentObject = parseObjectTag(curLine)
- txt = new textbox
- cnt = new control
- cnt->objectType = "TEXTBOX"
- cnt->controlType = "TextBox"
- if(currentObject = "TEXTBOX") then
- txt->multiLine = false
- else
- txt->multiLine = true
- end if
- case "<COMMANDBUTTON>"
- currentObject = parseObjectTag(curLine)
- btn = new button
- cnt = new control
- cnt->objectType = currentObject
- cnt->controlType = "Button"
- case "<SPINNER>"
- currentObject = parseObjectTag(curLine)
- spn = new spinner
- cnt = new control
- cnt->objectType = currentObject
- cnt->controlType = "NumericUpDown"
- case "<GRID>"
- currentObject = parseObjectTag(curLine)
- grd = new grid
- cnt = new control
- cnt->objectType = currentObject
- cnt->controlType = "DataGridView"
- case else
- inObject = false
- end select
- else
- 'Expect properties or end of object tag
- if(curLine = "<END_" + currentObject + ">") then
- 'No longer expecting object properties
- inObject = false
- select case currentObject
- case "FORM"
- case "LABEL"
- cnt->objectName = lbl->objectName
- controls.add(*cnt)
- delete cnt
- labels.add(*lbl)
- delete lbl
- case "TEXTBOX", "EDITBOX"
- cnt->objectName = txt->objectName
- controls.add(*cnt)
- delete cnt
- textboxes.add(*txt)
- delete txt
- case "COMMANDBUTTON"
- cnt->objectName = btn->objectName
- controls.add(*cnt)
- delete cnt
- buttons.add(*btn)
- delete btn
- case "SPINNER"
- cnt->objectName = spn->objectName
- controls.add(*cnt)
- delete cnt
- spinners.add(*spn)
- delete spn
- case "GRID"
- cnt->objectName = grd->objectName
- controls.add(*cnt)
- delete cnt
- grids.add(*grd)
- delete grd
- end select
- else
- 'Feed properties to the object
- dim as string prop = left(curLine,instr(curLine," ")-1)
- dim as integer numVal = val(mid(curLine, inStrRev(curLine, " ")+1, len(curLine)))
- dim as string strVal = mid(curLine, inStrRev(curLine, "=")+3, len(curLine) - inStrRev(curLine, "=") - 3)
- dim as boolean boolVal = iif(UCASE(strVal) = "T", true, false)
- 'Current object
- select case currentObject
- case "FORM"
- select case prop
- case "Name"
- frm.objectName = strVal
- case "Caption"
- frm.text = strVal
- case "Width"
- frm.wdth = numVal
- case "Height"
- frm.hght = numVal
- case "BackColor"
- frm.backColorR = val(left(str(numVal), inStr(str(numVal), ",")-1))
- frm.backColorG = val(mid(str(numVal), inStr(str(numVal), ",")+1, inStr(str(numVal), ",")-1))
- frm.backColorB = val(right(str(numVal), inStr(str(numVal), ",")-1))
- end select
- case "LABEL"
- select case prop
- case "Name"
- lbl->objectName = strVal
- case "Caption"
- lbl->text = strVal
- case "AutoSize"
- lbl->autoSize = boolVal
- case "TabIndex"
- lbl->tabIndex = numVal
- case "Width"
- lbl->wdth = numVal
- case "Height"
- lbl->hght = numVal
- case "Left"
- lbl->px = numVal
- case "Top"
- lbl->py = numVal
- case "FontName"
- btn->fnt.fontName = strVal
- end select
- case "TEXTBOX", "EDITBOX"
- select case prop
- case "Name"
- txt->objectName = strVal
- case "PasswordChar"
- txt->passwordChar = strVal
- case "MaxLength"
- txt->maxLength = numVal
- case "TabIndex"
- txt->tabIndex = numVal
- case "Width"
- txt->wdth = numVal
- case "Height"
- txt->hght = numVal
- case "Left"
- txt->px = numVal
- case "Top"
- txt->py = numVal
- case "FontName"
- btn->fnt.fontName = strVal
- end select
- case "COMMANDBUTTON"
- select case prop
- case "Name"
- btn->objectName = strVal
- case "Caption"
- btn->text = strVal
- case "AutoSize"
- btn->autoSize = numVal
- case "Width"
- btn->wdth = numVal
- case "Height"
- btn->hght = numVal
- case "Left"
- btn->px = numVal
- case "Top"
- btn->py = numVal
- case "FontName"
- btn->fnt.fontName = strVal
- end select
- case "SPINNER"
- select case prop
- case "Name"
- spn->objectName = strVal
- case "Width"
- spn->wdth = numVal
- case "Height"
- spn->hght = numVal
- case "Left"
- spn->px = numVal
- case "Top"
- spn->py = numVal
- case "FontName"
- btn->fnt.fontName = strVal
- end select
- case "GRID"
- select case prop
- case "Name"
- grd->objectName = strVal
- case "Width"
- grd->wdth = numVal
- case "Height"
- grd->hght = numVal
- case "Left"
- grd->px = numVal
- case "Top"
- grd->py = numVal
- case "FontName"
- btn->fnt.fontName = strVal
- end select
- end select
- end if
- end if
- loop until(file.endOfFile)
- file.closeFile()
- for i as integer = 0 to controls.length()-1
- select case controls.item[i].objectType
- case ""
- end select
- next i
- 'var jj = 1
- 'print labels.item[jj].objectName
- 'print labels.item[jj].text
- 'print labels.item[jj].wdth
- 'print labels.item[jj].hght
- 'print labels.item[jj].px
- 'print labels.item[jj].py
- 'Create the designer file
- file.openWrite(frm.objectName + ".Designer.cs")
- file.print("namespace ConnorsMasterPiece")
- file.print("{")
- file.print(" partial class frmTest3")
- file.print(" {")
- file.print(" /// <summary>")
- file.print(" /// Required designer variable.")
- file.print(" /// </summary>")
- file.print(" private System.ComponentModel.IContainer components = null;")
- file.print(" ")
- file.print(" /// <summary>")
- file.print(" /// Clean up any resources being used.")
- file.print(" /// </summary>")
- file.print(!" /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>")
- file.print(" protected override void Dispose(bool disposing)")
- file.print(" {")
- file.print(" if (disposing && (components != null))")
- file.print(" {")
- file.print(" components.Dispose();")
- file.print(" }")
- file.print(" base.Dispose(disposing);")
- file.print(" }")
- file.print(" ")
- file.print(" #region Windows Form Designer generated code")
- file.print(" /// <summary>")
- file.print(" /// Required method for Designer support - do not modify")
- file.print(" /// the contents of this method with the code editor.")
- file.print(" /// </summary>")
- file.print(" ")
- file.print(" private void InitializeComponent()")
- file.print(" {")
- for i as integer = 0 to controls.length()-1
- dim as string mainLine
- mainLine = "this." + controls.item[i].objectName + " = new System.Windows.Forms."
- file.print(" " + mainLine + controls.item[i].controlType + "();")
- next i
- for i as integer = 0 to controls.length()-1
- select case controls.item[i].objectType
- case "SPINNER"
- file.print(" ((System.ComponentModel.ISupportInitialize)(this." + controls.item[i].objectName + ")).BeginInit();")
- case "GRID"
- file.print(" ((System.ComponentModel.ISupportInitialize)(this." + controls.item[i].objectName + ")).BeginInit();")
- end select
- next i
- file.print(" this.SuspendLayout();")
- for i as integer = 0 to controls.length()-1
- file.print(" //")
- file.print(" // " + controls.item[i].objectName)
- file.print(" //")
- next i
- file.print(" //")
- file.print(" // " + frm.objectName)
- file.print(" //")
- file.print(" this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);")
- file.print(" this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;")
- file.print(" this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(" + str(frm.backColorR) + ")))), ((int)(((byte)(" + str(frm.backColorG) + ")))), ((int)(((byte)(" + str(frm.backColorB) + ")))));")
- file.print(" this.ClientSize = new System.Drawing.Size(" + str(frm.wdth) + ", " + str(frm.hght) + ");")
- for i as integer = controls.length()-1 to 0 step -1
- file.print(" this.Controls.Add(this." + controls.item[i].objectName + ");")
- next i
- file.print(!" this.Font = new System.Drawing.Font(\"" + frm.fnt.fontName + !"\", " + str(frm.fnt.size) + "F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));")
- file.print(!" this.Name = \"" + frm.objectName + !"\";")
- for i as integer = 0 to controls.length()-1
- select case controls.item[i].objectType
- case "SPINNER"
- file.print(" ((System.ComponentModel.ISupportInitialize)(this." + controls.item[i].objectName + ")).EndInit();")
- case "GRID"
- file.print(" ((System.ComponentModel.ISupportInitialize)(this." + controls.item[i].objectName + ")).EndInit();")
- end select
- next i
- file.print(" this.ResumeLayout(false);")
- file.print(" this.PerformLayout();")
- file.print(" ")
- file.print(" }")
- file.print(" ")
- file.print(" #endregion")
- file.print(" ")
- for i as integer = 0 to controls.length()-1
- file.print(" private System.Windows.Forms." + controls.item[i].controlType + " " + controls.item[i].objectName + ";")
- next i
- file.print(" }")
- file.print("}")
- file.closeFile()
- 'Create the main .cs file
- file.openWrite(frm.objectName + ".cs")
- file.print("using System;")
- file.print("using System.Collections.Generic;")
- file.print("using System.ComponentModel;")
- file.print("using System.Data;")
- file.print("using System.Drawing;")
- file.print("using System.Linq;")
- file.print("using System.Text;")
- file.print("using System.Threading.Tasks;")
- file.print("using System.Windows.Forms;")
- file.print()
- file.print("namespace _NAMESPACE_")
- file.print("{")
- file.print(" public partial class " + frm.objectName + " : Form")
- file.print(" {")
- file.print(" public " + frm.objectName + "()")
- file.print(" {")
- file.print(" InitializeComponent();")
- file.print(" }")
- file.print(" }")
- file.print("}")
- file.closeFile()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement