编辑:
对于任何好奇的人,这是完成的结果.
http://jsfiddle.net/Javalsu/vxP5q/743/embedded/result/
我正在构建我在此链接中找到的代码
http://thecodeplayer.com/walkthrough/html5-canvas-snow-effect
我想让这更像是雪花效果而不是雪效果,我需要让每个元素都有不同的颜色.但似乎一次为整个画布设置填充颜色.
有没有办法为每个元素指定不同的填充颜色,或者我是以完全错误的方式进行此操作?
谢谢
更新:如果有人需要五彩纸屑,这是成品
window.onload = function () {
//canvas init
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
//canvas dimensions
var W = window.innerWidth;
var H = window.innerHeight;
canvas.width = W;
canvas.height = H;
//snowflake particles
var mp = 200; //max particles
var particles = [];
for (var i = 0; i < mp; i++) {
particles.push({
x: Math.random() * W, //x-coordinate
y: Math.random() * H, //y-coordinate
r: Math.random() * 15 + 1, …
Run Code Online (Sandbox Code Playgroud) 我试图通过创建一个扩展方法来一般地处理过滤来清理我的代码.
这是我想要清理的代码.
var queryResult = (from r in dc.Retailers select r);
if (!string.IsNullOrEmpty(firstName))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(firstName.Trim(), ex.FirstName.Trim()) > 0);
if (!string.IsNullOrEmpty(lastName))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(lastName.Trim(), ex.LastName.Trim()) > 0);
if (!string.IsNullOrEmpty(companyName))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(companyName.Trim(), ex.CompanyName.Trim()) > 0);
if (!string.IsNullOrEmpty(phone))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(phone.Trim(), ex.Phone.Trim()) > 0);
if (!string.IsNullOrEmpty(email))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(email.Trim(), ex.Email.Trim()) > 0);
if (!string.IsNullOrEmpty(city))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(city.Trim(), ex.City.Trim()) > 0);
if (!string.IsNullOrEmpty(zip))
queryResult = queryResult.Where(ex => SqlFunctions.PatIndex(zip.Trim(), ex.Zip.Trim()) > …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个可以水平滚动的缩略图列表,但无论我做什么都会打破.
这就是我现在拥有的
ul{
width: 100%;
list-style-type: none;
margin: auto;
overflow-x: scroll;
}
li{
height: 100px;
width: 100px;
border: 1px solid red;
display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
关于我做错了什么的任何想法?谢谢!
我在文本块周围有一个边框,以创建一个圆角的漂亮背景.但无论我做什么,边框宽度始终是其父级的大小.我想将其限制为其内容的大小.我尝试将宽度绑定到它的内容的实际宽度,但是这对任何绑定模式都不起作用.
<Border x:Name="TagPreviewBorder" CornerRadius="5"
Width="{Binding ElementName=TagPreviewTextBlock, Path=ActualWidth, Mode=TwoWay}">
<TextBlock x:Name="TagPreviewTextBlock"/>
</Border>
Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码从网址下载图像
HttpClient client = new HttpClient();
var stream = await client.GetStreamAsync(new Uri("<your url>"));
var file = await KnownFolders.PictureLibrary.CreateFileAsync("myfile.png");
using (var targetStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
using (stream)
await stream.CopyToAsync(targetStream.AsStreamForWrite());
}
Run Code Online (Sandbox Code Playgroud)
一些用户报告说它并不总是下载整个图像.他们有时得到部分图像,其余的只是垃圾.
这有什么理由吗?谢谢!
我正在使用Google Gauges,并希望在量表中的值后添加%符号.我的值显示没有百分比符号(整数0 - 100),但是当我开始尝试添加百分比符号时,事情变得很糟糕.
这是我尝试过的
// Format the data to include % symbol
var formatter = new google.visualization.NumberFormat(
{suffix: '\u0025'}
//{suffix: '%'}
//{pattern: '#%'}
);
Run Code Online (Sandbox Code Playgroud)
所有三次尝试都显示正确的可视化,但对于实际值文本,我会得到不同的结果.
使用任一后缀方法,它会添加两个小数位:
6 => 6.00%
26 => 26.00%
等等
使用模式方法,它将值乘以100
6 => 600%
26 => 2600%
等等
有关如何简单地显示值和百分号的任何线索?
我有一个父实体和一个子实体。
在数据库中,父级的主键是p_p_id
,子级中的外键是相同的p_p_id
数据库中没有外键约束。
实体具有在各自的类中设置的指向彼此的属性。
家长班
public virtual ChildProject ThisChildProject { get; set; }
Run Code Online (Sandbox Code Playgroud)
儿童班
public virtual ParentProject ThisParentProjection { get; set; }
Run Code Online (Sandbox Code Playgroud)
这些属性或任何一个类的Id上都没有注释。
在配置中,我尝试在子级中进行映射。
HasRequired(i => i.ThisParentProject).WithOptional(o => o.ThisChildProject );
Run Code Online (Sandbox Code Playgroud)
发生的情况是EF尝试使用子级的主键和父级的主键进行映射。
但是我想在子级和父级的主键中使用定义的FK
我有一个可以通过 api 设置的图像,我希望图像在宽度超过 250 像素时被剪裁。这有效。但是,图像与一些文本块一起位于堆栈面板中。即使我们看到的图像被剪裁了,实际图像宽度仍然超过 250 像素。
这是xaml
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Button Foreground="Black" Content="Button" x:Name="BackButton" Style="{StaticResource BackButtonStyle}" Visibility="Collapsed" VerticalAlignment="Center" Margin="25,0,0,0" Click="BackButtonClick" />
<Border>
<Image x:Name="LogoImage" Source="Images/Logo.png" Height="50" Margin="15 0 0 0" Stretch="Uniform" VerticalAlignment="Center">
<Image.Clip>
<RectangleGeometry Rect="0 0 50 250"></RectangleGeometry>
</Image.Clip>
</Image>
</Border>
<TextBlock Foreground="Black" x:Name="NameTextbox" Margin="15, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
<TextBlock VerticalAlignment="Bottom" x:Name="ErrorMessage" Text="Unable to reach server" Foreground="Red" Margin="15 0 0 0" FontSize="26" FontWeight="Bold" Visibility="Collapsed"></TextBlock>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
因此,假设图像宽度为 2000 像素。然后图像后面的文本块将被推出屏幕,但只有 250 像素的图像将是可见的。
有什么建议吗?
我有一个listview对象,它通过一个javascript函数从web api读取数据,该函数将数据附加到listmodel.我已经在下面附上了listview和listmodel.
我想在用户靠近或到达listview的最后一个元素时实现一种无限滚动.
我无法弄清楚如何检测滚动事件并抓住相对滚动位置.
谢谢你的帮助.
ListModel {
id: subModel
function getSub(idx){
return (idx >=0 && idx < count) ? get(idx).display_name: "";
}
}
ListView {
clip: true
width: parent.width
height: parent.height - searchButton.height
model: subModel
on
delegate: ListingDelegate{
text: title;
subText: subTitle;
icon: Qt.resolvedUrl(thumbnail)
__iconWidth: units.gu(5)
__iconHeight: units.gu(5)
}
}
}
Run Code Online (Sandbox Code Playgroud) 下面是一个描述我正在尝试做的事情的片段。在我的应用程序中,我有一个贯穿始终的 replaysubject。在某个时候,我想获得从主题发出的最后一个值,但last
似乎不适用于 ReplaySubject。
const subject = new Rx.ReplaySubject();
subject.next(1);
subject.next(2);
subject.next(3);
subject.next(4);
subject.subscribe(num => console.log(num));
var lastObserver = subject.last();
lastObserver.subscribe(num => console.log('last: ' + num));
Run Code Online (Sandbox Code Playgroud)
上面的代码不会为 触发任何东西lastObserver
,但 subscribe 工作得很好。