Server/MainForm.cs
changeset 57 544132d07c3b
parent 55 b5ed2e29be23
child 58 2a527027024d
     1.1 --- a/Server/MainForm.cs	Sun Sep 21 13:40:21 2014 +0200
     1.2 +++ b/Server/MainForm.cs	Sun Sep 21 19:07:18 2014 +0200
     1.3 @@ -43,6 +43,8 @@
     1.4              //We have a bug when drawing minimized and reusing our bitmap
     1.5              iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
     1.6              iCreateBitmap = false;
     1.7 +            //
     1.8 +            //this.tableLayoutPanel.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel_CellPaint);
     1.9          }
    1.10  
    1.11          private void MainForm_Load(object sender, EventArgs e)
    1.12 @@ -55,6 +57,31 @@
    1.13              }
    1.14          }
    1.15  
    1.16 +        //Testing that stuff
    1.17 +        private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
    1.18 +        {
    1.19 +            var panel = sender as TableLayoutPanel;
    1.20 +            //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
    1.21 +            var rectangle = e.CellBounds;
    1.22 +            using (var pen = new Pen(Color.Black, 1))
    1.23 +            {
    1.24 +                pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
    1.25 +                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
    1.26 +
    1.27 +                if (e.Row == (panel.RowCount - 1))
    1.28 +                {
    1.29 +                    rectangle.Height -= 1;
    1.30 +                }
    1.31 +
    1.32 +                if (e.Column == (panel.ColumnCount - 1))
    1.33 +                {
    1.34 +                    rectangle.Width -= 1;
    1.35 +                }
    1.36 +
    1.37 +                e.Graphics.DrawRectangle(pen, rectangle);
    1.38 +            }
    1.39 +        }
    1.40 +
    1.41  
    1.42          private void buttonFont_Click(object sender, EventArgs e)
    1.43          {
    1.44 @@ -180,9 +207,20 @@
    1.45          }
    1.46  
    1.47  
    1.48 +        public delegate uint ColorProcessingDelegate(uint aPixel);
    1.49 +
    1.50 +        public static uint ColorUntouched(uint aPixel)
    1.51 +        {
    1.52 +            return aPixel;
    1.53 +        }
    1.54 +
    1.55 +        public static uint ColorInversed(uint aPixel)
    1.56 +        {
    1.57 +            return ~aPixel;
    1.58 +        }
    1.59 +
    1.60          public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
    1.61  
    1.62 -
    1.63          public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
    1.64          {
    1.65              return aBmp.Width - aX - 1;
    1.66 @@ -226,6 +264,19 @@
    1.67                  tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
    1.68                  //iBmp.Save("D:\\capture.png");
    1.69  
    1.70 +
    1.71 +                //Select our pixel processing routine
    1.72 +                ColorProcessingDelegate colorFx;
    1.73 +
    1.74 +                if (cds.InverseColors)
    1.75 +                {
    1.76 +                    colorFx = ColorInversed;
    1.77 +                }
    1.78 +                else
    1.79 +                {
    1.80 +                    colorFx = ColorUntouched;
    1.81 +                }
    1.82 +
    1.83                  //Select proper coordinate translation functions
    1.84                  //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
    1.85                  CoordinateTranslationDelegate screenX;
    1.86 @@ -250,9 +301,12 @@
    1.87                          unchecked
    1.88                          {
    1.89                              uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
    1.90 +                            //Apply color effects
    1.91 +                            color = colorFx(color);
    1.92                              //For some reason when the app is minimized in the task bar only the alpha of our color is set.
    1.93                              //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
    1.94 -                            iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
    1.95 +                            //iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
    1.96 +                            iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), color);
    1.97                          }
    1.98                      }
    1.99                  }
   1.100 @@ -384,6 +438,7 @@
   1.101              CheckFontHeight();
   1.102              checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
   1.103              checkBoxReverseScreen.Checked = cds.ReverseScreen;
   1.104 +            checkBoxInverseColors.Checked = cds.InverseColors;
   1.105              comboBoxDisplayType.SelectedIndex = cds.DisplayType;
   1.106              timer.Interval = cds.TimerInterval;
   1.107              maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
   1.108 @@ -453,6 +508,7 @@
   1.109              tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
   1.110              cds.ShowBorders = checkBoxShowBorders.Checked;
   1.111              Properties.Settings.Default.Save();
   1.112 +            CheckFontHeight();
   1.113          }
   1.114  
   1.115          private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
   1.116 @@ -469,6 +525,13 @@
   1.117              Properties.Settings.Default.Save();
   1.118          }
   1.119  
   1.120 +        private void checkBoxInverseColors_CheckedChanged(object sender, EventArgs e)
   1.121 +        {
   1.122 +            //Save our inverse colors setting
   1.123 +            cds.InverseColors = checkBoxInverseColors.Checked;
   1.124 +            Properties.Settings.Default.Save();
   1.125 +        }
   1.126 +
   1.127          private void MainForm_Resize(object sender, EventArgs e)
   1.128          {
   1.129              if (WindowState == FormWindowState.Minimized)