C# Event Accessors#

I'm working on a project where a customer needs some custom controls.  One of the requirements is to have a UserControl contain a TextBox and a Button and to expose an event that will be raised when the button is clicked.  Easy enough, but to enhance the design time experience instead of adding a ButtonClick event for example, I added the following to the UserControl

public new event EventHandler Click
{
   add
   {
      lock (m_button)
      {
         m_button.Click +=
value;
      }
   }
   remove
   {
      lock (m_button)
      {
         m_button.Click -=
value;
      }
   }
}

What this does is instead of adding the EventHandler to the UserControl.Click event, I add it straight to the m_button.Click event.  Not terribly complicated but gives a better design time experience and avoids creating a new event to expose.

For more info on declaring events see here.


C#
Thursday, November 23, 2006 9:37:07 AM (Eastern Standard Time, UTC-05:00) #    Comments [1]  | 

 

WCF for CF#

.NET 3.0 RC1 (formerly WinFx) is available for the desktop but as a device developer you always feel left out.  Well Roman Batoukov of the CF team gives us the lowdown on WCF for CF.  Their choice for transport channel...email which is an interesting choice and somewhat agree for certain scenarios.  Of course it's extensible so we are already thinking of some other transport channels we can develop for mobile/embedded devices because let's face it, not everyone runs Exchange :)


Thursday, November 02, 2006 5:32:31 PM (Eastern Standard Time, UTC-05:00) #    Comments [0]  | 

 

OpenNETCF Samples Overview#

We have had almost 6300 downloads of our samples for the Smart Device Framework 2.0 but I was answering a question in the newsgroups one day and wanted to reference the samples but couldn't find any references to what's included in the samples. 

Considering I put together the samples installation, I actually had to install it to remember what was installed with it! This got me thinking, if I couldn't remember what was in it how are others supposed to know what's in the installation especially since there is no 'readme' or summary anywhere.

That problem is now solved.  We have put together documentation for the samples available for the Smart Device Framework 2.0. You can download the initial document here.  We will have it up on the website in a few days.

Even if you don't use the Smart Device Framework the samples could be useful if you are a Compact Framework Developer.


Thursday, November 02, 2006 5:13:52 PM (Eastern Standard Time, UTC-05:00) #    Comments [0]  | 

 

OpenNETCF.Media.WaveAudio.Wave Class#

We have received a few customer request to use the Wave.SetVolume and Wave.GetVolume methods in the OpenNETCF.Media.WaveAudio.Wave class.  Unfortunately, there is no default constructor for the Wave class so you cannot directly call these methods.

Using a little bit of Reflection we can get the private contructor of the Wave class using Type.GetConstructors().

Here is some sample code to call Wave.SetVolume and Wave.GetVolume.  (NOTE:  this is currently not supported and may not work in future releases of the Smart Device Framework)

OpenNETCF.Media.WaveAudio.Wave wave = null;

ConstructorInfo[] ci = typeof(OpenNETCF.Media.WaveAudio.Wave).GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

if (ci.Length == 1)

wave = (OpenNETCF.Media.WaveAudio.Wave)ci[0].Invoke(null);

if (wave != null)

wave.SetVolume(1);


Wednesday, November 01, 2006 2:42:36 AM (Eastern Standard Time, UTC-05:00) #    Comments [0]  | 

 

All content © 2008, Mark Arteaga
Related Sites
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts