European Silverlight Hosting BLOG

BLOG about Latest Silverlight Hosting and Its Techologies - Dedicated to European Windows Hosting Customer

Silverlight Hosting- HostForLIFE.eu :: Why Should I Use Silverlight?

clock November 27, 2020 07:04 by author Peter

Why should I use Silverlight? Why does Silverlight stand ahead of all other technologies?

Well!! When I began to write small applications using Silverlight, there were many questions in my mind.

Why do we use Silverlight? What would be the reason for Silverlight when there is ASP.NET, Windows apps, and the latest WPF.

I am trying to resolve these conflicts over here.

As per my working knowledge, Microsoft released ASP.NET and the Windows Application platform. It was a great revolution for the web and the internet world.

Windows applications are called thick clients and an ASP.NET Web application is called a thin client. Since a Windows application will be installed in the client machine, it is called a thick client. Whereas in a web application, there is no installation required on the client-side.

But, there were two problems the company/developer faced.

They needed to maintain two versions for Windows and web applications. i.e. the company has to maintain two versions of the same application. Because some clients want the same application in both a Windows version and a web version. So, it becomes a great headache for companies and developers. Since it was taking not only time for the UI design/Application layer but also for code-behind work.
 
Even though Ajax is a superb concept adapted to ASP.Net for animation like some of the visual effects, still there was difficulty achieving the same UI types for both web and Windows Applications.
 
Since there is a need for two versions of applications, there is a maintenance problem.
 
So later Microsoft came up with a new technology called "WPF". WPF was introduced with a new style of markup language called XAML. There are two types of applications; one is Web browser WPF and WPF application. A WPF web browser app runs in a browser and works as a web application and the other WPF application works as a Windows application. So a developer can use the same XAML for both versions.
 
The look and feel of both versions are the same and it provides a rich UI better than a normal ASP.Net and Windows application.

But, again there was a problem; that is, again the company/developer must maintain two versions of an application:

Web browser WPF.
Normal WPF (as Win form).

So, again Microsoft came up with a new and robust technology called "SILVERLIGHT". Silverlight falls in between thin and thick client concepts.

So, in Silverlight Microsoft has introduced Silverlight applications and Silverlight out-of-browser applications. Silverlight as an out-of-browser application provides the same effect as Windows applications. Even though its run's under the sandbox and doesn't have full pledge permissions as in Windows applications, still it has some of the permissions to access local resources.

So, there is no need to maintain two versions of applications. Any Silverlight application can be converted into an Out-Of-Browser app and as well as revert it into a web app. The app will have the power of the desktop but delivered by the web.

Next, let me cover some more extra futures of Silverlight:

Smart client
 
Already I have explained the smart client concept in my previous articles.
 
A smart client is nothing but, the application will be installed on the client, and whenever the application launches, downloads the latest and also is able to handle online as well as offline with the help of a local DB.
 
Service-oriented business applications
 
Socket Programming.
 
One of the most important things is socket programming in Silverlight. First of all, what are sockets?
 
Silverlight has built-in support for sockets which creates really very interesting possibilities.
 
Suppose, if I need to update on the client-side for each update in the server, then probably I should go for polling.
 
In this polling, the client contacts the server for each regular interval of time to get the updates.
 
Even though there is no update on the server, still the client checks for updates. So, this could cause a traffic overload or unnecessary server round trips.
 
How would it be, if there is a system which sends the updates from the server whenever the data is changed?
 
In this case, sockets are relevant. So, sockets are nothing but, a listener server to listen to clients.
 
By using this socket, a client can send data to the server as well as the server can send data to the client. So, it is a two-way transaction or duplex mode.
 
The .Net framework supports sockets in the namespace "System.net.sockets".
 
I will explain about socket programming in the next chapter.
 
While operating outside the sandbox of the browser.
 
There are some restrictions for the web application so that they can not get round in the browser because of security. We can't access the system, can't write the user's disk except for cookies and HTML 5 offline storage. Also can't access devices connected to the user machine.
 
By using a Silverlight Out –of – Browser app or elevated trust these restrictions can be lifted.
 
When an application needs to look exactly alike in all platforms.
 
There is no guarantee on HTML5/web applications about rendering over different browsers. So, if you want a pixel perfect app, then Silverlight would be the better option.
 
When there is a need to support multi-touch.

ASP.NET



Silverlight Hosting- HostForLIFE.eu :: How to Custom Events on Silverlight Controls ?

clock November 20, 2020 08:56 by author Peter

Today, I am going to tell you about Custom Events on Silverlight 5 controls. Generally when you employ or develop controls the events you employ are a lot of straight forward however this case, we possess a dial therefore the 'mouseover' or click is not actually need you would like. So exactly what we need is once the dial moves to some place we need the 'position changed' event called.

To start out along with you need a few custom event args as we wish to pass the 'angle' from the dial towards the event handler inside the consuming application. Therefore the custom event args appearance such as this:
public class DialEventArgs : EventArgs
{
private double angle;
public DialEventArgs(double _Angle)
{
this.angle = _Angle;
}
public double Angle
{
get
{
return angle;
}
}
}


During this case it is a fairly straight forward class which drives from eventargs so we add a constructor which lets us established the angle property simply. Next we would like in our own control class to outline the event such as this :
public delegate void PositionChangeHandler (Object Sender, DialEventArgs e);
public event PositionChangeHandler PositionChangedEvent;
protected virtual void OnPositionChanged(DialEventArgs e)
{
PositionChangedEvent(this, e);
}


Using this set up a consuming xaml page if they utilize the control can set an event handler for that event. However first we have to truly call the event once the angle in the dial changes : In the method which sets the angle we've this code :
OnPositionChanged(new DialEventArgs(AngleOfRotation));

Currently if you get an event handler set in xaml you will get the event called in the correct time. In xaml this may look such as this:
<cc:Dial x:Name="NewKnobControl" Height="100" Width="100" PositionChangedEvent="NewKnobControl_PositionChangedEvent" Minimum="45.0" Max="135" >
<cc:Dial.KnobFace>
<Grid >
<Ellipse Fill="Aquamarine" />
<Rectangle x:Name="Indicator" Height="10" Width="49" Fill="Blue" Margin="1,45,50,45" />
</Grid>
</cc:Dial.KnobFace>
</cc:Dial>


Now inside the client code you'll need an event handler and during this case inside my demo app it's similar to this :
private void NewKnobControl_PositionChangedEvent(Object sender, DialEventArgs e)
{
// applicable values
double Angle = e.Angle;
}



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Tag cloud

Sign in