Skip to main content

Posts

Showing posts from August, 2009

MVVM - Binding Multiple Radio Buttons To a single Enum Property in WPF

I had a property in my View Model, of an Enum type, and wanted to bind multiple radio buttons to this.

Firstly, I wrote a simple Enum to Bool converter, like this.

public class EnumToBoolConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (parameter.Equals(value)) return true; else return false; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return parameter; } #endregion }

And my enumeration is like

public enum CompanyTypes { Type1Comp, Type2Comp, Type3Comp } Now, in my XAML, I provided the enumeration as the ConverterParameter, of the Converter we wrote earlier, like
<Wi…

Creating an Operating System using C#

Have you ever wrote an Operating System, even if it is very simple? If you've ever tried, you know that it is a fun thing to do.



Long time back, in college, when I was doing my diploma and later my B-Tech graduation in Computer Science, I remember most of us got fascinated and inspired by the Linux kernel - and eventually most of us rolled out our own simple boot loaders and Operating Systems!!


And most of us used Asm + C. As C is a very low level language - you can do a lot of things directly. Any of the C library methods (like malloc, printf, crlscr etc) need to be implemented first, to invoke them from C




I'll give an example below.


Let us see how the C library methods are implemented under the hood. We'll go with a clrscr example. When you implement such methods, you'll access system devices directly. For ex, for clrscr (clearing the screen) we know that the video memory is resident at 0xB8000. Hence, to write to screen or to clear it, we start by assigning a pointer t…