Posts

A Simple Radial Panel for WPF and SilverLight

Image
Geometry was one of the coolest topics in school for me. Probably because it uses a lot of figures to convey the concepts. Here I am trying to explain how we can leverage the Layout system in WPF and Silver light by taking an example of creating a Radial Panel. A RadialPanel lays out its children in a circular fasion. So before going in to the technical details, let us see how this problem get solved algorithmically.If you are asked to arrange a bunch of items in a circular path, what all things would you consider?. 1) How much space do I have? – Say X * Y rectangular area is the available size. 2) I will draw an approximate Circle (Or ellipse) inside the X*Y space. Assuming that the Radii are ‘Rx and Ry' 3) How many items are there to arrange? Say N – number 4) I know that 360 degrees are the total angular space for a circle. So angular distance between each item will be 360/N degrees. 6) I can calculate the coordinate point to which an item should be placed. That is by doing the ...

WPF Finance Contest Results Announced

I would like to share a good news that I have been selected as on of the finalists in the WPF contest , You can see the results and the download the entries here The Grand Prize winner : Szymon Kobalczyk Finalists : 1) Jacob Carpenter 2) Jobi Joy - thats me:) And the Honorable Mention went to Paul Hounshell

WPF Finance Application

Image
Here are some videos and screenshots of the application I build for the WPF Finance Contest. This Application will function as both Stock Ticker and Stock Analyzer tool. This has been designed to change Themes and Colors at run time. Stock Ticker The Application starts running as a Stock Ticker at first and shows up as the topmost window; user can move the ticker window by dragging the Clock on the left side of the window. User can right click on the Ticker Symbol to flip them and see the Intra-day line Chart. While in the Analyzer mode you can drag and drop Symbols to the Stock Ticker and the Scrips will get serialized and saved for the next session. Stock Analyzer By Clicking on a small arrow (Expander) at the bottom of the ticker, the user can switch in to the Analyzer mode. Now you can drag symbols from the ticker and drop on to the expanded area or Search symbol in the left pane and analyze. You can drag many chart symbols in to the Analyzing area and the Summary details will ...

Show all the System.Windows.Media.Colors using DataBinding

Image
Here is a sample to show all the Colors or even Brushes of WPF System.Windows.Media.Colors class. < ListBox ItemsSource = " {Binding Mode=OneWay, Source={StaticResource helper}} "   ItemTemplate = " {DynamicResource DataTemplate1} " /> Bellow is a function which gives all of its properties as PropertyInfo Collection.(If anybody out here knows a way to eliminate the use of this Helper class, please point that here) public class Helper {     public PropertyInfo[] GetPropNames( Type type)     {         return type.GetProperties();     } } Now you can write an ObjectDataProvider in XAML to call this function and then a DataTemplate to bind the PropertyName to the approapriate Dependancy Property. See the XAML   < Window.Resources >     < ObjectDataProvider x:Key = " helper " MethodName = " GetPropNames " ObjectType = " {x:Type local:Helper} " >       < ...

Time Picker User Control

The easiest way to create a WPF TimePicker control is to make a user control wrapped for TimeSpan CLR object. Here is a very simple sample which does that. Basically TimeControl is having 4 DPs one for the entire Value (Which is a TimeSpan) and individual Hours, Minutes and Seconds. (We can optionally add Days and Milliseconds also to make the control rich). Here is a C# class TimeControl.xaml.cs public partial class TimeControl : UserControl { public TimeControl() { InitializeComponent(); } public TimeSpan Value { get { return ( TimeSpan )GetValue(ValueProperty); } set { SetValue(ValueProperty, value ); } } public static readonly DependencyProperty ValueProperty = DependencyProperty .Register( "Value" , typeof ( TimeSpan ), typeof ( TimeControl ), new UIPropertyMetadata ( DateTime .Now.TimeOfDay, new PropertyChangedCallback (OnValueChanged))); ...

Blendables essentials mix v1.0 now available

A bunch of controls and utilities for Windows Presentation Foundation(WPF) has been released by Identitymine. You can take a look at Blendables here . And there is a WPF programming contest is also going on there . Have you ever wished to have a Carousal3D in your WPF app? or a ready to use Zoombox or a TimelinePanel. And have you ever thought of doing more things inside the XAML itself with out doing much C# coding? then you really need this exciting utility comming along with Blendables called EvalBinding and Simple Binding. Cheers!!!

Simple WPF Clock using Microsoft Expression Blend

Image
Today I spend some time playing with Microsoft Expression Blend . and thought of creating a XAML Clock using Blend itself. Surprisingly it took less than 2 hours for me to create a good looking Clock. Here is the preview of my XAML Clock . Below are the simple design steps I followed. 1) Created a Class TimeAngles which stores Angles corresponds to Hour,Minute and second. 2) Created an IValueConverter class for converting the DateTime.Now to Angles. 3) Bounded the each Angle properties of TimeAngles class to the Rotation RenderTransform of each Clock Hand (Which are Rectangle in my code) 4) Updated the DataContext of Clock in each second through a Despatcher Timer. Here is a screen shot of the project opened up my Blend. I have used BitMapEffect extensively to achieve this kind of a UI. Source code is Available here

Compare Objects in XAML using a generic IValueConverter

Here is a way for XAM Designers to compare two instances inside XAML using an IValueConverter. Imagine that you have a ComboBox and few other controls. ComboBox is bounded to a Collection of objects (In my attached code I am binding it to an Enum). In such a situation the UI designer wants to enable/disable some other controls based on the selected value of the ComboBox. He can use the following IValueConnverter class as a Generic comparer which will return a true or false. public class GenericComparer : IValueConverter { object IValueConverter .Convert( object value, Type targetType, object parameter, CultureInfo culture) { if (value == null ) return false ; // If the object has implemented IComparable if (value is IComparable ) { if ((( IComparable )value).CompareTo(parameter) == 0) return true ; } else if (value.Equals(parameter)) return true ; return false ; } Now instantiate a comparer in the resource as follows. ……………… If we wanted to control the IsEnabled property of a...