SagiK-Repository / C_Sharp_Deep_Learn

C#을 깊게 배웁니다.
0 stars 1 forks source link

Devexpress WPF WainIndicator #23

Open SAgiKPJH opened 4 months ago

SAgiKPJH commented 4 months ago
SAgiKPJH commented 4 months ago

Resource 기반

<dx:DXWindow
    x:Class="DXSample.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DXSample"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    Title="DXApplication" Height="700" Width="1100"
    SnapsToDevicePixels="True" UseLayoutRounding="True"
    >
    <dx:DXWindow.Resources>

        <ControlTemplate x:Key="{dx:WaitIndicatorThemeKey ResourceKey=WaitIndicatorTemplate}" TargetType="{x:Type dx:WaitIndicator}">
            <Grid x:Name="Root" Margin="{TemplateBinding ContentPadding}" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="Visibility">
                        <VisualState x:Name="Visible">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.1">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <!--BEGIN WPF-->
                                <BooleanAnimationUsingKeyFrames Storyboard.TargetName="progressBar" Storyboard.TargetProperty="IsIndeterminate">
                                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.1" Value="True" />
                                </BooleanAnimationUsingKeyFrames>
                                <!--END WPF-->
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Collapsed">
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" BeginTime="0:0:0.1" Duration="0:0:0.1" From="1" To="0" />
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.2">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <!--BEGIN WPF-->
                                <BooleanAnimationUsingKeyFrames Storyboard.TargetName="progressBar" Storyboard.TargetProperty="IsIndeterminate">
                                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.1" Value="False" />
                                </BooleanAnimationUsingKeyFrames>
                                <!--END WPF-->
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <dx:WaitIndicatorContainer>
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <ProgressBar x:Name="progressBar" Background="#FFFFFFFF" BorderBrush="Red" Foreground="Red" BorderThickness="4" Margin="12,12,8,12" Width="40" Height="40" HorizontalAlignment="Center" VerticalAlignment="Center" Template="{StaticResource DefaultWaitIndicator}" IsIndeterminate="True"/>
                        <ContentPresenter Grid.Column="1" Content="{TemplateBinding ActualContent}" Margin="{TemplateBinding Padding}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="Center" />
                    </Grid>
                </dx:WaitIndicatorContainer>
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="{dx:WaitIndicatorThemeKey ResourceKey=WaitIndicatorContainerTemplate, ThemeName=MetropolisLight}" TargetType="{x:Type dx:WaitIndicatorContainer}">

            <Border Background="#FFFFFFFF" BorderBrush="#FFB9B9B9" BorderThickness="1">
                <ContentPresenter />
            </Border>
        </ControlTemplate>

        <Style TargetType="{x:Type dx:WaitIndicator}">
            <Setter Property="Template" Value="{DynamicResource {dx:WaitIndicatorThemeKey ResourceKey=WaitIndicatorTemplate}}"/>
        </Style>
    </dx:DXWindow.Resources>

    <Grid>
        <dx:WaitIndicator DeferedVisibility="True" BorderThickness="0"/>
    </Grid>

</dx:DXWindow>
SAgiKPJH commented 4 months ago

내부 정의 기반

<dx:WaitIndicator
    x:Class="ADC.Client.Host.Wpf.Components.Molecules.WaitIndicator"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:atoms="clr-namespace:ADC.Client.Host.Wpf.Components.Atoms"
    xmlns:local="clr-namespace:ADC.Client.Host.Wpf.Components.Molecules"
    mc:Ignorable="d"
    d:DesignHeight="450"
    d:DesignWidth="800">
    <dx:WaitIndicator.Resources>
        <dxmvvm:BooleanToVisibilityConverter
            x:Key="BooleanToVisibilityConverter" />

        <ControlTemplate
            x:Key="DefaultWaitIndicator"
            TargetType="{x:Type ProgressBar}">
            <Grid
                x:Name="TemplateRoot"
                SnapsToDevicePixels="true">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup
                        x:Name="CommonStates">
                        <VisualState
                            x:Name="Determinate" />
                        <VisualState
                            x:Name="Indeterminate">
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                                    Storyboard.TargetName="Glyph"
                                    RepeatBehavior="Forever"
                                    Duration="00:00:1"
                                    From="-32"
                                    To="32" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid>
                    <Border
                        Background="{TemplateBinding BorderBrush}"
                        CornerRadius="128">
                        <Grid
                            Margin="{TemplateBinding BorderThickness}">
                            <Border
                                Background="{TemplateBinding Background}"
                                CornerRadius="128" />
                        </Grid>
                    </Border>
                    <Grid
                        Margin="{TemplateBinding BorderThickness}"
                        dx:FrameworkElementHelper.IsClipped="True"
                        ClipToBounds="True">
                        <Path
                            x:Name="Glyph"
                            Stretch="Fill"
                            Fill="{TemplateBinding Foreground}"
                            Data="F1 M 506,131L 522.898,131L 513,122L 518.097,122L 530.097,133L 518.097,144L 513.097,144L 522.916,135L 506,135L 506,131 Z "
                            Width="24"
                            Height="22"
                            RenderTransformOrigin="0.5,0.5">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform />
                                    <SkewTransform />
                                    <RotateTransform />
                                    <TranslateTransform />
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Grid>
                </Grid>
            </Grid>
        </ControlTemplate>

    </dx:WaitIndicator.Resources>
    <dx:WaitIndicator.Template>
        <ControlTemplate
            TargetType="{x:Type dx:WaitIndicator}">
            <Grid
                x:Name="Root"
                Margin="{TemplateBinding ContentPadding}"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Visibility="Collapsed">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup
                        x:Name="Visibility">
                        <VisualState
                            x:Name="Visible">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                                    Storyboard.TargetName="Root"
                                    Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame
                                        KeyTime="0:0:0.1">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <!--BEGIN WPF-->
                                <BooleanAnimationUsingKeyFrames
                                    Storyboard.TargetName="progressBar"
                                    Storyboard.TargetProperty="IsIndeterminate">
                                    <DiscreteBooleanKeyFrame
                                        KeyTime="0:0:0.1"
                                        Value="True" />
                                </BooleanAnimationUsingKeyFrames>
                                <!--END WPF-->
                            </Storyboard>
                        </VisualState>
                        <VisualState
                            x:Name="Collapsed">
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetName="Root"
                                    Storyboard.TargetProperty="Opacity"
                                    BeginTime="0:0:0.1"
                                    Duration="0:0:0.1"
                                    From="1"
                                    To="0" />
                                <ObjectAnimationUsingKeyFrames
                                    Storyboard.TargetName="Root"
                                    Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame
                                        KeyTime="0:0:0.2">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <!--BEGIN WPF-->
                                <BooleanAnimationUsingKeyFrames
                                    Storyboard.TargetName="progressBar"
                                    Storyboard.TargetProperty="IsIndeterminate">
                                    <DiscreteBooleanKeyFrame
                                        KeyTime="0:0:0.1"
                                        Value="False" />
                                </BooleanAnimationUsingKeyFrames>
                                <!--END WPF-->
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <dx:WaitIndicatorContainer>
                    <Grid
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition
                                Width="*" />
                            <ColumnDefinition
                                Width="*" />
                        </Grid.ColumnDefinitions>
                        <ProgressBar
                            x:Name="progressBar"
                            Background="#FFFFFFFF"
                            BorderBrush="Red"
                            Foreground="Red"
                            BorderThickness="4"
                            Margin="12,12,8,12"
                            Width="40"
                            Height="40"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Template="{StaticResource DefaultWaitIndicator}"
                            IsIndeterminate="True" />
                        <ContentPresenter
                            Grid.Column="1"
                            Content="{TemplateBinding ActualContent}"
                            Margin="{TemplateBinding Padding}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            VerticalAlignment="Center" />
                    </Grid>
                </dx:WaitIndicatorContainer>
            </Grid>
        </ControlTemplate>
    </dx:WaitIndicator.Template>
</dx:WaitIndicator>
SAgiKPJH commented 4 months ago

Custom

<dx:WaitIndicator
    x:Class="ADC.Client.Host.Wpf.Components.Molecules.WaitIndicator"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:atoms="clr-namespace:ADC.Client.Host.Wpf.Components.Atoms"
    xmlns:local="clr-namespace:ADC.Client.Host.Wpf.Components.Molecules"
    mc:Ignorable="d"
    d:DesignHeight="450"
    d:DesignWidth="800"
    >
    <dx:WaitIndicator.Resources>
        <dxmvvm:BooleanToVisibilityConverter
            x:Key="BooleanToVisibilityConverter" />
        <SolidColorBrush
            x:Key="AccentColor"
            Color="{DynamicResource SystemAccentColor1Brush}" />
        <SolidColorBrush
            x:Key="BGColor"
            Color="{DynamicResource SystemBGColor2Brush}" />
        <SolidColorBrush
            x:Key="BGBorderBrush"
            Color="{DynamicResource MainBorderColor1Brush}" />
        <SolidColorBrush
            x:Key="FontColor"
            Color="{DynamicResource SystemTextColor1Brush}" />
    </dx:WaitIndicator.Resources>

    <dx:WaitIndicator.Template>
        <ControlTemplate
            TargetType="{x:Type dx:WaitIndicator}">
            <Grid x:Name="Root"
                Margin="{TemplateBinding ContentPadding}"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup
                        x:Name="Visibility">
                        <VisualState
                            x:Name="Visible">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                                    Storyboard.TargetName="Root"
                                    Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame
                                        KeyTime="0:0:0.1">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState
                            x:Name="Collapsed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                                    Storyboard.TargetName="Root"
                                    Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame
                                        KeyTime="0:0:0.2">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>

                <dx:WaitIndicatorContainer>
                    <StackPanel
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Center">
                        <TextBlock
                            HorizontalAlignment="Center"
                            FontFamily="Segoe UI Variable"
                            FontSize="21"
                            Foreground="{DynamicResource FontColor}"
                            Text="{Binding Title, RelativeSource={RelativeSource AncestorType=local:WaitIndicator}}" />
                        <ProgressBar
                            Height="4"
                            Margin="36 0 36 0"
                            BorderThickness="0"
                            Background="Transparent"
                            BorderBrush="Transparent"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Center"
                            IsIndeterminate="True" />
                    </StackPanel>

                    <dx:WaitIndicatorContainer.Template>
                        <ControlTemplate
                            TargetType="{x:Type dx:WaitIndicatorContainer}">

                            <Border
                                Width="300"
                                Height="90"
                                CornerRadius="8"
                                BorderThickness="0.5"
                                BorderBrush="DarkGray"
                                Background="{DynamicResource BGColor}">
                                <ContentPresenter />
                            </Border>
                        </ControlTemplate>
                    </dx:WaitIndicatorContainer.Template>
                </dx:WaitIndicatorContainer>
            </Grid>
        </ControlTemplate>
    </dx:WaitIndicator.Template>
</dx:WaitIndicator>
SAgiKPJH commented 4 months ago

<dx:ThemedWindow x:Class="ADC.Client.Host.Wpf.Views.Login.LoginWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:abstraction="clr-namespace:ADC.Client.Host.Wpf.Abstractions.MarkupExtensions" xmlns:atoms="clr-namespace:ADC.Client.Host.Wpf.Components.Atoms" xmlns:behaviors="clr-namespace:ADC.Client.Host.Wpf.Abstractions.Behaviors" xmlns:converter="clr-namespace:ADC.Client.Host.Wpf.Abstractions.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" xmlns:extension="clr-namespace:ADC.Client.Host.Wpf.Abstractions.Extensions" xmlns:local="clr-namespace:ADC.Client.Host.Wpf.Views.Login" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:molecules="clr-namespace:ADC.Client.Host.Wpf.Components.Molecules" xmlns:organisms="clr-namespace:ADC.Client.Host.Wpf.Views.Login.Organisms" xmlns:setting="clr-namespace:ADC.Client.Host.Wpf.Views.Setting" xmlns:viewModels="clr-namespace:ADC.Client.Adapter.Presentation.ViewModels.Login;assembly=ADC.Client.Adapter.Presentation" Title="{extension:Localization Logins.LoginTitle}" Width="800" Height="630" d:DataContext="{d:DesignInstance {x:Type viewModels:LoginViewModel}}" d:Title="LoginTitle" DataContext="{abstraction:DependencySource Type={x:Type viewModels:LoginViewModel}}" ResizeMode="NoResize" ShowIcon="False" ShowTitle="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d">