770 likes | 960 Views
Developing Windows and Web Applications using Visual Studio.NET. Drew Robson. Tip. Unused methods, after removing UI controls. Session 2: Last week?. C# 3.0, C# 4.0 http://www.extensionmethod.net/ LINQ Databining with LINQ. Agenda. User Experience (UX)
E N D
Developing Windows and Web Applications using Visual Studio.NET Drew Robson
Tip • Unused methods, after removing UI controls
Session 2: Last week? • C# 3.0, C# 4.0 • http://www.extensionmethod.net/ • LINQ • Databining with LINQ
Agenda • User Experience (UX) • Tips and Techniques, Best practices • Windows Forms Capabilities and Demo’s • Tools to better UX & code • UX Resources
Every business app does • Data entry
Every business app does • Finding data
Every business app does • Displaying data
Every business app • Data entry • Validation • Finding data • Filtering data • Rich data queries • Displaying data • Different Views • Reports (nice printing) • Authorization?
User Experience • 3 pillars
UX - Feel • Make a site feel alive • React fast • Interact with user • “Joy of use”
Who designs the UI? • Developers • UI to test their software as they build • UI increases in complexity • Application grows but the UI isn’t consistent • Know how the controls work (or they should!!) • Designers • Design the UI but not realize WHAT is possible • Understand a Visual Consistency but not how its built
User • “User driven“ • Testing is done with the user • Prototyping • Usability testing • Let the user solve a task and see (measure) what he does
Why Windows Forms? • Bandwidth – Presentation layer • Cache / persistent state • Faster Server • Because of less requests and less work… thanks to processing power being used on client • Richer interface • No buggy DHTML/JavaScript • More responsive • Faster to develop • No cross-browser issues • Build complex controls quickly
Why NOT Windows Forms? • Not allowed in some Standard Operating Environments • Cross-platform requirements (Linux, PC, Mac) • Deployment of the Application is harder / Centralised logic • Requires an always-connected data service
Who Do I Please? • Network Admins • Developers • End Users • Accountants Browser Based Solution Rich Client Solution
Do you design a mockup UI first? • Who uses prototypes? • Sketchflow • Balsamiq
Designing a Mockup UI • Avoid the thought of a “throw away” prototype. • Use as the first step to start a project (or get a project) - WYSIWYG • Get great initial feedback • Better than 100 page document • Get a designer involved if need be (Developers can’t design) • Tip: Always add the client logo + colours. They are easily impressed!
Designing a Mockup UI • Would you design the Database first or the UI? • The database schema should be designed before the UI is started • If you are doing fixed price work, signed-off mockups serve as a great way to stop goal posts moving. Any changes to the mockups thereafter will result in additional work.
Winform Architecture • Visual Inheritance • Composition and Containment (Panels, Usercontrols) • Databinding • ToolTips • Error Provider and Validators • Appsettings
Visual Inheritance • The constructor of each form/control class contains a call of a private method "InitializeComponent()". If B is derived from A, then the constructor of A is called first • A() • A.InitializedComponent() • B() • B.InitialzeComponent()
Visual Inheritance • Controls on the Base Form are BY DEFAULT “private” and cannot be edited in the inherited form • Solution: Change the modifer to “Protected”
Inherited Forms – For Every Form • Common Behaviour • Company Icon • Remembering its size and location • Adding itself to a global forms collection (to find forms that are already open, or to close all open forms) ** Application.OpenForms • Logging usage frequency and performance of forms (load time) • No Controls!
StartPosition • CenterParent only for modal dialogs (to prevent multi-monitor confusion) • CenterScreen only for the main form (MainForm), or a splash screen • WindowsDefaultLocation for everything else (99% of forms) - prevents windows from appearing on top of one another
FormBorderStyle • FixedDialog only for modal dialog boxes • FixedSingle only for the main form: MainForm(FixedSingle has an icon whereas FixedDialog doesn't) • None for splash screen • Sizable for any form that has multi-line textbox, grid, listbox or such
Hiding Values • Developers fiddle! Browsable: whether a property or event should be displayed in a Properties window. http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.aspx EditorBrowsable: whether a property or method is viewable in an editor.http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx
Hiding Values using System.ComponentModel; [Browsable(false), EditorBrowsable(false)] public new Font Font { get { return base.Font; } set { base.Font = value; } } Imports System.ComponentModel<Browsable(False), EditorBrowsable(false)> _ Public Shadows Property Font() As Font Get Return MyBase.Font End Get Set(ByVal Value As Font) 'MyBase.Font = Value 'normal property syntaxMyBase.Font = New Font(Me.Font.FontFamily, 20) End SetEnd Property
User Controls • You lose the AcceptButton and CancelButton properties from the Designer e.g. OK, Cancel, Apply Therefore the OK, Cancel and Apply buttons cannot be on User Controls.
User Controls • You can use a user control more than once on the same form e.g. Mailing Address, Billing Address • You can reuse logic in the code behind the controls e.g. Search control • User controls are less prone to visual inheritance errors
User Controls • Each control is used only once
User Controls • Implemented for reuse
User Controls – TabPages Possible Exception: • When a form has multiple tabs, and each tab has numerous controls – it can be easier to use User Control in this case • Smaller designer generated code • More than one person can be working on a different ‘tab’