Client/MainForm.cs
changeset 83 150c4a9d7e26
parent 80 408ef0501cb7
child 106 32270ff62819
     1.1 --- a/Client/MainForm.cs	Sat Dec 27 21:50:15 2014 +0100
     1.2 +++ b/Client/MainForm.cs	Sat Dec 27 21:52:14 2014 +0100
     1.3 @@ -134,16 +134,24 @@
     1.4              //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
     1.5              iTextFieldTop.Text = textBoxTop.Text;
     1.6              iTextFieldTop.Alignment = Alignment;
     1.7 -            iClient.SetField(iTextFieldTop);
     1.8 +            bool res = iClient.SetField(iTextFieldTop);
     1.9 +
    1.10 +            if (!res)
    1.11 +            {
    1.12 +                MessageBox.Show("Create you fields first", "Field update error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    1.13 +            }
    1.14 +
    1.15 +
    1.16          }
    1.17  
    1.18          private void buttonSetText_Click(object sender, EventArgs e)
    1.19          {
    1.20 -            //iClient.SetText(0,"Top");
    1.21 -            //iClient.SetText(1, "Bottom");
    1.22 -            //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
    1.23 +            //Set one column two lines layout
    1.24 +            TableLayout layout = new TableLayout(1, 2);
    1.25 +            iClient.SetLayout(layout);
    1.26  
    1.27 -            iClient.SetFields(new DataField[]
    1.28 +            //Set our fields
    1.29 +            iClient.CreateFields(new DataField[]
    1.30              {
    1.31                  new DataField(0, textBoxTop.Text, Alignment),
    1.32                  new DataField(1, textBoxBottom.Text, Alignment)
    1.33 @@ -178,7 +186,7 @@
    1.34              }
    1.35  
    1.36              DataField field = new DataField(0, bitmap);
    1.37 -            field.ColumnSpan = 2;
    1.38 +            //field.ColumnSpan = 2;
    1.39              iClient.SetField(field);
    1.40          }
    1.41  
    1.42 @@ -221,10 +229,9 @@
    1.43              DataField field = new DataField(0, bitmap);
    1.44              //We want our bitmap field to span across two rows
    1.45              field.RowSpan = 2;
    1.46 -            iClient.SetField(field);
    1.47  
    1.48              //Set texts
    1.49 -            iClient.SetFields(new DataField[]
    1.50 +            iClient.CreateFields(new DataField[]
    1.51              {
    1.52                  field,
    1.53                  new DataField(1, textBoxTop.Text, Alignment),
    1.54 @@ -232,5 +239,78 @@
    1.55              });
    1.56  
    1.57          }
    1.58 +
    1.59 +        private void buttonIndicatorsLayout_Click(object sender, EventArgs e)
    1.60 +        {
    1.61 +            //Define a 2 by 4 layout
    1.62 +            TableLayout layout = new TableLayout(2, 4);
    1.63 +            //First column
    1.64 +            layout.Columns[0].Width = 87.5F;
    1.65 +            //Second column
    1.66 +            layout.Columns[1].Width = 12.5F;
    1.67 +            //Send layout to server
    1.68 +            iClient.SetLayout(layout);
    1.69 +
    1.70 +            //Create a bitmap for our indicators field
    1.71 +            int x1 = 0;
    1.72 +            int y1 = 0;
    1.73 +            int x2 = 32;
    1.74 +            int y2 = 16;
    1.75 +
    1.76 +            Bitmap bitmap = new Bitmap(x2, y2);
    1.77 +            Pen blackPen = new Pen(Color.Black, 3);
    1.78 +
    1.79 +            // Draw line to screen.
    1.80 +            using (var graphics = Graphics.FromImage(bitmap))
    1.81 +            {
    1.82 +                graphics.DrawLine(blackPen, x1, y1, x2, y2);
    1.83 +                graphics.DrawLine(blackPen, x1, y2, x2, y1);
    1.84 +            }
    1.85 +
    1.86 +            //Create a bitmap field from the bitmap we just created
    1.87 +            DataField indicator1 = new DataField(2, bitmap);
    1.88 +            //Create a bitmap field from the bitmap we just created
    1.89 +            DataField indicator2 = new DataField(3, bitmap);
    1.90 +            //Create a bitmap field from the bitmap we just created
    1.91 +            DataField indicator3 = new DataField(4, bitmap);
    1.92 +            //Create a bitmap field from the bitmap we just created
    1.93 +            DataField indicator4 = new DataField(5, bitmap);
    1.94 +
    1.95 +            //
    1.96 +            DataField textFieldTop = new DataField(0, textBoxTop.Text, Alignment);
    1.97 +            textFieldTop.RowSpan = 2;
    1.98 +
    1.99 +            DataField textFieldBottom = new DataField(1, textBoxBottom.Text, Alignment);
   1.100 +            textFieldBottom.RowSpan = 2;
   1.101 +
   1.102 +
   1.103 +            //Set texts
   1.104 +            iClient.CreateFields(new DataField[]
   1.105 +            {
   1.106 +                textFieldTop,
   1.107 +                indicator1,
   1.108 +                indicator2,
   1.109 +                textFieldBottom,
   1.110 +                indicator3,
   1.111 +                indicator4
   1.112 +            });
   1.113 +
   1.114 +        }
   1.115 +
   1.116 +        private void buttonUpdateTexts_Click(object sender, EventArgs e)
   1.117 +        {
   1.118 +
   1.119 +            bool res = iClient.SetFields(new DataField[]
   1.120 +            {
   1.121 +                new DataField(0, textBoxTop.Text, Alignment),
   1.122 +                new DataField(1, textBoxBottom.Text, Alignment)
   1.123 +            });
   1.124 +
   1.125 +            if (!res)
   1.126 +            {
   1.127 +                MessageBox.Show("Create you fields first", "Field update error", MessageBoxButtons.OK, MessageBoxIcon.Error);
   1.128 +            }
   1.129 +
   1.130 +        }
   1.131      }
   1.132  }