SIGN UP MEMBER LOGIN:    
ARTICLE

Fuligginedialogs in C#

Posted by zeppaman Articles | Windows Forms C# May 09, 2006
In this article the author explained how we can expand feature of the framework for an immediate use of MessageBox.Show(); function.
Reader Level:

Introduction

How many times have you used the instruction: MessageBox.Show();? Well, in this article is explained how we can expand this feature of the framework for an immediate use of this function.

The Namespace

First of all I divided the main namespace in three parts:

Fuliggine.Dialogs.Embedded; Embedded Dialogs like zoom form or find form
Fuliggine.Dialogs.Static; Static dialogs like message box
Fuliggine.Dialogs.Dinamic; Costumizable dialogs (not yet implemented)

 

 

HOW TO USE

Firs of all add the following references:

using Fuliggine;
using Fuliggine.Dialogs.Static;
using Fuliggine.Dialogs.Embedded;

To call a static dialog you need:

//Do a question
FuliggineBox.ShowQuestion("Sei Allergico al Gatto?");
//notify error
FuliggineBox.ShowError("Sei Allergico al Gatto.","ATTENTO");
//Show integer
int i= 15;
FuliggineBox.ShowValue(i);
//Show an object or somelese unknown
FuliggineBox.ShowObject("Comments to print",this);

To see all the way to call those methods look at the code source. To call a embedded dialog you need to:

ZoomForm zf = new ZoomForm();

zf.Zoom=28;

if(zf.ShowDialog()==DialogResult.OK)

{

          FuliggineBox.ShowError(zf.Zoom.ToString());

}

Source Code

For the FuliggineBox I declared a static class where I called the method MessageBox.Show. With this we can use custom message calling FuliggineBox.ShowQuestion("???"); instead of

MessageBox.Show( Text ,"Question",MessageBoxButtons.YesNo, MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);

public class FuliggineBox

{

          //

          //Fuliggine Question

          //

          public static DialogResult ShowQuestion(string Text)

          {

                   return

                   MessageBox.Show( Text ,"Question",MessageBoxButtons.YesNo,

                   MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);

          }

          //...

For the embedded dialogs I used a Form that's equipped with all the needed controls, and properties. For example I am showing the code for the propertyDialog:

  1. I made a class derived from a Form.
  2. I placed the propertycontrol in the "form".
  3. I added a property called "Selectedobject".

namespace Fuliggine.Dialogs.Embedded

{

public class ControlPropertyForm : System.Windows.Forms.Form

{

          private System.Windows.Forms.PropertyGrid propertyGrid1;

          //this property must be set before call(...to show somethings)

          public object Selectedobject

          {

                   get{return this.propertyGrid1.SelectedObject;}

                   set{this.propertyGrid1.SelectedObject=value;}

          }

          public ControlPropertyForm()

          {

                   //

                   // The InitializeComponent() call is required for Windows Forms designer support.

                   //

                   InitializeComponent();

          }

          #region Windows Forms Designer generated code

}

}

And we will call this dialogs as:

pf.Selectedobject=this;//Or Someelse...

pf.Show();//Or ShowDialog

At the End...

In the future, I will expand the number of embedded dialogs adding -Font Dialog -Color Dialog - and every dialogs you need and I will add the left class Fuliggine.Dialogs.Dinamics.

Framework Problematics

This code is written under sharpdevelop with framework2. If you use a different compiler/version of framework, you only need to add the files in your solution and rebuild all.

Credits

If you want to see my other work please visit my home page: http://zeppaman.altervista.org

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor