示例#1
0
        /// <summary>
        /// Displays the AboutForm for the entry assembly.
        /// </summary>
        public static new void Show()
        {
            string assemblyName = Assembly.GetEntryAssembly().GetName().Name;
            string fileName     = assemblyName + ".AboutFormParameters.xml";
            AboutFormParameters parameters
                = AboutFormParameters.LoadXml(fileName);
            AboutForm form = new AboutForm(parameters);

            form.ShowDialog();
        }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parameters">
        /// An object encapsulating information such as the author's name,
        /// copyright details and location of the license agreement.
        /// </param>
        private AboutForm(AboutFormParameters parameters)
        {
            //
            // The InitializeComponent() call is required for Windows Forms
            // designer support.
            //
            InitializeComponent();

            //
            // Add constructor code after the InitializeComponent() call.
            //
            if (parameters == null)
            {
                parameters = new AboutFormParameters();
            }

            _verticalPosition = _verticalPadding;
            this.Width        = parameters.FormWidth;
            this.Height       = _verticalPadding;

            this.ShowInTaskbar   = false;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;

            this.Text = "About " + parameters.ApplicationName;
            if (string.IsNullOrEmpty(parameters.ExtraCopyrightStatement) == false)
            {
                AddLabel(parameters.ExtraCopyrightStatement);
            }
            AddLabel("Copyright (C) " + parameters.CopyrightYear
                     + " " + parameters.Author);

            TextBox agreementBox = new TextBox();

            agreementBox.ReadOnly   = true;
            agreementBox.Multiline  = true;
            agreementBox.ScrollBars = ScrollBars.Vertical;
            agreementBox.Height     = 200;
            agreementBox.Text       = File.ReadAllText(parameters.LicenseFileName);
            agreementBox.Select(0, 0);
            AddControl(agreementBox);

            if (parameters.CreditableWorks.Count > 0)
            {
                DataGridView grid = new DataGridView();
                grid.Columns.Add("Author", "");
                grid.Columns.Add("WorkName", "");
                grid.ReadOnly             = true;
                grid.RowHeadersVisible    = false;
                grid.ColumnHeadersVisible = false;
                grid.AutoSizeColumnsMode  = DataGridViewAutoSizeColumnsMode.Fill;
                grid.AutoSizeRowsMode     = DataGridViewAutoSizeRowsMode.AllCells;
                grid.Height = 200;

                AddLabel("Contains work by the following:");
                foreach (CreditableWork work in parameters.CreditableWorks)
                {
                    int rowCount = grid.Rows.Add(work.Author, work.WorkName);
                    for (int i = 0; i < 2; i++)
                    {
                        grid.Rows[rowCount].Cells[i].Style.WrapMode
                            = DataGridViewTriState.True;
                    }
                }
                grid.AllowUserToAddRows = false;
                AddControl(grid);
            }
        }