VintaSoft Annotation .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions
<Window x:Class="DicomExample.MainWindow"
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:local="clr-namespace:DicomExample"
xmlns:ImagingControls="clr-namespace:Vintasoft.Imaging.Wpf.UI;assembly=Vintasoft.Imaging.Wpf.UI"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<ImagingControls:WpfImageViewer
Margin="194,17,160,17"
Background="Black"
Grid.Column="0"
SizeMode="BestFit"
CenterImage="True"
InputGestureCopy="{x:Null}"
InputGestureCut="{x:Null}"
InputGestureDelete="{x:Null}"
InputGestureInsert="{x:Null}"
IsKeyboardNavigationEnabled="True"
x:Name="imageViewer1" />
<Button Content="Open image" HorizontalAlignment="Left" Margin="34,46,0,0" VerticalAlignment="Top" Height="32" Width="77" Click="Button_Click"/>
</Grid>
</Window>
Here is source code of MainWindow.xaml.cs file:
using Microsoft.Win32;
using System.Windows;
using System.Windows.Input;
using Vintasoft.Imaging.Dicom.Wpf.UI.VisualTools;
using Vintasoft.Imaging.UI;
using Vintasoft.Imaging.Wpf.UI.VisualTools;
namespace DicomExample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// create DICOM visual tool
WpfDicomViewerTool dicomViewerTool = new WpfDicomViewerTool();
// specify that DICOM visual tool should change window level in DICOM image when right mouse button is used
dicomViewerTool.SetInteractionMode(VintasoftMouseButtons.Right, DicomViewerToolInteractionMode.WindowLevel);
// specify that DICOM visual tool should zoom DICOM image when mouse wheel is used
dicomViewerTool.MouseWheelInteractionMode = DicomViewerToolMouseWheelInteractionMode.Zoom;
// set cursor for action that changes window level in DICOM image
dicomViewerTool.WindowLevelCursor = Cursors.Pen;
// create pan tool
WpfPanTool panTool = new WpfPanTool();
// create composite visual tool, which combines pan tool and DICOM viewer tool, and set visual tool as current visual tool of image viewer
imageViewer1.VisualTool = new WpfCompositeVisualTool(panTool, dicomViewerTool);
// disable scrolling in image viewer
imageViewer1.AutoScroll = false;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openDicomFileDialog = new OpenFileDialog();
if (openDicomFileDialog.ShowDialog() == true)
{
imageViewer1.Images.Add(openDicomFileDialog.FileName);
}
}
}
}
Please let me know if you will have any question or problem.