//150503 public ControlInfo(string pstrSource, ref int plonProcessLocation, ref int plonNestDepth, ref Collection plstAllControls, ref Collection pcolControlsByName) public ControlInfo(string pstrSource, ref int plonProcessLocation, ref int plonNestDepth, ref Collection plstAllControls, ref Collection pcolControlsByName, bool pbolInsideFormFooter) { mbolInsideFormFooter = pbolInsideFormFooter; plstAllControls.Add(this); //note - you'll notice most "Do Until"s will have "Or plonProcessLocation >= Len(pstrSource)" in the condition for stopping the looping. This is to be sure if we unexpectedly find the end of the file that we don't error. Probably would be a better idea to actually throw an error if that happened rather than just falling out of the function while (!(pstrSource.Substring(plonProcessLocation, 5) == "Begin" | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; } plonProcessLocation += 5; //step over "Begin" plonNestDepth++; //not used? if (pstrSource.Substring(plonProcessLocation, 1) == " ") { plonProcessLocation++; //if there is a begin type then there will be a space } //find Begin type (if it has one) if (pstrSource.Substring(plonProcessLocation, 2) != System.Environment.NewLine) { //has Begin type //set start Begin type int slonStartBeginTypePos = plonProcessLocation; //find end of Begin type - pretty sure that function always is vbCrLf while (!(pstrSource.Substring(plonProcessLocation, 2) == System.Environment.NewLine | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; } //set length of Begin type int slonBeginTypeLength = plonProcessLocation - slonStartBeginTypePos; //Begin type mstrBeginType = pstrSource.Substring(slonStartBeginTypePos, slonBeginTypeLength); } plonProcessLocation += 2;//step over vbCRLf mlonControlLinesStartPos = plonProcessLocation; while (!(pstrSource.Substring(plonProcessLocation, 3) == "End")) { //run loop until finding "End" while (!(pstrSource.Substring(plonProcessLocation, 1) != " " | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; } if ((pstrSource.Substring(plonProcessLocation, 5) == "Begin")) { ControlInfo sclsControlInfo = null; sclsControlInfo = new ControlInfo(pstrSource, ref plonProcessLocation, ref plonNestDepth, ref plstAllControls, ref pcolControlsByName, mstrBeginType == "FormFooter" | mbolInsideFormFooter == true); mclsSubControls.Add(sclsControlInfo); } else if (pstrSource.Substring(plonProcessLocation, 3) == "End") { //do nothing - will kick out of Do Until loop } else { //its an Attribute Attribute sstcAttr = default(Attribute); sstcAttr = new Attribute(); //AttrName int slonStartAttrNamePos = plonProcessLocation; while (!(pstrSource.Substring(plonProcessLocation, 1) == " " | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; //find space - there is always a space after attr name } sstcAttr.Name = pstrSource.Substring(slonStartAttrNamePos, plonProcessLocation - slonStartAttrNamePos); while (!(pstrSource.Substring(plonProcessLocation, 1) == "=" | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; } plonProcessLocation++; //step over "=" //AttrValue int slonStartAttrValuePos = 0; slonStartAttrValuePos = plonProcessLocation; while (!(pstrSource.Substring(plonProcessLocation, 2) == System.Environment.NewLine | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; } sstcAttr.Value = pstrSource.Substring(slonStartAttrValuePos, plonProcessLocation - slonStartAttrValuePos); if (sstcAttr.Name == "Name") { mstrName = sstcAttr.Value; //150216 } if (sstcAttr.Name == "OnClick") { mstrOnClick = sstcAttr.Value; } if (sstcAttr.Name == "Caption") { mstrCaption = sstcAttr.Value; } if (sstcAttr.Name == "Visible") { mstrVisible = sstcAttr.Value; } if (sstcAttr.Name == "DefaultValue") { mstrDefaultValue = sstcAttr.Value; } if (sstcAttr.Name == "RowSource") { mstrRowSource = sstcAttr.Value; } if (sstcAttr.Name == "Left") { mintLeft = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "Top") { mintTop = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "Width") { mintWidth = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "Height") { mintHeight = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "SpecialEffect") { mintSpecialEffect = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "BorderWidth") { mintBorderWidth = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "ColumnCount") { mintColumnCount = Convert.ToInt32(sstcAttr.Value); } if (sstcAttr.Name == "TabIndex") { mintTabIndex = Convert.ToInt32(sstcAttr.Value); } //Ian,Alex - this is where you'd set any new properties you've added, after adding above where comment indicates //Translate vauge attribute values to correct HTML values if (mstrVisible == " NotDefault") { mstrVisible = "hidden"; } if (sstcAttr.Name == "Name") { pcolControlsByName.Add(this, sstcAttr.Value); //not used yet - I thought it would be needed but so far no } //there are Attributes (mostly bits, like GUID, PictureDate,...) that we don't care about - form is GUID = BEGIN .... END if (sstcAttr.Value == " Begin") { while (!(pstrSource.Substring(plonProcessLocation, 3) == "End" | plonProcessLocation >= pstrSource.Length)) { plonProcessLocation++; } plonProcessLocation += 3; //step over "End" } else { mlstAttributes.Add(sstcAttr); } plonProcessLocation += 2; //step over vbCrLf } } plonNestDepth--; //not used yet? mstrControlLines = pstrSource.Substring(mlonControlLinesStartPos, plonProcessLocation - mlonControlLinesStartPos); plonProcessLocation += 3; //step over "End" plonProcessLocation += 2; //step over vbCrLf }
private List <ControlInfo> mclsSubControls = new List <ControlInfo>(); //pretty sure not used yet - not sure if will be needed public void AddSubControl(ControlInfo pclsSubControl) { mclsSubControls.Add(pclsSubControl); }
//Public Property ControlLines() As String // Get // Return mstrControlLines // End Get // Set(ByVal pstrControlLines As String) // mstrControlLines = pstrControlLines // End Set //End Property //150108 Public Sub New(pstrSource As String, ByRef plonProcessLocation As Long, ByRef plonNestDepth As Long, ByRef plstAllControls As Collection) //don't think plonNestDepth is really needed - pcolControlsByName just parameter so far, code to set not done yet public ControlInfo(string pstrSource, ref int plonProcessLocation, ref int plonNestDepth, ref Collection plstAllControls, ref Collection pcolControlsByName) { //note - you'll notice most "Do Until"s will have "Or plonProcessLocation >= Len(pstrSource)" in the condition for stopping the looping. This is to be sure if we unexpectedly find the end of the file that we don't error. Probably would be a better idea to actually throw an error if that happened rather than just falling out of the function while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len("Begin")) == "Begin" | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } plonProcessLocation = plonProcessLocation + Strings.Len("Begin"); //step over Begin plonNestDepth = plonNestDepth + 1; //find Begin type (if it has one) if (Strings.Mid(pstrSource, plonProcessLocation, 2) != Constants.vbCrLf) { //has Begin type plonProcessLocation = plonProcessLocation + 1; //step over space after Begin //set start Begin type int slonStartBeginTypePos = 0; slonStartBeginTypePos = plonProcessLocation; //find end of Begin type - pretty sure that function always is vbCrLf while (!(Strings.Mid(pstrSource, plonProcessLocation, 2) == Constants.vbCrLf | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } //set length of Begin type int slonBeginTypeLength = 0; slonBeginTypeLength = plonProcessLocation - slonStartBeginTypePos; //Begin type mstrBeginType = Strings.Mid(pstrSource, slonStartBeginTypePos, slonBeginTypeLength); } plonProcessLocation = plonProcessLocation + 2; //step over vbCRLf mlonControlLinesStartPos = plonProcessLocation; while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len("End")) == "End")) { while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len(" ")) != " " | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } if (Strings.Mid(pstrSource, plonProcessLocation, Strings.Len("Begin")) == "Begin") { ControlInfo sclsControlInfo = null; sclsControlInfo = new ControlInfo(pstrSource, ref plonProcessLocation, ref plonNestDepth, ref plstAllControls, ref pcolControlsByName); mclsSubControls.Add(sclsControlInfo); } else if (Strings.Mid(pstrSource, plonProcessLocation, Strings.Len("End")) == "End") { //do nothing - will kick out of Do Until loop } else { //its an Attribute Attribute sstcAttr = default(Attribute); sstcAttr = new Attribute(); //AttrName int slonStartAttrNamePos = 0; slonStartAttrNamePos = plonProcessLocation; while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len(" ")) == " " | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } sstcAttr.Name = Strings.Mid(pstrSource, slonStartAttrNamePos, plonProcessLocation - slonStartAttrNamePos); while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len("=")) == "=" | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } plonProcessLocation = plonProcessLocation + Strings.Len("="); //step over = //AttrValue int slonStartAttrValuePos = 0; slonStartAttrValuePos = plonProcessLocation; while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len(Constants.vbCrLf)) == Constants.vbCrLf | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } sstcAttr.Value = Strings.Mid(pstrSource, slonStartAttrValuePos, plonProcessLocation - slonStartAttrValuePos); if (sstcAttr.Name == "Name") { pcolControlsByName.Add(this, sstcAttr.Value); } //there are Attributes (mostly bits, like GUID, PictureDate,...) that we don't care about - form is GUID = BEGIN .... END if (sstcAttr.Value == " Begin") { while (!(Strings.Mid(pstrSource, plonProcessLocation, Strings.Len("End")) == "End" | plonProcessLocation >= Strings.Len(pstrSource))) { plonProcessLocation = plonProcessLocation + 1; } plonProcessLocation = plonProcessLocation + Strings.Len("End"); //step over End } else { mlstAttributes.Add(sstcAttr); } plonProcessLocation = plonProcessLocation + Strings.Len(Constants.vbCrLf); //step over vbCrLf } } plonNestDepth = plonNestDepth - 1; mstrControlLines = Strings.Mid(pstrSource, mlonControlLinesStartPos, plonProcessLocation - mlonControlLinesStartPos); plonProcessLocation = plonProcessLocation + Strings.Len("End"); //step over End plonProcessLocation = plonProcessLocation + Strings.Len(Constants.vbCrLf); //step over vbCrLf }