领胜LDS 键盘AOI检测项目
xcd
2020-06-24 d6c577e17ee7bb5331dd51d803f9b42441b0f0e5
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Bro.Common.ImageCanvas">
 
    <!--
        Default style and template for the ZoomAndPanControl.
    -->
    <Style TargetType="{x:Type local:ZoomAndPanControl}">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="#80C0C0C0" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ZoomAndPanControl}">
                    <Grid>
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
 
                            <!--
                                The ContentPresenter is used to scale and offset the content of ZoomAndPanControl.
                                
                                A transforms computed from 'ViewportZoom', 'ContentOffsetX' and 'ContentOffsetY' are assigned
                                to the 'RenderTransform' property in OnApplyTemplate in ZoomAndPanControl.cs.
                                
                                The alignment is set to top-left.  This allows the content offset to be used to place
                                the content in the center of the viewport when the viewport is bigger than the content.
                            -->
                            <ContentPresenter x:Name="PART_Content"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top" />
 
                        </Border>
 
                        <Canvas x:Name="PART_DragZoomCanvas"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Visibility="Collapsed">
                            <Border x:Name="PART_DragZoomBorder"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="1" />
                        </Canvas>
                    </Grid>
                </ControlTemplate>
 
            </Setter.Value>
        </Setter>
    </Style>
 
    <Style TargetType="{x:Type local:ZoomAndPanScrollViewer}">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="#80C0C0C0" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ZoomAndPanScrollViewer}">
                    <ScrollViewer x:Name="PART_ZoomAndPanScrollViewer"
                                  CanContentScroll="True"
                                  HorizontalScrollBarVisibility="Auto"
                                  VerticalScrollBarVisibility="Auto">
                        <local:ZoomAndPanControl x:Name="PART_ZoomAndPanControl"
                                                 Background="{TemplateBinding Background}"
                                                 BorderBrush="{TemplateBinding BorderBrush}"
                                                 BorderThickness="{TemplateBinding BorderThickness}"
                                                 MinimumZoomType="{TemplateBinding MinimumZoomType}"
                                                 MousePosition="{Binding RelativeSource={RelativeSource TemplatedParent}, Mode=OneWayToSource, Path=MousePosition}"
                                                 UseAnimations="{Binding RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, Path=UseAnimations}"
                                                 ViewportZoom="{Binding RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Path=ViewportZoom}"
                                                 ZoomAndPanInitialPosition="{TemplateBinding ZoomAndPanInitialPosition}">
                            <ContentPresenter HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Content="{TemplateBinding Content}" />
 
                        </local:ZoomAndPanControl>
                    </ScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
 
    <!--
        Default style and template for the ZoomAndPanViewBox.
    -->
    <Style TargetType="{x:Type local:ZoomAndPanViewBox}">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="#80C0C0C0" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ZoomAndPanViewBox}">
                    <Viewbox>
                        <Canvas Name="PART_Content"
                                Width="{Binding Path=Content.ActualWidth}"
                                Height="{Binding Path=Content.ActualHeight}">
                            <Border Name="PART_DraggingBorder"
                                    Canvas.Left="{Binding Path=ZoomAndPanContent.ContentOffsetX, Mode=TwoWay}"
                                    Canvas.Top="{Binding Path=ZoomAndPanContent.ContentOffsetY, Mode=TwoWay}"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="10"
                                    CornerRadius="1">
                                <Border.Width>
                                    <MultiBinding Converter="{local:ZoomAndPanViewBoxClampConverter}" ConverterParameter="width">
                                        <Binding Mode="OneWay" Path="ZoomAndPanContent.ContentViewportWidth" />
                                        <Binding Mode="OneWay" Path="ZoomAndPanContent.ContentOffsetX" />
                                        <Binding Mode="OneWay" Path="ZoomAndPanContent.ViewportZoom" />
                                        <Binding Path="ZoomAndPanContent" />
                                    </MultiBinding>
                                </Border.Width>
                                <Border.Height>
                                    <MultiBinding Converter="{local:ZoomAndPanViewBoxClampConverter}" ConverterParameter="height">
                                        <Binding Mode="OneWay" Path="ZoomAndPanContent.ContentViewportHeight" />
                                        <Binding Mode="OneWay" Path="ZoomAndPanContent.ContentOffsetY" />
                                        <Binding Mode="OneWay" Path="ZoomAndPanContent.ViewportZoom" />
                                        <Binding Path="ZoomAndPanContent" />
                                    </MultiBinding>
                                </Border.Height>
                            </Border>
                            <Border Name="PART_SizingBorder"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="10"
                                    CornerRadius="1"
                                    Visibility="Hidden" />
                        </Canvas>
                    </Viewbox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>