RegionNames.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace PDF_Office.Model
  8. {
  9. /// <summary>
  10. /// 存放公用模块的RegionName
  11. /// </summary>
  12. public static class RegionNames
  13. {
  14. /// <summary>
  15. /// 最外层的Region名称
  16. /// </summary>
  17. public static string MainRegion = "MainRegion";
  18. /// <summary>
  19. /// 首页右侧快捷工具Content RegionName
  20. /// </summary>
  21. public static string ToolRegionName
  22. {
  23. get
  24. {
  25. return GetRegionName("ToolRegionName");
  26. }
  27. }
  28. /// <summary>
  29. /// 阅读页PDFViewer 对应的Content RegionName
  30. /// </summary>
  31. public static string ViwerRegionName
  32. {
  33. get
  34. {
  35. return GetRegionName("ViwerRegionName");
  36. }
  37. }
  38. /// <summary>
  39. /// BOTA内容项 对应的Content RegionName
  40. /// </summary>
  41. public static string BOTARegionName
  42. {
  43. get
  44. {
  45. return GetRegionName("BOTARegionName");
  46. }
  47. }
  48. /// <summary>
  49. /// 属性面板 对应的Content RegionName
  50. /// </summary>
  51. public static string PropertyRegionName
  52. {
  53. get
  54. {
  55. return GetRegionName("PropertyRegionName");
  56. }
  57. }
  58. /// <summary>
  59. /// 工具功能(页面编辑、水印、密文等)对应的Content RegionName
  60. /// </summary>
  61. public static string ToolContentRegionName
  62. {
  63. get
  64. {
  65. return GetRegionName("ToolContentRegionName");
  66. }
  67. }
  68. /// <summary>
  69. /// 工具菜单栏对应的Content RegionName
  70. /// </summary>
  71. public static string ToolsBarContentRegionName
  72. {
  73. get
  74. {
  75. return GetRegionName("ToolsBarContentRegionName");
  76. }
  77. }
  78. /// <summary>
  79. /// 底部工具栏对应的Content RegionName
  80. /// </summary>
  81. public static string BottomToolRegionName
  82. {
  83. get
  84. {
  85. return GetRegionName("BottomToolRegionName");
  86. }
  87. }
  88. /// <summary>
  89. /// 获取MainWindowsViewModel RegionNames字典里的RegionName,
  90. /// 如果字典里没有键值就新建一个GUID,并插入到
  91. /// </summary>
  92. /// <returns></returns>
  93. public static string GetRegionName(string key)
  94. {
  95. if (App.mainWindowViewModel.SelectedItem.RegionContentNames.ContainsKey(key))
  96. {
  97. return App.mainWindowViewModel.SelectedItem.RegionContentNames[key];
  98. }
  99. else
  100. {
  101. string name = Guid.NewGuid().ToString();
  102. App.mainWindowViewModel.SelectedItem.RegionContentNames[key] = name;
  103. return name;
  104. }
  105. }
  106. /// <summary>
  107. /// 如果不存在key,则插入key,并设置Value
  108. /// 如果存在key,则更改Value
  109. /// </summary>
  110. public static void SetRegionName(string key, string Value)
  111. {
  112. if (App.mainWindowViewModel.SelectedItem.RegionContentNames.ContainsKey(key))
  113. {
  114. App.mainWindowViewModel.SelectedItem.RegionContentNames[key] = Value;
  115. }
  116. else
  117. {
  118. App.mainWindowViewModel.SelectedItem.RegionContentNames[key] = Value;
  119. }
  120. }
  121. }
  122. }