/// <reference path="../GeneratedArtifacts/viewModel.js" />
/// <reference path="../Scripts/wijmo.cba.js" />

myapp.gauges = [];
myapp.LinearGaugeDirection.LinearGauge_render = function (element, contentItem) {
    var gauge = new c1.cba.LinearGauge($(element), contentItem);
    myapp.gauges.push(gauge.wjControl);
};

myapp.LinearGaugeDirection.Direction_render = function (element, contentItem) {
    $("<select><option>Left</option><option selected>Right</option><option>Down</option><option>Up</option></select>")
    .appendTo($(element))
    .change(function () {
        var val = $(this).val();
        $.each(myapp.gauges, function (index, gauge) {
            gauge.direction = val;
            switch (val) {
                case "Left":
                case "Right":
                    $(gauge.hostElement).width(230);
                    $(gauge.hostElement).height(18);
                    break;
                case "Down":
                case "Up":
                    $(gauge.hostElement).width(18);
                    $(gauge.hostElement).height(230);
                    break;
            }
        })
    });
};