LEADTOOLS WPFとSilverlight(Leadtools.Windows.Controlsアセンブリ)

フレームを表示

ImageBoxクラス






メンバ 
WPF/Silverlight System.Windows.Media.ImageSourceを示すコントロールを表します。
オブジェクトモデル
構文
解説

ImageBoxクラスは、WPF/Silverlight System.Windows.Media.ImageSourceまたはその派生クラスの1つを示すのを可能にします。LEADTOOLS Leadtools.RasterImageを示すために、RasterImageBoxコントロールを使います。

背景画像(すなわちスクロールすることを必要としないimageまたはWPF/Silverlightアプリケーションの他のどのインタラクティブ操作)を表示したいとき、このコントロールは適当です。そのようなインタラクティブ操作が必要とされるならば、ImageViewerを使います、さもなければ、RasterImageViewerは制御します。

imageコンテンツがロードされるまで、imageコンテンツがコントロールの最終的なサイズと位置を決定するのに用いられるので、コントロールのSystem.Windows.FrameworkElement.ActualWidthSystem.Windows.FrameworkElement.ActualHeightはゼロとして報告します。

固定粒度調整のために、System.Windows.FrameworkElement.WidthSystem.Windows.FrameworkElement.Heightプロパティは、設定されることができます。しかし、メディアのアスペクト比を保存するために、両方ともでなくSystem.Windows.FrameworkElement.WidthまたはSystem.Windows.FrameworkElement.Heightプロパティを設定します。

ImageBoxコントロールサポートが、以下の機能性:です

サンプル
Copy Code  
Imports Leadtools.Windows.Controls

Private Class MyWindow1 : Inherits Window
    Private theImage As ImageBox
    Public Sub New()
        ' Create the  viewer
        theImage = New ImageBox()

        ' Create Dock Panel

        Dim panel As DockPanel = New DockPanel()
        Content = panel

        DockPanel.SetDock(theImage, Dock.Bottom)

        theImage.HorizontalAlignment = HorizontalAlignment.Center
        theImage.VerticalAlignment = VerticalAlignment.Bottom
        theImage.UseDpi = True
        theImage.ScreenDpiX = 96
        theImage.ScreenDpiY = 96

        panel.Children.Add(theImage)

        ' load an image into the viewer
        theImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))

        Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)

        AddHandler theImage.MouseDown, AddressOf theImage_MouseClick
    End Sub

    Private Sub theImage_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
        Select Case theImage.SizeMode
            Case SizeMode.Normal
                theImage.SizeMode = SizeMode.Stretch

            Case SizeMode.Stretch
                theImage.SizeMode = SizeMode.Fit

            Case SizeMode.Fit
                theImage.SizeMode = SizeMode.FitAlways

            Case SizeMode.FitAlways
                theImage.SizeMode = SizeMode.FitWidth

            Case SizeMode.FitWidth
                theImage.SizeMode = SizeMode.Normal
        End Select

        Title = String.Format("Size mode = {0}, double click to change", theImage.SizeMode)

    End Sub
End Class

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools.Help;
using Leadtools.Windows.Controls;

class MyWindow1 : Window
{
   ImageBox theImage;
   public MyWindow1()
   {
      // Create the  viewer
      theImage = new ImageBox();

      // Create Dock Panel

      DockPanel panel = new DockPanel();
      Content = panel;

      DockPanel.SetDock(theImage, Dock.Bottom);

      theImage.HorizontalAlignment = HorizontalAlignment.Center;
      theImage.VerticalAlignment= VerticalAlignment.Bottom;
      theImage.UseDpi = true;
      theImage.ScreenDpiX = 96;
      theImage.ScreenDpiY = 96;

      panel.Children.Add(theImage);

      // load an image into the viewer
      theImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));

      Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);

      theImage.MouseDown += new MouseButtonEventHandler(theImage_MouseClick);
   }

   void theImage_MouseClick(object sender, MouseButtonEventArgs e)
   {
      switch(theImage.SizeMode)
      {
         case SizeMode.Normal:
            theImage.SizeMode = SizeMode.Stretch;
            break;

         case SizeMode.Stretch:
            theImage.SizeMode = SizeMode.Fit;
            break;

         case SizeMode.Fit:
            theImage.SizeMode = SizeMode.FitAlways;
            break;

         case SizeMode.FitAlways:
            theImage.SizeMode = SizeMode.FitWidth;
            break;

         case SizeMode.FitWidth:
            theImage.SizeMode = SizeMode.Normal;
            break;
      }

      Title = string.Format("Size mode = {0}, double click to change", theImage.SizeMode);

   }
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Help;
using Leadtools.Windows.Controls;

class MyWindow1 : ChildWindow
{
   ImageBox theImage;
   public MyWindow1()
   {
      // Create the  viewer
      theImage = new ImageBox();

      // Create Dock Panel

      StackPanel panel = new StackPanel();
      Content = panel;

      theImage.HorizontalAlignment = HorizontalAlignment.Center;
      theImage.VerticalAlignment= VerticalAlignment.Bottom;
      theImage.UseDpi = true;
      theImage.ScreenDpiX = 96;
      theImage.ScreenDpiY = 96;

      panel.Children.Add(theImage);

      // load an image into the viewer
      theImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));

      Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);

      theImage.MouseLeftButtonDown +=new MouseButtonEventHandler(theImage_MouseLeftButtonDown);
   }

   void theImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
   {
      switch (theImage.SizeMode)
      {
         case SizeMode.Normal:
            theImage.SizeMode = SizeMode.Stretch;
            break;

         case SizeMode.Stretch:
            theImage.SizeMode = SizeMode.Fit;
            break;

         case SizeMode.Fit:
            theImage.SizeMode = SizeMode.FitAlways;
            break;

         case SizeMode.FitAlways:
            theImage.SizeMode = SizeMode.FitWidth;
            break;

         case SizeMode.FitWidth:
            theImage.SizeMode = SizeMode.Normal;
            break;
      }

      Title = string.Format("Size mode = {0}, double click to change", theImage.SizeMode);
   }
}
Imports Leadtools.Windows.Controls

Private Class MyWindow1 : Inherits ChildWindow
   Private theImage As ImageBox
   Public Sub New()
      ' Create the  viewer
      theImage = New ImageBox()

      ' Create Dock Panel

      Dim panel As StackPanel = New StackPanel()
      Content = panel

      theImage.HorizontalAlignment = HorizontalAlignment.Center
      theImage.VerticalAlignment= VerticalAlignment.Bottom
      theImage.UseDpi = True
      theImage.ScreenDpiX = 96
      theImage.ScreenDpiY = 96

      panel.Children.Add(theImage)

      ' load an image into the viewer
      theImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))

      Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)

      AddHandler theImage.MouseLeftButtonDown, AddressOf theImage_MouseLeftButtonDown
   End Sub

   Private Sub theImage_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
      Select Case theImage.SizeMode
         Case SizeMode.Normal
            theImage.SizeMode = SizeMode.Stretch

         Case SizeMode.Stretch
            theImage.SizeMode = SizeMode.Fit

         Case SizeMode.Fit
            theImage.SizeMode = SizeMode.FitAlways

         Case SizeMode.FitAlways
            theImage.SizeMode = SizeMode.FitWidth

         Case SizeMode.FitWidth
            theImage.SizeMode = SizeMode.Normal
      End Select

      Title = String.Format("Size mode = {0}, double click to change", theImage.SizeMode)
   End Sub
End Class
<!--WPF example-->
 <Window x:Class="WPFSamples.ImageBox"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"
 Height="600" Width="800">
   <DockPanel>
     <Leadtools_Windows_Controls:ImageBox
     Name="theImage"
   Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg"
   DockPanel.Dock= "Bottom"
   HorizontalAlignment="Center" VerticalAlignment="Bottom" SizeMode="Fit" UseDpi="true">

     </Leadtools_Windows_Controls:ImageBox >
   </DockPanel>
   <Window.Title>
     "Apply a effect"
   </Window.Title>
 </Window>
 
 <!--Silverlight example-->
 <UserControl x:Class="SilverlightApplication1.MainPage"
 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:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"
 mc:Ignorable="d"
 d:DesignHeight="300" d:DesignWidth="400">
   <Grid x:Name="LayoutRoot" Background="White">
      <Leadtools_Windows_Controls:ImageBox Name="theImage" Source="http://www.MyServer.com/images/MyImage.png" HorizontalAlignment="Center" VerticalAlignment="Bottom" SizeMode="Fit" UseDpi="true">
      </Leadtools_Windows_Controls:ImageBox >
   </Grid>
</UserControl>
必要条件

ターゲットプラットホーム

参照

参照

ImageBoxメンバ
Leadtools.Windows.Controls名前空間
RasterImageとWPF/Silverlight