前提・実現したいこと
ネットで拾ってきたleap motionのプログラムを書き換えてマウスカーソルの下に拡大画像が来るようにしたいと考えています
https://thinkit.co.jp/story/2013/11/11/4674?nopaging=1
どなたか知恵を貸してください
発生している問題・エラーメッセージ
ソースイメージのマウスカーソル座標に,対応したズームイメージの座標の画像(円形)を表示させたいのですが,どうしてもうまくいきません
該当のソースコード
XAML
1<Window x:Class="MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 Title="MainWindow" Height="1080" Width="1920" WindowState="Maximized"> 5 <Canvas Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="1920" Height="1080"> 6 <Image x:Name="sourceImage" HorizontalAlignment="Stretch" Height="1080" VerticalAlignment="Stretch" Width="1920" Canvas.Top="0" Source="Image/S__82993161.jpg" Canvas.Left="0"/> 7 <Image x:Name="zoomImage" Stretch="Uniform" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="1900" Height="1085" Source="Image/S__82993161.jpg" Canvas.Left="10" Canvas.Top="-15"> 8 <Image.RenderTransform> 9 <ScaleTransform ScaleX="3" ScaleY="3"/> 10 </Image.RenderTransform> 11 <Image.Clip> 12 <EllipseGeometry x:Name="Lens" RadiusX="30" RadiusY="30" Center="0.0,0.0"> 13 <EllipseGeometry.Transform> 14 <TransformGroup> 15 <ScaleTransform ScaleX="1" ScaleY="1"/> 16 <SkewTransform /> 17 <RotateTransform/> 18 <TranslateTransform/> 19 </TransformGroup> 20 </EllipseGeometry.Transform> 21 </EllipseGeometry> 22 </Image.Clip> 23 </Image> 24 <InkPresenter Name="paintCanvas"/> 25 </Canvas> 26</Window> 27
vb
1 2Imports Leap 3Imports System.Windows.Ink 4Imports System 5Imports System.Windows 6Imports System.Windows.Input 7Imports System.Windows.Media.Imaging 8Imports System.Windows.Interop 9 10 11 12 13 14 15Class MainWindow 16 Private Declare Function SetCursorPos Lib "user32" (x As Integer, y As Integer) As Boolean 17 Private Declare Function apimouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean 18 Private Const MOUSEEVENTF_LEFTDOWN = &H2 19 Private Const MOUSEEVENTF_LEFTUP = &H4 20 Private Const MOUSEEVENTF_MOVE = &H1 21 Private leap As New Controller 22 Private touchIndicator As New DrawingAttributes 23 Private touchPoint As StylusPoint 24 Private tx As Double 25 Private ty As Double 26 Private x As Integer 27 Private y As Integer 28 Private ImageX As Double 29 Private ImageY As Double 30 'Private Index As Integer 31 Private windowWidth As Double = 1920 32 Private windowHeight As Double = 1080 33 34 'Private no As Integer 35 Private FingersCount As Integer 36 37 38 39 40 Private Sub sourceImage_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles sourceImage.MouseLeftButtonDown 41 zoomImage.Visibility = Windows.Visibility.Visible 42 ImageX = e.GetPosition(sourceImage).X 43 ImageY = e.GetPosition(sourceImage).Y 44 LensPosition(ImageX, ImageY) 45 End Sub 46 47 Private Sub sourceImage_MouseMove(sender As Object, e As MouseEventArgs) Handles sourceImage.MouseMove 48 ImageX = e.GetPosition(sourceImage).X 49 ImageY = e.GetPosition(sourceImage).Y 50 Console.WriteLine(ImageX, ImageY) 51 LensPosition(ImageX, ImageY) 52 End Sub 53 54 Private Sub sourceImage_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles sourceImage.MouseLeftButtonUp 55 zoomImage.Visibility = Windows.Visibility.Collapsed 56 End Sub 57 58 59 60 Private Sub LensPosition(x As Double, y As Double) 61 Lens.Center = New Point(ImageX, ImageY) 62 63 End Sub 64 65 66End Class 67
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/10 06:54