private Point GetFieldLocation(FormatField field) { Point point = new Point(0, 0); int pointX = 0; int pointY = 0; //Look into the property first. if (!string.IsNullOrEmpty(field.Property)) { if (field.PropertyObject.Items.ContainsKey("X")) { pointX = field.PropertyObject.X * widthUnitPixel; } if (field.PropertyObject.Items.ContainsKey("Y")) { pointY = field.PropertyObject.Y * unitPixel; } } //If no such field, then look into column and line. if (pointX == 0) { pointX = (field.Column - 1) * 2 * widthUnitPixel; } if (pointY == 0) { pointY = (field.Line - 1) * 2 * unitPixel; } point = new Point(pointX, pointY); return(point); }
private void ShowLabel(FormatField field, Control parent) { Label label = new Label(); //if (!string.IsNullOrEmpty(field.Property)) //{ // label.Location = new Point(field.PropertyObject.X * widthUnitPixel, field.PropertyObject.Y * unitPixel); // label.Width = field.PropertyObject.Width * widthUnitPixel; // label.Height = field.PropertyObject.Height * unitPixel; // label.Text = field.PropertyObject.Items["Caption"]; //} //else //{ // label.Location = new Point((field.Column - 1) * 2 * widthUnitPixel, (field.Line - 1) * 2 * unitPixel); // label.Width = field.Length * 2 * widthUnitPixel; // //label.Height = field.PropertyObject.Height * unitPixel; // label.Text = field.Output; //} label.Location = GetFieldLocation(field); label.Width = GetFieldWidth(field); label.Height = GetFieldHeight(field); label.Text = GetFieldCaption(field); parent.Controls.Add(label); UpdateSize(parent, label); }
private int GetFieldHeight(FormatField field) { if (!string.IsNullOrEmpty(field.Property)) { return(field.PropertyObject.Height * unitPixel); } else { return(unitPixel); } }
private int GetFieldWidth(FormatField field) { if (!string.IsNullOrEmpty(field.Property)) { return(field.PropertyObject.Width * widthUnitPixel); } else { return(field.Length * 2 * widthUnitPixel); } }
private void ShowSingleTextControl(FormatField field, Control parent) { TextBox textBox = new TextBox(); textBox.Location = GetFieldLocation(field); textBox.Width = GetFieldWidth(field); textBox.Height = GetFieldHeight(field); string inputName = GetFieldInput(field); if (!string.IsNullOrEmpty(inputName)) { textBox.Name = inputName.Replace('.', '_'); } parent.Controls.Add(textBox); UpdateSize(parent, textBox); }
private string GetFieldCaption(FormatField field) { string caption = ""; if (!string.IsNullOrEmpty(field.Property)) { if (field.PropertyObject.Items.ContainsKey("Caption")) { caption = field.PropertyObject.Items["Caption"]; } } else { caption = field.Output; } return(caption); }
private string GetFieldInput(FormatField field) { string inputName = ""; if (!string.IsNullOrEmpty(field.Property)) { if (field.PropertyObject.Items.ContainsKey("Input")) { inputName = field.PropertyObject.Items["Input"]; } } else { inputName = field.Input; } return(inputName); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="parent"></param> private void ShowTextControl(FormatField field, Control parent) { if (field.Window == 0) { ShowSingleTextControl(field, parent); } else { if (field.PropertyObject.Items.ContainsKey("Elastic")) { ShowMultiTextControl(field, parent); } else { ShowListBox(field, parent); } } }
private void ShowMultiTextControl(FormatField field, Control parent) { Scintilla textBox = new Scintilla(); SetCodeViewerStyle(textBox); textBox.Location = GetFieldLocation(field); textBox.Width = GetFieldWidth(field); textBox.Height = GetFieldHeight(field) * field.Window; string inputName = GetFieldInput(field); if (!string.IsNullOrEmpty(inputName)) { textBox.Name = inputName.Replace('.', '_'); } parent.Controls.Add(textBox); UpdateSize(parent, textBox); }
private void ShowListBox(FormatField field, Control parent) { ListBox listBox = new ListBox(); //listBox.Location = new Point(field.PropertyObject.X * widthUnitPixel, field.PropertyObject.Y * unitPixel); //listBox.Width = field.PropertyObject.Width * widthUnitPixel; //listBox.Height = field.PropertyObject.Height * field.Window * unitPixel; listBox.Location = GetFieldLocation(field); listBox.Width = GetFieldWidth(field); listBox.Height = GetFieldHeight(field) * field.Window; string inputName = GetFieldInput(field); if (!string.IsNullOrEmpty(inputName)) { listBox.Name = inputName.Replace('.', '_'); } parent.Controls.Add(listBox); UpdateSize(parent, listBox); }
private void ShowFormat(Format formatObject, Control parent) { int fieldIndex = 0; while (fieldIndex < formatObject.Fields.Count) { FormatField field = formatObject.Fields[fieldIndex]; if (!string.IsNullOrEmpty(field.Property)) { if (field.PropertyObject.FieldType == "Label") { ShowLabel(field, parent); } else if (field.PropertyObject.FieldType == "Text") { ShowTextControl(field, parent); } else { } } else { //Label if (field.Attribute == 2) { ShowLabel(field, parent); } else if (field.Attribute == 1) //Text Box { ShowTextControl(field, parent); } if (!string.IsNullOrEmpty(field.Output)) { ShowLabel(field, parent); } } fieldIndex++; } }