Search Forum
(57415 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


              
Printable Version

Fuliggine Dialogs
By Zeppaman

  • Download source files - 405 Kb
  • Download demo project - 108 Kb
  • Introduction

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

    The Namespace

    First of all I divide 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 using reference:
    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 alla the way to call thoose 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 declare a static class where i call the method MessageBox.Show.Whit this escamotage 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 use a Form that's equiped with all the needed controls,and properties.For example I show the code for the propertyDialog: 1.I make a class derived from a Form 2.I put the propertycontrol in the "form" 3.I add 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 eill call this dialogs As:
                pf.Selectedobject=this;//Or Someelse...
    
                pf.Show();//Or ShowDialog
    

    At the End...

    In the future ,I will exand 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 compilator/version of framework , you only need to add the files in your solution and rebuild all.