Exemplo n.º 1
0
        /// <summary>
        /// Constructor</summary>
        /// <param name="title">Optional dialog title. If null, the title is "About"</param>
        /// <param name="url">Optional URL of tool's home page. If null, no URL Control is shown</param>
        /// <param name="clientControl">Optional Control to be added. If this is a RichTextBox, URLs
        /// will launch the user's browser if the user clicks on them.</param>
        /// <param name="logo">Custom logo image. If null, the SCEA logo is used.</param>
        /// <remarks>Image size should be 200 x 200</remarks>
        /// <param name="credits">Optional application credits list. Can be null.</param>
        /// <param name="addAtfInfo">Whether ATF version and credits should be added to end of credits</param>
        public AboutDialog(
            string title,
            string url,
            Control clientControl,
            Image logo,
            IList <string> credits,
            bool addAtfInfo)
        {
            // Required for Windows Form Designer support
            InitializeComponent();

            if (title == null)
            {
                title = "About".Localize();
            }
            Text = title;

            if (logo == null)
            {
                logo = Sce.Atf.ResourceUtil.GetImage(Resources.AtfLogoImage);
            }

            if (credits == null)
            {
                credits = new List <string>();
            }

            if (addAtfInfo)
            {
                Version v = AtfVersion.GetVersion();
                // Use the Localizer.Localize() syntax instead of using an extension method, because
                //  our tool, LocalizableStringExtractor, doesn't work with parentheses around the
                //  concatenated string literal.
                // ReSharper disable once InvokeAsExtensionMethod
                credits.Add(string.Format(Localizer.Localize(
                                              "Authoring Tools Framework (ATF {0}), by " +
                                              "Alan Beckus, Matt Mahony, Pat O'Leary, Paul Skibitzke, and Max Elliott." +
                                              " Copyright © 2014 Sony Computer Entertainment America LLC", "{0} is the version number"), v));
            }

            pictureBox.Size  = logo.Size;
            pictureBox.Image = logo;

            if (clientControl != null)
            {
                clientControl.Dock = DockStyle.Fill;
                clientPanel.Controls.Add(clientControl);

                m_richTextBox = clientControl as RichTextBox;
                if (m_richTextBox != null)
                {
                    m_richTextBox.LinkClicked += RichTextBoxOnLinkClicked;
                }
            }

            // link to project home page
            if (url != null)
            {
                // To-do: this seems like a useful utility method that surely must exist somewhere,
                //  to return how many characters can fit in a given amount of space for a particular font.
                //float fontSize = linkLabel.Font.SizeInPoints;
                //int numVisibleChars = (int)((linkLabel.ClientRectangle.Width / fontSize) * GdiUtil.DpiFactor * (96.0f / 72.0f));

                m_url = url;
                //int numCharsForUrl = numVisibleChars - linkLabel.Text.Length;
                //url = PathUtil.GetCompactedPath(url, numCharsForUrl);//to-do: this throws a System.ExecutionEngineException!
                linkLabel.Links.Add(linkLabel.Text.Length, url.Length, url);
                linkLabel.Text      += url;
                linkLabel.MouseDown += linkLabel_MouseDown;
                linkLabel.Visible    = true;
            }
            else
            {
                linkLabel.Visible = false;
            }

            if (credits.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string credit in credits)
                {
                    sb.Append(credit);
                    sb.Append(Environment.NewLine);
                }
                creditsTextBox.Text = sb.ToString();
            }
            else
            {
                Controls.Remove(creditsTextBox);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor</summary>
        /// <param name="title">Optional dialog title. If null, the title is "About"</param>
        /// <param name="url">Optional URL of tool's home page. If null, no URL Control is shown</param>
        /// <param name="clientControl">Optional Control to be added. If this is a RichTextBox, URLs
        /// will launch the user's browser if the user clicks on them.</param>
        /// <param name="logo">Custom logo image. If null, the SCEA logo is used.</param>
        /// <remarks>Image size should be 200 x 200</remarks>
        /// <param name="credits">Optional application credits list. Can be null.</param>
        /// <param name="addAtfInfo">Whether ATF version and credits should be added to end of credits</param>
        public AboutDialog(
            string title,
            string url,
            Control clientControl,
            Image logo,
            IList <string> credits,
            bool addAtfInfo)
        {
            // Required for Windows Form Designer support
            InitializeComponent();

            if (title == null)
            {
                title = "About".Localize();
            }
            Text = title;

            if (logo == null)
            {
                logo = Sce.Atf.ResourceUtil.GetImage(Resources.AtfLogoImage);
            }

            if (credits == null)
            {
                credits = new List <string>();
            }

            if (addAtfInfo)
            {
                Version v = AtfVersion.GetVersion();
                // Note, that my attempts to use Localize() fail because the generated MSIL breaks the
                //  LocalizableStringExtractor program, due to the use of a 'bytearray'. So, until we
                //  fix our extractor program, this credit string can't easily be localized.--Ron
                credits.Add(string.Format("Authoring Tools Framework (ATF {0}), by Ron Little, Jianhua Shen," +
                                          " Julianne Harrington, Alan Beckus, Matt Mahony, Pat O'Leary, Paul Skibitzke, and Max Elliott." +
                                          " Copyright © 2014 Sony Computer Entertainment America LLC".Localize("{0} is the version number"), v));
            }

            pictureBox.Size  = logo.Size;
            pictureBox.Image = logo;

            if (clientControl != null)
            {
                clientControl.Dock = DockStyle.Fill;
                clientPanel.Controls.Add(clientControl);

                m_richTextBox = clientControl as RichTextBox;
                if (m_richTextBox != null)
                {
                    m_richTextBox.LinkClicked += RichTextBoxOnLinkClicked;
                }
            }

            // link to project home page
            if (url != null)
            {
                // To-do: this seems like a useful utility method that surely must exist somewhere,
                //  to return how many characters can fit in a given amount of space for a particular font.
                //float fontSize = linkLabel.Font.SizeInPoints;
                //int numVisibleChars = (int)((linkLabel.ClientRectangle.Width / fontSize) * GdiUtil.DpiFactor * (96.0f / 72.0f));

                m_url = url;
                //int numCharsForUrl = numVisibleChars - linkLabel.Text.Length;
                //url = PathUtil.GetCompactedPath(url, numCharsForUrl);//to-do: this throws a System.ExecutionEngineException!
                linkLabel.Links.Add(linkLabel.Text.Length, url.Length, url);
                linkLabel.Text      += url;
                linkLabel.MouseDown += linkLabel_MouseDown;
                linkLabel.Visible    = true;
            }
            else
            {
                linkLabel.Visible = false;
            }

            if (credits.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string credit in credits)
                {
                    sb.Append(credit);
                    sb.Append(Environment.NewLine);
                }
                creditsTextBox.Text = sb.ToString();
            }
            else
            {
                Controls.Remove(creditsTextBox);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// construct Splash Form and assing background image if provided.
        /// </summary>
        private SplashForm(Type type, string resourcePath)
        {
            Bitmap   bkgImage  = null;
            Assembly assem     = Assembly.GetAssembly(type);
            var      attr      = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(assem, typeof(AssemblyCopyrightAttribute));
            string   copyright = attr.Copyright;

            if (!string.IsNullOrEmpty(resourcePath))
            {
                Stream strm = assem.GetManifestResourceStream(resourcePath);
                if (strm != null)
                {
                    bkgImage = new Bitmap(strm);
                }
            }

            this.SuspendLayout();

            //
            // lblAppVer
            //
            this.lblAppVer           = new Label();
            this.lblAppVer.BackColor = Color.Transparent;
            this.lblAppVer.ForeColor = Color.LightGray;
            this.lblAppVer.Font      = new Font("Trebuchet MS", 10.0f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.lblAppVer.Name      = "lblAppVer";
            this.lblAppVer.Text      = "Version " + Application.ProductVersion;
            this.lblAppVer.Width     = 200;
            lblAppVer.AutoSize       = true;


            // lblATFVer
            this.lblATFVer           = new System.Windows.Forms.Label();
            this.lblATFVer.BackColor = System.Drawing.Color.Transparent;
            this.lblATFVer.ForeColor = Color.LightGray;
            this.lblATFVer.Font      = new System.Drawing.Font("Trebuchet MS", 10.0f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblATFVer.Name      = "lblATFVer";
            this.lblATFVer.Text      = "Uses ATF Version " + AtfVersion.GetVersion();
            this.lblATFVer.Width     = 200;
            lblATFVer.AutoSize       = true;


            //
            // lblCopyright
            //
            this.lblCopyright           = new System.Windows.Forms.Label();
            this.lblCopyright.BackColor = System.Drawing.Color.Transparent;
            this.lblCopyright.ForeColor = Color.LightGray;
            this.lblCopyright.Font      = new System.Drawing.Font("Trebuchet MS", 10.0f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblCopyright.Name      = "lblCopyright";
            this.lblCopyright.Text      = copyright;
            this.lblCopyright.Width     = 500;
            this.AutoSize = true;


            //
            // SplashForm
            //
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            this.BackColor     = System.Drawing.SystemColors.ControlLight;
            this.ControlBox    = false;
            this.Controls.Add(this.lblATFVer);
            this.Controls.Add(this.lblAppVer);
            this.Controls.Add(this.lblCopyright);
            this.DoubleBuffered  = true;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;
            this.Name            = "SplashForm";
            this.ShowIcon        = false;
            this.ShowInTaskbar   = false;
            this.StartPosition   = FormStartPosition.CenterScreen;
            this.SizeGripStyle   = System.Windows.Forms.SizeGripStyle.Hide;
            this.TopMost         = true;

            if (bkgImage != null)
            {
                this.Size            = bkgImage.Size;
                this.BackgroundImage = bkgImage;
            }

            this.ResumeLayout(false);
            this.PerformLayout();

            SizeChanged += (sender, e) =>
            {
                // Reposition labels.
                const int x = 10;
                int       y = Height - lblCopyright.Height - 6;

                lblCopyright.Location = new Point(x, y);

                y -= lblATFVer.Height;
                lblATFVer.Location = new Point(x, y);

                y -= (lblAppVer.Height);
                lblAppVer.Location
                    = new Point(x, y);
            };
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor</summary>
        /// <param name="title">Optional dialog title. If null, the title is "About"</param>
        /// <param name="url">Optional URL of tool's home page. If null, no URL Control is shown</param>
        /// <param name="clientControl">Optional Control to be added. If this is a RichTextBox, URLs
        /// will launch the user's browser if the user clicks on them.</param>
        /// <param name="logo">Custom logo image. If null, the SCEA logo is used.</param>
        /// <remarks>Image size should be 200 x 200</remarks>
        /// <param name="credits">Optional application credits list. Can be null.</param>
        /// <param name="addAtfInfo">Whether ATF version and credits should be added to end of credits</param>
        public AboutDialog(
            string title,
            string url,
            Control clientControl,
            Image logo,
            IList <string> credits,
            bool addAtfInfo)
        {
            // Required for Windows Form Designer support
            InitializeComponent();

            if (title == null)
            {
                title = "About".Localize(); //tested by TestExtractLocalizableStrings()
            }
            Text = title;

            if (logo == null)
            {
                logo = Sce.Atf.ResourceUtil.GetImage(Resources.AtfLogoImage);
            }

            if (credits == null)
            {
                credits = new List <string>();
            }

            if (addAtfInfo)
            {
                Version v = AtfVersion.GetVersion();
                credits.Add(string.Format("Authoring Tools Framework (ATF {0}),".Localize("{0} is the version number") +
                                          " by Ron Little, Jianhua Shen," +
                                          " Julianne Harrington, Alan Beckus, Matt Mahony, Pat O'Leary, Paul Skibitzke, and Max Elliott." +
                                          " Copyright © 2014 Sony Computer Entertainment America LLC", v));

                // Test a commented-out version of Localize().
                //credits.Add(string.Format("Authoring Tools Framework (ATF {0}), by Ron Little, Jianhua Shen," +
                //    " Julianne Harrington, Alan Beckus, Matt Mahony, Pat O'Leary, Paul Skibitzke, and Max Elliott." +
                //    " Copyright © 2014 Sony Computer Entertainment America LLC".Localize("{0} is the version number"), v));

                // Test that \r and \n get turned into carriage-return and newline characters.
                string message = string.Format("Check out the file\r\n\r\n{0}\r\n\r\nto be able to save the changes?".Localize(),
                                               document.Uri.LocalPath);

                // Test all character literals. https://msdn.microsoft.com/en-us/library/aa691087(v=vs.71).aspx
                string test = "\'\"\\\0\a\b\f\\n\r\t\v\xf\x2a\x02a\0x002a9\u002a\U0000002a".Localize();

                // Test verbatim string with escaped double-quotes (the only possible escaped character).
                // https://msdn.microsoft.com/en-us/library/aa691090(v=vs.71).aspx
                test = @"abc 123""
\\\n\r\t\a
".Localize();

                Localizer.Localize(
                    @"def 123""
\\\n\r\t\a
"
                    );
            }

            pictureBox.Size  = logo.Size;
            pictureBox.Image = logo;

            if (clientControl != null)
            {
                clientControl.Dock = DockStyle.Fill;
                clientPanel.Controls.Add(clientControl);

                m_richTextBox = clientControl as RichTextBox;
                if (m_richTextBox != null)
                {
                    m_richTextBox.LinkClicked += RichTextBoxOnLinkClicked;
                }
            }

            // link to project home page
            if (url != null)
            {
                // To-do: this seems like a useful utility method that surely must exist somewhere,
                //  to return how many characters can fit in a given amount of space for a particular font.
                //float fontSize = linkLabel.Font.SizeInPoints;
                //int numVisibleChars = (int)((linkLabel.ClientRectangle.Width / fontSize) * GdiUtil.DpiFactor * (96.0f / 72.0f));

                m_url = url;
                //int numCharsForUrl = numVisibleChars - linkLabel.Text.Length;
                //url = PathUtil.GetCompactedPath(url, numCharsForUrl);//to-do: this throws a System.ExecutionEngineException!
                linkLabel.Links.Add(linkLabel.Text.Length, url.Length, url);
                linkLabel.Text      += url;
                linkLabel.MouseDown += linkLabel_MouseDown;
                linkLabel.Visible    = true;
            }
            else
            {
                linkLabel.Visible = false;
            }

            if (credits.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string credit in credits)
                {
                    sb.Append(credit);
                    sb.Append(Environment.NewLine);
                }
                creditsTextBox.Text = sb.ToString();
            }
            else
            {
                Controls.Remove(creditsTextBox);
            }
        }