How Do I: SqlAzureLOB Line of Business
How Do I: Use Dallas Data with WinForms Applications?
How Do I: Use SQL Azure with WinForms applications?
How Do I: WinForms WPF Integration
How Do I: LINQ with Entity Framework
How Do I: Entity Framework and Windows Forms Using VS 2010 beta
How Do I: Use the Windows 7 Taskbar ProgressBar
How Do I: Use JumpLists in Windows 7 Applications
How Do I: Use Overlay Icons in Win 7 app with Windows API Codepack and VS 2010 B2?
How Do I: Customize a user control with the smart tag feature
How Do I: Use the FileSystemWatcher Class
How Do I: Use the Observer Pattern
How Do I: Use The Tag Property of Controls
How Do I: Use Linq With Files
How Do I: Create a Report From a Business Object?
How Do I: Create a Report From a Database?
Using the Enterprise Library – Exploring Validation
WinForms-EnterpriseLibrary
WinForms-FormToForm Using Properties
Control When Bound Data is Updated
FormToForm Using Parameters
How Do I: Use the MSChart Control in VS 2008
How Do I: Use Visual Studio 2008 SP1′s PrintForm Control
How Do I: Use Compiler Constants
How Do I: Use Hashing to Secure Information
How Do I: Use Isolated Storage
How Do I: Use the NotifyIcon Control
How Do I: Use NullableTypes in Windows Forms
How Do I: Use Encryption in Windows Forms
How Do I: Create Bindable Objects
Singleton Design Pattern
How Do I: Manage Files and Special Folders
Using Generics
Using Generic Queues
How Do I: Localize Applications using the CultureInfo Class
How Do I: Winforms, A to Z, Part 2
How Do I: Winforms, A to Z, Part 1
How Do I: Manage MDI and SDI Windows Forms
HDI-Winforms-Exceptions
Read the rest of this entry »
Comments Off
Filed under:
Microsoft
I’m working on an athletic workout journal application that will include an Interval / Countdown Timer.
I plan to build several versions of this application in different technologies (WPF, Web, Phone) but I’m building the first version in Windows Forms.
I want the user to be able to dynamically set the size of the “Stopwatch” display font, then resize the form and have the text re-center in the form, taking into consideration the new font size.
Stuff like this is easy in HTML, but not so much in Windows Forms.
Though I’m still in the early stages I thought I’d share the bit of math that I’ve come up with and invite any suggestions you might have.
Code Snippet
- using System.Text;
- using System.Windows.Forms;
- namespace WorkOutTimer
- {
- public partial class TimerMainForm : Form
- {
- public TimerMainForm()
- {
- InitializeComponent();
- }
- private void TimerMainForm_Resize(object sender, EventArgs e)
- {
- Int32 fs = System.Convert.ToInt32(textBoxFontSize.Text);
- TimerClock.Font = new Font(FontFamily.GenericSansSerif, fs, FontStyle.Bold, GraphicsUnit.Pixel);
- Point mp = new Point(((this.Size.Width – TimerClock.Width) / 2), 20);
- TimerClock.Location = mp;
- }
- }
- }
Comments Off
Filed under:
Microsoft








