Lecture 8 Building an MDI Application. Introduction The MDI (Multiple Document Interface) provides a way to display multiple (child) windows forms inside.

Slides:



Advertisements
Similar presentations
1111 Creating ASPX Controls Programatically Objectives You will be able to Dynamically add controls to a page. Dynamically alter properties of controls.
Advertisements

 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Copyright © 2012 Pearson Education, Inc. Chapter 11 MORE WINDOWS CONTROLS & STANDARD DIALOG BOXES.
User Interface Programming in C#: Graphics
.NET Class 4 – Windows-based Application. WinForm Application Homogeny programming model. Rich class library Classes are shared by all.NET languages.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
GTECH 731 Lab Session 4 Lab 3 Review, Lab 4 Intro 9/28/10 Lab 3 Review Lab 4 Overview.
ImageJ Tutorial.
Prepared by George Holt Digital Photography BITMAP GRAPHIC ESSENTIALS.
Lecture 2 Managing Windows OS Introduction to.NET Framework C# & Microsoft Visual Studio.NET 2008.
1 Interface Types & Polymorphism & introduction to graphics programming in Java.
BIL528 – Bilgisayar Programlama II Introduction 1.
How does the web browser display a webpage? Main task Create an A4 poster where you create a flow diagram showing the various stages and process.
Dr Dat Tran - Week 4 Lecture Notes 1 MenuStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
Računarska grafika GDI+ (Graphics Device Interface Plus)
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
IE 411/511: Visual Programming for Industrial Applications
MDI vs. SDI MDI – Multiple Document Interface SDI – Single Document Interface In an SDI application, each form acts independently of the others. A MDI.
Data Binding to Controls Programming in C# Data Binding to Controls CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Object Oriented Programming Graphics and Multimedia Dr. Mike Spann
C# Programming Lecture 4 “GDI+” PGL01/CSP/2006.
Copyright © 2006 Thomas P. Skinner1 Chapter 5 Indexers, Interfaces, and Enumerators.
Animation and Double-Buffering. The animation methods described here are based on standard techniques of double-buffering applicable to most high-level.
The Web Collection, Revealed MACROMEDIA STUDIO 8 INTEGRATING.
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
Why Icon? An icon is a small picture that represents a file. Icons help you execute commands, open programs or documents quickly. It is also useful to.
Dr Dat Tran - Week 4 Lecture Notes 1 ToolStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
1 Scroll Bars Providing Scrollbars. 2 Objectives You will be able to: Use Windows Graphics to display tabular information on a Windows form. Add graphics.
Chapter 11 Bitmaps, Icons and Cursors. Copyright 2006 © Thomas P. Skinner2 Background Bitmaps are easy in.NET. Two kinds of graphics: 1.Vector 2.Bitmaps.
Visual C# 2012 How to Program 1. 2  A graphical user interface (GUI) allows a user to interact visually with a program.  Figure 14.1 shows a Visual.
Lecture 7: Basics of Machine Vision. WebCam Capture Demo.
Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.
BIL528 – Bilgisayar Programlama II Introduction 1.
GRAPHIC DESIGN – PHOTOSHOP AND FLASH Instructor: Qumber Hussain Start: 24 Aug 2009 End: 28 Sept 2009 Days/Time: Mon & Wed 1400 – AUGUST 2009 –
To access our web services, go to……. Click on Customer Login.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Lecture 6: Advanced GUI Controls. Up to now we have used simple controls such as buttons and textboxes. Now we will review some interactive (e.g. dialog)
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.
Lecture 7 Dialog Controls MDI Parent/Child Interaction.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Dr Dat Tran - Week 2 Lecture Notes 1 Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences & Engineering.
Copyright © 2012 Pearson Education, Inc. Chapter 5 Loops, File, and Random Numbers.
Lecture 14: File I/O Common Dialogs Toolbox Widgets.
Image File Formats By Dr. Rajeev Srivastava 1. Image File Formats Header and Image data. A typical image file format contains two fields namely Dr. Rajeev.
1 Printing a Document. 2 Objectives You will be able to print a real multipage document.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Mike Mulhearn & Drew Hobbs IMAGE ICON.  Paints icons from images  Images can be JPEG, JPG, GIF, PNG, BMP, WBMP  Images may also be created from a URL,
Windows form programming. namespace MyNamespace { public class MyForm : System.Windows.Forms.Form { public MyForm() { this.Text = "Hello Form"; }
Module 3: Creating Windows-based Applications. Overview Creating the Main Menu Creating and Using Common Dialog Boxes Creating and Using Custom Dialog.
Representation of image data
SDI & MDI SDI -> Single Document Interface
Praktikum 2 Konversi RGB.
EEC-693/793 Applied Computer Vision with Depth Cameras
Object Oriented Programming
MUTENESS ASSİSTMENT 1)WHY CHOICE ? 2)ABOUT DESİGN 3)WHICH CODES USING
Lecture 1 Making a C# GUI Program
Picture Viewer.
How to Add Images Using an 'openFile' Dialog
MDI Picture Viewer Application
ThS. Nguyễn Hà Giang Khoa CNTT - Hutech
Copyright © 2006 Thomas P. Skinner
EEC-693/793 Applied Computer Vision with Depth Cameras
Object Oriented Programming
Module 8: Creating Windows-based Applications
Web Service.
EEC-693/793 Applied Computer Vision with Depth Cameras
EEC-693/793 Applied Computer Vision with Depth Cameras
The Web Collection Standard CS3 Revealed
Presentation transcript:

Lecture 8 Building an MDI Application

Introduction The MDI (Multiple Document Interface) provides a way to display multiple (child) windows forms inside a single main (parent) windows form. In this example we will build an MDI application for image processing called... Image Blaster 9000 A brief overview of the features: Open and Save images of type - jpg, gif, and bmp Copy/Pase images from one child window to another. Incorporate an existing class of image filters. Apply various image manipulation filters e.g. grayscale, binary, posterize, erode, laplacian...

using System; using System.Drawing; using System.Drawing.Imaging; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ImageBlaster9000 { public struct PixelData { public byte blue; public byte green; public byte red; } public unsafe class ImgPro { Bitmap bitmap; int width; BitmapData bitmapData = null; Byte* pBase = null; public ImgPro(Bitmap bitmap) { this.bitmap = bitmap; } public void Save(string filename) { bitmap.Save(filename, ImageFormat.Jpeg); } public void Dispose() { bitmap.Dispose(); } public Bitmap Bitmap { get { return (bitmap); } public Point PixelSize { get { GraphicsUnit unit = GraphicsUnit.Pixel; RectangleF bounds = bitmap.GetBounds(ref unit); return new Point((int)bounds.Width, (int)bounds.Height); } public void GrayScale() { Point size = PixelSize; LockBitmap(); for (int x = 0; x < size.X; x++) { for (int y = 0; y < size.Y; y++) { PixelData* pPixel = PixelAt(x, y); int value = (pPixel->red + pPixel->green + pPixel->blue) / 3; pPixel->red = (byte)value; pPixel->green = (byte)value; pPixel->blue = (byte)value; } UnlockBitmap(); } The Fast Image Processing Class - ImgPro The properties in this class make use of static memory byte-arrays to speed up pixel-level processing. These techniques are implemented in the PixelAt( ), LockBitmap( ), and UnlockBitmap( ) methods. The ImgPro Class is available on the course Web page.

public void LockBitmap() { GraphicsUnit unit = GraphicsUnit.Pixel; RectangleF boundsF = bitmap.GetBounds(ref unit); Rectangle bounds = new Rectangle((int)boundsF.X, (int)boundsF.Y, (int)boundsF.Width, (int)boundsF.Height); width = (int)boundsF.Width * sizeof(PixelData); if (width % 4 != 0) width = 4 * (width / 4 + 1); bitmapData = bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); pBase = (byte*)bitmapData.Scan0.ToPointer(); } public PixelData* PixelAt(int x, int y) { return (PixelData*)(pBase + y * width + x * sizeof(PixelData)); } public void UnlockBitmap() { bitmap.UnlockBits(bitmapData); bitmapData = null; pBase = null; } LockBitmap( ), PixelAt( ), and UnlockBitmap( )

Permitting your Program to Run in Unsafe Mode open the Properties Page - not the Properties Window or Properties Panel or Properties Drop down Menu Item or...

Properties Page check the "All unsafe code" checkbox

public partial class FormMain : Form { public int newindex = 0; public FormMain() { InitializeComponent(); } private void makeNewMdiChild() { ImageBlaster9000.FormChild child = new ImageBlaster9000.FormChild(this); child.Show(); this.ActiveMdiChild.Text = "New-File-" + Convert.ToString(newindex); newindex += 1; } private void newToolStripMenuItem_Click(object sender, EventArgs e) { makeNewMdiChild(); } private void openImage() { int len; string fileName = ""; OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "JPEG files (*.jpg)|*.jpg|GIF files (*.gif)|*.gif|Bitmap files (*.bmp)|*.bmp"; if (dlg.ShowDialog() == DialogResult.OK) { fileName = dlg.FileName; Bitmap img = new Bitmap(fileName); makeNewMdiChild(); FormChild activeChild = this.ActiveMdiChild as FormChild; len = fileName.Length; if (len > 40) activeChild.Text = fileName.Substring(0, 35) + "..." + fileName.Substring(len - 4, 4); else activeChild.Text = fileName; activeChild.loadImage(fileName); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { openImage(); }

private void grayscaleToolStripMenuItem_Click(object sender, EventArgs e) { FormChild activeChild = this.ActiveMdiChild as FormChild; if(activeChild != null) activeChild.grayscale(); } private void grayscaleDemoToolStripMenuItem_Click(object sender, EventArgs e) { FormChild activeChild = this.ActiveMdiChild as FormChild; if(activeChild != null) activeChild.grayscaledemo(); }