Windows Programming C# Software Development. Overview  DLLs / PInvoke  DirectX .NET Component Library  Custom Controls  Event Model (in C++)  GUI.

Slides:



Advertisements
Similar presentations
Windows Test Review.
Advertisements

Chapter 9 Color, Sound and Graphics
Chapter 1: An Introduction to Visual Basic 2012
COMPREHENSIVE Windows Tutorial 3 Personalizing Your Windows Environment.
User Interface Programming in C#: Graphics
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
© by Pearson Education, Inc. All Rights Reserved.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
.NET Class 4 – Windows-based Application. WinForm Application Homogeny programming model. Rich class library Classes are shared by all.NET languages.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Graphics and Multimedia. Outline Introduction Graphics Contexts and Graphics Objects Color Control.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Chapter 13: Advanced GUI and Graphics
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Graphics and Multimedia. Introduction The language contains many sophisticated drawing capabilities as part of namespace System.Drawing and the other.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
1 Chapter 26 D&D – Graphics Outline 26.1 Introduction 26.3 Graphics Contexts and Graphics Objects 26.4 Color Control 26.5 Font Control 26.6 Drawing Lines,
Lecture Set 13 Drawing Mouse and Keyboard Events Part A - Drawing.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
1 Graphical User Interfaces Part 2 Outline Multiple Document Interface (MDI) Windows Visual Inheritance User-Defined Controls.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface A Brief Introduction to GDI+ S.R.G. Fraser, Pro Visual C++/CLI.
CST238 Week 5 Questions / Concerns? Announcements – HW#1 due (Project ideas) – Check-off Take Home lab#4 Recap New topics – Drawing Coming up: – GUI Bloopers.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
1 Windows Graphics. 2 Objectives You will be able to Use the Windows GDI+ to draw arbitrary figures and text on a Windows form. Add a handler for the.
IE 411/511: Visual Programming for Industrial Applications
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Object Oriented Programming Graphics and Multimedia Dr. Mike Spann
Graphics and Multimedia Part #2
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
XP New Perspectives on Windows XP Tutorial 1 Exploring the Basics.
Ray Konopka Developing Custom.NET Component Designers DevCon Course No: 4106.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
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
Lecture 5 Graphics Erick Pranata. » Graphics Overview » About GDI+ » Getting Started.
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.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Chapter Eleven The X Window System. 2 Lesson A Starting and Navigating an X Window System.
Ray Konopka Creating Custom Microsoft.NET Framework Controls in Delphi.
Ray Konopka Developing Custom.NET Components DevCon Course No: 3118.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Lecture # 6 Graphical User Interface(GUI). Introduction A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application.
Appendix A: Windows Forms. 2 Overview Describe the structure of a Windows Forms application –application entry point –forms –components and controls Introduce.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
GDI +. Graphics class's methods System.Drawing Graphics Objects.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
 2007 Pearson Education, Inc. All rights reserved Introduction to the Visual Basic Express 2005 IDE.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter One An Introduction to Visual Basic 2008.
Chapter 1: An Introduction to Visual Basic .NET
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 – Introduction to the Visual Studio .NET IDE
Chapter 1: An Introduction to Visual Basic 2015
Graphics and Multimedia
Drawing Mouse and Keyboard Events Part A - Drawing
Chapter 2 – Introduction to the Visual Studio .NET IDE
ThS. Nguyễn Hà Giang Khoa CNTT - Hutech
CASE Tools Graphical User Interface Programming Using C#
Presentation transcript:

Windows Programming C# Software Development

Overview  DLLs / PInvoke  DirectX .NET Component Library  Custom Controls  Event Model (in C++)  GUI Events  Custom Filters  Drawing, Painting, Printing

Using DLLs  To gain access to a DLL, use the DllImport attribute to tag the method  Use the extern keyword on the method  Return/parameter types don't necessarily need to match only the datatype size needs to match DllImport("gdi32.dll")] public static extern int SetPixel(int hDC, int x, int y, int crColor);

PInvoke  Calling a dll method is called P-Invoke (platform invoke)  Simply call the method Some types (hdc, handles, etc) are exposed in the.NET interface (See WindowsManipulation and SetPixel Demos)

DirectX  See Mike Go  Go Mike Go

.NET Component Library  System.Windows.Forms.Control Base class for controls  Visual Components Handles Keyboard and Mouse Input Provides bounds for painting  Does not actually paint anything by default Provides a Windows Handle Has ambient properties  if not set, an ambient property uses its parent's value Provides accessibility support (See MSDN)

Windows Forms  Properties Text  Text on top of the form BackColor  Background color ForeColor  Text Color Font  Font used by child controls FormBorderStyle  Border Style ControlBox  Minimize, Maximize and Close buttons ShowInTaskbar  Indicates whether to show in the taskbar or not

Splash screen  On a Form, set: Text = ""; ControlBox = false; Create a Panel with the BackgroundImage property set to your picture

Menus  Create a Context Menu or a MainMenu  Associate it with the Form (or Control)

Adding Controls Programmatically  Form (or any other container control) has a Controls property Button newBtn = new Button … this.Controls.Add(newBtn);

Custom Controls  Create a new UserControl file in your project Default UserControl class inherits from UserControl You can inherit from a pre-built control (like button) or from Control itself

UserControl Attributes  ToolboxBitmap Sets the icon for the UserControl  Browsable Pass it false to prevent the member from being displayed  Category Places the control in the specified category  DefaultValue Sets a default value for the member  Description Sets the description associated with the member  DesignOnly Specifies that the member can only be set at design time

Adding UserControls to Toolbox  Build the UserControl  Right-click the toolbox  Choose Add/Remove, browse to the built assembly (.dll or.exe file).

Painting  Subscribe to the Paint event Gives access to the appropriate Graphics object  Call Refresh() Invalidates the entire client area including child controls  Call Invalidate() Invalidates the given region (client area by default)  Some controls have BeginUpdate and EndUpdate methods BeginUpdate disables drawing  Call when you are changing/updating the control EndUpdate enables drawing  Call when you are finished changing/updating the control

Paint Event  private void Form1_Paint(object sender, PaintEventArgs e)  PaintEventArgs contains: ClipRectangle being painted Graphics for the current object

Graphics object  Methods: Clear() DrawArc() DrawBezier() etc. (See DrawDemo)

Brushes  System.Drawing.Brush abstract class Subclasses:  HatchBrush  LinearGradientBrush  PathGradientBrush  SolidBrush  TextureBrush Can get texture from an image Represents a color, gradient, image etc. Fills the interior region of an area Must be disposed when you're finished using it  Limited resource on Win9x/Me (as are pens)

Brush example:  Brush brush = new SolidBrush(Color.Red);  Brush brush = new TextureBrush(new Bitmap("MyImage.gif"));  Brush brush = Brushes.Brown;

System.Drawing.Brushes  System-stored default brushes All kinds of crazy colors Do not dispose System-stored resources SolidBrush type

Pens  System.Drawing.Pen  Represent a color and width  Used to draw lines and curves  Has an associated brush  Can set: DashPattern DashCap StartCap (arrow, etc) EndCap etc.  Need to be disposed when finished using

System.Drawing.Pens  System-stored default pens All kinds of crazy colors Do not dispose System-stored resources  Also System.Drawing.SystemPens

Fonts  Immutable To change a font, you must create a new one, then reassign the property

Color  Represents an ARGB color  Contains hundreds of Pre-defined colors