AboutDialog.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace PaintDotNet
  5. {
  6. /// <summary>
  7. /// 关于软件
  8. /// </summary>
  9. internal class AboutDialog : PdnBaseForm
  10. {
  11. private Button okButton;
  12. private Label creditsLabel;
  13. private RichTextBox richCreditsBox;
  14. private TextBox copyrightLabel;
  15. private Label versionLabel;
  16. private PdnBanner pdnBanner;
  17. private AppWorkspace appWorkspace;
  18. private ToolStripItemCollection collectionLeft;
  19. private TreeNode animeLeft;
  20. private string txtPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ModuleConfig.txt";
  21. private string[] menuIdArr;
  22. private int type;//1-关于,2-软件构成
  23. public AboutDialog()
  24. {
  25. }
  26. public AboutDialog(AppWorkspace appWorkspace,int type)
  27. {
  28. this.appWorkspace = appWorkspace;
  29. this.type = type;
  30. //
  31. // Required for Windows Form Designer support
  32. //
  33. InitializeComponent();
  34. string textFormat = string.Empty;
  35. if (type == 1)
  36. {
  37. textFormat = PdnResources.GetString("Menu.Help.AboutWin.Text");
  38. VersionInformation();
  39. }
  40. else if(type == 2)
  41. {
  42. InitVisibleMenuId();
  43. InitLeftTreeViewData();
  44. textFormat = PdnResources.GetString("AboutDialog.Text.Format");
  45. }
  46. this.richCreditsBox.BackColor = SystemColors.Window;
  47. this.Text = string.Format(textFormat, PdnInfo.GetBareProductName());
  48. this.pdnBanner.BannerText = string.Empty;// PdnInfo.GetFriendlyVersionString();
  49. //this.richCreditsBox.LoadFile(PdnResources.GetResourceStream("Files.AboutCredits.rtf"), RichTextBoxStreamType.RichText);
  50. this.copyrightLabel.Text = PdnInfo.GetCopyrightString();
  51. this.Icon = PdnInfo.AppIcon;
  52. this.okButton.Text = PdnResources.GetString("Form.OkButton.Text");
  53. this.okButton.Location = new Point((this.ClientSize.Width - this.okButton.Width) / 2, this.okButton.Top);
  54. this.creditsLabel.Text = PdnResources.GetString("AboutDialog.CreditsLabel.Text");
  55. Font bannerFont = this.pdnBanner.BannerFont;
  56. Font newBannerFont = Utility.CreateFont(bannerFont.Name, 8.0f, bannerFont.Style);
  57. this.pdnBanner.BannerFont = newBannerFont;
  58. newBannerFont.Dispose();
  59. bannerFont.Dispose();
  60. this.versionLabel.Text = PdnInfo.GetFullAppName();
  61. //VersionInformation();
  62. }
  63. #region Windows Form Designer generated code
  64. /// <summary>
  65. /// Required method for Designer support - do not modify
  66. /// the contents of this method with the code editor.
  67. /// </summary>
  68. private void InitializeComponent()
  69. {
  70. this.okButton = new Button();
  71. this.creditsLabel = new Label();
  72. this.richCreditsBox = new RichTextBox();
  73. this.copyrightLabel = new TextBox();
  74. this.pdnBanner = new PdnBanner();
  75. this.versionLabel = new Label();
  76. this.SuspendLayout();
  77. //
  78. // okButton
  79. //
  80. this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
  81. this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  82. this.okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  83. this.okButton.Location = new System.Drawing.Point(139, 346);
  84. this.okButton.Name = "okButton";
  85. this.okButton.Size = new System.Drawing.Size(75, 23);
  86. this.okButton.TabIndex = 0;
  87. //
  88. // creditsLabel
  89. //
  90. this.creditsLabel.Location = new System.Drawing.Point(7, 132);
  91. this.creditsLabel.Name = "creditsLabel";
  92. this.creditsLabel.Size = new System.Drawing.Size(200, 16);
  93. this.creditsLabel.TabIndex = 5;
  94. //
  95. // richCreditsBox
  96. //
  97. this.richCreditsBox.CausesValidation = false;
  98. this.richCreditsBox.Location = new System.Drawing.Point(10, 153);
  99. this.richCreditsBox.Name = "richCreditsBox";
  100. this.richCreditsBox.ReadOnly = true;
  101. this.richCreditsBox.Size = new System.Drawing.Size(476, 187);
  102. this.richCreditsBox.TabIndex = 6;
  103. this.richCreditsBox.Text = "";
  104. this.richCreditsBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichCreditsBox_LinkClicked);
  105. //
  106. // copyrightLabel
  107. //
  108. this.copyrightLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
  109. this.copyrightLabel.Location = new System.Drawing.Point(10, 95);
  110. this.copyrightLabel.Multiline = true;
  111. this.copyrightLabel.Name = "copyrightLabel";
  112. this.copyrightLabel.ReadOnly = true;
  113. this.copyrightLabel.Size = new System.Drawing.Size(481, 36);
  114. this.copyrightLabel.TabIndex = 4;
  115. //
  116. // pdnBanner
  117. //
  118. this.pdnBanner.BannerFont = new System.Drawing.Font("Tahoma", 10F);
  119. this.pdnBanner.BannerText = "headingText";
  120. this.pdnBanner.Location = new System.Drawing.Point(0, 0);
  121. this.pdnBanner.Name = "pdnBanner";
  122. this.pdnBanner.Size = new System.Drawing.Size(495, 71);
  123. this.pdnBanner.TabIndex = 7;
  124. //
  125. // versionLabel
  126. //
  127. this.versionLabel.AutoSize = true;
  128. this.versionLabel.Location = new System.Drawing.Point(7, 77);
  129. this.versionLabel.Name = "versionLabel";
  130. this.versionLabel.Size = new System.Drawing.Size(0, 13);
  131. this.versionLabel.TabIndex = 8;
  132. //
  133. // AboutDialog
  134. //
  135. this.AcceptButton = this.okButton;
  136. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  137. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
  138. this.CancelButton = this.okButton;
  139. this.ClientSize = new System.Drawing.Size(495, 375);
  140. this.Controls.Add(this.versionLabel);
  141. this.Controls.Add(this.copyrightLabel);
  142. this.Controls.Add(this.richCreditsBox);
  143. this.Controls.Add(this.creditsLabel);
  144. this.Controls.Add(this.pdnBanner);
  145. this.Controls.Add(this.okButton);
  146. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  147. this.Location = new System.Drawing.Point(0, 0);
  148. this.MaximizeBox = false;
  149. this.MinimizeBox = false;
  150. this.Name = "AboutDialog";
  151. this.ShowInTaskbar = false;
  152. this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
  153. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  154. this.Controls.SetChildIndex(this.okButton, 0);
  155. this.Controls.SetChildIndex(this.pdnBanner, 0);
  156. this.Controls.SetChildIndex(this.creditsLabel, 0);
  157. this.Controls.SetChildIndex(this.richCreditsBox, 0);
  158. this.Controls.SetChildIndex(this.copyrightLabel, 0);
  159. this.Controls.SetChildIndex(this.versionLabel, 0);
  160. this.ResumeLayout(false);
  161. this.PerformLayout();
  162. }
  163. #endregion
  164. private void RichCreditsBox_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
  165. {
  166. if (null != e.LinkText && e.LinkText.StartsWith("http://"))
  167. {
  168. PdnInfo.OpenUrl(this, e.LinkText);
  169. }
  170. }
  171. /// <summary>
  172. /// 获取txt文件中已保存的菜单可用id
  173. /// </summary>
  174. private void InitVisibleMenuId()
  175. {
  176. if (System.IO.File.Exists(txtPath))
  177. {
  178. string str = System.IO.File.ReadAllText(txtPath);
  179. if (str.IndexOf(',') != -1)
  180. {
  181. menuIdArr = str.Split(',');
  182. }
  183. else
  184. {
  185. if (!string.IsNullOrEmpty(str))
  186. {
  187. menuIdArr = new string[] { str };
  188. }
  189. }
  190. }
  191. }
  192. /// <summary>
  193. /// 初始化左侧treeview数据
  194. /// </summary>
  195. private void InitLeftTreeViewData()
  196. {
  197. this.collectionLeft = this.appWorkspace.ToolBar.MainMenu.Items;
  198. this.animeLeft = new TreeNode(PdnResources.GetString("Menu.menu.Text"));
  199. this.RecursiveDataLeft(collectionLeft, animeLeft);
  200. this.animeLeft.Expand();
  201. //this.treeView1.Nodes.Add(animeLeft);
  202. }
  203. /// <summary>
  204. /// 左侧递归进行数据组织
  205. /// </summary>
  206. private void RecursiveDataLeft(ToolStripItemCollection collection, TreeNode anime)
  207. {
  208. for (int i = 0; i < collection.Count; i++)
  209. {
  210. TreeNode node = new TreeNode(collection[i].Text);
  211. if (collection[i] is PdnMenuItem)
  212. {
  213. PdnMenuItem item = (PdnMenuItem)collection[i];
  214. if (!item.CanShowInSenseShield)
  215. continue;
  216. node.Tag = item.MenuId;
  217. if (menuIdArr != null && menuIdArr.Length > 0)
  218. {
  219. if (Array.IndexOf(menuIdArr, item.MenuId.ToString()) != -1)
  220. {
  221. this.richCreditsBox.Text += node.Text + "\r\n";
  222. node.Checked = true;
  223. }
  224. else
  225. {
  226. node.Checked = false;
  227. }
  228. }
  229. if (collection[i].Name.Equals("OpenRecent") || collection[i].Name.Equals("CameraSelection"))
  230. continue;
  231. if (item.MenuId == 1100)
  232. {
  233. RecursiveDataLeft(((PdnMenuItem)collection[i]).DropDownItems, node);
  234. }
  235. }
  236. }
  237. }
  238. public void VersionInformation()
  239. {
  240. this.richCreditsBox.Text = PdnResources.GetString("Menu.Help.About.Introduce.Text");
  241. }
  242. }
  243. }