첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    WindowStartupLocation="CenterScreen"
    Width="800"
    Height="600"
    Title="Thumb 클래스 : 객체 이동하기/크기 조정하기/회전하기"
    Background="#303030"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Resource/DesignerItem.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <CheckBox
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Margin="20 20 0 0"
            Foreground="LightGray"
            Content="Select"
            Click="checkBox_Click" />
        <Canvas x:Name="canvas"
            ClipToBounds="True"
            SnapsToDevicePixels="True">
            <!--Blue Ellipse -->
            <ContentControl Canvas.Left="650" Canvas.Top="300"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="100"
                Height="100"
                Padding="1">
                <Ellipse IsHitTestVisible="False">
                    <Shape.Fill>
                        <RadialGradientBrush
                            Center="0.2 0.2"
                            RadiusX="0.8"
                            RadiusY="0.8"
                            GradientOrigin="0.2 0.2">
                            <GradientStop Color="LightBlue" Offset="0"   />
                            <GradientStop Color="Blue"      Offset="0.9" />
                        </RadialGradientBrush>
                    </Shape.Fill>
                </Ellipse>
            </ContentControl>
            <!-- Green Ellipse -->
            <ContentControl Canvas.Left="590" Canvas.Top="320"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="100"
                Height="100"
                Padding="1">
                <Ellipse IsHitTestVisible="False">
                    <Shape.Fill>
                        <RadialGradientBrush
                            Center="0.2 0.2"
                            RadiusX="0.8"
                            RadiusY="0.8"
                            GradientOrigin="0.2 0.2">
                            <GradientStop Color="Lime"      Offset="0"   />
                            <GradientStop Color="#ff00aa00" Offset="0.9" />
                        </RadialGradientBrush>
                    </Shape.Fill>
                </Ellipse>
            </ContentControl>
            <!-- Oragne Ellipse -->
            <ContentControl Canvas.Left="645" Canvas.Top="370"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="100"
                Height="100"
                Padding="1">
                <Ellipse IsHitTestVisible="False">
                    <Shape.Fill>
                        <RadialGradientBrush
                            Center="0.2 0.2"
                            RadiusX="0.8"
                            RadiusY="0.8"
                            GradientOrigin="0.2 0.2">
                            <GradientStop Color="White"     Offset="0"   />
                            <GradientStop Color="#ffff8300" Offset="0.9" />
                        </RadialGradientBrush>
                    </Shape.Fill>
                </Ellipse>
            </ContentControl>
            <!-- Cross Image -->
            <ContentControl Canvas.Left="210" Canvas.Top="220"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="100"
                Height="100">
                <Image
                    Stretch="Fill"
                    IsHitTestVisible="False"
                    Source="Media/cross.png" />
            </ContentControl>
            <!-- Paint Image -->
            <ContentControl Canvas.Left="75" Canvas.Top="385"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="100"
                Height="100">
                <Image
                    Stretch="Fill"
                    IsHitTestVisible="False"
                    Source="Media/paint.png"/>
            </ContentControl>
            <!-- Satelite -->
            <ContentControl Canvas.Left="50" Canvas.Top="75"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="130"
                Height="130">
                <ContentControl.Resources>
                    <Storyboard x:Key="SateliteStoryboardKey" >
                        <DoubleAnimation
                            From="0"
                            To="360"
                            AutoReverse="False"
                            RepeatBehavior="Forever"
                            Duration="00:00:20"
                            Storyboard.TargetName="rotation"
                            Storyboard.TargetProperty="Angle">
                        </DoubleAnimation>
                    </Storyboard>
                </ContentControl.Resources>
                <Viewbox Stretch="Fill">
                    <Label Name="label"
                        RenderTransformOrigin="0.5 0.5"
                        IsHitTestVisible="False"
                        Foreground="Yellow"
                        FontFamily="Webdings"
                        FontSize="200"
                        Content="">
                        <Label.RenderTransform>
                            <RotateTransform x:Name="rotation" />
                        </Label.RenderTransform>
                    </Label>
                </Viewbox>
                <ContentControl.Triggers>
                    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                        <BeginStoryboard Storyboard="{StaticResource SateliteStoryboardKey}" />
                    </EventTrigger>
                </ContentControl.Triggers>
            </ContentControl>
            <!-- Media -->
            <ContentControl Canvas.Left="640" Canvas.Top="80"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="130"
                Height="130"
                Padding="2">
                <Grid>
                    <Border
                        BorderBrush="#e0e0e0"
                        BorderThickness="0 1 0 0"
                        CornerRadius="5"
                        Background="{DynamicResource FrameBackgroundLinearGradientBrushKey}"
                        IsHitTestVisible="False"/>
                    <Border
                        BorderBrush="Black"
                        BorderThickness="0 0 0 1"
                        CornerRadius="5" />
                    <Border
                        Margin="5 5 5 25"
                        CornerRadius="0"
                        Background="Transparent"
                        IsHitTestVisible="False" />
                    <Border
                        Margin="5 5 5 25"
                        BorderBrush="#e0e0e0"
                        BorderThickness="0 0 1 1"
                        CornerRadius="0" />
                    <Border
                        Margin="5 5 5 25"
                        BorderBrush="#303030"
                        BorderThickness="1 1 0 0"
                        CornerRadius="0">
                        <MediaElement Name="mediaElement"
                            Margin="0 0 1 1"
                            Stretch="Fill"
                            IsHitTestVisible="False">
                            <MediaElement.Triggers>
                                <EventTrigger RoutedEvent="MediaElement.Loaded">
                                    <EventTrigger.Actions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <MediaTimeline
                                                    Storyboard.TargetName="mediaElement"
                                                    RepeatBehavior="Forever"
                                                    Source="./media/intro.wmv" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger.Actions>
                                </EventTrigger>
                            </MediaElement.Triggers>
                        </MediaElement>
                    </Border>
                </Grid>
            </ContentControl>
            <!-- TextBox -->
            <ContentControl Canvas.Left="360" Canvas.Top="60"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="130"
                Height="130"
                Padding="2">
                <Grid>
                    <Border
                        BorderBrush="#e0e0e0"
                        BorderThickness="0 1 0 0"
                        CornerRadius="5"
                        Background="{DynamicResource FrameBackgroundLinearGradientBrushKey}"
                        IsHitTestVisible="False" />
                    <Border
                        BorderBrush="Black"
                        BorderThickness="0 0 0 1"
                        CornerRadius="5" />
                    <Border
                        Margin="5 5 5 25"
                        CornerRadius="5"
                        Background="WhiteSmoke"
                        IsHitTestVisible="False" />
                    <Border
                        Margin="5 5 5 25"
                        BorderBrush="White"
                        BorderThickness="0 0 1 1"
                        CornerRadius="5" />
                    <Border
                        Margin="5 5 5 25"
                        BorderBrush="Black"
                        BorderThickness="1 1 0 0"
                        CornerRadius="5">
                        <TextBox
                            Margin="1 1 0 0"
                            BorderThickness="0"
                            Background="Transparent"
                            Foreground="DimGray"
                            FontSize="11"
                            TextWrapping="Wrap"
                            AcceptsReturn="True"
                            Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." />
                    </Border>
                </Grid>
            </ContentControl>
            <!-- ECG -->
            <ContentControl Canvas.Left="380" Canvas.Top="340"
                Style="{StaticResource DesignerItemStyleKey}"
                Width="130"
                Height="130"
                Padding="2">
                <Grid IsHitTestVisible="False">
                    <Border
                        BorderBrush="#e0e0e0"
                        BorderThickness="0 1 0 0"
                        CornerRadius="5"
                        Background="{DynamicResource FrameBackgroundLinearGradientBrushKey}" />
                    <Border
                        BorderBrush="Black"
                        BorderThickness="0 0 0 1"
                        CornerRadius="5" />
                    <Border
                        Margin="5 5 5 25"
                        CornerRadius="5"
                        Background="{StaticResource GridDrawingBrushKey}"
                        IsHitTestVisible="False" />
                    <Border
                        Margin="5 5 5 25"
                        BorderBrush="#e0e0E0"
                        BorderThickness="0 0 1 1"
                        CornerRadius="5" />
                    <Border
                        Margin="5 5 5 25"
                        BorderBrush="#303030"
                        BorderThickness="1 1 0 0"
                        CornerRadius="5">
                        <Grid>
                            <Grid.Resources>
                                <Style TargetType="Line">
                                    <Setter Property="Stroke"  Value="Lime" />
                                    <Setter Property="Opacity" Value="0.5"  />
                                </Style>
                                <Storyboard x:Key="OnLoadedStoryboardKey">
                                    <DoubleAnimation
                                        From="0"
                                        To="1.0"
                                        RepeatBehavior="Forever"
                                        Duration="00:00:2"
                                        Storyboard.TargetName="backgroundBrush"
                                        Storyboard.TargetProperty="GradientStops[2].Offset">
                                    </DoubleAnimation>
                                    <DoubleAnimation
                                        From="0.01"
                                        To="1.01"
                                        RepeatBehavior="Forever"
                                        Duration="00:00:2"
                                        Storyboard.TargetName="backgroundBrush"
                                        Storyboard.TargetProperty ="GradientStops[3].Offset">
                                    </DoubleAnimation>
                                    <DoubleAnimation
                                        From="-0.9"
                                        To="0.1"
                                        RepeatBehavior="Forever"
                                        Duration="00:00:2"
                                        Storyboard.TargetName="backgroundBrush"
                                        Storyboard.TargetProperty ="GradientStops[1].Offset">
                                    </DoubleAnimation>
                                </Storyboard>
                            </Grid.Resources>
                            <Grid.Triggers>
                                <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                    <BeginStoryboard Storyboard="{StaticResource OnLoadedStoryboardKey}" />
                                </EventTrigger>
                            </Grid.Triggers>
                            <Grid Background="Transparent">
                                <Border
                                    BorderBrush="#00f300"
                                    BorderThickness="0"
                                    Margin="10">
                                    <Path Name="polyLine"
                                        Margin="5"
                                        StrokeThickness="1"
                                        Stretch="Fill"
                                        Data="M 0 10 4 10 6 8 7 10 9 10 10 11 11 1 12 13 13 10 18 10
                                              21 8 24 10 30 10 34 10 36 8 37 10 39 10 40 11 41 1 42 13
                                              43 10 48 10 51 8 54 10">
                                        <Path.Stroke>
                                            <LinearGradientBrush x:Name="backgroundBrush"
                                                StartPoint="0 0"
                                                EndPoint="1 0"
                                                SpreadMethod="Repeat">
                                                <GradientStop Color="Transparent" Offset ="0.0" />
                                                <GradientStop Color="Transparent" Offset ="0.0" />
                                                <GradientStop Color="#00ff00"     Offset ="0.0" />
                                                <GradientStop Color="Transparent" Offset ="0.0" />
                                                <GradientStop Color="Transparent" Offset ="1"   />
                                            </LinearGradientBrush>
                                        </Path.Stroke>
                                    </Path>
                                </Border>
                            </Grid>
                        </Grid>
                    </Border>
                </Grid>
            </ContentControl>
        </Canvas>
    </Grid>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 체크 박스 클릭시 처리하기 - checkBox_Click(sender, e)

        /// <summary>
        /// 체크 박스 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void checkBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox checkBox = sender as CheckBox;

            if(checkBox != null && checkBox.IsChecked == true)
            {
                foreach(Control child in this.canvas.Children)
                {
                    Selector.SetIsSelected(child, true);
                }
            }
            else
            {
                foreach(Control child in this.canvas.Children)
                {
                    Selector.SetIsSelected(child, false);
                }
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요