Click here to Skip to main content
15,895,011 members
Articles / Desktop Programming / Windows Forms

BizDraw framework for .NET

Rate me:
Please Sign up or sign in to vote.
4.80/5 (21 votes)
30 May 20075 min read 128.2K   3.2K   102  
A small framework to design and print documents containing shapes, text, images, bar codes...
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection ;
using System.Windows.Forms ;
namespace BizDraw.Controls
{
    public class Command
    {
        private string _name;
        private object _host;
        private MethodInfo _method;
        private List<ToolStripItem> _items = new List<ToolStripItem>();
        public Command(string name, object host, MethodInfo method,bool enabledDefault, params ToolStripItem[] items)
        {
            Name = name;
            Host = host;
            Method = method;
            if (items != null)
            {
                foreach (ToolStripItem i in items)
                {
                    i.Click += new EventHandler(i_Click);
                    this.Items.Add(i);
                }
            }
            if (!enabledDefault )
                Disable();
        }
        void i_Click(object sender, EventArgs e)
        {
            try
            {
                this.Method.Invoke(Host, null);
            }
            catch (System.Reflection.TargetInvocationException tex)
            {
                MessageBox.Show(tex.InnerException.Message );
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        public object Host
        {
            get { return _host; }
            set { _host = value; }
        }
        public MethodInfo Method
        {
            get { return _method; }
            set { _method = value; }
        }
        public List<ToolStripItem> Items
        {
            get { return _items; }
            set { _items = value; }
        }

        public void Enable()
        {
            foreach (ToolStripItem i in this.Items)
                i.Enabled = true;
        }
        public void Disable()
        {
            foreach (ToolStripItem i in this.Items)
                i.Enabled = false;
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
MCSD Asp.Net certified developer

Comments and Discussions