CPSC 481 – Week #7 Sowmya Somanath

Slides:



Advertisements
Similar presentations
Module 1: Creating an Application by Using Windows Presentation Foundation Overview of WPF Creating a Simple WPF Application Handling Events and Commands.
Advertisements

Getting Started with PowerPoint
Whats New in Office 2010?. Major Changes in Office 2010 The Office Ribbon, which first made its appearance in Office 2007, now appears in all Office 2010.
MS® PowerPoint.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
® Microsoft Office 2010 Word Tutorial 3 Creating a Multiple-Page Report.
Site Modules > Page Builder Access the Page Builder module through the Site Modules top navigation link. Access Page Builder from the Site Modules navigation.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Painter Application Introducing Graphics with Windows Presentation Foundation.
® Microsoft Office 2010 Word Tutorial 3 Creating a Multiple-Page Report.
Programming Based on Events
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.
Copyright 2007, Paradigm Publishing Inc. POWERPOINT 2007 CHAPTER 1 BACKNEXTEND 1-1 LINKS TO OBJECTIVES Create Presentation Open, Save, Run, Print, Close,Delete.
Compunet Corporation Programming with Visual Basic.NET GUI Chapter 3 Week 13 Tariq Aziz and Kevin Jones.
Review of last session The Weebly Dashboard The Weebly Dashboard Controls your account and your sites Controls your account and your sites From here you.
A Prezi presentation is like creating a mind map. It is created on a blank canvas and you decide where the information goes on this canvas.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
JQuery Page Slider. Our goal is to get to the functionality of the Panic Coda web site.Panic Coda web site.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
KRAD makes it easy to handle HTML events in your webpage. Kuali University: Apply Now Lab 6: Fun with HTML Events Lab Objectives HTML Events – what are.
V 1.0 Programming III. Creation of additional windows Routed events.
1 COS240 O-O Languages AUBG, COS dept Lecture 33 Building Apps Technologies C# (WPF part 1)
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
February 2006Colby College ITS Formatting Techniques for Excel 2003.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
Back to Table of Contents CAPA Website Tutorial Anne Dang, CCPA Webmaster for CAPA.
Module 11 Control Customization. Module Overview Overview of Control Authoring Creating Controls Managing Control Appearance by Using Visual States Integrating.
Chapter 2 Creating a Research Paper with References and Sources Microsoft Word 2013.
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
IE 411/511: Visual Programming for Industrial Applications
BIM211 – Visual Programming Objects, Collections, and Events 1.
C# Events and WPF #W5. Horizontal Prototype WPF Designed for rapid user interface design Used for many devices: Windows Phone, Tablets, PCs,
Chapter 12 FRAMES. HOW FRAMES WORK When you view a framed page in a browser, you are actually looking at several HTML documents at once. The key to making.
V 1.1 Programming III. Creating additional windows Event handling: preview/routed events.
Basic WPF Controls Doncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer
V 1.0 Programming III. Automatic notifications (…Changed, INofityPropertyChanged, ObservableCollection ) Data formatters Data conversions Resources.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
COS240 O-O Languages AUBG, COS dept Lecture 33 Title: C# vs. Java (GUI Programming) Reference: COS240 Syllabus.
BIL528 – Bilgisayar Programlama II Introduction 1.
Review of last session Add text to your website Add text to your website Title Title Paragraph Paragraph Title and paragraph Title and paragraph Add photographs.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
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.
Windows Presentation Foundation (WPF). Introduction Separates appearance of user interface from behavior Appearance usually specified by XAML Behavior.
More exercises with C# Fateme Rajabi #W6. Add an image to your project Right click on your project name in solution explorer Add -> Existing item -> browse.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Principles of Web Design 6 th Edition Chapter 9 – Site Navigation.
© Anselm Spoerri Lecture 7 Meaning –Guiding Principles for Term Project Mechanics –Interactivity Recap –Simple and Disjointed Rollovers and Image Map –Navigation.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Module 4 Taking Control of the User Interface. Module Overview Sharing Logical Resources in an Application Creating Consistent User Interfaces by Using.
CPSC 481 – Week 11 Expression Blend Sowmya Somanath (based on tutorials by Bon Adriel Aseniero and David Ledo)
Events Part I Mouse Events. Learning Objectives By the end of this lecture, you should be able to: – Understand what is meant by an ‘event’ – Appreciate.
Changing a Word table format Changing a Word table format (1 of 5) 1. Double click the Word table you want to edit. 1.
V 1.0 Programming III. Automatic notifications with data binding (…Changed, INofityPropertyChanged, ObservableCollection, DataTemplate) Data formatters.
BIL528 – Bilgisayar Programlama II Methods 1. Contents Methods 2.
Lecture Set 7 Procedures and Event Handlers Part B - The Structure of an Application Event Handlers.
PowerPoint Basics Tutorial 2: A Slide Show In this tutorial you’re going to create a presentation from scratch. You will have to keep this presentation.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
REC [ ] How to implement CAMERA RECORDING for USB WEBCAM or IP CAMERA in C#.NET SOURCE CODE: ! Welcome to this presentation that explains.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Designed with MockApp is not freeware... It’s Tweetware. If you’ve already either twitted, digged, blogged, etc. about MockApp, this copy is legally yours.
Introduction to Silverlight
Reference: COS240 Syllabus
Introduction to Silverlight
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Events Part I Mouse Events.
Presentation transcript:

CPSC 481 – Week #7 Sowmya Somanath

Reminder Monday Nov 2 in class – 1.Write-up – redesign rational (i.e. changes from first prototype) 2.Screen snapshots 3.Grading sheet from handout 4.Horizontal prototype presentation freeze Either your slides to me OR submit them on a USB along with your write-up.

Reminder Wednesday Nov 4 in tutorial (15 min each group) – T04: Horizontal prototype presentation Friday Nov 6 in tutorial (15 min each group) – T02: Horizontal prototype presentation

Plan for Today More WPF – useful for implementing vertical prototype. Please download Week 7 slides from:

User Controls

User controls pack a set of UI elements. Useful when repeating same UI patterns Instead of copy pasting code, you can re-use user controls.

User Controls 1.Add a user control to your class. Name it UserControlDemo

User Controls 2. Add Elements to your user control

User Controls 3. Add below code to MainWindow.xaml

User Controls 4. Add below code to MainWindow.cs private void button1_Click(object sender, RoutedEventArgs e) { UserControlDemo ucdemo = new UserControlDemo(); Grid.SetRow(ucdemo, 1); grid1.Children.Add(ucdemo); }

User Control and Transitions: Navigation Method

1.Create 3 user controls. Name them: MainMenu, Page 1 and Page 2 2.Add a Switcher.cs to the project – This class will handle switching between different user controls using System.Windows.Controls; public static MainWindow pageSwitcher; public static void Switch(UserControl newPage) { pageSwitcher.Navigate(newPage); } You will need this to use Navigate() method

3. Add the following code to MainWindow.cs public MainWindow() { InitializeComponent(); Switcher.pageSwitcher = this; Switcher.Switch(new MainMenu()); } public void Navigate(UserControl nextPage) { this.Content = nextPage; }

4. Design MainMenu, Page 1 and Page 2 to look like this:

5. For MainMenu, Page 1 and Page 2 add the following events private void Button_Click(object sender, RoutedEventArgs e) { Switcher.Switch(new MainMenu()); } private void Button_Click_1(object sender, RoutedEventArgs e) { Switcher.Switch(new Page1()); } private void Button_Click_2(object sender, RoutedEventArgs e) { Switcher.Switch(new Page2()); }

User Control and Transitions: Excercise1

Don’t duplicate this

Solution

Solution private void button1_Click(object sender, RoutedEventArgs e) { Next _next = new Next(); stack1.Children.Clear(); stack1.Children.Add(_next); } private void button2_Click(object sender, RoutedEventArgs e) { Back _back = new Back(); stack1.Children.Clear(); stack1.Children.Add(_back); }

User Control and Scroll Viewers: Excercise2

Create a user control for an that looks like this:

Solution

Create a scroll viewer in MainWindow.xaml:

Solution

Make the Sender a property that can be different in each instance of an . When the delete Button is clicked, the should be removed from the view. Use the scroll viewer in your main window to show 20 s (using the User Control you created) ---- Create a for loop that initializes 20 User Controls To make it easy, initialze the Sender of each to “Sender” + I e.g. Sender 0, Sender 1….

Solution public partial class UserControl { private string name; public string Name { get { return name; } set { name = value; this.SenderTextblock.Content = this.name; } public () { InitializeComponent(); this.DeleteGroup.MouseLeftButtonDown += DeleteGroup_MouseLeftButtonDown; } void DeleteGroup_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { (this.Parent as Panel).Children.Remove(this); }

Solution public MainWindow() { InitializeComponent(); for(int i = 0; i < 20; i++) { = new (); .Name = "Sender " + i.ToString(); this. s.Children.Add( ); }

Styles and Templates: Button

Give the style a key you can refer it by Create this as a resource – window/ user control

Control Template defines how a control is drawn Can also include a setter property that can be changed:

Style and Template: Excercise3

Define a template for a button that has default border color of black. Create a button instance that uses the template but changes border color to blue.

Solution

List Boxes

Drag a ListBox into the XAML List Boxes

Click to modify items

List Boxes Click to add Select ‘ListBoxItem’

List Boxes Change content

Can get the currently-selected index: listbox1.SelectedIndex

ListBox: Excercise4

Create a listbox like below and change TextBox content based on listbox selection. Add ‘SelectionChanged’ event handler.

Solution private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { textbox1.Text = (String)((ListBoxItem)listbox1.SelectedItem).Content; }

Simple Animation

Add an ellipse to your xaml Simple animations

Simple animation Add this code to the top of your C# file: using System.Windows.Media.Animation; Add this inside your user control class before the constructor: private Storyboard myStoryboard;

Simple animation // animate fade in and fade out DoubleAnimation animation = new DoubleAnimation(); animation.From = 1.0; animation.To = 0.0; animation.Duration = new Duration(TimeSpan.FromSeconds(5)); animation.AutoReverse = true; animation.RepeatBehavior = RepeatBehavior.Forever; myStoryboard = new Storyboard(); myStoryboard.Children.Add(animation); Storyboard.SetTargetName(animation, ellipse1.Name); Storyboard.SetTargetProperty(animation, new PropertyPath(Ellipse.OpacityProperty)); // Use the Loaded event to start the Storyboard. ellipse1.Loaded += new RoutedEventHandler(myEllipseLoaded);

Simple animation private void myEllipseLoaded(object sender, RoutedEventArgs e) { myStoryboard.Begin(this); }

Simple animations: Excercise5

Change the animation so that the width of the ellipse is animated.

Solution // animate change width DoubleAnimation animation = new DoubleAnimation(); animation.From = 120.0; animation.To = 240.0; animation.Duration = new Duration(TimeSpan.FromSeconds(5)); animation.AutoReverse = true; animation.RepeatBehavior = RepeatBehavior.Forever; myStoryboard = new Storyboard(); myStoryboard.Children.Add(animation); Storyboard.SetTargetName(animation, ellipse1.Name); Storyboard.SetTargetProperty(animation, new PropertyPath(Ellipse.WidthProperty));

Mouse based Interactions

Add an ellipse to your xaml Click and Drag

Click and Drag Add MouseDown, MouseMove and MouseUp events to the ellipse

Drag and Move bool captured = false; private void ellipse1_MouseDown(object sender, MouseButtonEventArgs e) { captured = true; } private void ellipse1_MouseMove(object sender, MouseEventArgs e) { if (captured) { Thickness margin = ellipse1.Margin; margin.Left = e.GetPosition(grid1).X - (ellipse1.Width / 2); margin.Top = e.GetPosition(grid1).Y - (ellipse1.Height / 2); ellipse1.Margin = margin; } private void ellipse1_MouseUp(object sender, MouseButtonEventArgs e) { captured = false; }

Triggers

Allow you to change the value of a given property once a certain condition changes Allow you to do this entirely in XAML Three types: 1.Property trigger 2.Data trigger 3.Event trigger

Property Trigger Defined by element. Watches a specific property on the owner control, and whenever that property has a specific value, it changes other properties.

Property trigger example

Property trigger example Result: Underlines and colours the text red on mouse-over.

Data Triggers Defined by element. Watches a specific property that can be anywhere (not specifically on the owner control), and whenever that property has a specific value, it changes other properties.

Data Trigger example

Triggers Data trigger example Result: Changes the text to “Yes!” and the text colour to green when the checkbox is checked.

Event Triggers Defined by element. Triggers in response to an event being called. Triggers exactly once that event is called.

Event Trigger example...

Event Trigger example...

Event Trigger Result: Animation enlarges the text on mouse-over, and shrinks it back to its original size on mouse-leave.

Image as a Button Exercise: Create a button that displays as an image.

Image as a Button Solution: