我正在尝试在我的W10 UWP应用中将远程图像设置为桌面壁纸/手机锁屏:
string name = "test_image.jpg";
Uri uri = new Uri("http://www.ucl.ac.uk/news/news-articles/1213/muscle-fibres-heart.jpg");
// download image from uri into temp storagefile
var file = await StorageFile.CreateStreamedFileFromUriAsync(name, uri, RandomAccessStreamReference.CreateFromUri(uri));
// file is readonly, copy to a new location to remove restrictions
var file2 = await file.CopyAsync(KnownFolders.PicturesLibrary);
// test -- WORKS!
//var file3 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Design/1.jpg"));
// try set lockscreen/wallpaper
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) // Phone
success = await UserProfilePersonalizationSettings.Current.TrySetLockScreenImageAsync(file2);
else // PC
success = await UserProfilePersonalizationSettings.Current.TrySetWallpaperImageAsync(file2);
Run Code Online (Sandbox Code Playgroud)
file1不起作用,因为它是只读的,所以我将它复制到一个新的位置(图片库)以删除限制 - > file2.
注意: …
我有一个带有包含两列的网格的页面,第一个包含一个按钮,用于切换第二列的可见性(通过ViewModel绑定).如何添加动画以显示/隐藏第二列(使用Pivot作为内容)到此方案?
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Button Command="{Binding TogglePivot}"/>
</Grid>
<Pivot x:Name="Content_Pivot" Grid.Column="1">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<!-- Hidden state -->
<VisualState x:Name="Hidden">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content_Pivot" Storyboard.TargetProperty="Width">
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<!-- Visible state -->
<VisualState x:Name="Visible">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content_Pivot" Storyboard.TargetProperty="Width">
<DiscreteObjectKeyFrame KeyTime="0" Value="600"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<interactivity:Interaction.Behaviors>
<!-- Show -->
<core:DataTriggerBehavior Binding="{Binding IsVisible}" ComparisonCondition="Equal" Value="True">
<core:GoToStateAction StateName="Visible"/>
</core:DataTriggerBehavior>
<!-- Hide -->
<core:DataTriggerBehavior Binding="{Binding IsVisible}" ComparisonCondition="Equal" Value="False">
<core:GoToStateAction StateName="Hidden" />
</core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors>
<!-- Content.. …Run Code Online (Sandbox Code Playgroud) 我想使用前一行值进行涉及当前行的计算。矩阵看起来像:
A B
[1,] 1 2
[2,] 2 3
[3,] 3 4
[4,] 4 5
[5,] 5 6
Run Code Online (Sandbox Code Playgroud)
我想做以下操作:(cell[i]/cell[i-1])-1,本质上计算从当前行到前一行(不包括第一行)的百分比变化(-1 到 1)。
输出应如下所示:
C D
[1,] NA NA
[2,] 1.0 0.5
[3,] 0.5 0.33
[4,] 0.33 0.25
[5,] 0.25 0.20
Run Code Online (Sandbox Code Playgroud)
这可以使用 for 循环轻松完成,但我正在处理大型数据集,因此我想使用 apply(或其他内置函数)来提高性能和更清晰的代码。
到目前为止,我想出了:
test.perc <- sapply(test, function(x,y) x-x[y])
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
有任何想法吗?
谢谢。
我收到了cannot instantiate abstract class错误.现在我知道这个的含义,但我不知道我的代码是如何做错的.我在这里,寻求帮助.
我有
Action.h:
#ifndef ACTION_H
#define ACTION_H
// ===== Dependencies ===== //
#include ...
...
// ===== Classes ===== //
class Action
{
public:
Action();
void set(...);
virtual void doAction() = 0;
};
#endif
Run Code Online (Sandbox Code Playgroud)
MoveAction.h:
#ifndef MOVE_ACTION_H
#define MOVE_ACTION_H
// ===== Dependencies ===== //
#include ...
...
// ===== Classes ===== //
class MoveAction : public Action
{
public:
MoveAction(...); // Constructor
using Action::set;
void doAction(); // Do action
private:
...
};
#endif …Run Code Online (Sandbox Code Playgroud) 我有一个标题Room.h定义如下:
#ifndef ROOM_H
#define ROOM_H
class Room
{
public:
Room();
private:
Room north;
Room south;
Room east;
Room west;
};
#endif
Run Code Online (Sandbox Code Playgroud)
但是我得到Error: incomplete type is not allowed了每个Room变量.这种设计有根本缺陷吗?
c# ×2
c++ ×2
abstract ×1
animation ×1
apply ×1
cells ×1
class ×1
inheritance ×1
matrix ×1
nested ×1
polymorphism ×1
r ×1
types ×1
uwp ×1
virtual ×1
wallpaper ×1
windows-10 ×1
winrt-xaml ×1
xaml ×1