小编Tra*_*iew的帖子

W10 UWP - 将远程图像设置为桌面墙纸/锁屏

我正在尝试在我的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.

注意: …

c# wallpaper windows-runtime win-universal-app windows-10

7
推荐指数
1
解决办法
1438
查看次数

C#UWP XAML动画

我有一个带有包含两列的网格的页面,第一个包含一个按钮,用于切换第二列的可见性(通过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)

c# animation xaml winrt-xaml uwp

5
推荐指数
1
解决办法
9551
查看次数

R 应用并从前一行获取值

我想使用前一行值进行涉及当前行的计算。矩阵看起来像:

      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)

但它不起作用。

有任何想法吗?

谢谢。

r matrix cells apply

4
推荐指数
1
解决办法
8607
查看次数

C++继承和抽象函数实现

我收到了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)

c++ polymorphism virtual inheritance abstract

1
推荐指数
1
解决办法
99
查看次数

C++不完整类型是不允许类内部使用的?

我有一个标题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++ types nested class

0
推荐指数
2
解决办法
738
查看次数