Archived
Renamed Examples to Implementation
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<UserControl
|
||||
x:Class="Ocr.Gui.Controls.ImageControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:converters="clr-namespace:Ocr.Gui.Converters"
|
||||
xmlns:controls="clr-namespace:Ocr.Gui.Controls"
|
||||
d:DataContext="{d:DesignInstance controls:ImageControl}"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<converters:ImageConverter x:Key="Converter.CImage" />
|
||||
|
||||
<ControlTemplate x:Key="ControlTemplate.ImageControl.Default" TargetType="controls:ImageControl">
|
||||
<Border DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
|
||||
Padding="4"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<Image RenderOptions.BitmapScalingMode="NearestNeighbor"
|
||||
Stretch="Uniform"
|
||||
Source="{Binding Image, Converter={StaticResource Converter.CImage}}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="Style.ImageControl.Default" TargetType="controls:ImageControl">
|
||||
<Setter Property="Template" Value="{StaticResource ControlTemplate.ImageControl.Default}" />
|
||||
</Style>
|
||||
|
||||
<Style BasedOn="{StaticResource Style.ImageControl.Default}" TargetType="controls:ImageControl" />
|
||||
</UserControl.Resources>
|
||||
<Grid />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,44 @@
|
||||
using ImageMagick;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Ocr.Gui.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for ImageControl.xaml
|
||||
/// </summary>
|
||||
public partial class ImageControl : UserControl
|
||||
{
|
||||
/// <inheritdoc cref="Image"/>
|
||||
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
|
||||
nameof(Image), typeof(MagickImage), typeof(ImageControl), new PropertyMetadata(default(MagickImage)));
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="MagickImage"/> displayed in this <see cref="ImageControl"/>
|
||||
/// </summary>
|
||||
public MagickImage Image
|
||||
{
|
||||
get => (MagickImage)GetValue(ImageProperty);
|
||||
set => SetValue(ImageProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ImageName"/>
|
||||
public static readonly DependencyProperty ImageNameProperty = DependencyProperty.Register(
|
||||
nameof(ImageName), typeof(object), typeof(ImageControl),
|
||||
new PropertyMetadata(default(object)));
|
||||
|
||||
/// <summary>
|
||||
/// The name of the loaded image
|
||||
/// </summary>
|
||||
public object ImageName
|
||||
{
|
||||
get => (object)GetValue(ImageNameProperty);
|
||||
set => SetValue(ImageNameProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user