Sofia, Bulgaria | 9-10 October.NET Windows Forms Tips and Tricks Cathi Gero Prenia Software & Consulting Services Cathi Gero Prenia Software.

Slides:



Advertisements
Similar presentations
Interaction Design: Visio
Advertisements

Document Properties: adding information to your Microsoft Office documents Step 1: Add information to Document Properties What are Document Properties.
Microsoft ® Office Access ® 2007 Training Easy Access with templates I: Create a database susanguggenheim-is.com presents:
Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Step-by-Step: Add a Graphical Hyperlink USE the Special Events Final presentation that is still open from the previous exercise. 1.Go to slide 4, and click.
Chapter 5 Creating an Image Map
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Microsoft Word 2010 Lesson 1: Introduction to Word.
Ch. 6 Web Page Design – Absolute Positioning, Image Maps, and Navigation Bars Mr. Ursone.
© by Pearson Education, Inc. All Rights Reserved.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Introduction To Form Builder
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Chapter 1 Getting Started With Dreamweaver. Explore the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
1 Advanced PowerPoint Cliff Solomon. 2 Presentation Outline Inserting Movies and Animations Into Your Presentations Using Progressive Disclosures and.
InDesign CS3 Lesson 3 Working with Frames. Using Frames Frames are containers in which you place graphics or text. Frames can also be used as graphic.
ICS 665 Jesse Abdul. jQuery UI Overview  jQuery UI javascript library Includes all UI component functionality  jQuery UI CSS framework Includes standard.
Creating a Web Page HTML, FrontPage, Word, Composer.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Web Technologies Website Development Trade & Industrial Education
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Prezentacja autorstwa:
Presented by : Olivia Lin. Outline Preparation works –What software do I need? Source of sample codes –Online source: Supergeo Developer Network (SGDN)
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
Website Development with Dreamweaver
ASP.NET Web Server Controls Basic Web Server Controls.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
© 2012 The McGraw-Hill Companies, Inc. All rights reserved. word 2010 Chapter 3 Formatting Documents.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Chapter Two Creating a First Project in Visual Basic.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Chapter 3 ADOBE INDESIGN CS3 Chapter 3 SETTING UP A DOCUMENT.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
LANDESK SOFTWARE CONFIDENTIAL Tips and Tricks with Filters Jenny Lardh.
January 2006Colby College ITS Setting Up Course Pages.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please.
© I-Logix Rhapsody C++ V /01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V /01/04.
Appendix A: Windows Forms. 2 Overview Describe the structure of a Windows Forms application –application entry point –forms –components and controls Introduce.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Mike Harsh PRSL001 Program Manager Microsoft Corporation
Java FX: Scene Builder.
Introduction to JavaScript Events
Chapter 2 – Introduction to the Visual Studio .NET IDE
Toolbars and Status Bars
Chapter 1: An Introduction to Visual Basic 2015
Introduction to Events
Chapter 2 – Introduction to the Visual Studio .NET IDE
Module 05: Building ASP .NET Applications
6. WinForms 2003 C# GUI - Basics.
Presentation transcript:

Sofia, Bulgaria | 9-10 October.NET Windows Forms Tips and Tricks Cathi Gero Prenia Software & Consulting Services Cathi Gero Prenia Software & Consulting Services

Sofia, Bulgaria | 9-10 October Cathi Gero ●Prenia Software & Consulting Services Corp. ( ●Specialize in.NET mentoring / application development / training ●Certified Public Accountant (C.P.A.) ●Microsoft C# /.NET MVP ●Monthly column called Cathi Gero’s.NET Tips in UniversalThread Magazine ●Author of articles for MSDN, TSS, and other publications ●Sits on.NET Advisory Council ●Weblog: ●Prenia Software & Consulting Services Corp. ( ●Specialize in.NET mentoring / application development / training ●Certified Public Accountant (C.P.A.) ●Microsoft C# /.NET MVP ●Monthly column called Cathi Gero’s.NET Tips in UniversalThread Magazine ●Author of articles for MSDN, TSS, and other publications ●Sits on.NET Advisory Council ●Weblog:

Sofia, Bulgaria | 9-10 October Real-World Tips and Tricks ●Using the System Tray for Your Application ●Automatically Advance To Next Control ●Using Extended Providers ●Create Balloon Style Tooltips ●Using API Calls to Provide Additional Functionality ●Making the Window Flash in the TaskBar ●Determining the Icon Associated With a File Type ●Only Allow One Instance of an Application ●Using the System Tray for Your Application ●Automatically Advance To Next Control ●Using Extended Providers ●Create Balloon Style Tooltips ●Using API Calls to Provide Additional Functionality ●Making the Window Flash in the TaskBar ●Determining the Icon Associated With a File Type ●Only Allow One Instance of an Application

Sofia, Bulgaria | 9-10 October Real-World Tips and Tricks ●How to Use Image Mapping ●How to Use Image Transitioning ●Take Advantage of Alpha Levels ●How to Load a TreeView On-Demand ●How to Use a Virtual Earth Inside a Form ●Allow Users to Easily Modify Application Settings ●Use the PropertyGrid control ●How to Use Image Mapping ●How to Use Image Transitioning ●Take Advantage of Alpha Levels ●How to Load a TreeView On-Demand ●How to Use a Virtual Earth Inside a Form ●Allow Users to Easily Modify Application Settings ●Use the PropertyGrid control

Sofia, Bulgaria | 9-10 October Using the System Tray ●Use the NotifyIcon control ●Associate a ContextMenu for user control in the system tray ●Set the ContextMenu property of the NotifyIcon control to the ContextMenu control ●Use the NotifyIcon control ●Associate a ContextMenu for user control in the system tray ●Set the ContextMenu property of the NotifyIcon control to the ContextMenu control

Sofia, Bulgaria | 9-10 October Using the System Tray Continued ●To have application be invisible at start- up: ●Instantiate main form before calling Application.Run ●Set the form’s Visible property to false ●To have application be invisible at start- up: ●Instantiate main form before calling Application.Run ●Set the form’s Visible property to false static void Main() { SystemTrayForm MainForm = new SystemTrayForm(); SystemTrayForm MainForm = new SystemTrayForm(); MainForm.Visible = false; MainForm.Visible = false; Application.Run(); Application.Run();}

Sofia, Bulgaria | 9-10 October Using the System Tray Continued ●Set NotifyIcon ’s Text property to description to show in System Tray ●When exiting application ●Set the NotifyIcon ’s Visible property to false before calling Application.Exit ●Set NotifyIcon ’s Text property to description to show in System Tray ●When exiting application ●Set the NotifyIcon ’s Visible property to false before calling Application.Exit D1 notifyIcon1.Visible = false; this.Close();Application.Exit();

Sofia, Bulgaria | 9-10 October Automatically Advancing To Next Control ●Once the MaxLength of a control is reached, advance to the next control ●Allows for faster data input by users ●Sub-class controls and add event handlers ●Use the TextChanged event handler to determine if max length has been reached ●Call parent form’s SelectNextControl method ●Once the MaxLength of a control is reached, advance to the next control ●Allows for faster data input by users ●Sub-class controls and add event handlers ●Use the TextChanged event handler to determine if max length has been reached ●Call parent form’s SelectNextControl method

Sofia, Bulgaria | 9-10 October Automatically Advancing To Next Control ● SelectNextControl method has the following parameters: ●Control : The Control at which to start the search ●Forward : true to move forward in the tab order; false to move backward in the tab order ●TabStopOnly : true to ignore the controls with the TabStop property set to false; otherwise, false ●Nested : true to include nested (children of child controls) child controls; otherwise, false ●Wrap : true to continue searching from the first control in the tab order after the last control has been reached; otherwise, false ● SelectNextControl method has the following parameters: ●Control : The Control at which to start the search ●Forward : true to move forward in the tab order; false to move backward in the tab order ●TabStopOnly : true to ignore the controls with the TabStop property set to false; otherwise, false ●Nested : true to include nested (children of child controls) child controls; otherwise, false ●Wrap : true to continue searching from the first control in the tab order after the last control has been reached; otherwise, false D2

Sofia, Bulgaria | 9-10 October Using Extended Providers ●A control that works with several controls ●Inserts additional properties into each control that it extends ●A control that works with several controls ●Inserts additional properties into each control that it extends

Sofia, Bulgaria | 9-10 October Using Extended Providers Continued ●Derive a class from: ● System.ComponentModel.Component ● System.ComponentModel.IExtenderProvide r ●Implement CanExtend method ●Called whenever a control in a form is selected in the forms designer ●Derive a class from: ● System.ComponentModel.Component ● System.ComponentModel.IExtenderProvide r ●Implement CanExtend method ●Called whenever a control in a form is selected in the forms designer bool IExtenderProvider.CanExtend(object extendee) { return (extendee is Control); }

Sofia, Bulgaria | 9-10 October Using Extended Providers Continued ●For each property to be added to the controls apply the ProvideProperty attribute to the class declaration [ProvideProperty("ToolTip", typeof(Control))] public class BalloonToolTip : Component, IExtenderProvider IExtenderProvider{......}

Sofia, Bulgaria | 9-10 October Using Extended Providers Continued ●Create the Get/Set for each property ●Uses a syntactical naming convention ●“Get” + name of the property ●“Set” + name of the property ●Create the Get/Set for each property ●Uses a syntactical naming convention ●“Get” + name of the property ●“Set” + name of the property [DefaultValue("")] public string GetToolTip(Control control) { string retval = (string)m_controls[control]; if (retval == null) return ""; return retval; } HashTable

Sofia, Bulgaria | 9-10 October Using Extended Providers Continued ●Each control has a new property ●Called the name using the ProvideProperty attribute followed by the word “on” and the instance name of the extender provider object ●Each control has a new property ●Called the name using the ProvideProperty attribute followed by the word “on” and the instance name of the extender provider object D3

Sofia, Bulgaria | 9-10 October API Calls to Add Additional Functionality ●The Windows API still provides useful functionality not found in the.NET Framework (yet!) ●Make the form reference flash in the TaskBar ●Determine the icon associated with a File Type ●Only allow one instance of a application to run ●The Windows API still provides useful functionality not found in the.NET Framework (yet!) ●Make the form reference flash in the TaskBar ●Determine the icon associated with a File Type ●Only allow one instance of a application to run

Sofia, Bulgaria | 9-10 October Making the Form Flash in the TaskBar ●Useful when running a long process to inform the user when it has completed ●Use the FlashWindowEx API found in the User32.dll ●Useful when running a long process to inform the user when it has completed ●Use the FlashWindowEx API found in the User32.dll D4

Sofia, Bulgaria | 9-10 October Finding the Associated Icon For a File Type ●Show the icon when displaying file names for richer UI ●Use the SHGetFileInfo API found in the Shell32.dll ●Show the icon when displaying file names for richer UI ●Use the SHGetFileInfo API found in the Shell32.dll D5

Sofia, Bulgaria | 9-10 October Allow Only One Instance of an Application ●Only allow one instance of an application to run ●Use the ShowWindowAsync API found in the User32.dll ●Find if another application instance is running ●If true then bring up that instance and exit out ●Only allow one instance of an application to run ●Use the ShowWindowAsync API found in the User32.dll ●Find if another application instance is running ●If true then bring up that instance and exit out D

Sofia, Bulgaria | 9-10 October Image Mapping ●Allows the user to click on a portion of an image and trap where the click occurred ●No control in WinForms like available in web development ●Drop ImageMap custom control on form ●Add “hot-spots” within your image ●Ellipse shape – AddEllipse method ●Rectangle shape – AddRectangle method ●Polygon shape – AddPolygon method ●Raises the RegionClick event when mouse clicked in a “hot-spot” ●Allows the user to click on a portion of an image and trap where the click occurred ●No control in WinForms like available in web development ●Drop ImageMap custom control on form ●Add “hot-spots” within your image ●Ellipse shape – AddEllipse method ●Rectangle shape – AddRectangle method ●Polygon shape – AddPolygon method ●Raises the RegionClick event when mouse clicked in a “hot-spot” D6

Sofia, Bulgaria | 9-10 October Image Transitioning ●Allows fading for images instead of the entire form ●To fade an image, use a timer to decrease the alpha (opacity) setting for the image ●Override the form’s OnPaint event handler ●Set the alpha for each image using the System.Drawing.Image.ColorMatrix class ●Repaint that area ●Allows fading for images instead of the entire form ●To fade an image, use a timer to decrease the alpha (opacity) setting for the image ●Override the form’s OnPaint event handler ●Set the alpha for each image using the System.Drawing.Image.ColorMatrix class ●Repaint that area D7

Sofia, Bulgaria | 9-10 October Load a TreeView On-Demand ●Only load the top nodes ●Allows for fast loading and unlimited number of nodes ●Create a dummy child node for all parent nodes containing children ●In the TreeView’s BeforeExpand event handler remove the dummy child node and then add all the children ●Only load the top nodes ●Allows for fast loading and unlimited number of nodes ●Create a dummy child node for all parent nodes containing children ●In the TreeView’s BeforeExpand event handler remove the dummy child node and then add all the children D8

Sofia, Bulgaria | 9-10 October Use Virtual Earth Inside a Form ●Mapping / imagery tiles ●User Navigation ●Bird’s Eye imagery ●Pushpins ●Find places / addresses ●Driving Directions / routing ●Mapping / imagery tiles ●User Navigation ●Bird’s Eye imagery ●Pushpins ●Find places / addresses ●Driving Directions / routing D9 map = new VEMap("myMap"); map.LoadMap(new VELatLong(lat_a, lon_a),zoom_a,VEMapStyle.Road);

Sofia, Bulgaria | 9-10 October Using the PropertyGrid ●The heart of the Property Browser in Visual Studio.NET ●Provides a simple model for displaying property settings ●Easier and more space-efficient than laying out a dialog ●Use the SelectedObject property to get/set the information to show in the PropertyGrid ●Use attributes to control how the property is displayed ●MSDN: rary/en-us/dndotnet/html/usingpropgrid.asp rary/en-us/dndotnet/html/usingpropgrid.asp ●The heart of the Property Browser in Visual Studio.NET ●Provides a simple model for displaying property settings ●Easier and more space-efficient than laying out a dialog ●Use the SelectedObject property to get/set the information to show in the PropertyGrid ●Use attributes to control how the property is displayed ●MSDN: rary/en-us/dndotnet/html/usingpropgrid.asp rary/en-us/dndotnet/html/usingpropgrid.asp

Sofia, Bulgaria | 9-10 October Using the PropertyGrid Continued D Imports System.ComponentModel Required for the Attributes DefaultPropertyAttribute("Title") Indicates the default property for the PropertyGrid (i.e. where cursor is located when loaded) CategoryAttribute("Application") Category attribute indicating the Category to which the property belongs to. Properties belonging to one category are grouped together. Browsable(True) Indicates whether the property is shown in the grid [ReadOnly](False) Indicates that the property is read-only or not BindableAttribute(False) Indicates whether the property can be bound to a data source or not DefaultValueAttribute("") Default value for the property DesignOnly(False) If true, it indicates that the property is Read-only at run time DescriptionAttribute("Enter Title for the application") Property Description. This description appears in the bottom when you click the property.

Sofia, Bulgaria | 9-10 October Questions? ●Sample code can be downloaded at: ●Cathi Gero, ●Weblog: ●Sample code can be downloaded at: ●Cathi Gero, ●Weblog: