public void SetSelectedField(int index) { try { field = page.Fields[index]; }catch(Exception) { return; } }
public void AddFieldToView( int index, Field field ) { dialog.AddFieldToVBox(index, field.Name, field.Keyboard, field.MaxLen, field.Example, field.Message, field.Title, field.Regex, field.Split, field.Text); }
public void AddFieldToModel(Field field) { Page.Fields.Add(field); }
public void AddField(Field field) { Model.Pages[0].Fields.Add(field); }
public FormModel ConvertPhpPartToXml(String phpPart) { MatchCollection matches = Regex.Matches(phpPart, @"'(\w*)' => '?(.[^']*)'?,"); Dictionary<String, String> dict = ConstructDictionary(matches); FormModel model = new FormModel(); Field field = new Field(); field.Name = "id1"; foreach(KeyValuePair<String, String> pair in dict) { if(pair.Key == "reg_exp") { field.Regex = pair.Value; if(field.Regex.Contains("a") || field.Regex.Contains("z") || field.Regex.Contains("A") || field.Regex.Contains("Z")) { field.Keyboard = Field.KeyboardType.Letters; } // field.MaxLen = CalculateMaxLenRegex(field.Regex); } else if(pair.Key == "acc_mask") { field.MaxLen = CalculateMaxLenString(pair.Value); field.Split = ConertMask(pair.Value); } else if(pair.Key == "acc_name") { field.Title = pair.Value; if(!pair.Value.ToLower().Contains("введите")) field.Message = "Введите " + pair.Value.ToLower(); else field.Message = pair.Value; } else if(pair.Key == "name") { model.Name = pair.Value; } else if(pair.Key == "condition_info") { if(pair.Value.Length == 0) continue; field.Help = Regex.Replace(pair.Value, @"<.+?>", " "); } else if(pair.Key == "display_scheme") { if(pair.Value.Contains("<page>")) { model.Pages.AddRange(ConstructAndReturnPages(pair.Value)); } else if(pair.Value.Contains("<field ")) { model.Pages.Add(ConstructPage(pair.Value)); } } } model.Pages[0].Fields.Add(field); return model; }
protected Field ConstructDisplaySchemeField(XmlNode node, int fieldNum) { Field field = new Field(); field.Name = "id" + (fieldNum + 2).ToString(); XmlAttribute keyboard = node.Attributes["keyboard"]; if(keyboard != null && keyboard.Value.Length != 0) { // TODO: Might wanna add some more if(keyboard.Value == "latletters") field.Keyboard = Field.KeyboardType.Letters; else if (keyboard.Value.Contains("letters")) field.Keyboard = Field.KeyboardType.LettersEnRu; } XmlAttribute hint = node.Attributes["hint"]; if(hint!=null && hint.Value.Length != 0) { if(!hint.Value.ToLower().Contains("введите")) field.Message = "Введите " + hint.Value.ToLower(); else field.Message = hint.Value; } XmlAttribute mask = node.Attributes["mask"]; if(mask != null && mask.Value.Length!=0) { String maskStr = mask.Value; int indexOfSemiColumn = mask.Value.IndexOf(";"); if(indexOfSemiColumn > 3 ) maskStr = maskStr.Substring(0, indexOfSemiColumn); maskStr = maskStr.Replace("9", "*"); maskStr = maskStr.Replace("//", ""); maskStr = maskStr.Replace("\\", ""); field.Split = maskStr; } XmlAttribute regex = node.Attributes["regexp"]; if(regex !=null && regex.Value.Length!=0) { field.Regex = regex.Value; } return field; }