如何在WPF进度栏中使用PSD? [英] How to use PSD in WPF progressbar?

查看:83
本文介绍了如何在WPF进度栏中使用PSD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PSD文件,我想在WPF中将其用作进度条. 我不知道该怎么做.

I have a PSD file, I want to use it in WPF as a progressbar. I don't know how to do it.

我读了这个 https://msdn.microsoft.com/en -us/library ...

在这里,我必须从文件"菜单中选择导入Adobe Photoshop文件..."

There is written, I have to Choose "Import Adobe Photoshop File..." from the "File" menu

但是我有"Visual Studio 2015混合版",没有这样的选项.

But I have "Blend for Visual Studio 2015", there is not such option.

我需要安装Expression Studio吗?

Do I need to install Expression Studio?

导入后,如何将其用作进度条并在必要时进行更新?

After importing, how to use it as a progressbar and update it when necessary ?

PSD文件的图像链接= http://s21.postimg.org/70igirqif/Capture .png 请帮助,在这种情况下我无法获得任何详细的教程,我完全无能为力.

The PSD file's image Link = http://s21.postimg.org/70igirqif/Capture.png Please help, I couldn't get any detailed tutorial in this case, I am completely helpless.

推荐答案

以下是在ProgressBar中使用图像的示例ControlTemplate:

Here is a sample ControlTemplate for using an image in a ProgressBar:

<ControlTemplate
    x:Key="ImageProgressBarTemplate"
    TargetType="ProgressBar">    
    <ControlTemplate.Triggers>
        <EventTrigger
            RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard>
                <Storyboard
                    x:Name="str">
                    <RectAnimation
                        x:Name="quatanim"
                        Storyboard.TargetName="imgbrush"
                        Storyboard.TargetProperty="(ImageBrush.Viewport)"
                        From="0,0,36,36"
                        To="36,0,36,36"
                        Duration="0:0:5"
                        AutoReverse="False"
                        RepeatBehavior="Forever" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </ControlTemplate.Triggers>

    <!-- Custom progress bar goes here -->
    <Border
        Name="PART_Track"
        Width="{TemplateBinding Width}"
        BorderBrush="{TemplateBinding BorderBrush}"
        BorderThickness="{TemplateBinding BorderThickness}"
        Background="{TemplateBinding Background}"
        Height="{TemplateBinding Height}"
        CornerRadius="0"
        Padding="1.5">

        <Grid>
            <!-- Rounded mask (stretches to fill Grid) -->
            <Border
                Name="mask"
                Background="#EEEEEE"
                CornerRadius="0" />

            <!-- Any content -->

            <Rectangle
                Name="PART_Indicator"
                HorizontalAlignment="Left"
                Height="{TemplateBinding Height}">    
                <Rectangle.OpacityMask>
                    <VisualBrush
                        Visual="{Binding ElementName=mask}" />
                </Rectangle.OpacityMask>    
                <Rectangle.Fill>    
                    <ImageBrush
                        x:Name="imgbrush"
                        ImageSource="/myproject;component/Assets/myimage.png"
                        AlignmentX="Left"
                        Stretch="Fill"
                        TileMode="Tile"
                        AlignmentY="Top"
                        ViewportUnits="Absolute"
                        Viewport="0,0,36,36"
                        ViewboxUnits="RelativeToBoundingBox"
                        Viewbox="0,0,1,1">
                    </ImageBrush>    
                </Rectangle.Fill>    
            </Rectangle>    
        </Grid>    
    </Border>    
</ControlTemplate>

将其应用于进度栏:

<ProgressBar Template="{StaticResource ImageProgressBarTemplate}"/>

这篇关于如何在WPF进度栏中使用PSD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆