Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 private int GetFieldHeight(FormatField field)
 {
     if (!string.IsNullOrEmpty(field.Property))
     {
         return(field.PropertyObject.Height * unitPixel);
     }
     else
     {
         return(unitPixel);
     }
 }
Пример #4
0
 private int GetFieldWidth(FormatField field)
 {
     if (!string.IsNullOrEmpty(field.Property))
     {
         return(field.PropertyObject.Width * widthUnitPixel);
     }
     else
     {
         return(field.Length * 2 * widthUnitPixel);
     }
 }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
 /// <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);
         }
     }
 }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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++;
            }
        }