diff options
Diffstat (limited to 'About.cs')
-rw-r--r-- | About.cs | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/About.cs b/About.cs new file mode 100644 index 0000000..6e03d83 --- /dev/null +++ b/About.cs @@ -0,0 +1,172 @@ +// Noddybox.GUI - various GUI support routines +// Copyright (C) 2004 Ian Cowburn +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// $Id$ +// +using System; +using System.Windows.Forms; +using System.Text; +using System.Resources; +using System.Reflection; + +namespace Noddybox.GUI +{ + /// <summary> + /// Generic Noddybox About/Help box + /// </summary> + public class About : System.Windows.Forms.Form + { + private System.Windows.Forms.Label m_helpLabel; + private System.Windows.Forms.Button m_gplButton; + private System.Windows.Forms.RichTextBox m_help; + private System.Windows.Forms.Label m_gpl; + private System.Windows.Forms.Button m_ok; + + /// <summary> + /// Displays an about box, with a button to display the GPL (or optionally + /// the GPL in the help window). + /// </summary> + /// <param name="title">The title of the program</param> + /// <param name="rtf_help">Help file. Set to null to display the GPL instead.</param> + public About(string title, string rtf_help) + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + StringBuilder s=new StringBuilder(); + + Text=title; + + s.Append("This program is distributed in the hope that it will be useful, "); + s.Append("but WITHOUT ANY WARRANTY; without even the implied warranty of "); + s.Append("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "); + s.Append("GNU General Public License for more details."); + + m_gpl.Text=s.ToString(); + + if (rtf_help!=null) + { + m_help.Rtf=rtf_help; + } + else + { + m_gplButton.Hide(); + m_helpLabel.Text="GNU General Public License:"; + + ResourceManager mgr=new ResourceManager("Noddybox.GUI", + Assembly.GetExecutingAssembly()); + + byte[] gpl=(byte[])mgr.GetObject("GPL"); + + m_help.Text=new ASCIIEncoding().GetString(gpl); + } + } + + #region Windows Forms Designer generated code + /// <summary> + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// </summary> + private void InitializeComponent() { + this.m_ok = new System.Windows.Forms.Button(); + this.m_gpl = new System.Windows.Forms.Label(); + this.m_help = new System.Windows.Forms.RichTextBox(); + this.m_gplButton = new System.Windows.Forms.Button(); + this.m_helpLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // m_ok + // + this.m_ok.Location = new System.Drawing.Point(424, 368); + this.m_ok.Name = "m_ok"; + this.m_ok.Size = new System.Drawing.Size(88, 24); + this.m_ok.TabIndex = 2; + this.m_ok.Text = "OK"; + this.m_ok.Click += new System.EventHandler(this.OnOK); + // + // m_gpl + // + this.m_gpl.Location = new System.Drawing.Point(72, 8); + this.m_gpl.Name = "m_gpl"; + this.m_gpl.Size = new System.Drawing.Size(392, 56); + this.m_gpl.TabIndex = 0; + // + // m_help + // + this.m_help.BackColor = System.Drawing.SystemColors.Window; + this.m_help.Cursor = System.Windows.Forms.Cursors.Default; + this.m_help.Location = new System.Drawing.Point(8, 96); + this.m_help.Name = "m_help"; + this.m_help.ReadOnly = true; + this.m_help.Size = new System.Drawing.Size(504, 264); + this.m_help.TabIndex = 9; + this.m_help.Text = ""; + // + // m_gplButton + // + this.m_gplButton.Location = new System.Drawing.Point(8, 368); + this.m_gplButton.Name = "m_gplButton"; + this.m_gplButton.Size = new System.Drawing.Size(192, 24); + this.m_gplButton.TabIndex = 10; + this.m_gplButton.Text = "View GNU General Public License"; + this.m_gplButton.Click += new System.EventHandler(this.OnGPL); + // + // m_helpLabel + // + this.m_helpLabel.Location = new System.Drawing.Point(8, 80); + this.m_helpLabel.Name = "m_helpLabel"; + this.m_helpLabel.Size = new System.Drawing.Size(504, 16); + this.m_helpLabel.TabIndex = 8; + this.m_helpLabel.Text = "Help:"; + // + // About + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 14); + this.ClientSize = new System.Drawing.Size(522, 399); + this.Controls.Add(this.m_gplButton); + this.Controls.Add(this.m_help); + this.Controls.Add(this.m_helpLabel); + this.Controls.Add(this.m_ok); + this.Controls.Add(this.m_gpl); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "About"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "About"; + this.ResumeLayout(false); + } + #endregion + + + void OnOK(object sender, System.EventArgs e) + { + Close(); + } + void OnGPL(object sender, System.EventArgs e) + { + GPL gpl=new GPL(); + + gpl.ShowDialog(); + } + + } +} |