diff -r e86d84480b32 -r 544132d07c3b Server/MainForm.cs --- a/Server/MainForm.cs Sun Sep 21 13:40:21 2014 +0200 +++ b/Server/MainForm.cs Sun Sep 21 19:07:18 2014 +0200 @@ -43,6 +43,8 @@ //We have a bug when drawing minimized and reusing our bitmap iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); iCreateBitmap = false; + // + //this.tableLayoutPanel.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel_CellPaint); } private void MainForm_Load(object sender, EventArgs e) @@ -55,6 +57,31 @@ } } + //Testing that stuff + private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e) + { + var panel = sender as TableLayoutPanel; + //e.Graphics.SmoothingMode = SmoothingMode.HighQuality; + var rectangle = e.CellBounds; + using (var pen = new Pen(Color.Black, 1)) + { + pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center; + pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; + + if (e.Row == (panel.RowCount - 1)) + { + rectangle.Height -= 1; + } + + if (e.Column == (panel.ColumnCount - 1)) + { + rectangle.Width -= 1; + } + + e.Graphics.DrawRectangle(pen, rectangle); + } + } + private void buttonFont_Click(object sender, EventArgs e) { @@ -180,9 +207,20 @@ } + public delegate uint ColorProcessingDelegate(uint aPixel); + + public static uint ColorUntouched(uint aPixel) + { + return aPixel; + } + + public static uint ColorInversed(uint aPixel) + { + return ~aPixel; + } + public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt); - public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX) { return aBmp.Width - aX - 1; @@ -226,6 +264,19 @@ tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle); //iBmp.Save("D:\\capture.png"); + + //Select our pixel processing routine + ColorProcessingDelegate colorFx; + + if (cds.InverseColors) + { + colorFx = ColorInversed; + } + else + { + colorFx = ColorUntouched; + } + //Select proper coordinate translation functions //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels CoordinateTranslationDelegate screenX; @@ -250,9 +301,12 @@ unchecked { uint color = (uint)iBmp.GetPixel(i, j).ToArgb(); + //Apply color effects + color = colorFx(color); //For some reason when the app is minimized in the task bar only the alpha of our color is set. //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't. - iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000))); + //iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000))); + iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), color); } } } @@ -384,6 +438,7 @@ CheckFontHeight(); checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup; checkBoxReverseScreen.Checked = cds.ReverseScreen; + checkBoxInverseColors.Checked = cds.InverseColors; comboBoxDisplayType.SelectedIndex = cds.DisplayType; timer.Interval = cds.TimerInterval; maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString(); @@ -453,6 +508,7 @@ tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None); cds.ShowBorders = checkBoxShowBorders.Checked; Properties.Settings.Default.Save(); + CheckFontHeight(); } private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e) @@ -469,6 +525,13 @@ Properties.Settings.Default.Save(); } + private void checkBoxInverseColors_CheckedChanged(object sender, EventArgs e) + { + //Save our inverse colors setting + cds.InverseColors = checkBoxInverseColors.Checked; + Properties.Settings.Default.Save(); + } + private void MainForm_Resize(object sender, EventArgs e) { if (WindowState == FormWindowState.Minimized)