我正在尝试修改别人写的东西。我对 xaml 的了解并不多,但是我的搜索和尝试将我发现的内容结合起来以尝试完成此任务使我得到了您将在下面看到的内容。
我们有一个网页使用 Silverlight 来显示几个统计数据。
我正在尝试创建一个警报,一旦我们更改 rss 提要中的值,该警报就会闪烁。
我已经得到它,所以背景颜色会改变,但不会闪烁。当我尝试取消评论我对 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 不正确的错误的评论。