ChatNoticeDialog.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. namespace Client.MirScenes.Dialogs
  4. {
  5. public class ChatNoticeDialog : MirImageControl
  6. {
  7. public MirImageControl Layout;
  8. public MirLabel TextLabel1, TextLabel2;
  9. private long ViewTime = 10000;
  10. private long CurrentTime = 0;
  11. public ChatNoticeDialog()
  12. {
  13. Index = 1361;
  14. Library = Libraries.Prguse;
  15. Movable = false;
  16. Sort = false;
  17. Location = new Point(Settings.ScreenWidth / 2 - Size.Width / 2, Settings.ScreenHeight / 6 - Size.Height / 2);
  18. Opacity = 0.7F;
  19. TextLabel1 = new MirLabel
  20. {
  21. Text = "",
  22. Font = new Font(Settings.FontName, 10F),
  23. DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
  24. Parent = this,
  25. NotControl = true,
  26. Location = new Point(0, -6),
  27. Size = new Size(660, 40),
  28. ForeColour = Color.Yellow,
  29. OutLineColour = Color.Black,
  30. };
  31. TextLabel2 = new MirLabel
  32. {
  33. Text = "",
  34. Font = new Font(Settings.FontName, 15F),
  35. DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
  36. Parent = this,
  37. NotControl = true,
  38. Location = new Point(0, 0),
  39. Size = new Size(660, 40),
  40. ForeColour = Color.Yellow,
  41. OutLineColour = Color.Black,
  42. };
  43. Layout = new MirImageControl
  44. {
  45. Index = 1360,
  46. Library = Libraries.Prguse,
  47. Location = new Point(0, 0),
  48. Parent = this
  49. };
  50. AfterDraw += ChatNotice_AfterDraw;
  51. }
  52. private void ChatNotice_AfterDraw(object sender, EventArgs e)
  53. {
  54. if (CurrentTime < CMain.Time)
  55. {
  56. Hide();
  57. }
  58. }
  59. public void ShowNotice(string text, int type = 0)
  60. {
  61. Index = type == 0 ? 1361 : 1363;
  62. Layout.Index = type == 0 ? 1360 : 1362;
  63. TextLabel1.Text = TextLabel2.Text = text;
  64. TextLabel1.Visible = type == 0;
  65. TextLabel2.Visible = type == 1;
  66. Show();
  67. CurrentTime = CMain.Time + ViewTime;
  68. }
  69. }
  70. }