Software Programs and Projects

This Software Programs and Projects include programing tips and technology using different languages like VC++,ASP,JSP C#.Net,PHP,VB.Net,JavaScript,ASP.NET .Software Programs and Projects blog mainly support to software programmers and provide help through the mail.

What is XAML?

XAML is a declarative markup language. As applied to the .NET Framework programming model, XAML simplifies creating a UI for a .NET Framework application. You can create visible UI elements in the declarative XAML markup, and then separate the UI definition from the run-time logic by using code-behind files, joined to the markup through partial class definitions. XAML directly represents the instantiation of objects in a specific set of backing types defined in assemblies. This is unlike most other markup languages, which are typically an interpreted language without such a direct tie to a backing type system. XAML enables a workflow where separate parties can work on the UI and the logic of an application, using potentially different tools.

When represented as text, XAML files are XML files that generally have the .xaml extension. The files can be encoded by any XML encoding, but encoding as UTF-8 is typical.

  • XAML stands for Extended Application Markup Langauge.
  • XAML specifies the user interface for Silverlight or WPF application.
  • XAML is used declare controls on Silverlight or WPF Page.
  • In simple terms XAML Page is similar to .Aspx Page in asp.net website.
  • In .Aspx Page we use Html to form UI, while in XAML we use Xml to form UI

XAML Syntax in Brief 
The following sections explain the basic forms of XAML syntax, and give a short markup example. These sections are not intended to provide complete information about each syntax form, such as how these are represented in the backing type system. For more information about the specifics of XAML syntax for each of the syntax forms introduced in this topic, see XAML Syntax In Detail.
Much of the material in the next few sections will be elementary to you, if you have previous familiarity with the XML language. This is a consequence of one of the basic design principles of XAML. XAML The XAML language defines concepts of its own, but these concepts work within the XML language and markup form.


tag-What is XAML?

Introduction to Windows Presentation Foundation


The Windows Presentation Foundation is Microsofts next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher.

WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent.

Separation of Appearance and Behavior

WPF separates the appearance of an user interface from its behavior. The appearance is generally specified in the Extensible Application Markup Language (XAML), the behavior is implemented in a managed programming language like C# or Visual Basic. The two parts are tied together by databinding, events and commands. The separation of appearance and behavior brings the following benefits:

* Appearance and behaviour are loosely coupled
* Designers and developers can work on separate models.
* Graphical design tools can work on simple XML documents instead of parsing code.

Programming with WPF

WPF exists as a subset of .NET Framework types that are for the most part located in the System.Windows namespace. If you have previously built applications with .NET Framework using managed technologies like ASP.NET and Windows Forms, the fundamental WPF programming experience should be familiar; you instantiate classes, set properties, call methods, and handle events, all using your favorite .NET Framework programming language, such as C# or Visual Basic.

To support some of the more powerful WPF capabilities and to simplify the programming experience, WPF includes additional programming constructs that enhance properties and events: dependency properties and routed events. For more information on dependency properties, see Dependency Properties Overview. For more information on routed events, see Routed Events Overview.
Markup and Code-Behind

WPF offers additional programming enhancements for Windows client application development. One obvious enhancement is the ability to develop an application using both markup and code-behind, an experience that ASP.NET developers should be familiar with. You generally use Extensible Application Markup Language (XAML) markup to implement the appearance of an application while using managed programming languages (code-behind) to implement its behavior. This separation of appearance and behavior has the following benefits:

*
Development and maintenance costs are reduced because appearance-specific markup is not tightly coupled with behavior-specific code.

* Development is more efficient because designers can implement an application's appearance simultaneously with developers who are implementing the application's behavior.

* Multiple design tools can be used to implement and share XAML markup, to target the requirements of the application development contributors; Microsoft Expression Blend provides an experience that suits designers, while Visual Studio 2005 targets developers.

* Globalization and localization for WPF applications is greatly simplified (see WPF Globalization and Localization Overview).

The following is a brief introduction to WPF markup and code-behind. For more information on this programming model, see XAML Overview (WPF) and Code-Behind and XAML in WPF.



tag:-Introduction to Windows Presentation Foundation

Introduction to XAML

XAML stands for Extensible Application Markup Language. Its a simple language based on XML to create and initialize .NET objects with hierarchical relations. Altough it was originally invented for WPF it can by used to create any kind of object trees.

Today XAML is used to create user interfaces in WPF, Silverlight, declare workflows in WF and for electronic paper in the XPS standard.

All classes in WPF have parameterless constructors and make excessive usage of properties. That is done to make it perfectly fit for XML languages like XAML.
Advantages of XAML

All you can do in XAML can also be done in code. XAML ist just another way to create and initialize objects. You can use WPF without using XAML. It's up to you if you want to declare it in XAML or write it in code. Declare your UI in XAML has some advantages:

  • XAML code is short and clear to read
  • Separation of designer code and logic
  • Graphical design tools like Expression Blend require XAML as source.
  • The separation of XAML and UI logic allows it to clearly separate the roles of designer and developer.

LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

We use the term language-integrated query to indicate that query is an integrated feature of the developer's primary programming languages (for example, Visual C#, Visual Basic). Language-integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code. Language-integrated query also allows a single general purpose declarative query facility to be applied to all in-memory information, not just information from external sources.

.NET Language-Integrated Query defines a set of general purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language. The standard query operators allow queries to be applied to any IEnumerable-based information source. LINQ allows third parties to augment the set of standard query operators with new domain-specific operators that are appropriate for the target domain or technology. More importantly, third parties are also free to replace the standard query operators with their own implementations that provide additional services such as remote evaluation, query translation, optimization, and so on. By adhering to the conventions of the LINQ pattern, such implementations enjoy the same language integration and tool support as the standard query operators.

The extensibility of the query architecture is used in the LINQ project itself to provide implementations that work over both XML and SQL data. The query operators over XML (LINQ to XML) use an efficient, easy-to-use, in-memory XML facility to provide XPath/XQuery functionality in the host programming language. The query operators over relational data (LINQ to SQL) build on the integration of SQL-based schema definitions into the common language runtime (CLR) type system. This integration provides strong typing over relational data while retaining the expressive power of the relational model and the performance of query evaluation directly in the underlying store.


Example :

using System;
using System.Linq;
using System.Collections.Generic;

class app {
static void Main() {
string[] names = { "Burke", "Connor", "Frank",
"Everett", "Albert", "George",
"Harris", "David" };

IEnumerable query = from s in names
where s.Length == 5
orderby s
select s.ToUpper();

foreach (string item in query)
Console.WriteLine(item);
}
}


The local variable query is initialized with a query expression.A query expression operates on one or more information sources by
applying one or more query operators from either the standard query operators or domain-specific operators. This expression uses three of
the standard query operators: Where, OrderBy, and Select.







tag:-Linq and Introduction



Save Bitmap Image Into JPG Format

public void saveJpeg(string path, Bitmap img, long quality)

{
try
{
// Encoder parameter for image quality
EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, quality);

// Jpeg image codec
ImageCodecInfo jpegCodec = this.getEncoderInfo("image/jpeg");

if (jpegCodec == null)
return;

EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = qualityParam;

img.Save(path, jpegCodec, encoderParams);
encoderParams.Dispose();
qualityParam.Dispose();
}
catch (Exception)
{
}


}


private ImageCodecInfo getEncoderInfo(string mimeType)
{
// Get image codecs for all image formats
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

// Find the correct image codec
for (int i = 0; i <>
if (codecs[i].MimeType == mimeType)
return codecs[i];
return null;
}


tag:Save Bitmap Image Into Jpeg Format

How can send the Email in the Asp.net?


try
{
string strPassword = string.Empty;
string strMailFrom = string.Empty;
string smtpServer = "ServerName";

SmtpClient smtp = new SmtpClient();
strMailFrom = "Email Id";
strPassword = "Password";
smtp.Host = smtpServer;
smtp.Port = 25;

//smtp.EnableSsl = true;
//check the Authentication
If(true)
{
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential(strMailFrom, strPassword);
}


MailMessage mail = new MailMessage();
mail.From = new MailAddress(strMailFrom);
mail.To.Add("EmailId");
mail.Bcc.Add("EmailId");
mail.Subject = m_strEmailSubject.ToString();
mail.Body = m_strEmailMessage.ToString();
smtp.Send(mail);


}
catch (Exception objException)
{
throw new Exception(objException.Message.ToString());

}


tag-:How can send the Email in the Asp.net?
Smtp,Email,SmtpClient

Upload and Resize Image in the Asp.net Using C#.Net .

const int IMAGE_WIDTH = 550;
const int IMAGE_HEIGHT = 176;
(We can change the Width and Height)



public void UploadImageAd()
{
try
{
string strFolderName = "Banner_Images";
string strFolderPath = Server.MapPath(strFolderName);
//string strSavePath = "~/" + strFolderName + "/";
string strFileName = string.Empty;
string strSaveFilePath=strFolderPath;
if (!Directory.Exists(strFolderPath))
{
Directory.CreateDirectory(strFolderPath);
}
if (FileUploadImage.HasFile)
{
strFileName = FileUploadImage.FileName;
strSaveFilePath += "/" + strFileName;
string strRealImagePath = Server.MapPath("RealImage");
strRealImagePath += "/" + strFileName;
FileUploadImage.SaveAs(strRealImagePath);
//Resize and Save Image
string strImageUrl = strRealImagePath;
ResizeImage(strImageUrl,strSaveFilePath);
//RealImage
//
m_strImagePath = "~/" + strFolderName + "/" + strFileName;
}

}
catch (Exception objException)
{
throw new Exception(objException.Message.ToString());
}
}


public void ResizeImage(string strImageUrl,string strSaveFilePath)
{
try
{
System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(strImageUrl);
System.Drawing.Image.GetThumbnailImageAbort dummyCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(IMAGE_WIDTH, IMAGE_HEIGHT, dummyCallBack, IntPtr.Zero);
//Save the thumbnail in Png format. You may change it to a diff format with the ImageFormat property
thumbNailImg.Save(strSaveFilePath, ImageFormat.Png);
thumbNailImg.Dispose();
}
catch (Exception ObjException)
{
throw new Exception(ObjException.Message.ToString());
}

}



tag-Upload and Resize Image in the Asp.net Using C#.Net .
Resize image ,Upload Image in VS 2005

How to get Appsettings Value From the Web.Config File ?

try
{
string strAlertThreshold = ConfigurationManager.AppSettings["AlertThreshold"].ToString();
m_iAlertThreshold = Convert.ToInt32(strAlertThreshold);
return true;
}
catch (Exception objException)
{
m_iAlertThreshold = 0;
throw new Exception(objException.Message.ToString());
}

return false;

tag-:How to get Appsettings Value From the Web.Config File

How can update Web.config File in the Asp.NET ?

Update
AppSettings in the web.Config File (Asp.net)


public bool ChangeAppSettings(string strKey, string strValue)
{
XmlDocument doc = new XmlDocument();
bool bChange = false;
string configFile = Server.MapPath("web.config"); //Path.Combine(strSiteFolder, "web.config");
doc.Load(configFile);

XmlElement Root = doc.DocumentElement;

Dictionary appSettings = new Dictionary();
//appSettings.Add("AlertThreshold", "15");
appSettings.Add(strKey, strValue);
XmlNode appNode = Root["appSettings"];
foreach (XmlNode node in appNode.ChildNodes)
{
if (node.Attributes != null)
{
try
{
string key = node.Attributes.GetNamedItem("key").Value;
string value = node.Attributes.GetNamedItem("value").Value;
if (appSettings.ContainsKey(key) && value != appSettings[key].ToString())
{
node.Attributes.GetNamedItem("value").Value = appSettings[key].ToString();
bChange = true;
}
}
catch (Exception)
{
throw new Exception("While reading the web.config, this line had no key/value attributes modify: " + node.InnerText);
}
}
}

if (bChange) //Update web.config only if changes are made to web.config file
{
try
{
doc.Save(configFile);
return true;
}
catch (IOException objException)
{
throw new Exception(objException.Message.ToString());
}
}
else
{
return false;
}
}


protected void btnSetThreshold_Click(object sender, EventArgs e)
{
try
{
const string KEY_THRESHOLD = "AlertThreshold";
string strValue = this.txtWebThreshold.Text.Trim();
if (ChangeAppSettings(KEY_THRESHOLD, strValue))
{
this.lblStatus.Text = "Web Threshold Updated Succefully";
}
}
catch (Exception objException)
{
throw new Exception(objException.Message.ToString());
}
}
#endregion



tag:How can update Web.config File in the Asp.NET
Update Web.Config File
Update AppSettings in the web.Config File (Asp.net)

iPhone Application Tutorial

Delegation is a pattern where one object periodically sends messages to another object specified as its delegate to ask for input or to notify the delegate that an event is occurring. You use it as an alternative to class inheritance for extending the functionality of reusable objects. In this application, the application object tells its delegate that the main start-up routines have finished and that the custom configuration can begin. For this application, you want the delegate to create an instance of a controller to set up and manage the view. In addition, the text field will tell its delegate (which in this case will be the same controller) when the user has tapped Return.


Model-View-Controller
The Model-View-Controller (or “MVC”) design pattern sets out three roles for objects in an application.
Model objects represent data such as SpaceShips and Rockets in a game, ToDo items and Contacts in a productivity application, or Circles and Squares in a drawing application. In this application, the data is going to be very simple—just a string—and it’’s not actually used outside of a single method, so strictly speaking it’’s not even necessary. It’’s the principle that’’s important here, though. In other applications the model will be more complicated and accessed from a variety of
locations.

View objects know how to display data and may allow the user to edit the data. In this application you need a main view to contain several other views—a text field to capture information from the user, a second text field to display text based on the user’’s input, and a button to let the user tell us that the secondary text should be updated.

Controller objects mediate between models and views. In this application, the controller object will take the data from the input text field, store it in a string, and update a second text field appropriately. The update will be initiated as a result of an action sent by the button.


Getting Started with iPhone Programming


Welcome to the world of iPhone programming! That you are now holding this book shows that you are fascinated with the idea of developing your iPhone applications and want to join the ranks of those tens of thousands of developers whose applications are already deployed in the AppStore.

As the old Chinese adage says, “To accomplish your mission, first sharpen your tools.” Successful programming requires you fi rst of all to know your tools well. Indeed, this couldn”t be more true for iPhone programming — you need to know quite a few tools before you can even get started. Hence, the goal of this chapter is to show you the various relevant tools and information you need to jump on the iPhone development bandwagon. Without further ado, it’’s time to get down to work.

Image Analysis and Processing Tutorial


Image analysis combines techniques that compute statistics and measurements based on the gray-level intensities of the image pixels. You can use the image analysis functions to determine whether the image quality is good enough for your inspection task. Also, you can analyze an image to understand its content and to decide which type of inspection tools to use to solve your application. Image analysis functions also provide measurements that you can use to perform basic inspection tasks such as presence or absence verification.

Common tools you can use for image analysis include histograms, line profiles, and intensity measurements.

Histogram

A histogram counts and graphs the total number of pixels at each grayscale level. Use the histogram to determine if the overall intensity in the image is suitable for your inspection task. From the histogram, you can tell whether the image contains distinct regions of a certain gray-level value. Based on the histogram data, you can adjust your image acquisition conditions to acquire higher quality images. You can detect two important criteria by looking at the histogram:

Underexposure or saturation–Too little light in the imaging environment leads to underexposure of the imaging sensor. Too much light causes overexposure, or saturation, of the imaging sensor. Images acquired with underexposed or saturated conditions do not contain all the information that you need to inspect your object. It is important to detect these imaging conditions and correct for them during the setup of your imaging system.



C# Solutions for a Face Detection and Recognition System



Key issues on using a new programming language - C# - in implementation of a face detection and recognition (FDR) system are presented. Mainly the following aspects are detailed: how to acquire an image, broadcast a video stream, manipulate a database, and finally, the detection/recognition phase, all in relation with theirs possible C#/.NET solutions. Emphasis was placed on artificial neural network (ANN) methods for face detection/recognition along with C# object oriented implementation proposal.

In June 2000, Microsoft announced both the .NET platform and a new programming language called C# [1-3]. .NET is a framework that covers all the layers of software development from the operating system up. It actually wraps the operating system, insulating software developed with .NET from most operating system specifics such as file handling and memory allocation. It provides a new application programming interface (API) to the services and APIs of classic Windows operating systems while bringing together a number of disparate technologies that emerged from Microsoft during the late 1990s. It provides the richest level of integration among presentation technologies, component technologies, and data technologies ever seen on a Microsoft platform. This includes COM+ component services, a commitment to XML and object-oriented design, support for new web services protocols such as SOAP, WSDL, and UDDI, etc. .NET framework components .

Image acquisition includes the first two stages depicted in Figure 3, namely image grabbing and preprocessing. Eventually, at this step, the video stream could be broadcasted, in real time, over Internet. Considering the coding difficulties, using C# together with a videocapture device (videocamera, webcam), grabbing a still image from the video stream and, eventually, Internet broadcast it via a web server, is nowdays the most problematic aspect of the C# FDR implementation. Most of the problems are promised to be solved in the near future by DirectX 10 /Windows Longhorn launching. It seems that there are only two ways to communicate with a videocapture device:

Considering an image representing a frame taken from a video stream or a graphic file selected from a database; the problem of face detection consist of finding the spatial location within the scene where human faces are located. This problem is quite challenging due numerous issues, e.g. pose, presence or absence of structural components, facial expression, occlusion, orientation, imaging conditions.

DirectX in C#

Several techniques of implementing DirectX functionality into C# application will be presented. Their common attribute is an idea of component object model (COM) because DirectX is based on component technology. This paper will be focused on use of DirectX graphical capabilities within the C# code of the Microsoft .NET Framework. Three main techniques will be described. First, COM interoperability which allows us to decide what specific functionality to use. There will be also mentioned some basic principles like memory management and garbage collector (GC) and some approaches based on wrapper classes. Second, Visual Basic type library that includes all the functionality, and third, the complete solution known as DirectX 9.0. Each technique will be supported with a code snippet and with several reasons stating its suitability. Nowadays, the need for security can be more important than for the efficiency. This also gives a right answer for the question of how good is solution provided by use of DirectX and .NET Framework.

The purpose of this paper is to provide a basic idea about implementation of DirectX graphical interface in the code of C# language in the .NET Framework. A goal is to have such an environment where the code for C# looks similar to the C++ one. This work is a part of project ROTOR, more detailed information is placed at [Her03]. DirectX version 8.1 and above is assumed, if not said explicitly. Complete information on DirectX and .NET Framework can be found in electronic resources [MSDN02].

The .NET Framework Environment where the C# code is executed. It uses Garbage Collector (GC) for system memory management, which automates such tasks as a memory allocation, release, fragmentation, etc. No pointers are allowed here (managed code) but if necessary, the unmanaged code can be entered. In this mode pointers are allowed but GC doesn”t work - it is a developer responsibility to manage the memory. Therefore the managed code should be used but there is a problem: DirectX is using pointer parameters to pass data into its functions. How to face this pointer-problem will be shown later in the paragraph “COM Benefits”.

#region Start Mail Delevery
///


/// Start Mail Delevery

private void btnStart_Click(object sender, EventArgs e)
{
StartMailThreading();
}
#endregion

#region Start Mail Threading
///
/// Start Mail Threading
///

public void StartMailThreading()
{
// Create the worker thread and start it
ThreadStart starter = new ThreadStart(this.UpdateListBox);
Thread t = new Thread(starter);
t.Start();
// Loop 4 times, adding a message to the ListBox each time
for (int i = 0; i < 4; i++) ;
{
this.listBoxSendItems.Items.Add("Campaign Started");
this.listBoxSendItems.Update();
// Process any queued events on the UI thread
Application.DoEvents();
// Suspend processing for 1 second
Thread.Sleep(1000);
}
this.listBoxSendItems.Items.Add("Last message from UI thread");
this.listBoxSendItems.Update();
}
#endregion

#region Update ListBox Control
///
/// Update ListBox Control
///

public void UpdateListBox()
{
for (int j = 0; j < 20; j++)
{
// Set the message to be added to the ListBox from the worker
// thread
this.Message = "Worker thread loop count = " + j.ToString();
// Invoke the WorkerUpdate method in the ListBox’s thread
// context
this.listBoxSendItems.Invoke(new EventHandler(WorkerUpdate));
Thread.Sleep(100);
}
}
#endregion

#region WorkerUpdate
// The delegate that’s called from the worker thread
// to update the ListBox
public void WorkerUpdate(object sender, EventArgs e)
{
this.listBoxSendItems.Items.Add(this.Message);
this.listBoxSendItems.Update();
}
#endregion

private void FormCampaignLog_Load(object sender, EventArgs e)
{
Thread trd = new Thread(new ThreadStart(this.startProgress));
trd.IsBackground = true;
trd.Start();
}

void startProgress()
{
for (int i = 0;i<100;i++)
{
SetControlPropertyValue(progressBar1, "value", i); //This is a thread safe method
System.Threading.Thread.Sleep(100);
}
}

private void SetControlPropertyValue(Control oControl, string propName, object propValue)
{
if (oControl.InvokeRequired)
{
SetControlValueCallback d = new SetControlValueCallback(SetControlPropertyValue);
oControl.Invoke(d, new object[] { oControl, propName, propValue });

}
else
{
Type t = oControl.GetType();
PropertyInfo[] props = t.GetProperties();
foreach (PropertyInfo p in props)
{
if (p.Name.ToUpper() == propName.ToUpper())
{
p.SetValue(oControl, propValue, null);

}
}
}
}

How can display VLC ( Video Lan ) Player in ASP.NET


<asp:GridView ID="GrdVideo" runat="server" AutoGenerateColumns="False" PageSize="1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<object id="vlc_IE" height="240" width="320" classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921">
<embed type="application/x-vlc-plugin" version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc" autoplay="yes" target='<%#Eval("Video")%>' ></embed>
<param name="AutoPlay" value="True" />
<param name="Src" value='<%#Eval("Video")%>' />
<param name="volume" value="50" />

</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings PageButtonCount="1" />
</asp:GridView>


Code

Get values from the database (video Path) and binding into the Gridview control using DataTable .Example for creating Datatable

DataTable myDataTable = new DataTable();
DataColumn myDataColumn;
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Video";
myDataTable.Columns.Add(myDataColumn);
DataRow row;
row = myDataTable.NewRow();
row["Video"] = strUrl;
myDataTable.Rows.Add(row);
GrdVideo.DataSource = myDataTable.DefaultView;
GrdVideo.DataBind();



How to display Video in Windows MediaPlayer in Asp.Net






How can display VLC ( Video Lan ) Player in ASP.NET