123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace PaintDotNet
- {
- /// <summary>
- /// 关于软件
- /// </summary>
- internal class AboutDialog : PdnBaseForm
- {
- private Button okButton;
- private Label creditsLabel;
- private RichTextBox richCreditsBox;
- private TextBox copyrightLabel;
- private Label versionLabel;
- private PdnBanner pdnBanner;
- private AppWorkspace appWorkspace;
- private ToolStripItemCollection collectionLeft;
- private TreeNode animeLeft;
- private string txtPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ModuleConfig.txt";
- private string[] menuIdArr;
- private int type;//1-关于,2-软件构成
- public AboutDialog()
- {
- }
- public AboutDialog(AppWorkspace appWorkspace,int type)
- {
- this.appWorkspace = appWorkspace;
- this.type = type;
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- string textFormat = string.Empty;
- if (type == 1)
- {
- textFormat = PdnResources.GetString("Menu.Help.AboutWin.Text");
- VersionInformation();
- }
- else if(type == 2)
- {
- InitVisibleMenuId();
- InitLeftTreeViewData();
- textFormat = PdnResources.GetString("AboutDialog.Text.Format");
- }
-
- this.richCreditsBox.BackColor = SystemColors.Window;
-
- this.Text = string.Format(textFormat, PdnInfo.GetBareProductName());
- this.pdnBanner.BannerText = string.Empty;// PdnInfo.GetFriendlyVersionString();
- //this.richCreditsBox.LoadFile(PdnResources.GetResourceStream("Files.AboutCredits.rtf"), RichTextBoxStreamType.RichText);
- this.copyrightLabel.Text = PdnInfo.GetCopyrightString();
- this.Icon = PdnInfo.AppIcon;
- this.okButton.Text = PdnResources.GetString("Form.OkButton.Text");
- this.okButton.Location = new Point((this.ClientSize.Width - this.okButton.Width) / 2, this.okButton.Top);
- this.creditsLabel.Text = PdnResources.GetString("AboutDialog.CreditsLabel.Text");
- Font bannerFont = this.pdnBanner.BannerFont;
- Font newBannerFont = Utility.CreateFont(bannerFont.Name, 8.0f, bannerFont.Style);
- this.pdnBanner.BannerFont = newBannerFont;
- newBannerFont.Dispose();
- bannerFont.Dispose();
- this.versionLabel.Text = PdnInfo.GetFullAppName();
- //VersionInformation();
- }
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.okButton = new Button();
- this.creditsLabel = new Label();
- this.richCreditsBox = new RichTextBox();
- this.copyrightLabel = new TextBox();
- this.pdnBanner = new PdnBanner();
- this.versionLabel = new Label();
- this.SuspendLayout();
- //
- // okButton
- //
- this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
- this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.okButton.Location = new System.Drawing.Point(139, 346);
- this.okButton.Name = "okButton";
- this.okButton.Size = new System.Drawing.Size(75, 23);
- this.okButton.TabIndex = 0;
- //
- // creditsLabel
- //
- this.creditsLabel.Location = new System.Drawing.Point(7, 132);
- this.creditsLabel.Name = "creditsLabel";
- this.creditsLabel.Size = new System.Drawing.Size(200, 16);
- this.creditsLabel.TabIndex = 5;
- //
- // richCreditsBox
- //
- this.richCreditsBox.CausesValidation = false;
- this.richCreditsBox.Location = new System.Drawing.Point(10, 153);
- this.richCreditsBox.Name = "richCreditsBox";
- this.richCreditsBox.ReadOnly = true;
- this.richCreditsBox.Size = new System.Drawing.Size(476, 187);
- this.richCreditsBox.TabIndex = 6;
- this.richCreditsBox.Text = "";
- this.richCreditsBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichCreditsBox_LinkClicked);
- //
- // copyrightLabel
- //
- this.copyrightLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.copyrightLabel.Location = new System.Drawing.Point(10, 95);
- this.copyrightLabel.Multiline = true;
- this.copyrightLabel.Name = "copyrightLabel";
- this.copyrightLabel.ReadOnly = true;
- this.copyrightLabel.Size = new System.Drawing.Size(481, 36);
- this.copyrightLabel.TabIndex = 4;
- //
- // pdnBanner
- //
- this.pdnBanner.BannerFont = new System.Drawing.Font("Tahoma", 10F);
- this.pdnBanner.BannerText = "headingText";
- this.pdnBanner.Location = new System.Drawing.Point(0, 0);
- this.pdnBanner.Name = "pdnBanner";
- this.pdnBanner.Size = new System.Drawing.Size(495, 71);
- this.pdnBanner.TabIndex = 7;
- //
- // versionLabel
- //
- this.versionLabel.AutoSize = true;
- this.versionLabel.Location = new System.Drawing.Point(7, 77);
- this.versionLabel.Name = "versionLabel";
- this.versionLabel.Size = new System.Drawing.Size(0, 13);
- this.versionLabel.TabIndex = 8;
- //
- // AboutDialog
- //
- this.AcceptButton = this.okButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- this.CancelButton = this.okButton;
- this.ClientSize = new System.Drawing.Size(495, 375);
- this.Controls.Add(this.versionLabel);
- this.Controls.Add(this.copyrightLabel);
- this.Controls.Add(this.richCreditsBox);
- this.Controls.Add(this.creditsLabel);
- this.Controls.Add(this.pdnBanner);
- this.Controls.Add(this.okButton);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.Location = new System.Drawing.Point(0, 0);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "AboutDialog";
- this.ShowInTaskbar = false;
- this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Controls.SetChildIndex(this.okButton, 0);
- this.Controls.SetChildIndex(this.pdnBanner, 0);
- this.Controls.SetChildIndex(this.creditsLabel, 0);
- this.Controls.SetChildIndex(this.richCreditsBox, 0);
- this.Controls.SetChildIndex(this.copyrightLabel, 0);
- this.Controls.SetChildIndex(this.versionLabel, 0);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private void RichCreditsBox_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
- {
- if (null != e.LinkText && e.LinkText.StartsWith("http://"))
- {
- PdnInfo.OpenUrl(this, e.LinkText);
- }
- }
- /// <summary>
- /// 获取txt文件中已保存的菜单可用id
- /// </summary>
- private void InitVisibleMenuId()
- {
- if (System.IO.File.Exists(txtPath))
- {
- string str = System.IO.File.ReadAllText(txtPath);
- if (str.IndexOf(',') != -1)
- {
- menuIdArr = str.Split(',');
- }
- else
- {
- if (!string.IsNullOrEmpty(str))
- {
- menuIdArr = new string[] { str };
- }
- }
- }
- }
- /// <summary>
- /// 初始化左侧treeview数据
- /// </summary>
- private void InitLeftTreeViewData()
- {
- this.collectionLeft = this.appWorkspace.ToolBar.MainMenu.Items;
- this.animeLeft = new TreeNode(PdnResources.GetString("Menu.menu.Text"));
- this.RecursiveDataLeft(collectionLeft, animeLeft);
- this.animeLeft.Expand();
- //this.treeView1.Nodes.Add(animeLeft);
- }
- /// <summary>
- /// 左侧递归进行数据组织
- /// </summary>
- private void RecursiveDataLeft(ToolStripItemCollection collection, TreeNode anime)
- {
- for (int i = 0; i < collection.Count; i++)
- {
- TreeNode node = new TreeNode(collection[i].Text);
- if (collection[i] is PdnMenuItem)
- {
- PdnMenuItem item = (PdnMenuItem)collection[i];
- if (!item.CanShowInSenseShield)
- continue;
- node.Tag = item.MenuId;
- if (menuIdArr != null && menuIdArr.Length > 0)
- {
- if (Array.IndexOf(menuIdArr, item.MenuId.ToString()) != -1)
- {
- this.richCreditsBox.Text += node.Text + "\r\n";
- node.Checked = true;
- }
- else
- {
- node.Checked = false;
- }
- }
- if (collection[i].Name.Equals("OpenRecent") || collection[i].Name.Equals("CameraSelection"))
- continue;
- if (item.MenuId == 1100)
- {
- RecursiveDataLeft(((PdnMenuItem)collection[i]).DropDownItems, node);
- }
- }
- }
- }
- public void VersionInformation()
- {
- this.richCreditsBox.Text = PdnResources.GetString("Menu.Help.About.Introduce.Text");
- }
- }
- }
|