aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Editors/CanvasItemEditor.xaml
blob: 06fe70c73e6b0639cd6371a9c38e34b940bb739e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<local:ElementEditor x:Class="Tango.Editors.CanvasItemEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:gif="http://wpfanimatedgif.codeplex.com"
             xmlns:converters="clr-namespace:Tango.Editors.Converters"
             xmlns:sharedConverters="clr-namespace:Tango.Shared.Converters;assembly=Tango.Shared"
             xmlns:fa="http://schemas.fontawesome.io/icons/"
             xmlns:local="clr-namespace:Tango.Editors"
             xmlns:html="clr-namespace:TheArtOfDev.HtmlRenderer.WPF;assembly=HtmlRenderer.WPF"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="10" MinHeight="10" RenderTransformOrigin="0.5,0.5" Visibility="{Binding RelativeSource={RelativeSource Self},Path=CanvasItem.Visible,Converter={StaticResource BoolToVisibilityConverter}}" IsHitTestVisible="{Binding RelativeSource={RelativeSource Self},Path=CanvasItem.Visible}">

    <UserControl.Resources>
        <converters:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibilityConverter"></converters:InverseBoolToVisibilityConverter>
        <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter>
        <converters:DetachedConverter x:Key="DetachedConverter"></converters:DetachedConverter>
        <sharedConverters:OverlayToImageConverter x:Key="OverlayToImageConverter"></sharedConverters:OverlayToImageConverter>
        <sharedConverters:CompositeColorToColorConverter x:Key="CompositeColorToColorConverter"></sharedConverters:CompositeColorToColorConverter>

        <!--Theme-->
        <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush>
        <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush>
    </UserControl.Resources>

    <UserControl.RenderTransform>
        <TransformGroup>
            <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform>
        </TransformGroup>
    </UserControl.RenderTransform>

    <Grid>
        <Grid Visibility="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.EnableHtml,Converter={StaticResource InverseBoolToVisibilityConverter}}">
            <Grid x:Name="normalGrid">
                <Grid.Style>
                    <Style TargetType="Grid">
                        <Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.OverlayPadding}"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.ItemOverlay}" Value="None">
                                <Setter Property="Margin" Value="0"></Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <Image Stretch="Fill" gif:ImageBehavior.AnimatedSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.CompositeImage.Image}"  RenderOptions.BitmapScalingMode="Fant"></Image>
                <fa:ImageAwesome Foreground="DimGray" Stretch="Fill" Icon="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.DefaultIcon}">
                    <fa:ImageAwesome.Style>
                        <Style TargetType="fa:ImageAwesome">
                            <Setter Property="Visibility" Value="Hidden"></Setter>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.CompositeImage.Image}" Value="{x:Null}">
                                    <Setter Property="Visibility" Value="Visible"></Setter>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </fa:ImageAwesome.Style>
                </fa:ImageAwesome>
            </Grid>

            <Grid>
                <Grid.Style>
                    <Style TargetType="Grid">
                        <Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.OverlayPadding}"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.ItemOverlay}" Value="None">
                                <Setter Property="Margin" Value="0"></Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <ContentControl x:Name="customContent" IsHitTestVisible="False"></ContentControl>
            </Grid>

            <Image RenderOptions.BitmapScalingMode="Fant" Source="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.ItemOverlay,Converter={StaticResource OverlayToImageConverter}}" Stretch="Fill" IsHitTestVisible="False"></Image>

            <!--Labels-->

            <!--Bottom-->
            <Label Margin="-10 0 -10 -105" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="100" Padding="0" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" IsHitTestVisible="False" DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem}" FontSize="{Binding LabelFontSize}" FontFamily="{Binding LabelFontFamily}">
                <Label.Foreground>
                    <SolidColorBrush Color="{Binding LabelColor,Converter={StaticResource CompositeColorToColorConverter}}"></SolidColorBrush>
                </Label.Foreground>
                <Label.Style>
                    <Style TargetType="Label">
                        <Setter Property="Visibility" Value="Hidden"></Setter>
                        <Setter Property="Effect" Value="{x:Null}"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding LabelPosition}" Value="Bottom">
                                <Setter Property="Visibility" Value="Visible"></Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding LabelDropShadow}" Value="True">
                                <Setter Property="Effect">
                                    <Setter.Value>
                                        <DropShadowEffect BlurRadius="10"></DropShadowEffect>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
                <TextBlock TextAlignment="Center" Text="{Binding Label}" TextWrapping="Wrap"></TextBlock>
            </Label>

            <!--Top-->
            <Label Margin="-10 -105 -10 0" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="100" Padding="0" VerticalContentAlignment="Bottom" HorizontalContentAlignment="Center" IsHitTestVisible="False" DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem}" FontSize="{Binding LabelFontSize}" FontFamily="{Binding LabelFontFamily}">
                <Label.Foreground>
                    <SolidColorBrush Color="{Binding LabelColor,Converter={StaticResource CompositeColorToColorConverter}}"></SolidColorBrush>
                </Label.Foreground>
                <Label.Style>
                    <Style TargetType="Label">
                        <Setter Property="Visibility" Value="Hidden"></Setter>
                        <Setter Property="Effect" Value="{x:Null}"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding LabelPosition}" Value="Top">
                                <Setter Property="Visibility" Value="Visible"></Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding LabelDropShadow}" Value="True">
                                <Setter Property="Effect">
                                    <Setter.Value>
                                        <DropShadowEffect BlurRadius="10"></DropShadowEffect>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
                <TextBlock TextAlignment="Center" Text="{Binding Label}" TextWrapping="Wrap"></TextBlock>
            </Label>

            <!--Right-->
            <Label Margin="0 0 -305 0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="300" Height="100" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Padding="0" IsHitTestVisible="False" DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem}" FontSize="{Binding LabelFontSize}" FontFamily="{Binding LabelFontFamily}">
                <Label.Foreground>
                    <SolidColorBrush Color="{Binding LabelColor,Converter={StaticResource CompositeColorToColorConverter}}"></SolidColorBrush>
                </Label.Foreground>
                <Label.Style>
                    <Style TargetType="Label">
                        <Setter Property="Visibility" Value="Hidden"></Setter>
                        <Setter Property="Effect" Value="{x:Null}"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding LabelPosition}" Value="Right">
                                <Setter Property="Visibility" Value="Visible"></Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding LabelDropShadow}" Value="True">
                                <Setter Property="Effect">
                                    <Setter.Value>
                                        <DropShadowEffect BlurRadius="10"></DropShadowEffect>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
                <TextBlock TextAlignment="Left" Text="{Binding Label}" TextWrapping="Wrap"></TextBlock>
            </Label>

            <!--Left-->
            <Label Margin="-305 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" Width="300" Height="100" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" Padding="0" IsHitTestVisible="False" DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem}" FontSize="{Binding LabelFontSize}" FontFamily="{Binding LabelFontFamily}">
                <Label.Foreground>
                    <SolidColorBrush Color="{Binding LabelColor,Converter={StaticResource CompositeColorToColorConverter}}"></SolidColorBrush>
                </Label.Foreground>
                <Label.Style>
                    <Style TargetType="Label">
                        <Setter Property="Visibility" Value="Hidden"></Setter>
                        <Setter Property="Effect" Value="{x:Null}"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding LabelPosition}" Value="Left">
                                <Setter Property="Visibility" Value="Visible"></Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding LabelDropShadow}" Value="True">
                                <Setter Property="Effect">
                                    <Setter.Value>
                                        <DropShadowEffect BlurRadius="10"></DropShadowEffect>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
                <TextBlock TextAlignment="Right" Text="{Binding Label}" TextWrapping="Wrap"></TextBlock>
            </Label>
        </Grid>

        <Grid Visibility="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.EnableHtml,Converter={StaticResource BoolToVisibilityConverter}}">
            <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.HtmlScalingMode}" Width="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" Height="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualHeight}">
                <html:HtmlPanel Background="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" x:Name="html" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=CanvasItem.HtmlContent}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalContentAlignment="Top"></html:HtmlPanel>
            </Viewbox>
        </Grid>

        <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected),Converter={StaticResource BoolToVisibilityConverter}}">
            <Grid>
                <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=InnerContent}"></ContentPresenter>

                <Thumb Opacity="0" DragDelta="MoveDrag" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
                <Thumb HorizontalAlignment="Left" Cursor="SizeWE" Opacity="0" DragDelta="DragLeft" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
                <Thumb HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" DragDelta="DragRight" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
                <Thumb VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" DragDelta="DragTop" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
                <Thumb VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" DragDelta="DragBottom" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>

                <Grid ClipToBounds="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 -20 0 0" Width="10" Height="10">
                    <Ellipse Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" StrokeThickness="2"></Ellipse>
                    <Rectangle HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0 10 0 -8" StrokeThickness="1" Stroke="Red"></Rectangle>
                    <Thumb Opacity="0" DragDelta="DragAngle" DragStarted="DragStarted" Cursor="Arrow" DragCompleted="OnDragEnded"></Thumb>
                </Grid>

                <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-8 -8 0 0">
                    <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 2 0 0"></Border>
                    <Thumb Opacity="0" DragDelta="DragTopLeft" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb>
                </Grid>

                <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 -8 -8 0">
                    <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 2 2 0"></Border>
                    <Thumb Opacity="0" DragDelta="DragTopRight" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb>
                </Grid>

                <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -8 -8">
                    <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 0 2 2"></Border>
                    <Thumb Opacity="0" DragDelta="DragBottomRight" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb>
                </Grid>

                <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="-8 0 0 -8">
                    <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 0 0 2"></Border>
                    <Thumb Opacity="0" DragDelta="DragBottomLeft" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</local:ElementEditor>