author | sl |
Sun, 21 Sep 2014 19:07:18 +0200 | |
changeset 57 | 544132d07c3b |
parent 56 | e86d84480b32 |
child 58 | 2a527027024d |
1.1 --- a/Client/Client.cs Sun Sep 21 13:40:21 2014 +0200 1.2 +++ b/Client/Client.cs Sun Sep 21 19:07:18 2014 +0200 1.3 @@ -60,8 +60,8 @@ 1.4 public string Name { get; set; } 1.5 public string SessionId { get { return InnerChannel.SessionId; } } 1.6 1.7 - public Client(InstanceContext callbackInstance) 1.8 - : base(callbackInstance, new NetTcpBinding(SecurityMode.None, true), new EndpointAddress("net.tcp://localhost:8001/DisplayService")) 1.9 + public Client(ICallback aCallback) 1.10 + : base(new InstanceContext(aCallback), new NetTcpBinding(SecurityMode.None, true), new EndpointAddress("net.tcp://localhost:8001/DisplayService")) 1.11 { } 1.12 1.13 public void SetName(string aClientName) 1.14 @@ -84,5 +84,10 @@ 1.15 { 1.16 return Channel.ClientCount(); 1.17 } 1.18 + 1.19 + public bool IsReady() 1.20 + { 1.21 + return State == CommunicationState.Opened; 1.22 + } 1.23 } 1.24 }
2.1 --- a/Client/MainForm.cs Sun Sep 21 13:40:21 2014 +0200 2.2 +++ b/Client/MainForm.cs Sun Sep 21 19:07:18 2014 +0200 2.3 @@ -33,9 +33,7 @@ 2.4 private void MainForm_Load(object sender, EventArgs e) 2.5 { 2.6 iCallback = new Callback(this); 2.7 - //Instance context is then managed by our client class 2.8 - InstanceContext instanceContext = new InstanceContext(iCallback); 2.9 - iClient = new Client(instanceContext); 2.10 + iClient = new Client(iCallback); 2.11 2.12 //Connect using unique name 2.13 //string name = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt");
3.1 --- a/Server/Display.cs Sun Sep 21 13:40:21 2014 +0200 3.2 +++ b/Server/Display.cs Sun Sep 21 19:07:18 2014 +0200 3.3 @@ -85,7 +85,7 @@ 3.4 return MiniDisplayHeightInPixels(iDevice); 3.5 } 3.6 3.7 - public void SetPixel(int aX, int aY, int aValue) 3.8 + public void SetPixel(int aX, int aY, uint aValue) 3.9 { 3.10 MiniDisplaySetPixel(iDevice,aX,aY,aValue); 3.11 } 3.12 @@ -246,7 +246,7 @@ 3.13 public static extern int MiniDisplayHeightInPixels(IntPtr aDevice); 3.14 3.15 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] 3.16 - public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue); 3.17 + public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, uint aValue); 3.18 3.19 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] 3.20 public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
4.1 --- a/Server/DisplaySettings.cs Sun Sep 21 13:40:21 2014 +0200 4.2 +++ b/Server/DisplaySettings.cs Sun Sep 21 19:07:18 2014 +0200 4.3 @@ -24,6 +24,7 @@ 4.4 DisplayType = 0; 4.5 TimerInterval = 150; 4.6 ReverseScreen = false; 4.7 + InverseColors = true; 4.8 ShowBorders = false; 4.9 FontName = "Microsoft Sans Serif, 9.75pt"; 4.10 } 4.11 @@ -44,6 +45,9 @@ 4.12 public bool ReverseScreen { get; set; } 4.13 4.14 [DataMember] 4.15 + public bool InverseColors { get; set; } 4.16 + 4.17 + [DataMember] 4.18 public bool ShowBorders { get; set; } 4.19 4.20 [DataMember]
5.1 --- a/Server/MainForm.Designer.cs Sun Sep 21 13:40:21 2014 +0200 5.2 +++ b/Server/MainForm.Designer.cs Sun Sep 21 19:07:18 2014 +0200 5.3 @@ -31,6 +31,8 @@ 5.4 this.components = new System.ComponentModel.Container(); 5.5 this.panelDisplay = new System.Windows.Forms.Panel(); 5.6 this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 5.7 + this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); 5.8 + this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); 5.9 this.fontDialog = new System.Windows.Forms.FontDialog(); 5.10 this.timer = new System.Windows.Forms.Timer(this.components); 5.11 this.statusStrip = new System.Windows.Forms.StatusStrip(); 5.12 @@ -72,10 +74,9 @@ 5.13 this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox(); 5.14 this.buttonRemoveRow = new System.Windows.Forms.Button(); 5.15 this.buttonAddRow = new System.Windows.Forms.Button(); 5.16 - this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); 5.17 - this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); 5.18 this.labelFontWidth = new System.Windows.Forms.Label(); 5.19 this.labelFontHeight = new System.Windows.Forms.Label(); 5.20 + this.checkBoxInverseColors = new System.Windows.Forms.CheckBox(); 5.21 this.panelDisplay.SuspendLayout(); 5.22 this.tableLayoutPanel.SuspendLayout(); 5.23 this.statusStrip.SuspendLayout(); 5.24 @@ -206,6 +207,39 @@ 5.25 this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64); 5.26 this.tableLayoutPanel.TabIndex = 5; 5.27 // 5.28 + // marqueeLabelTop 5.29 + // 5.30 + this.marqueeLabelTop.AutoEllipsis = true; 5.31 + this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; 5.32 + this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; 5.33 + this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1); 5.34 + this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); 5.35 + this.marqueeLabelTop.Name = "marqueeLabelTop"; 5.36 + this.marqueeLabelTop.OwnTimer = false; 5.37 + this.marqueeLabelTop.PixelsPerSecond = 64; 5.38 + this.marqueeLabelTop.Separator = "|"; 5.39 + this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30); 5.40 + this.marqueeLabelTop.TabIndex = 2; 5.41 + this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; 5.42 + this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 5.43 + this.marqueeLabelTop.UseCompatibleTextRendering = true; 5.44 + // 5.45 + // marqueeLabelBottom 5.46 + // 5.47 + this.marqueeLabelBottom.AutoEllipsis = true; 5.48 + this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; 5.49 + this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32); 5.50 + this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); 5.51 + this.marqueeLabelBottom.Name = "marqueeLabelBottom"; 5.52 + this.marqueeLabelBottom.OwnTimer = false; 5.53 + this.marqueeLabelBottom.PixelsPerSecond = 64; 5.54 + this.marqueeLabelBottom.Separator = "|"; 5.55 + this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31); 5.56 + this.marqueeLabelBottom.TabIndex = 3; 5.57 + this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; 5.58 + this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 5.59 + this.marqueeLabelBottom.UseCompatibleTextRendering = true; 5.60 + // 5.61 // timer 5.62 // 5.63 this.timer.Enabled = true; 5.64 @@ -542,6 +576,7 @@ 5.65 // 5.66 // tabPageDesign 5.67 // 5.68 + this.tabPageDesign.Controls.Add(this.checkBoxInverseColors); 5.69 this.tabPageDesign.Controls.Add(this.buttonAlignRight); 5.70 this.tabPageDesign.Controls.Add(this.buttonAlignCenter); 5.71 this.tabPageDesign.Controls.Add(this.buttonAlignLeft); 5.72 @@ -643,39 +678,6 @@ 5.73 this.buttonAddRow.UseVisualStyleBackColor = true; 5.74 this.buttonAddRow.Click += new System.EventHandler(this.buttonAddRow_Click); 5.75 // 5.76 - // marqueeLabelTop 5.77 - // 5.78 - this.marqueeLabelTop.AutoEllipsis = true; 5.79 - this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; 5.80 - this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; 5.81 - this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1); 5.82 - this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); 5.83 - this.marqueeLabelTop.Name = "marqueeLabelTop"; 5.84 - this.marqueeLabelTop.OwnTimer = false; 5.85 - this.marqueeLabelTop.PixelsPerSecond = 64; 5.86 - this.marqueeLabelTop.Separator = "|"; 5.87 - this.marqueeLabelTop.Size = new System.Drawing.Size(254, 9); 5.88 - this.marqueeLabelTop.TabIndex = 2; 5.89 - this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; 5.90 - this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 5.91 - this.marqueeLabelTop.UseCompatibleTextRendering = true; 5.92 - // 5.93 - // marqueeLabelBottom 5.94 - // 5.95 - this.marqueeLabelBottom.AutoEllipsis = true; 5.96 - this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; 5.97 - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 21); 5.98 - this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); 5.99 - this.marqueeLabelBottom.Name = "marqueeLabelBottom"; 5.100 - this.marqueeLabelBottom.OwnTimer = false; 5.101 - this.marqueeLabelBottom.PixelsPerSecond = 64; 5.102 - this.marqueeLabelBottom.Separator = "|"; 5.103 - this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20); 5.104 - this.marqueeLabelBottom.TabIndex = 3; 5.105 - this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; 5.106 - this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 5.107 - this.marqueeLabelBottom.UseCompatibleTextRendering = true; 5.108 - // 5.109 // labelFontWidth 5.110 // 5.111 this.labelFontWidth.AutoSize = true; 5.112 @@ -694,6 +696,18 @@ 5.113 this.labelFontHeight.TabIndex = 20; 5.114 this.labelFontHeight.Text = "Font height"; 5.115 // 5.116 + // checkBoxInverseColors 5.117 + // 5.118 + this.checkBoxInverseColors.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 5.119 + this.checkBoxInverseColors.AutoSize = true; 5.120 + this.checkBoxInverseColors.Location = new System.Drawing.Point(485, 52); 5.121 + this.checkBoxInverseColors.Name = "checkBoxInverseColors"; 5.122 + this.checkBoxInverseColors.Size = new System.Drawing.Size(92, 17); 5.123 + this.checkBoxInverseColors.TabIndex = 21; 5.124 + this.checkBoxInverseColors.Text = "Inverse colors"; 5.125 + this.checkBoxInverseColors.UseVisualStyleBackColor = true; 5.126 + this.checkBoxInverseColors.CheckedChanged += new System.EventHandler(this.checkBoxInverseColors_CheckedChanged); 5.127 + // 5.128 // MainForm 5.129 // 5.130 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 5.131 @@ -776,6 +790,7 @@ 5.132 private System.Windows.Forms.Button buttonHideClock; 5.133 private System.Windows.Forms.Label labelFontWidth; 5.134 private System.Windows.Forms.Label labelFontHeight; 5.135 + private System.Windows.Forms.CheckBox checkBoxInverseColors; 5.136 } 5.137 } 5.138
6.1 --- a/Server/MainForm.cs Sun Sep 21 13:40:21 2014 +0200 6.2 +++ b/Server/MainForm.cs Sun Sep 21 19:07:18 2014 +0200 6.3 @@ -43,6 +43,8 @@ 6.4 //We have a bug when drawing minimized and reusing our bitmap 6.5 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); 6.6 iCreateBitmap = false; 6.7 + // 6.8 + //this.tableLayoutPanel.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel_CellPaint); 6.9 } 6.10 6.11 private void MainForm_Load(object sender, EventArgs e) 6.12 @@ -55,6 +57,31 @@ 6.13 } 6.14 } 6.15 6.16 + //Testing that stuff 6.17 + private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e) 6.18 + { 6.19 + var panel = sender as TableLayoutPanel; 6.20 + //e.Graphics.SmoothingMode = SmoothingMode.HighQuality; 6.21 + var rectangle = e.CellBounds; 6.22 + using (var pen = new Pen(Color.Black, 1)) 6.23 + { 6.24 + pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center; 6.25 + pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; 6.26 + 6.27 + if (e.Row == (panel.RowCount - 1)) 6.28 + { 6.29 + rectangle.Height -= 1; 6.30 + } 6.31 + 6.32 + if (e.Column == (panel.ColumnCount - 1)) 6.33 + { 6.34 + rectangle.Width -= 1; 6.35 + } 6.36 + 6.37 + e.Graphics.DrawRectangle(pen, rectangle); 6.38 + } 6.39 + } 6.40 + 6.41 6.42 private void buttonFont_Click(object sender, EventArgs e) 6.43 { 6.44 @@ -180,9 +207,20 @@ 6.45 } 6.46 6.47 6.48 + public delegate uint ColorProcessingDelegate(uint aPixel); 6.49 + 6.50 + public static uint ColorUntouched(uint aPixel) 6.51 + { 6.52 + return aPixel; 6.53 + } 6.54 + 6.55 + public static uint ColorInversed(uint aPixel) 6.56 + { 6.57 + return ~aPixel; 6.58 + } 6.59 + 6.60 public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt); 6.61 6.62 - 6.63 public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX) 6.64 { 6.65 return aBmp.Width - aX - 1; 6.66 @@ -226,6 +264,19 @@ 6.67 tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle); 6.68 //iBmp.Save("D:\\capture.png"); 6.69 6.70 + 6.71 + //Select our pixel processing routine 6.72 + ColorProcessingDelegate colorFx; 6.73 + 6.74 + if (cds.InverseColors) 6.75 + { 6.76 + colorFx = ColorInversed; 6.77 + } 6.78 + else 6.79 + { 6.80 + colorFx = ColorUntouched; 6.81 + } 6.82 + 6.83 //Select proper coordinate translation functions 6.84 //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels 6.85 CoordinateTranslationDelegate screenX; 6.86 @@ -250,9 +301,12 @@ 6.87 unchecked 6.88 { 6.89 uint color = (uint)iBmp.GetPixel(i, j).ToArgb(); 6.90 + //Apply color effects 6.91 + color = colorFx(color); 6.92 //For some reason when the app is minimized in the task bar only the alpha of our color is set. 6.93 //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't. 6.94 - iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000))); 6.95 + //iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000))); 6.96 + iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), color); 6.97 } 6.98 } 6.99 } 6.100 @@ -384,6 +438,7 @@ 6.101 CheckFontHeight(); 6.102 checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup; 6.103 checkBoxReverseScreen.Checked = cds.ReverseScreen; 6.104 + checkBoxInverseColors.Checked = cds.InverseColors; 6.105 comboBoxDisplayType.SelectedIndex = cds.DisplayType; 6.106 timer.Interval = cds.TimerInterval; 6.107 maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString(); 6.108 @@ -453,6 +508,7 @@ 6.109 tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None); 6.110 cds.ShowBorders = checkBoxShowBorders.Checked; 6.111 Properties.Settings.Default.Save(); 6.112 + CheckFontHeight(); 6.113 } 6.114 6.115 private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e) 6.116 @@ -469,6 +525,13 @@ 6.117 Properties.Settings.Default.Save(); 6.118 } 6.119 6.120 + private void checkBoxInverseColors_CheckedChanged(object sender, EventArgs e) 6.121 + { 6.122 + //Save our inverse colors setting 6.123 + cds.InverseColors = checkBoxInverseColors.Checked; 6.124 + Properties.Settings.Default.Save(); 6.125 + } 6.126 + 6.127 private void MainForm_Resize(object sender, EventArgs e) 6.128 { 6.129 if (WindowState == FormWindowState.Minimized)