Category Archives: .NET

Integrating C# and PHP using XML-RPC and WCF

While investigating how to make C# and PHP interact with each other I run into an interesting extension of WCF Service Model for working over XML-RPC protocol. I played a bit with this extension and after fixing some bug in its source code I made it work with my little custom XML-RPC server implemented as Joomla XML-RPC plugin.

(more…)

How to specify WPF control size in millimeters using XAML

The first thing that we need to do to use millimeters in XAML is to define simple Mm2PixelConverter class that performs the conversion from millimeter to pixels:

[ValueConversion(typeof(double), typeof(double))]
class Mm2PixelConverter : IValueConverter
{
    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        double mm = (double)value;

        return WinUtil.Mm2Pixel(mm);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    #endregion
}

(more…)

Using ADO.NET Entity Framework with MySQL

In general, getting EF work with MySQL is a fairly simple task, that could be accomplished by downloading and installing ADO.NET driver for MySQL. But what concerns to me, it taken me about four hours to clarify some MySQL-specific details that affect generation of associations in Model Designer. Also after doing an experimentation with the code I realized that ADO.NET driver for MySQL, as well as other third party ADO.NET drivers, do not support “MARS” and, as far as I see, this significant restriction makes EF unusable with MySQL in large real-life projects. Please read below if you interested in more information on this questions.
(more…)

Seeing design time data in a WPF control

Sometimes the ability to see the data at design time significantly facilitates the creation of WPF controls. If I am developing a WPF control with complex UI using data bound controls, I usually define a property for accessing some typical data item:

public static ComplexData DesignTimeItem
{
    get
    {
        using (DatabaseContext db = new DatabaseContext())
        {
            var products = from p in db.products.Include("ProductType")
                           where p.product_id == 131
                           select p;

            product product = products.First();

            return new ComplexData(product, "100 kg");
        }
    }
}

(more…)