diff --git a/OverlayFormObj/OverlayForm.Helpers.cs b/OverlayFormObj/OverlayForm.Helpers.cs index 884a6d0..7eba3eb 100644 --- a/OverlayFormObj/OverlayForm.Helpers.cs +++ b/OverlayFormObj/OverlayForm.Helpers.cs @@ -35,7 +35,6 @@ namespace OverlayFormObj { this.marqueeText = newText; this.marqueeTextColor = textColor; - // 使用顯示字體進行測量 Font displayFont = new Font("Arial", 25, FontStyle.Bold); @@ -46,7 +45,7 @@ namespace OverlayFormObj switch (startPosition) { case MarqueeStartPosition.Middle: - this.marqueeXPos = (this.Width / 2) - (textWidth / 2) - 100; + this.marqueeXPos = (this.Width / 2) - (textWidth / 2)-100; break; case MarqueeStartPosition.Right: this.marqueeXPos = this.Width; @@ -92,12 +91,13 @@ namespace OverlayFormObj marqueeTimer_detection.Start(); } - public void UpdateMarqueeTextSecondLine(string newText) + public void UpdateMarqueeTextSecondLine(string newText,Color textColor) { + this.marqueeTextColor=textColor; Console.WriteLine(InvokeRequired); if (InvokeRequired) { - Invoke(new MethodInvoker(() => UpdateMarqueeTextSecondLine(newText))); + Invoke(new MethodInvoker(() => UpdateMarqueeTextSecondLine(newText,textColor))); return; } diff --git a/OverlayFormObj/OverlayForm.Labels.cs b/OverlayFormObj/OverlayForm.Labels.cs index de07fc0..3eab05f 100644 --- a/OverlayFormObj/OverlayForm.Labels.cs +++ b/OverlayFormObj/OverlayForm.Labels.cs @@ -266,7 +266,6 @@ namespace OverlayFormObj using (Font largeFont = new Font("微軟正黑體", 34, FontStyle.Bold)) using (Font secondLineFont = new Font("微軟正黑體", 34, FontStyle.Bold)) using (Brush whiteBrush = new SolidBrush(Color.White)) - using (Brush RedBrush = new SolidBrush(Color.Red)) using (Brush marqueeBrush = new SolidBrush(marqueeTextColor)) using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 0))) { @@ -279,22 +278,23 @@ namespace OverlayFormObj // 修改第二行文字的部分 float yPosition2 = 56; Rectangle clipRect = new Rectangle( - (int)(this.Width / 32), // 从1/8改成1/16(因为要居中) + // (int)(this.Width / 32), // 从1/8改成1/16(因为要居中) + (int)(this.Width*0.32), (int)yPosition2, - (int)(15 * this.Width / 16), // 从3/4改成7/8 + // (int)(15 * this.Width / 16), // 从3/4改成7/8 + (int)(this.Width*0.56), (int)textSize.Height ); Region originalClip = e.Graphics.Clip; e.Graphics.SetClip(clipRect); - // 获取当前应该显示的文字段落 string displayText = textSegments.Count > 0 ? textSegments[currentSegmentIndex] : marqueeTextSecondLine; SizeF textSizeSecondLine = e.Graphics.MeasureString(displayText, secondLineFont); float centeredXPos = (this.Width - textSizeSecondLine.Width) / 2; e.Graphics.FillRectangle(backgroundBrush, centeredXPos, yPosition2, textSizeSecondLine.Width, textSizeSecondLine.Height); // 系統公告塗色調整區域 - e.Graphics.DrawString(displayText, secondLineFont, RedBrush, new PointF(centeredXPos, yPosition2)); - + // e.Graphics.DrawString(displayText, secondLineFont, RedBrush, new PointF(centeredXPos, yPosition2)); + e.Graphics.DrawString(displayText, secondLineFont, marqueeBrush, new PointF((int)(this.Width*0.32), yPosition2)); // 还原裁剪区域 e.Graphics.Clip = originalClip; @@ -335,6 +335,7 @@ namespace OverlayFormObj topLeftLabel.Text = text; topLeftLabel.Visible = true; // 確保標籤顯示 Console.WriteLine($"更新顯示: {text}"); + Console.WriteLine(topLeftLabel.Location); } private void InitializeTopRightLabel() diff --git a/OverlayFormObj/OverlayForm.cs b/OverlayFormObj/OverlayForm.cs index 7aa6633..fe500de 100644 --- a/OverlayFormObj/OverlayForm.cs +++ b/OverlayFormObj/OverlayForm.cs @@ -98,15 +98,15 @@ namespace OverlayFormObj return; } - if (text.Length <= 16) + if (text.Length <= 24) { textSegments.Add(text); } else { - for (int i = 0; i < text.Length; i += 16) + for (int i = 0; i < text.Length; i += 24) { - int length = Math.Min(16, text.Length - i); + int length = Math.Min(24, text.Length - i); textSegments.Add(text.Substring(i, length)); } } diff --git a/PrimaryFormParts/PrimaryForm.Favorite.cs b/PrimaryFormParts/PrimaryForm.Favorite.cs index 90a2528..a68a7f1 100644 --- a/PrimaryFormParts/PrimaryForm.Favorite.cs +++ b/PrimaryFormParts/PrimaryForm.Favorite.cs @@ -24,16 +24,16 @@ namespace DualScreenDemo int[,] coords = new int[,] { - {794, 508, 70, 65}, - {878, 508, 70, 65}, - {962, 508, 70, 65}, - {1046, 508, 70, 65}, - {1130, 508, 70, 65}, - {794, 580, 70, 65}, - {878, 580, 70, 65}, - {962, 580, 70, 65}, - {1046, 580, 70, 65}, - {1130, 580, 70, 65} + {784, 508, 70, 65}, + {868, 508, 70, 65}, + {952, 508, 70, 65}, + {1036, 508, 70, 65}, + {1120, 508, 70, 65}, + {784, 580, 70, 65}, + {868, 580, 70, 65}, + {952, 580, 70, 65}, + {1036, 580, 70, 65}, + {1120, 580, 70, 65} }; int screenW = Screen.PrimaryScreen.Bounds.Width; @@ -86,7 +86,7 @@ namespace DualScreenDemo { Name = "enterFavoriteButton" }; - ResizeAndPositionButton(enterFavoriteButton, 832, 657, 70, 65); + ResizeAndPositionButton(enterFavoriteButton, 822, 657, 70, 65); enterFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["Enter"])); enterFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch; enterFavoriteButton.FlatStyle = FlatStyle.Flat; @@ -101,7 +101,7 @@ namespace DualScreenDemo { Name = "newFavoriteButton" }; - ResizeAndPositionButton(newFavoriteButton, 916, 657, 70, 65); + ResizeAndPositionButton(newFavoriteButton, 906, 657, 70, 65); newFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["New"])); newFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch; newFavoriteButton.FlatStyle = FlatStyle.Flat; @@ -116,7 +116,7 @@ namespace DualScreenDemo { Name = "refillFavoriteButton" }; - ResizeAndPositionButton(refillFavoriteButton, 999, 657, 70, 65); + ResizeAndPositionButton(refillFavoriteButton, 989, 657, 70, 65); refillFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["Refill"])); refillFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch; refillFavoriteButton.FlatStyle = FlatStyle.Flat; @@ -131,7 +131,7 @@ namespace DualScreenDemo { Name = "closeFavoriteButton" }; - ResizeAndPositionButton(closeFavoriteButton, 1083, 657, 70, 65); + ResizeAndPositionButton(closeFavoriteButton, 1073, 657, 70, 65); closeFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["Close"])); closeFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch; closeFavoriteButton.FlatStyle = FlatStyle.Flat; diff --git a/TCPServer.cs b/TCPServer.cs index 5f421b1..c55445d 100644 --- a/TCPServer.cs +++ b/TCPServer.cs @@ -174,8 +174,9 @@ namespace DualScreenDemo } else { - string marqueeMessage = "系統公告: " + message; - OverlayForm.MainForm.UpdateMarqueeTextSecondLine(marqueeMessage); + string marqueeMessage = "系統公告: " + message.Substring(match.Value.Length).Trim(); + Color textColor = GetColorFromString(match.Groups[2].Value); + OverlayForm.MainForm.UpdateMarqueeTextSecondLine(marqueeMessage,textColor); } }); byte[] okResponse = Encoding.UTF8.GetBytes("OK\n");