2508151600
中間跑馬燈長度更改,換色功能 我的最愛按鈕位置微調
This commit is contained in:
parent
d11cfd4987
commit
ab3ecf9597
@ -35,7 +35,6 @@ namespace OverlayFormObj
|
|||||||
{
|
{
|
||||||
this.marqueeText = newText;
|
this.marqueeText = newText;
|
||||||
this.marqueeTextColor = textColor;
|
this.marqueeTextColor = textColor;
|
||||||
|
|
||||||
// 使用顯示字體進行測量
|
// 使用顯示字體進行測量
|
||||||
Font displayFont = new Font("Arial", 25, FontStyle.Bold);
|
Font displayFont = new Font("Arial", 25, FontStyle.Bold);
|
||||||
|
|
||||||
@ -92,12 +91,13 @@ namespace OverlayFormObj
|
|||||||
marqueeTimer_detection.Start();
|
marqueeTimer_detection.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateMarqueeTextSecondLine(string newText)
|
public void UpdateMarqueeTextSecondLine(string newText,Color textColor)
|
||||||
{
|
{
|
||||||
|
this.marqueeTextColor=textColor;
|
||||||
Console.WriteLine(InvokeRequired);
|
Console.WriteLine(InvokeRequired);
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
{
|
{
|
||||||
Invoke(new MethodInvoker(() => UpdateMarqueeTextSecondLine(newText)));
|
Invoke(new MethodInvoker(() => UpdateMarqueeTextSecondLine(newText,textColor)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,6 @@ namespace OverlayFormObj
|
|||||||
using (Font largeFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
using (Font largeFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
||||||
using (Font secondLineFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
using (Font secondLineFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
||||||
using (Brush whiteBrush = new SolidBrush(Color.White))
|
using (Brush whiteBrush = new SolidBrush(Color.White))
|
||||||
using (Brush RedBrush = new SolidBrush(Color.Red))
|
|
||||||
using (Brush marqueeBrush = new SolidBrush(marqueeTextColor))
|
using (Brush marqueeBrush = new SolidBrush(marqueeTextColor))
|
||||||
using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 0)))
|
using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 0)))
|
||||||
{
|
{
|
||||||
@ -279,22 +278,23 @@ namespace OverlayFormObj
|
|||||||
// 修改第二行文字的部分
|
// 修改第二行文字的部分
|
||||||
float yPosition2 = 56;
|
float yPosition2 = 56;
|
||||||
Rectangle clipRect = new Rectangle(
|
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)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
|
(int)textSize.Height
|
||||||
);
|
);
|
||||||
Region originalClip = e.Graphics.Clip;
|
Region originalClip = e.Graphics.Clip;
|
||||||
e.Graphics.SetClip(clipRect);
|
e.Graphics.SetClip(clipRect);
|
||||||
|
|
||||||
// 获取当前应该显示的文字段落
|
// 获取当前应该显示的文字段落
|
||||||
string displayText = textSegments.Count > 0 ? textSegments[currentSegmentIndex] : marqueeTextSecondLine;
|
string displayText = textSegments.Count > 0 ? textSegments[currentSegmentIndex] : marqueeTextSecondLine;
|
||||||
SizeF textSizeSecondLine = e.Graphics.MeasureString(displayText, secondLineFont);
|
SizeF textSizeSecondLine = e.Graphics.MeasureString(displayText, secondLineFont);
|
||||||
float centeredXPos = (this.Width - textSizeSecondLine.Width) / 2;
|
float centeredXPos = (this.Width - textSizeSecondLine.Width) / 2;
|
||||||
e.Graphics.FillRectangle(backgroundBrush, centeredXPos, yPosition2, textSizeSecondLine.Width, textSizeSecondLine.Height);
|
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;
|
e.Graphics.Clip = originalClip;
|
||||||
|
|
||||||
@ -335,6 +335,7 @@ namespace OverlayFormObj
|
|||||||
topLeftLabel.Text = text;
|
topLeftLabel.Text = text;
|
||||||
topLeftLabel.Visible = true; // 確保標籤顯示
|
topLeftLabel.Visible = true; // 確保標籤顯示
|
||||||
Console.WriteLine($"更新顯示: {text}");
|
Console.WriteLine($"更新顯示: {text}");
|
||||||
|
Console.WriteLine(topLeftLabel.Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeTopRightLabel()
|
private void InitializeTopRightLabel()
|
||||||
|
@ -98,15 +98,15 @@ namespace OverlayFormObj
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.Length <= 16)
|
if (text.Length <= 24)
|
||||||
{
|
{
|
||||||
textSegments.Add(text);
|
textSegments.Add(text);
|
||||||
}
|
}
|
||||||
else
|
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));
|
textSegments.Add(text.Substring(i, length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,16 +24,16 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
int[,] coords = new int[,]
|
int[,] coords = new int[,]
|
||||||
{
|
{
|
||||||
{794, 508, 70, 65},
|
{784, 508, 70, 65},
|
||||||
{878, 508, 70, 65},
|
{868, 508, 70, 65},
|
||||||
{962, 508, 70, 65},
|
{952, 508, 70, 65},
|
||||||
{1046, 508, 70, 65},
|
{1036, 508, 70, 65},
|
||||||
{1130, 508, 70, 65},
|
{1120, 508, 70, 65},
|
||||||
{794, 580, 70, 65},
|
{784, 580, 70, 65},
|
||||||
{878, 580, 70, 65},
|
{868, 580, 70, 65},
|
||||||
{962, 580, 70, 65},
|
{952, 580, 70, 65},
|
||||||
{1046, 580, 70, 65},
|
{1036, 580, 70, 65},
|
||||||
{1130, 580, 70, 65}
|
{1120, 580, 70, 65}
|
||||||
};
|
};
|
||||||
|
|
||||||
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
||||||
@ -86,7 +86,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
Name = "enterFavoriteButton"
|
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.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["Enter"]));
|
||||||
enterFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
enterFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
enterFavoriteButton.FlatStyle = FlatStyle.Flat;
|
enterFavoriteButton.FlatStyle = FlatStyle.Flat;
|
||||||
@ -101,7 +101,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
Name = "newFavoriteButton"
|
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.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["New"]));
|
||||||
newFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
newFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
newFavoriteButton.FlatStyle = FlatStyle.Flat;
|
newFavoriteButton.FlatStyle = FlatStyle.Flat;
|
||||||
@ -116,7 +116,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
Name = "refillFavoriteButton"
|
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.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["Refill"]));
|
||||||
refillFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
refillFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
refillFavoriteButton.FlatStyle = FlatStyle.Flat;
|
refillFavoriteButton.FlatStyle = FlatStyle.Flat;
|
||||||
@ -131,7 +131,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
Name = "closeFavoriteButton"
|
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.BackgroundImage = Image.FromFile(Path.Combine(serverPath, data["Favorite"]["Close"]));
|
||||||
closeFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
closeFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
closeFavoriteButton.FlatStyle = FlatStyle.Flat;
|
closeFavoriteButton.FlatStyle = FlatStyle.Flat;
|
||||||
|
@ -174,8 +174,9 @@ namespace DualScreenDemo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string marqueeMessage = "系統公告: " + message;
|
string marqueeMessage = "系統公告: " + message.Substring(match.Value.Length).Trim();
|
||||||
OverlayForm.MainForm.UpdateMarqueeTextSecondLine(marqueeMessage);
|
Color textColor = GetColorFromString(match.Groups[2].Value);
|
||||||
|
OverlayForm.MainForm.UpdateMarqueeTextSecondLine(marqueeMessage,textColor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
byte[] okResponse = Encoding.UTF8.GetBytes("OK\n");
|
byte[] okResponse = Encoding.UTF8.GetBytes("OK\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user