I think Silverlight is a great technology that can be use to create great applications, or as a migration target from Visual Basic 6, Powerbuilder or Windows Forms apps which can take advantage of a very simplified deployment approach.
And use Artinsoft/ Mobilize automated solutions (see http://www.artinsoft.com/visual-basic-6-or-csharp-to-the-web.aspx )
Deployment is as simple as just publish your SL application on your intranet and your clients just need to press F5 to have the latest SL version.
Silverlight provides a good balance between ease of development and platform features(XAML and .NET and Visual Studio).
Silverlight can run cross-platform. (On Windows and Mac using the official Microsoft implementation and on Linux using Moonlight.
Support For Silverlight 4
Support For Silverlight 5
NOTE: Moonlight provides support for 32 and 64 bit Linux. It supports Silverlight 2.0, and some features of silverlight 3 and 4, but is not currently an active project.
I faced this problem recently. I tried and tried but I got different error messages for uninstall Silverlight 4 SDK and I needed to upgrade to Silverlight 5.
So after a lot of tears and suffering I came across the Microsoft Fix it.
http://support.microsoft.com/mats/Program_Install_and_Uninstall
I runned this program and indicated that I wanted to uninstall Microsoft Silverlight 4 SDK and it was like magic!
It checked the registry, and fixed it, and then uninstalled the MS Silvelight 4 SDK.
After that I just download the new installer run it and everything work! Isn’t it something J
Well I tought this was gonna be more difficult, but no. The Silverlight community is great and there are tons of
of code out there.
So I found a great project in codeplex called obviously http://silverlightbarcode.codeplex.com/
And printing barcode with that library is a peace of cake.
Just do something like this:
private void button1_Click(object sender, RoutedEventArgs e)
{
var p = new PrintDocument();
p.PrintPage += new EventHandler<PrintPageEventArgs>(p_PrintPage);
p.Print("NuevoDocument");
}
void p_PrintPage(object sender, PrintPageEventArgs e)
{
Canvas canvasBarCode = new Canvas();
canvasBarCode.Width = 200;
canvasBarCode.Height = 200;
Me.BarcodeSoftware.Barcode.Barcodes barcode =
new Me.BarcodeSoftware.Barcode.Barcodes();
barcode.BarcodeType =
Me.BarcodeSoftware.Barcode.Barcodes.BarcodeEnum.Code39;
barcode.Data = "123456";
barcode.encode();
string encodedData = barcode.EncodedData;
//if you want to put the barcode number
// add a label to canvas and set text to barcode.HumanText;
int encodedLength = 0;
for (int x = 0; x < encodedData.Length; x++)
{
if (encodedData[x] == 't')
encodedLength++;
else if (encodedData[x] == 'w')
encodedLength = encodedLength + 3;
}
float barWidth = (float)(canvasBarCode.Width / encodedLength);
if (barWidth < 1) barWidth = 1;
float thickWidth = barWidth * 3;
double incrementWidth = 0;
int swing = 0;
for (int x = 0; x < encodedData.Length; x++)
{
Brush brush;
if (swing == 0)
brush = new SolidColorBrush(Colors.Black);
else
brush = new SolidColorBrush(Colors.White);
if (encodedData[x] == 't')
{
Rectangle r = new Rectangle();
r.Fill = brush;
r.Width = barWidth;
r.Height = canvasBarCode.Height;
r.SetValue(Canvas.LeftProperty, incrementWidth);
r.SetValue(Canvas.TopProperty, 0.0);
canvasBarCode.Children.Add(r);
incrementWidth = incrementWidth + ((barWidth));
}
else if (encodedData[x] == 'w')
{
Rectangle r = new Rectangle();
r.Fill = brush;
r.Width = 3 * barWidth;
r.Height = canvasBarCode.Height;
r.SetValue(Canvas.LeftProperty, incrementWidth);
r.SetValue(Canvas.TopProperty, 0.0);
canvasBarCode.Children.Add(r);
incrementWidth = incrementWidth + (3 * (barWidth));
}
if (swing == 0)
swing = 1;
else
swing = 0;
}
e.PageVisual = canvasBarCode;
e.HasMorePages = false;
}
Well I tought this was gonna be more difficult, but no. The Silverlight community is great and there are tons of
of code out there.
So I found a great project in codeplex called obviously http://silverlightbarcode.codeplex.com/
And printing barcode with that library is a peace of cake.
Just do something like this:
private void button1_Click(object sender, RoutedEventArgs e)
{
var p = new PrintDocument();
p.PrintPage += new EventHandler<PrintPageEventArgs>(p_PrintPage);
p.Print("NuevoDocument");
}
void p_PrintPage(object sender, PrintPageEventArgs e)
{
Canvas canvasBarCode = new Canvas();
canvasBarCode.Width = 200;
canvasBarCode.Height = 200;
Me.BarcodeSoftware.Barcode.Barcodes barcode =
new Me.BarcodeSoftware.Barcode.Barcodes();
barcode.BarcodeType =
Me.BarcodeSoftware.Barcode.Barcodes.BarcodeEnum.Code39;
barcode.Data = "123456";
barcode.encode();
string encodedData = barcode.EncodedData;
//if you want to put the barcode number
// add a label to canvas and set text to barcode.HumanText;
int encodedLength = 0;
for (int x = 0; x < encodedData.Length; x++)
{
if (encodedData[x] == 't')
encodedLength++;
else if (encodedData[x] == 'w')
encodedLength = encodedLength + 3;
}
float barWidth = (float)(canvasBarCode.Width / encodedLength);
if (barWidth < 1) barWidth = 1;
float thickWidth = barWidth * 3;
double incrementWidth = 0;
int swing = 0;
for (int x = 0; x < encodedData.Length; x++)
{
Brush brush;
if (swing == 0)
brush = new SolidColorBrush(Colors.Black);
else
brush = new SolidColorBrush(Colors.White);
if (encodedData[x] == 't')
{
Rectangle r = new Rectangle();
r.Fill = brush;
r.Width = barWidth;
r.Height = canvasBarCode.Height;
r.SetValue(Canvas.LeftProperty, incrementWidth);
r.SetValue(Canvas.TopProperty, 0.0);
canvasBarCode.Children.Add(r);
incrementWidth = incrementWidth + ((barWidth));
}
else if (encodedData[x] == 'w')
{
Rectangle r = new Rectangle();
r.Fill = brush;
r.Width = 3 * barWidth;
r.Height = canvasBarCode.Height;
r.SetValue(Canvas.LeftProperty, incrementWidth);
r.SetValue(Canvas.TopProperty, 0.0);
canvasBarCode.Children.Add(r);
incrementWidth = incrementWidth + (3 * (barWidth));
}
if (swing == 0)
swing = 1;
else
swing = 0;
}
e.PageVisual = canvasBarCode;
e.HasMorePages = false;
}
Silverlight is when you have to add a lot of items.
I know, I know maybe you should choose another way to show that data,
but leaving philosophical-ui design discussions, the real problem is that
usually those components are bind to ObservableCollections.
ObservableCollections are a bit of an exhibitionist.
Each time you add an item it will yell
Hey!! Yoo-hoo! HEY!!! YOU!!
I'm HEREEEEEEEEEEEEEEEEEE!!!!
Look at me!! Look at Me!!! Look Mom No Hands!!! Look Dad no Feet!!! HEY!!!!!!!!
So if you have some code like:
for(int i=0;i<10000;i++)
{
comboItems.Add("item" + i);
}
A nice thing will be to be able to do something like:
var items = new String[10000]
for(int i=0;i<10000;i++)
{
items[i]="item" + i;
}
comboItems.AddRange(items);
And then provide just ONE notification of Collection Changed instead of a lot of
little cries for attention.
Well that is the reason for this new version of ObservableCollection that I call
RangeObservableCollection:
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
namespace Utils
{
public class RangeObservableCollection<T> : ObservableCollection<T>
{
private bool _suppressNotification = false;
public RangeObservableCollection() : base() { }
public RangeObservableCollection(IEnumerable<T> collection) : base(collection) { }
protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
{
if (!_suppressNotification) base.OnPropertyChanged(e);
}
protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (!_suppressNotification)
base.OnCollectionChanged(e);
}
/// <summary>
/// Adds a collection suppressing notification per item and just raising a notification
/// for the whole collection
/// </summary>
/// <param name="list"></param>
public void AddRange(IEnumerable<T> list)
{
if (list == null) throw new ArgumentNullException("list");
_suppressNotification = true;
foreach (T item in list)
{
Add(item);
}
_suppressNotification = false;
OnCollectionChanged(new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset));
}
}
}
The VS Profiler Team has an excellent post teaching how to use the VS2010 profiler with Silverlight Applications.
The steps are simple.
Run the A Visual Studio Command Prompt
And follow these steps:
- VSPerfClrEnv /sampleon
- "c:\Program Files (x86)\Internet Explorer\iexplore.exe" C:\Breakout\Breakout\Bin\Release\TestPage.html
- VSPerfCmd /start:sample /output:MyFile /attach:<PID of iexplore.exe process>
- Run your scenario
- VSPerfCmd /detach
- VSPerfCmd /shutdown
- VSPerfClrEnv /off
NOTE: information reposted from http://blogs.msdn.com/b/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx
When the finish you will have a file called MyFile.vsp and just open that with VS2010.