javascript XAML闪烁背景

时间:2013-01-25 20:34:18

标签: javascript silverlight xaml rss

我试图修改别人写的东西。我对xaml知之甚少,但是我的搜索和尝试将我发现的尝试结合起来并尝试完成此操作会让我看到你将在下面看到的内容。

我们有一个网页使用Silverlight来显示多个统计信息。

我正在尝试创建一个警报,一旦我们更改了rss Feed中的值,它就会闪烁。

我得到它以便背景颜色改变,但不闪烁。当我尝试取消注释我对xaml的添加时,页面的其余部分会加载,但是这会给我一个错误。任何帮助都会很棒,教给我一些我确定的东西。

    function ContentALRT(comp, sender) {
    var rss = GetRSS(comp.Sources[0]);  //GETRSS() IS IN AJAX.JS
    var xaml = '<Canvas><TextBlock Text="error" /></Canvas>';
    if (rss.error == "") {
        var cGradient = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="' + theme.Color.ButtonGradient1 + '" Offset="0.0" /><GradientStop Color="' + theme.Color.ButtonGradient2 + '" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
//  Commented out for future use to preserve gradient   var alertGradient1 = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="#C2F0C2" Offset="0.0" /><GradientStop Color="#248F24" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
//  Commented out for future use to preserve gradient   var alertGradient2 = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="' + theme.Color.AlertMidGradient + '" Offset="0.0" /><GradientStop Color="' + theme.Color.AlertDarkGradient + '" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
//  Commented out for future use to preserve gradient   var alertGradient3 = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="#FFB2B2" Offset="0.0" /><GradientStop Color="#800000" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
//  These gradients are to be used for "Flat" colors
        var alertGradient1 = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="#006600" Offset="0.0" /><GradientStop Color="#006600" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
        var alertGradient2 = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="#E68A00" Offset="0.0" /><GradientStop Color="#E68A00" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
        var alertGradient3 = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="#B22400" Offset="0.0" /><GradientStop Color="#B22400" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
        var glassGradient = '<Rectangle.Fill><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="#9FFF" Offset="0.0" /><GradientStop Color="#2FFF" Offset="1.0" /></LinearGradientBrush></Rectangle.Fill>';
        var iSlot = sender.findName("Slot" + comp.Slot);
        var iWidth = iSlot.Width - iSlot.Width / 5;
        //var FlashColor1 = "#B22400";
        //var FlashColor2 = theme.Color.ButtonGradient1;
        //comp.Update = "999999";

        var aData = rss.items[0].description.split(":");
        var gradient = cGradient;
        var font_color = theme.Color.BodyText;
        var title = rss.items[0].title;
        var alert = parseInt(aData[1]);
        //window.alert(aData[1]);

        if (alert > 0) {
            gradient = alertGradient3;
            }
        else{
            gradient = alertGradient1;
            }
//          
//          if (parseInt(aData[1].substring(13,14)) > 0) {
//              //IF CALL HAS BEEN ON HOLD LONGER THAN 0 SECONDS...
//          
//              GlobalAlert = true;                     
//          }

        xaml = '<Canvas>';
        xaml += '<Rectangle Height="' + iSlot.Height + '" Width="' + iSlot.Width + '" RadiusX="8" RadiusY="8" Stroke="' + theme.Color.ButtonBorder + '" StrokeThickness="' + theme.Size.BorderSize + '" >';
        xaml += gradient + '</Rectangle>';
        if (options.glass == "true") {
            xaml += '<Rectangle Canvas.Top="1" Canvas.Left="1" Height="' + (iSlot.Height / 2) + '" Width="' + (iSlot.Width - 2) + '" RadiusX="5" RadiusY="5" >';
            xaml += glassGradient + '</Rectangle>';
        }
        xaml += '<Canvas Canvas.Top="' + theme.Size.InnerMargin + '" Canvas.Left="' + theme.Size.InnerMargin + '" Width="' + (iSlot.Width - (theme.Size.InnerMargin * 2)) + '" >';
        xaml += '<TextBlock Text="[' + title + ' Queue]" Foreground="' + font_color + '" FontFamily="' + theme.Style.Font + '" FontSize="' + theme.Size.BodyText + '" Loaded="CenterTextHorizontal" />';
        xaml += '<Canvas Canvas.Top="' + (theme.Size.BodyText * 1.6) + '" Width="' + (iSlot.Width - (theme.Size.InnerMargin * 2)) + '" >';
        for (var j = 0; j < aData.length; j++) {
            xaml += '<Canvas Canvas.Top="' + (theme.Size.TitleText * j) + '" Width="' + (iSlot.Width - (theme.Size.InnerMargin * 2)) + '" >';
            xaml += '<TextBlock Text="' + aData[j] + '" Foreground="' + font_color + '" FontFamily="' + theme.Style.Font + '" FontSize="' + theme.Size.TitleText + '" FontWeight="Bold" Loaded="CenterTextHorizontal" />';
            xaml += '</Canvas>';
        }

//      xaml += '<BeginStoryboard><Storyboard>';
//      xaml += '<ColorAnimation Storyboard.TargetProperty=("Rectangle") Duration="0:0:0.2" From="' + cGradient + '" To="' + gradient + '" RepeatBehavior="3x" AutoReverse="True"/>';
//      xaml += '</Storyboard></BeginStoryboard>';
        xaml += '</Canvas></Canvas></Canvas>';
    }
    return xaml;

}

最后评论的部分是我添加的内容。我删除了评论,我收到有关xaml不正确的错误。

0 个答案:

没有答案