0% found this document useful (0 votes)
19 views41 pages

CHPTR 3 ADT-II

The document outlines the curriculum for the Application Development Tool-II course at Dr. J. J. Magdum College of Engineering, focusing on .NET and C# programming. It covers key topics such as object-oriented programming, GUI development, delegates, events, file handling, and ADO.NET. The course includes lectures, practicals, and evaluations, with a recommended textbook and several reference books for further study.

Uploaded by

seema.bandgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views41 pages

CHPTR 3 ADT-II

The document outlines the curriculum for the Application Development Tool-II course at Dr. J. J. Magdum College of Engineering, focusing on .NET and C# programming. It covers key topics such as object-oriented programming, GUI development, delegates, events, file handling, and ADO.NET. The course includes lectures, practicals, and evaluations, with a recommended textbook and several reference books for further study.

Uploaded by

seema.bandgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Dr. J. J.

Magdum College of Engineering,Jaysingpur

Department of Information Technology

Class: T. Y. BTech Semester- VI

Subject: : Application Development Tool-II

Subject Instructor
Prof. J. T. Patil
Assistant Professor, Information Technology Department, JJMCOE, Jaysingpur
Structure overview
Class T.Y.Btech Semester- VI

Course Title Application Development Tool-II

1. Basic knowledge of Object Oriented


Prerequisite/s
Programming

Teaching Scheme: Lecture/Tutorial/Practical 2hr/week,-----,2hr/week

Credits 03

Evaluation Scheme: Theory/Term work/Practical ------/25 marks/50 marks


Course Title
Introduction to .net:
Unit 1 Evolution of .net, Benefits of .net, CLR, CTS, MSIL, JIT, BCL, metadata and assemblies in 4 Hr
detail, GAC and strong name assemblies, Security Manager.

C# fundamentals:
Data types - Value types, Reference types, boxing and unboxing, Arrays, Pass by value and
Unit 2 by reference and out parameters, params parameter. Namespaces, classes, objects, structs: 3 Hr
definition and creation.

Delegates and Events:


Creating and using delegates, multicasting with delegates, event sources, event handlers
GUI Programming: Introduction to GUI Application and their components, Windows
Unit 3 forms – buttons, check boxes, radio buttons, panels, group boxes, list boxes, picture boxes, 8 Hr
Menus, ToolStrips, StatusStrips and progress bars, events, Creating and using MDI
application.

File handling:
The abstract stream class, working with StreamWriters and StreamReaders, Working with
Unit 4 4 Hr
StringWriters and StringReaders, Working with BinaryWriters and BinaryReaders.

ADO.NET:
Unit 5 Exploring ADO.net Entity framework, Connected and disconnected architecture, data 4 Hr
access with ADO.net.

Collection and Generic:


Unit 6 Collection classes in .net, Understanding Generics, generic collection classes in .net. 3 Hr
 Text Book:
1. C# 4.0 The Complete Reference: Herbert Schildt, McGraw Hill.

 Reference Books:
1. Microsoft Visual C# 2010 Step by Step: John sharp, Microsoft Press
2. NET 4.5 Programming (6 – in -1) Black Book – Kogent – Dreamtech
Press
3. CLR via C# :Jeffrey Richter, Microsoft Press, 3rd edition
4. ASP.Net 4.5 Black Book ,Dreamtech ,Wiley International.
Unit 1 : Delegates and Events
 Creating and using delegates
 multicasting with delegates
 event sources, event handlers
 GUI Programming: Introduction to GUI Application and
their components,
 Windows forms – buttons, check boxes, radio buttons, panels,
group boxes, list boxes, picture boxes, Menus, ToolStrips,
StatusStrips and progress bars, events,
 Creating and using MDI application.
Delegates:

 Delegate is a reference to a method

 Delegate allows us to hold reference to an object instance and method.

 It is a object reference

 they are like function pointers in C & C++

 reference has two properties

1. the type of object reference can point to

2.and actual object reference by the reference


Role of Delegates in C#:
Define a delegate
 Syntax:

public delegate int myDelegate(int x);

Here,

 delegate - a keyword

 int - return type of delegate

 myDelegate - delegate name

 int x - parameter that the delegate takes


Instantiate a delegate

 Suppose, we have a method named calculateSum() whose signature is the same


as myDelegate.

 To create an instance of myDelegate, we pass a method name as a parameter.

For example,

myDelegate d1 = new myDelegate(calculateSum);


Example: Calling a Method Using delegate

using System;
using System.Collections.Generic;
class Program
{
// define a method that returns sum of two int numbers
static int calculateSum(int x, int y)
{
return x + y;
}
// define a delegate
public delegate int myDelegate(int num1, int num2);
static void Main()
{
// create an instance of delegate by passing method name
myDelegate d = new myDelegate(calculateSum);
// calling calculateSum() using delegate
int result = d(5, 6);
Uses:

 They are like function pointers

 more powerful
 safe to use(type-safe)
 promote reusability of code and implement flexibility
 notify which method to call when an event is triggered
 define callback methods
Delegates work with methods

 Purpose : store a reference to a method

 when required invoke that method

 just like trigger

 properties of delegates
1. type /signature of method that delegate point to.
2. delegate reference can be used to reference to a method.
3. actual method referenced by the delegate
Type /signature of method that delegate point to.

1. Signature of the method includes :

return type and type of parameter

e.g. Int main ( STRING [] ARGS)

INT ADD ( INT A, INT B)


{
RETURN A+B;
}

SIGNATURE:
INT MYMETHOD (INT V , INT D)
namespace ConsoleApplication1
{
class Program
{
delegate int myd(int p, int q);

static void Main(string[] args)


{
myd d=new myd(add);
int v= d(15,15);
o/p: addition:30
Console.WriteLine("addition:{0}",v);
}
static int add(int a,int b)

{
return a+b;

}}}
Multicast delegate

 single delegate can encapsulate more than one method of matching


signature.

 Delegate object maintains list of method to call


 The multicast delegate is used to point to more than one method at a time. We use += operator to add

methods to delegate. For example,


using System;
class Program
{
// method that prints sum of two int numbers
public void sum(int x, int y)
{
Console.WriteLine("Sum is: " + (x + y));
}
// method that prints difference of two int numbers
public void difference(int x, int y)
{
Console.WriteLine("Difference is: " + (x - y));
}
// define a delegate of int type
public delegate void myDelegate(int num1, int num2);
static void Main()
// instance of Program class
Program obj = new Program();
// create an instance of delegate and
// pass sum method as a parameter
myDelegate d = new myDelegate(obj.sum);

// multicast delegate
// calls difference() method
d += obj.difference;

// pass values to two methods i.e sum() and difference()


d(6, 5); }}
Output:
Sum is:11
Difference is:1
Events:
 Event is a notification mechanism that depends on delegates

 Events are user actions such as key press, clicks, mouse movements, etc., or
some occurrence such as system generated notifications.

 For Example when you click a button, a button-click-event notification is sent to


the window hosting the button.

 Applications need to respond to events when they occur.

 For example, interrupts.

 Events are used for inter-process communication.


Events: Overview

 Event handling is a style of programming where one object notifies


another that something of interest has occurred
 A publish-subscribe programming model

 Events allow you to tie your own code into the functioning of an
independently created component

 Events are a type of “callback” mechanism


Events: Overview

 Events are well suited for user-interfaces

 The user does something (clicks a button, moves a mouse, changes a value, etc.)
and the program reacts in response

 Many other uses, e.g.

 Time-based events

 Asynchronous operation completed

 Email message has arrived

 A web session has begun


Events: Overview

 C# has native support for events

 Based upon delegates

 An event is essentially a field holding a delegate

 However, public users of the class can only register delegates

 They can only call += and -=

 They can’t invoke the event’s delegate

 Multicast delegates allow multiple objects to register with the same event
Syntax:
MyDelegate a;// delegate
event MyDelegate b; //event

class MyClass
{
public event MyDelegate GoodNews
{ add
{
// add accessor code here
} }
 It is very easy and at the end of this point, you will understand how
to create events and how to associate an event with a delegate, how
to raise an event, and how to handle an event in C# with examples.
 In C#, it’s very simple to define an event.

 What we need to do is, we need to use the event keyword.

 So, the event can be defined inside a class using the event keyword and the syntax
is given below.

 First, we need to define one delegate, and using that delegate only we need to
define an event as shown in the below image.
 As you can see, events are created using the delegate. Here, we created the
WorkPerformed event using the WorkPerformedHandler delegate.

 This is important because an event on its own does not really do anything. You
must have a pipeline or delegate which routes the data from Point A to Point B, that
is from Event Raiser to Event Handler or Event Listener and that is going to be our
delegate. So, events are really wrappers around the delegate. This is the entire
Example to understand How to Create Custom Event in C#:

1. using System;
2. namespace DelegatesDemo 12. public void DoWork(int hours,
WorkType workType)
3. { 13. {
4. //Step1: Define one delegate 14. //Raising Events
5. public delegate void WorkPerformedHandler(int hours, 15. }
16. }
WorkType workType);
17. public enum WorkType
6. public class Worker 18. {
7. { 19. Golf,
20. GotoMeetings,
8. //Step2: Define one event to notify the work progress
21. GenerateReports
using the custom delegate
22. }
9. public event WorkPerformedHandler WorkPerformed; 23. }
10. //Step2: Define another event to notify when the work is
completed using buil-in EventHandler delegate
11. public event EventHandler WorkCompleted;
Raising Events in C#:

 Once we defined the Events, then we need a way to Raise the Events. And this is important
otherwise, the listener would have no way to get the event data. Now, we are going to discuss
the different processes or techniques of Raising Events in C#.

 Events are Raised simply by calling the events like a method. So, you just need to use the
event name and you need to pass the parameter values. Why? Because behind the event, we
have delegates only. So, the way we invoke a delegate, in the same way, we need to invoke an
event or you can raise an event in C#.
Handling Events in C#:

 Now, we are going to discuss how to handle the event in C# which is raised by
the Event Raiser.
 Event handler cannot return a value.

 Parameters in the object raise the event

 eventargs object contains useful information about the event

 An event is a delegate type class member that is used by the object or

class to provide a notification to other objects that an event has occurred.

 The client object can act on an event by adding an event handler to the

event.
Instantiating Delegates and Handling Events in C#:

 To discuss the process of wiring up an event handler with the event.

 We have already discussed that the delegate method signature and event handler method
signature should and must be the same otherwise the event handler method will not get the
data from the delegate or pipeline. If the handler method wants to receive the data from the
pipeline, then the handler must have the same number, type, and order of parameters as the
delegate. For a better understanding, please have a look at the below image.
 In .NET Framework, we can use the += operator to attach an event with an
event handler. Here, is an example.
Difference between delegates and events

1. An event is an event.

2. A "delegate" assigns a particular event handler to an object instance.

3. Event is Arraylist of delegates .

4. Delegate ( as its English meaning ) : Secretary or someone who connect two persons
through him .

5. Delegate can fire only one method

6. But Event fire more than one delegate , each call one method

7. delegate is a type that references a method.

8. Event is a Modifier

9. Events enable a class or object to notify other classes or objects when something of
interest occurs
Steps for the events

 The event keyword lets you specify a delegate that will be called upon the occurrence of some
"event" in your code.

 The delegate can have one or more associated methods that will be called when your code
indicates that the event has occurred The following steps must be taken in order to create and use
C# events:

1. Create or identify a delegate. If you are defining your own event, you must also ensure that
there is a delegate to use with the event keyword.

2. Create a class that contains:

A. An event created from the delegate.

B.(optional) A method that verifies that an instance of the delegate declared with the event keyword
exists.

C.Methods that call the event. These methods can be overrides of some base class functionality.
3. Define one or more classes that connect methods to the event. Each of these
classes will include:

Associate one or more methods, using the += and -= operators, with the
event in the base class.

The definition of the method(s) that will be associated with the event.

4. Use the event:


 Create an object of the class that contains the event declaration.
 Create an object of the class that contains the event definition, using the
constructor that you defined.
GUI Programming: Introduction to GUI
Application
 Graphical User Interface (GUI) provides the user graphical means to interact with the system, GUI can
be combination of both hardware and software. Using GUI, User interprets the software

 GUI stands for Graphical User Interface. It refers to an interface that allows one to interact with
electronic devices like computers and tablets through graphic elements. It uses icons, menus and other
graphical representations to display information, as opposed to text-based commands. The graphic
elements enable users to give commands to the computer and select functions by using mouse or other
input devices.

 Typically, GUI is more resource consuming than that of CLI.

 With advancing technology, the programmers and designers create complex GUI that work with more
efficiency, accuracy and speed
History of GUI
 Earlier, there was no GUI so people used to interact with the command-line interface(CLI).
The CLI was not that friendly to use and the end-user was not familiar with all the
commands. So to bridge this gap, GUI was introduced. The main aim of the GUI was to
make the applications much more user-friendly.
GUI Components and Advantages
 GUI provides a set of components to interact with software and Hardware

 A GUI consists of graphical elements such as cursors, icons, and buttons that are
enhanced with sound and visual effects. Through these objects, users can use a computer
without knowing the commands.

 Basic components of GUI:


 Pointer: It is a symbol that appears on the display screen. It can be moved to select commands and
objects.
 Pointing device: It allows you move the pointer and select objects on the screen, e.g. mouse or trackball.
 Icons: It refers to small images on the display screen that represent commands, files, windows etc. Using
pointer and pointing device, you can execute these commands.
 Desktop: It is the display screen that contains the icons.

 The following are the elements of Graphical User Interface:


 Button , Icon , Dialog box ,Text box, Menu , Ribbon , Menu Bar , Tab , Window , Toolbar , Scrollbars
Advantages of Graphical User Interface

 The graphical User Interface is visually very appealing and detailed oriented.

 It ensures that people with little or even no knowledge of computers can use it and perform basic
computer functions.

 Graphical User Interface is easy to use since it does not require the user to use any command.

 Through Graphical User Interface, each and every response from the computer is visually
communicated.

 A good Graphical User Interface offers freedom to users.

 It makes the entire design more attractive and allows developers to have more control over visual
customization to improve user experience.

 Users can easily and quickly finish tasks using Graphical User Interface, unlike in CUI, which
requires multiple typed commands to complete a task.
Thank You!

You might also like