Hello everyone,
I just release my first personal WP7 application and it’s called Bixel.
Bixel locates the nearest Bixi stations in Montreal. You can add them to your favorites, see the directions and see the number of available docks and bikes.
I will add some features in the next few days but I wanted to release a functional version for the new Bixi season which begins today.
Here are some screenshots



Bixel is available for free on the Marketplace, in French and English.

Hello,
In my current project, I needed to watermark a WriteableBitmap with a text. As I couldn’t find anything I decided to create a small extension method to do so.
public static class WriteableBitmapEx
{
/// <summary>
/// Creates a watermark on the specified image
/// </summary>
/// <param name="input">The image to create the watermark from</param>
/// <param name="watermark">The text to watermark</param>
/// <param name="color">The color - default is White</param>
/// <param name="fontSize">The font size - default is 50</param>
/// <param name="opacity">The opacity - default is 0.25</param>
/// <param name="hasDropShadow">Specifies if a drop shadow effect must be added - default is true</param>
/// <returns>The watermarked image</returns>
public static WriteableBitmap Watermark(this WriteableBitmap input, string watermark, Color color = default(Color), double fontSize = 50, double opacity = 0.25, bool hasDropShadow = true)
{
var watermarked = GetTextBitmap(watermark, fontSize, color == default(Color) ? Colors.White : color, opacity, hasDropShadow);
var width = watermarked.PixelWidth;
var height = watermarked.PixelHeight;
var result = input.Clone();
var position = new Rect(input.PixelWidth - width - 20 /* right margin */, input.PixelHeight - height, width, height);
result.Blit(position, watermarked, new Rect(0, 0, width, height));
return result;
}
/// <summary>
/// Creates a WriteableBitmap from a text
/// </summary>
/// <param name="text"></param>
/// <param name="fontSize"></param>
/// <param name="color"></param>
/// <param name="opacity"></param>
/// <param name="hasDropShadow"></param>
/// <returns></returns>
private static WriteableBitmap GetTextBitmap(string text, double fontSize, Color color, double opacity, bool hasDropShadow)
{
TextBlock txt = new TextBlock();
txt.Text = text;
txt.FontSize = fontSize;
txt.Foreground = new SolidColorBrush(color);
txt.Opacity = opacity;
if (hasDropShadow) txt.Effect = new DropShadowEffect();
WriteableBitmap bitmap = new WriteableBitmap((int)txt.ActualWidth, (int)txt.ActualHeight);
bitmap.Render(txt, null);
bitmap.Invalidate();
return bitmap;
}
}
For this code to run, you need the WritableBitmapEx library.
As you can see, it’s quite simple. You just need to call the Watermark method and pass it the text you want to add in your image. You can also pass optional parameters like the color, the opacity, the fontsize or if you want a drop shadow effect. I could have specify other parameters like the position or the the font family but you can change the code if you need to.
Here’s what it can give

Hope this helps.
The other day I wanted to check the source code of the ScrollViewer of WP7. I started Reflector (profit while its still free) and I opened the System.Windows.dll assembly located at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone. When Reflector did the job I was surprised to see that all the methods/properties were empty !

After some investigations, I found out that these assemblys are used by Visual Studio for the Intelisense (among others) and so, for develoment.
The thing is I still couldn’t check the ScrollViewer’s source code.
Finally after new investigations, I discovered a link on the XDA forum which provide the WP7 emulator dump. I downloaded it and decompiled the GAC_System.Windows_v2_0_5_0_cneutral_1.dll assembly located this time at /SYS/SILVERLIGHT.
Et voila, the ScrollViewer’s source code is available.

Hope this helps.
Hello,
Today I’m gonna show you how to choose the webcam resolution when using Silverlight. By default most of them are in 640x480 which can be sometimes insufficient.
VideoCaptureDevice source = devices.SelectedItem as VideoCaptureDevice;
source.DesiredFormat = new VideoFormat(PixelFormatType.Unknown, 4096, 4096, 30);
The magic thing with this line, is that the camera will choose the best resolution available (and not absolutely 4096x4096).
You can also get all the supported formats using the SupportedFormats property.
Hope this help.
I just submitted a suggestion on Microsoft Connect to move the INotifyCollectionChanged from System.Windows.dll to System.dll.
You can review it here: https://connect.microsoft.com/VisualStudio/feedback/details/560184/move-inotifycollectionchanged-from-system-windows-dll-to-system-dll
Here’s the reason why I suggest that.
Actually I wanted to take advantages of the new feature of Silverlight/Visual Studio 2010 for sharing assemblies (see http://blogs.msdn.com/clrteam/archive/2009/12/01/sharing-silverlight-assemblies-with-net-apps.aspx). Everything went fine until I try to share a custom collection (with custom business logic) implementing INotifyCollectionChanged.
This modification has been made in the .NET Framework 4 (see https://connect.microsoft.com/VisualStudio/feedback/details/488607/move-inotifycollectionchanged-to-system-dll) so maybe it could be done in Silverlight too.
If you think this is justifiable you can vote for it.
Hi everyone,
I just created a multiplayer turn-based online game and I'm looking for a Silverlight graphist to realize the design of the game itself and of the hosting website (room, room chat, in-game chat...).
The game is 90% completed but I cant publish it as is, I need a good graphist for making it awesome!
In case of success and if we make some money, there will be equal share!
Just post a comment or contact me if you’re interested.
The Royal Society just published a manuscript of William Stukeley which relates the life of Sir Isaac Newton with, of course, the famous apple which leads to the general gravitational low.
This manuscript, as well as many others, are available for consultation through a Silverlight player but also a xbap version.
Hello everyone,
Today, I’d like to present you my entry for the MIX 10K Coding Challenge.

For those who don’t know this challenge, the rules are really simple. You have to submit an application whose the source code’s size is less than 10 kilobytes. The technologies allowed are Silverlight, HTML5 and Gestalt.
As you can guess, I chose Silverlight 3 and my source code’s size is 9.5 kilobytes.
So if you like my app, vote for me!
http://mix10k.visitmix.com/Entry/Details/140
Thanks!
Re,
Ok the title is not really explicit but in this post we’re going to see an image control which display the busy pointer that we saw in my previous post, until the image be loaded.
First we create the Xaml composed with two controls: an image and the Busy pointer.
<UserControl x:Class="xxx.ImageProgress"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:xxx">
<Grid x:Name="LayoutRoot" Background="White">
<Image x:Name="Image" Stretch="Fill" />
<local:BusyPointer x:Name="Buffer" />
</Grid>
</UserControl>
And some C#
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace xxx
{
public partial class ImageProgress : UserControl
{
public ImageProgress()
{
InitializeComponent();
}
public BitmapImage Source
{
get { return (BitmapImage)GetValue(SourceProperty); }
set
{
SetValue(SourceProperty, value);
value.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(value_DownloadProgress);
this.Image.Source = value;
this.BeginAnimation();
}
}
void value_DownloadProgress(object sender, DownloadProgressEventArgs e)
{
if (e.Progress == 100)
{
StopAnimation();
}
}
// Using a DependencyProperty as the backing store for Source. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SourceProperty =
DependencyProperty.Register("Source", typeof(BitmapImage), typeof(ImageProgress), new PropertyMetadata(new PropertyChangedCallback(OnSourceChanged)));
private static void OnSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
ImageProgress source = sender as ImageProgress;
if (source != null) source.Source = (BitmapImage)e.NewValue;
}
private void BeginAnimation()
{
this.Buffer.IsBusy = true;
}
private void StopAnimation()
{
this.Buffer.IsBusy = false;
this.Buffer.Visibility = Visibility.Collapsed;
}
}
}
I created a Dependency Property for the image’s source. When this DP is changed, I download the image from the source we I display the busy pointer. When the download is complete I stop the animation and hide it.
This control can be really useful if your application uses images from external source like Flickr or Bing.
We could check the ImageFailed event for notifying the user if there is an error.
Live sample: http://broux.developpez.com/public/SL/ImageProgress/index.html (the image is 4MB).
Hello everyone,
Today I’m gonna present you a control which can be really useful, since you can find him in Windows: the busy mouse pointer. This control is used for notice the user than something is happening.

The code for this control is quite simple.
#region Dependency Properties
public bool IsBusy
{
get { return (bool)GetValue(IsBusyProperty); }
set
{
SetValue(IsBusyProperty, value);
ChangeState();
}
}
// Using a DependencyProperty as the backing store for IsBusy. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsBusyProperty =
DependencyProperty.Register("IsBusy", typeof(bool), typeof(BusyPointer), new PropertyMetadata(new PropertyChangedCallback(OnBusyChanged)));
private static void OnBusyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
((BusyPointer)sender).IsBusy = (bool)e.NewValue;
}
#endregion
#region Initialization
public BusyPointer()
{
this.DefaultStyleKey = typeof(BusyPointer);
}
#endregion
#region Methods
private void ChangeState()
{
if (IsBusy) VisualStateManager.GoToState(this, "Busied", true);
else VisualStateManager.GoToState(this, "Normal", true);
}
#endregion
Juste a very simple control with a IsBusy property. When the value is true the animation starts, when it’s false it stops.
And the theme I use.
<Style TargetType="local:BusyPointer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:BusyPointer">
<Grid x:Name="LayoutRoot" Background="Transparent">
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal" />
<vsm:VisualState x:Name="Busied">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="VisualElement" Storyboard.TargetProperty="(UIElement.RenderTransform).Angle" RepeatBehavior="Forever">
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="360" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Ellipse Width="25" Height="25" StrokeThickness="5.5" x:Name="VisualElement">
<Ellipse.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF096475" Offset="0.571"/>
<GradientStop Color="#FFA8FCFC" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Stroke>
<Ellipse.RenderTransform>
<RotateTransform CenterX="12.5" CenterY="12.5" />
</Ellipse.RenderTransform>
</Ellipse>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
You can change the colors, the animation, the shape, everything!
Have fun!
More Posts
Next page »