Login to TechLifeForum X
Board Index Go to Reboot.Pro
  • Account Login
  • Register
TechLifeForum
  • Home
  • Members
  • Awards
  • Rules
  • Help
  • Donate
  • Live IRC
TechLifeForum / Programming and Development / .Net Framework Programming v
« Previous 1 ... 17 18 19 20 21 ... 46 Next »
/  AceInfoBox - Test[Advanced Search]
Reply to thread
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

[C#] AceInfoBox - Test

06-15-2012, 11:49 PM (This post was last modified: 06-15-2012 11:54 PM by AceInfinity.)
Post: #1
AceInfinity Offline
∞ IҊϜIɴITϵ ☭
*****
Microsoft MVP
Posts: 8,697
Joined: Jun 2011
Reputation: 61
AceInfoBox - Test
Use The Namespace:
Code: (SELECT ALL CODE)
using AceUtilities;

My InfoBox Information:
Code: (SELECT ALL CODE)
private infoStrings infoStrs = new infoStrings
{
    programName = "AceProgram",
    developerName = "AceInfinity",
    companyName = "TechLifeForum",
    creationDate = "June 2012",
    descriptionText = "This is a simple test to see how my AceInfoBox looks like. Testing Testing Testing Testing, TEST, TEST, TEST."
};

To Test:
Code: (SELECT ALL CODE)
private void button1_Click(object sender, EventArgs e)
{
    new AceInfoBox(infoStrs).ShowDialog();
}

My Full Class:
Code: (SELECT ALL CODE)
using System;
using System.Linq;
using System.Drawing;
using System.Windows.Forms;

namespace AceUtilities
{
    public class infoStrings
    {
        private string programN, devN, companyN, creationD, descText;

        public string programName
        {
            get { return programN; }
            set { programN = CheckLength(value); }
        }

        public string developerName
        {
            get { return devN; }
            set { devN = CheckLength(value); }
        }

        public string companyName
        {
            get { return companyN; }
            set { companyN = CheckLength(value); }
        }

        public string creationDate
        {
            get { return creationD; }
            set { creationD = CheckLength(value); }
        }

        public string descriptionText
        {
            get { return descText; }
            set { descText = CheckLength(value); }
        }


        private const int Maxlen = 75;
        private string CheckLength(string value)
        {
            return value.Length > Maxlen ? string.Concat(value.Take(75).ToArray()) + "..." : value;
        }
    }

    public class AceInfoBox : Form
    {

        public AceInfoBox(infoStrings InformationStrs, Icon icon = null, string FormTitle = "Application Information")
        {
            this.Text = FormTitle;
            this.Size = new Size(475, 150);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.Icon = icon ?? SystemIcons.Information;
            SetLabels(InformationStrs);
        }

        private void SetLabels(infoStrings StrInfo)
        {
            int disp = 15;
            int dispY = 20;

            for (int i = 0; i < 5; i++)
            {
                Label lbl = new Label();
                switch (i)
                {
                    case 0:
                        lbl.Text = string.Format("Program Name - {0}", StrInfo.programName);
                        break;
                    case 1:
                        lbl.Text = string.Format("Developer Name - {0}", StrInfo.developerName);
                        break;
                    case 2:
                        lbl.Text = string.Format("Company Name - {0}", StrInfo.companyName);
                        break;
                    case 3:
                        lbl.Text = string.Format("Creation Date - {0}", StrInfo.creationDate);
                        break;
                    case 4:
                        lbl.Text = string.Format("Description - {0}", StrInfo.descriptionText);
                        break;

                }

                lbl.Location = new Point(15, disp);
                disp += dispY;

                lbl.Size = new Size(this.Width, 15);
                this.Controls.Add(lbl);
            }
        }

    }
}

Very very basic outcome, but it was just a firsthand test without doing anything fancy. Use it to better your understanding and get to making your own if you want!



With this you can:
• Have your own infobox icon
• Change the infobox form text & all the label details

(I have a preventative function on each string property to add "..." to the end of the string after shortening it if it becomes too long, but perhaps, you could create a function or method to shorten and divide up into lines kind of like an auto-wrapping feature? You'd have to extend the form height though if the description is long enough to extend the bounds of the infobox form without modifying it's size though.)

Good example of the C# null coalescing operator in here as well! (??)

cheers



Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer


Development Site: aceinfinity.net
WWW Find
Reply
Reply to thread


Possibly Related Threads...

Thread: Author Replies: Views: Last Post
   Lazy Initialization Test (Lazy<T>) AceInfinity 3 211 08-07-2012 12:35 AM
Last Post: AceInfinity
  LINQ to MSIL Test AceInfinity 4 442 07-28-2012 07:37 PM
Last Post: AceInfinity
   File Reaper - Alpha Test Project [SearchPath API] AceInfinity 2 465 05-29-2012 11:17 AM
Last Post: AceInfinity

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:


Users browsing this thread
1 Guest(s)
Youtube Facebook Twitter Digg
Return to Top
All content © copyright TechLifeForum
Powered By MyBB, © 2002-2013 MyBB Group
Designed by ThemeFreak
Mobile Version