WPF Shapes. WPF Shapes, Canvas, Dialogs 1



Similar documents
ComponentOne. Windows for WPF

DIA Creating Charts and Diagrams

QUICK REFERENCE: ADOBE ILLUSTRATOR CS2 AND CS3 SECTION 1: CS3 TOOL BOX: PAGE 2 SECTION 2: CS2 TOOL BOX: PAGE 11

CXQuotes Doors and Windows Quotation software. Cogitrix

Click on various options: Publications by Wizard Publications by Design Blank Publication

If you know exactly how you want your business forms to look and don t mind detail

Creating an invitation

PowerPoint 2007 Basics Website:

Creating an invitation

Using Microsoft Word. Working With Objects

Instructions for Creating a Poster for Arts and Humanities Research Day Using PowerPoint

Welcome to CorelDRAW, a comprehensive vector-based drawing and graphic-design program for the graphics professional.

Creating and Using Links and Bookmarks in PDF Documents

Adobe Illustrator CS5 Part 1: Introduction to Illustrator

Understand the Sketcher workbench of CATIA V5.

Designing a Poster using MS-PowerPoint

SketchUp Instructions

paragraph(s). The bottom mark is for all following lines in that paragraph. The rectangle below the marks moves both marks at the same time.

Autodesk Fusion 360 Badge Guide: Design an F1 in Schools Trophy

Petrel TIPS&TRICKS from SCM

Sharing Files and Whiteboards

Making Visio Diagrams Come Alive with Data

Windows Presentation Foundation Tutorial 1

Create a Poster Using Publisher

Adobe InDesign Creative Cloud

Welcome to CorelDRAW, a comprehensive vector-based drawing and graphic-design program for the graphics professional.

Recipes4Success. Animate a Rocket Ship. Frames 6 - Drawing Tools

Create A Collage Of Warped Photos

NetMeeting - User Guide

Creating Web Pages with Microsoft FrontPage

Introduction to Microsoft Word 2008

If you know exactly how you want your business forms to look and don t mind

Working With Animation: Introduction to Flash

Microsoft Excel 2010 Charts and Graphs

Using Clicker 5. Hide/View Explorer. Go to the Home Grid. Create Grids. Folders, Grids, and Files. Navigation Tools

OPERATION MANUAL. MV-410RGB Layout Editor. Version 2.1- higher

A Guide to Microsoft Paint (Windows XP)

Create Charts in Excel

I ntroduction. Accessing Microsoft PowerPoint. Anatomy of a PowerPoint Window

Creating a Poster in PowerPoint A. Set Up Your Poster

Adobe Illustrator CS6 Tutorial

User Guide. Ahead Software AG

Smart Board Notebook Software A guide for new Smart Board users

HOW TO CREATE A SCANNED DIGITAL SIGNATURE AND INSERT INTO A PDF DOCUMENT

Overview of the Adobe Flash Professional CS6 workspace

Microsoft Picture Manager. Picture Manager

WPF vs Windows Forms

2013 Getting Started Guide

Virto SharePoint Gantt Chart App for Office 365 Release User and Installation Guide

ComponentOne. Window for Silverlight

Introduction to Computers: Session 3 Files, Folders and Windows

Design document Goal Technology Description

PA Payroll Exercise for Intermediate Excel

Publisher 2010 Cheat Sheet

Data Visualization. Brief Overview of ArcMap

Visualization of 2D Domains

Tutorials. If you have any questions, comments, or suggestions about these lessons, don't hesitate to contact us at

Course Project Lab 3 - Creating a Logo (Illustrator)

KaleidaGraph Quick Start Guide

What s New V 11. Preferences: Parameters: Layout/ Modifications: Reverse mouse scroll wheel zoom direction

TABLE OF CONTENTS. INTRODUCTION... 5 Advance Concrete... 5 Where to find information?... 6 INSTALLATION... 7 STARTING ADVANCE CONCRETE...

Schoolwires Staff Website Reference Guide

Scheduling Document Creation

Lession: 2 Animation Tool: Synfig Card or Page based Icon and Event based Time based Pencil: Synfig Studio: Getting Started: Toolbox Canvas Panels

Welcome to CorelDRAW, a comprehensive vector-based drawing and graphic-design program for the graphics professional.

ClarisWorks 5.0. Graphics

2. How to Use SMART Board as a Projector and Whiteboard

Quick Guide to IrfanView

Essay 5 Tutorial for a Three-Dimensional Heat Conduction Problem Using ANSYS Workbench

Sweet Home 3D user's guide

Inserting Graphics into Grant Applications & Other Word Documents

ABAQUS/CAE Tutorial: Analysis of an Aluminum Bracket

Step 1: Setting up the Document/Poster

Fireworks for Graphics and Images

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Quick use reference book

Communicate: In Print

Working with Tables: How to use tables in OpenOffice.org Writer

TUTORIAL 4 Building a Navigation Bar with Fireworks

Done. Click Done to close the Capture Preview window.

Chapter 4 Windows Applications: Notepad, WordPad, and Paint Additional Activities

In this session, we will explain some of the basics of word processing. 1. Start Microsoft Word 11. Edit the Document cut & move

Graphic Design. Background: The part of an artwork that appears to be farthest from the viewer, or in the distance of the scene.

Introduction to the TI-Nspire CX

Welcome to CSU The Software Used To Data Conference.

Epson Brightlink Interactive Board and Pen Training. Step One: Install the Brightlink Easy Interactive Driver

Creating Custom Crystal Reports Tutorial

PowerPoint 2007: Basics Learning Guide

3D Viewer. user's manual _2

SnagIt Add-Ins User Guide

MASKS & CHANNELS WORKING WITH MASKS AND CHANNELS

The following is an overview of lessons included in the tutorial.

PowerPoint: Graphics and SmartArt

Access 2007 Creating Forms Table of Contents

DESIGN A WEB SITE USING PUBLISHER Before you begin, plan your Web site

Sharing Software. Chapter 14

Create an Art Collage

Microsoft Word defaults to left justified (aligned) paragraphs. This means that new lines automatically line up with the left margin.

KOMPOZER Web Design Software

Transcription:

WPF Shapes WPF Shapes, Canvas, Dialogs 1

Shapes are elements WPF Shapes, Canvas, Dialogs 2 Shapes draw themselves, no invalidation or repainting needed when shape moves, window is resized, or shape s properties change. Shapes are organized like other elements. Place a shape in any of the layout containers, Canvas is useful because it allows shapes to be placed at specific coordinates Shapes support the same events as other elements: focus, key presses, mouse movements, mouse clicks, tooltips, context menus, and drag-anddrop operations. Here are examples on how to draw Rectangle and Ellipse.

Shape Properties WPF Shapes, Canvas, Dialogs 3 Fill Stroke StrokeThickness StrokeStartLineCap StrokeEndLineCap StrokeDashArray, StrokeDashOffset, StrokeDashCap StrokeLineJoin StrokeMiterLimit Sets brush that paints the surface of the shape Sets brush object that paints the shape's border Sets the thickness of the border. WPF splits the width on each side; value of 10 units wide gets 5 units of space on each side. Determine the contour of the edge of the beginning and end of the line. These properties have an effect only for the Line, the Polyline, and (sometimes) the Path shapes. Create a dashed border around shape, set the size and frequency of the dashes, and the contour of the edge where each dash linr begins and ends. Determine the contour of the shape s corners

WPF Shapes, Canvas, Dialogs 4 Stretch DefiningGeometry GeometryTransform RenderedGeometry Determines how a shape fills its available space. Creates a shape that expands to fit its container. A shape that expands in one direction by using Horizontal or VerticalAlignment properties Provides a Geometry object for the shape. A Geometry object describes the coordinates and size of a shape without including the UIElement support for keyboard and mouse events. Apply a Transform: skew, rotate, or displace a shape. Geometry object that describes the rendered shape. No Stroke or Fill property your shape won t appear.

Stretch enumeration WPF Shapes, Canvas, Dialogs 5 Fill Shape is stretched in width and height to fit its container exactly. (If you set an explicit height and width, this setting has no effect.) None Uniform The shape is not stretched. Unless you set a nonzero width and height (using the Height and Width or MinHeight and MinWidth properties), your shape won t appear. The width and height are sized up proportionately until the shape reaches the edge of the container. With explicit height and width, shape is sized within those bounds UniformToFill The width and height are sized proportionately until the shape fills all the a variable height and width. Usually size a shape explicitly or allow it to stretch to fit.

Brushes WPF Shapes, Canvas, Dialogs 6 Brushes fill an area: background, foreground, or border of an element fill or stroke of a shape. Brushes have change notification, on change any element that uses the brush repaints themself. Brushes support partial transparency. SystemBrushes class provides access to brushes using colors defined in the Windows system preferences for the current computer. The simplest type of brush is SolidColorBrush... // Assume cmd is an element (aka Button) cmd.background = new SolidColorBrush(Colors.AliceBlue); cmd.background = SystemColors.ControlBrush; int red = 0; int green = 255; int blue = 0; cmd.foreground = new SolidColorBrush(Color.FromRgb(red, green, blue));

Mouse Canvas Demo WPF Shapes, Canvas, Dialogs 7 MessageBox shown on rightbuttondown on "cast test" button MessageBox shown on rightbuttonup event

MouseCanvas XAML WPF Shapes, Canvas, Dialogs 8 <Window x:class="mousecanvas.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Mouse Canvas Demo: right button drags, or just move mouse" Height="300" Width="485"> <DockPanel x:name="dockpanel" LastChildFill="true" Margin="0,0,0,-5"> <Label x:name="statuslabel" Content="Drag or move the mouse in the canvas..." VerticalAlignment="Bottom" DockPanel.Dock="Bottom" FontSize="16" BorderBrush="Black" IsEnabled="False" Height="39"/>... // canvas xaml next page should be inserted here </DockPanel> </Window>

WPF Shapes, Canvas, Dialogs 9 <Canvas x:name="canvas" MouseMove="mouseMove" MouseRightButtonDown="selectEllipse" MouseRightButtonUp="releaseEllipse"> <Ellipse x:name="redellipse" Fill="Red" Height="100" Canvas.Left="111" Stroke="Black" Canvas.Top="99" Width="100" Panel.ZIndex="4" /> <Ellipse x:name="greenellipse" Fill="Lime" Height="47" Canvas.Left="326" Stroke="Black" Canvas.Top="99" Width="97" Panel.ZIndex="2" /> <Ellipse x:name="blueellipse" Fill="Blue" Height="130" Canvas.Left="257" Stroke="Black" Canvas.Top="84" Width="41"/> <Ellipse x:name="cyanellipse" Fill="Cyan" Height="60" Canvas.Left="30" Stroke="Black" Canvas.Top="30" Width="60" Panel.ZIndex="2" /> <Button x:name="abutton" Content="cast test" Canvas.Left="376" Canvas.Top="172" Width="75"/> </Canvas>

mouse drag values WPF Shapes, Canvas, Dialogs 10 Mouse drags rely on: selecting an element to drag usually with a mousedown event when selecting element positions are also initialized. dragging the mouse responding to mousemove events while mousedown is true. stopping the drag responding to a mouseup event During the drag there are many mousemove events. Each event has a mouse position property. To know the current event's movement, the previous value must be known. Let: x_shape and y_shape are the shape's current position x and y are the mouse's current position values x_canvas and y_canvas are the previous mouse positions Then: x_shape += x - x_canvas; x_canvas = x; y_shape += y - y_canvas; y_canvas = y;

selectellipse WPF Shapes, Canvas, Dialogs 11 // Application variables Ellipse selectedellipse; bool captured = false; double x_shape, x_canvas, y_shape, y_canvas; private void selectellipse(object sender, MouseButtonEventArgs e) // canvas MouseRightButtonDown { selectedellipse = (Ellipse)e.Source; if (selectedellipse!= null) { Mouse.Capture(selectedEllipse); // alternate version // ((UIElement) e.originalsource).capturemouse(); captured = true; x_shape = Canvas.GetLeft(selectedEllipse); x_canvas = e.getposition(canvas).x; y_shape = Canvas.GetTop(selectedEllipse); y_canvas = e.getposition(canvas).y; statuslabel.content = "Selected " + selectedellipse.name; } }

releaseellipse WPF Shapes, Canvas, Dialogs 12 // canvas MouseRightButtonUp private void releaseellipse(object sender, MouseButtonEventArgs e) { MessageBox.Show("releaseEllispse: \r\t sender = " + sender.tostring() + " \r\t source = " + e.source.tostring() + " \r\t original source = " + e.originalsource.tostring()); if (captured) { Mouse.Capture(null); // alternate version // ((UIElement) // e.originalsource).releasemousecapture(); captured = false; statuslabel.content = "Released " + selectedellipse.name; } }

mousemove WPF Shapes, Canvas, Dialogs 13 // canvas mousemove private void mousemove(object sender, MouseEventArgs e) { double x = e.getposition(canvas).x; double y = e.getposition(canvas).y; if (captured) { // an Ellipse has mouse capture x_shape += x - x_canvas; Canvas.SetLeft(selectedEllipse, x_shape); x_canvas = x; y_shape += y - y_canvas; Canvas.SetTop(selectedEllipse, y_shape); y_canvas = y; statuslabel.content = String.Format("{0} at ({1}, {2}) zindex = {3}", selectedellipse.name, x, y, Panel.GetZIndex(selectedEllipse)); } else statuslabel.content = String.Format("Mouse at ({0},{1})", x, y); }

Viewbox scale Canvas WPF Shapes, Canvas, Dialogs 14 Canvas uses explicit positioning; graphics won t resize to fit larger or smaller windows. Viewbox class derives from Decorator (like the Border class ) and can have a single child. Viewbox stretches or shrinks its child to fit available space. Viewbox's default is proportional scaling that preserves the aspect ratio of its contents. Place a Canvas inside a Viewbox, and place your shapes inside the Canvas.

Window WPF Shapes, Canvas, Dialogs 15 WPF Window class derives from ContentControl contains a single child (a layout container) paint the background with a brush (Background property). You can use the BorderBrush and BorderThickness properties to add a border around your window, this border is added inside the window frame (client area) Client area is the surface inside the window boundaries where you place your content. Nonclient area includes the border and the title bar at the top of the window. Operating system manages this area. Has many properties: Title, WindowStyle, WindowState, Window Icon (at top left corner), Top and Left (position), ResizeMode, ShowInTaskbar, SizeToContent,...

WPF Shapes, Canvas, Dialogs 16 To display a window, create an instance of the Window class and use: Show() a modeless window ShowDialog() a modal window TaskWindow wintask = new TaskWindow(); wintask.showdialog(); // Execution reaches this point after wintask is closed..net windows can own other windows floating toolbox and command windows. for example, the Find and Replace window in Microsoft Word.

Custom Dialogs WPF Shapes, Canvas, Dialogs 17 Showing a window modally offers the user a choice. The code that displays the window waits for the result of that choice and then acts on it. Windows have a DialogResult property: a true, false, or null value. Set the DialogResult, it s returned to the calling code as the return value of ShowDialog(). DialogWindow dialog = new DialogWindow(); if (dialog.showdialog() == true) { // The user accepted the action. Full speed ahead. } else { // The user canceled the action. } Set a button as the accept button (by setting IsDefault to true). Clicking that button sets the DialogResult to true. Set a button as the cancel button (by setting IsCancel to true), clicking will set the DialogResult to Cancel.