using System; using System.Drawing; using System.Windows.Forms; namespace PaintDotNet { /// /// 关于软件 /// 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 /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// 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); } } /// /// 获取txt文件中已保存的菜单可用id /// 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 }; } } } } /// /// 初始化左侧treeview数据 /// 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); } /// /// 左侧递归进行数据组织 /// 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"); } } }