You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

LogViewerConfig.cs 2.6 kB

9 years ago
9 years ago
9 years ago
9 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using Newtonsoft.Json;
  5. namespace Shadowsocks.Model
  6. {
  7. [Serializable]
  8. public class LogViewerConfig
  9. {
  10. public bool topMost;
  11. public bool wrapText;
  12. public bool toolbarShown;
  13. public Font Font { get; set; } = new Font("Consolas", 8F);
  14. public Color BackgroundColor { get; set; } = Color.Black;
  15. public Color TextColor { get; set; } = Color.White;
  16. public LogViewerConfig()
  17. {
  18. topMost = false;
  19. wrapText = false;
  20. toolbarShown = false;
  21. }
  22. #region Size
  23. public void SaveSize()
  24. {
  25. Properties.Settings.Default.Save();
  26. }
  27. [JsonIgnore]
  28. public int Width
  29. {
  30. get { return Properties.Settings.Default.LogViewerWidth; }
  31. set { Properties.Settings.Default.LogViewerWidth = value; }
  32. }
  33. [JsonIgnore]
  34. public int Height
  35. {
  36. get { return Properties.Settings.Default.LogViewerHeight; }
  37. set { Properties.Settings.Default.LogViewerHeight = value; }
  38. }
  39. [JsonIgnore]
  40. public int Top
  41. {
  42. get { return Properties.Settings.Default.LogViewerTop; }
  43. set { Properties.Settings.Default.LogViewerTop = value; }
  44. }
  45. [JsonIgnore]
  46. public int Left
  47. {
  48. get { return Properties.Settings.Default.LogViewerLeft; }
  49. set { Properties.Settings.Default.LogViewerLeft = value; }
  50. }
  51. [JsonIgnore]
  52. public bool Maximized
  53. {
  54. get { return Properties.Settings.Default.LogViewerMaximized; }
  55. set { Properties.Settings.Default.LogViewerMaximized = value; }
  56. }
  57. [JsonIgnore]
  58. // Use GetBestTop() and GetBestLeft() to ensure the log viwer form can be always display IN screen.
  59. public int BestLeft
  60. {
  61. get
  62. {
  63. int width = Width;
  64. width = (width >= 400) ? width : 400; // set up the minimum size
  65. return Screen.PrimaryScreen.WorkingArea.Width - width;
  66. }
  67. }
  68. [JsonIgnore]
  69. public int BestTop
  70. {
  71. get
  72. {
  73. int height = Height;
  74. height = (height >= 200) ? height : 200; // set up the minimum size
  75. return Screen.PrimaryScreen.WorkingArea.Height - height;
  76. }
  77. }
  78. #endregion
  79. }
  80. }