| By Xin Yan | Article Rating: |
|
| July 29, 2005 01:45 AM EDT | Reads: |
116,032 |
namespace SignInControl {
public partial class SignInControl : UserControl {
private ImageList animationImages = null;
private AnimationMode animationMode = AnimationMode.None;
private int animationCounter = 0;
public SignInControl(){
InitializeComponent();
}
public string UserName {
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
public string Password {
get { return textBox2.Text; }
set { textBox2.Text = value; }
}
public ImageList AnimationImages {
get { return animationImages; }
set { animationImages = value; }
}
public AnimationMode AnimationMode {
get { return animationMode; }
set { animationMode = value; UpdateAnimation(); }
}
private void UpdateAnimation() {
switch (animationMode) {
case AnimationMode.None:
animationTimer.Enabled = false;
break;
case AnimationMode.On:
animationCounter = 0;
animationTimer.Enabled = true;
break;
}
pictureBox1.Image = null;
}
private void animationTimer_Tick(object sender, EventArgs e) {
Image img = null;
if (animationImages != null
&& animationImages.Images.Count > 0) {
if (animationCounter
>= animationImages.Images.Count)
animationCounter = 0;
img = animationImages.Images[animationCounter];
animationCounter++;
}
pictureBox1.Image = img;
}
}
}
Listing 2
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/
2004/03/SmartDevices/XMTA.xsd">
<Class Name="SignInControl.SignInControl">
<Property Name="Password">
<Category>Data</Category>
<Description>Password user enterred.</Description>
</Property>
<Property Name="UserName">
<Category>Data</Category>
<Description>User name enterred.</Description>
</Property>
<Property Name="AnimationMode">
<Category>Appearance</Category>
<Description>Whether animation is on or off.
</Description>
</Property>
<Property Name="AnimationImages">
<Category>Appearance</Category>
<Description>Images used in animation.</Description>
</Property>
</Class>
</Classes>
Listing 3
PasswordInputMode inputMode = PasswordInputMode.Regular;
public PasswordInputMode PasswordInputMode {
get { return inputMode; }
set { inputMode = value; }
}
private void textBox2_GotFocus(object sender, EventArgs e) {
IntPtr hWnd = GetFocus();
if (PasswordInputMode == PasswordInputMode.NumberOnly)
SendMessage(hWnd, EM_SETINPUTMODE, 0, EIM_NUMBERS);
else
SendMessage(hWnd, EM_SETINPUTMODE, 0, EIM_TEXT);
}
private const uint EM_SETINPUTMODE = 0xDE;
private const uint EIM_NUMBERS = 2;
private const uint EIM_TEXT = 3;
[DllImport("coredll.dll")]
public static extern IntPtr GetFocus();
[DllImport("coredll.dll")]
public static extern int SendMessage(IntPtr hWnd,
uint Message, uint wParam, uint lParam);
Published July 29, 2005 Reads 116,032
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Xin Yan
Xin Yan has been a software design engineer at Microsoft for over 7 years. He works on Visual Studio developer tools platform team.
![]() |
Jay Dixit 10/11/07 07:07:23 AM EDT | |||
Hi truly a great article but i am new for it and just have some queries. Please help me for this. |
||||
![]() |
Jacques Herweijer 02/05/07 03:23:28 PM EST | |||
Hi great article, I completely understand the usercontrols now in a few minutes, its better than reading a book about it ! That however leaves me with 2 unanswered questions hope you can answer them. My first question is, How can I access the properties of the labels as soon as the usercontrol is used on a form, so I can change the Text property depending on the form I am using it on, or do I have to create a new usercontrol that inhertis your example for each label Text I want to use and drop that one on my form. I think this is very much work for just setting a label. And then my second one, How can I add controls to the usercontrol when I put it on my form ? For example if I wanted to add a button to the usercontrol when it is on my form but not in de usercontrol class itself (like a panel can contain controls) in Design-time ofcourse. Hope you can and be willing to give me an answer because I cannot find these answers anywhere. I think its hard to search the web when some functionallity is not available for Smart Device projects. Anyway Great article that give me a head start. |
||||
![]() |
.NET News Desk 07/28/05 02:49:36 PM EDT | |||
Creating Custom Controls for Microsoft .NET Compact Framework in Visual Studio 2005 |
||||
![]() |
.NET News Desk 07/28/05 02:49:30 PM EDT | |||
Creating Custom Controls for Microsoft .NET Compact Framework in Visual Studio 2005 |
||||
- Kindle 2 vs Nook
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Windows 7 – Microsoft’s First Step to the Cloud
- Cloud Expo and the End of Tech Recession
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Reality Check at the Cloud Computing Expo
- Visual Studio 2010 Is Cloud Friendly
- Fired SCO CEO Fires Back
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Best Practices
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Eval JavaScript in a Global Context
- Windows 7 – Microsoft’s First Step to the Cloud
- Google Maps and ASP.NET
- Crystal Reports XI & How It Has Changed
- Converting VB6 to VB.NET, Part I
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Where Are RIA Technologies Headed in 2008?
- How to Write High-Performance C# Code
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Implementing Tab Navigation with ASP.NET 2.0
- i-Technology Photo Exclusive: Bill Gates & Steve Jobs In "Nerds"
- .NET Archives: Getting Reacquainted with the Father of C#
- i-Technology Viewpoint: "SOA Sucks"
- Programmatically Posting Data to ASP .NET Web Applications


























