Click here to Skip to main content
15,881,173 members
Articles / Desktop Programming / Windows Forms

CX Part II

Rate me:
Please Sign up or sign in to vote.
4.97/5 (33 votes)
5 Aug 2009CPOL47 min read 53.6K   354   48  
Build a Metadata Designer for the CX Dynamic Composition Framework.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Cx.Attributes;
using Cx.EventArgs;
using Cx.Interfaces;
using Cx.WinForm;

namespace NumericKeypadComponent
{
	
	[CxComponentName("Numeric Keypad")]
	public partial class NumericKeypad : UserControl, ICxVisualComponentClass
	{
		// In this case, since there are 11 buttons that all fire into the same handler when clicked,
		// it's better to implement our event here rather than use an event transformation.
		[CxEvent] public event CxCharDlgt KeypadEvent;

		public NumericKeypad()
		{
			InitializeComponent();
		}

		public void Register(object form, ICxVisualComponent comp)
		{
			this.RegisterControl((Form)form, comp);
		}

		protected void KeypadClick(object sender, EventArgs e)
		{
			string padItem = (string)((Control)sender).Tag;
			RaiseKeypadEvent(padItem[0]);
		}

		protected virtual void RaiseKeypadEvent(char c)
		{
			EventHelpers.Fire(KeypadEvent, this, new CxEventArgs<char>(c));
		}
	}
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions