Skip to content

Commit 58e3592

Browse files
committed
get mouse point on mouse down
1 parent abef175 commit 58e3592

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

IconPopup.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
Title="IconPopup" Opacity="1" Background="Transparent" AllowsTransparency="True" WindowStyle="None" ResizeMode="NoResize" Width="33" Height="32" Closed="OnClosed" Focusable="False" Topmost="True" ShowActivated="False" ShowInTaskbar="False">
88
<Grid MouseEnter="Icon_OnMouseEnter" MouseLeave="Icon_OnMouseLeave">
99
<Image x:Name="Icon" Source="/images/icon-circle.png" Cursor="Hand" HorizontalAlignment="Center" Margin="2,2,2,2" RenderOptions.BitmapScalingMode="HighQuality" MouseLeftButtonDown="OnLeftMouseDown" VerticalAlignment="Center" />
10-
<!--<Image x:Name="Image2" Source="/images/translate-circle.png" Cursor="Hand" HorizontalAlignment="Right" Margin="0,2,2,2" RenderOptions.BitmapScalingMode="HighQuality" MouseLeftButtonUp="OnTranslateClick" />-->
1110
</Grid>
1211
</Window>

IconPopup.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public IconPopup()
3838
InitializeComponent();
3939

4040
// Create a timer
41-
_stayTimer = new Timer(2000);
41+
_stayTimer = new Timer(1111);
4242
// Hook up the Elapsed event for the timer.
4343
_stayTimer.Elapsed += OnStayTimedEvent;
4444

MainWindow.xaml.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public partial class MainWindow
3636
{
3737
public static TaskbarIcon NotifyIcon;
3838

39+
private static POINT p;
40+
3941
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
4042
private readonly IKeyboardMouseEvents _globalMouseKeyHook;
4143

@@ -113,6 +115,11 @@ private async void AfterKeySequence()
113115
if (Clipboard.ContainsText()) ProcessText(Clipboard.GetText());
114116
}
115117

118+
[DllImport("user32.dll")]
119+
[Obsolete]
120+
private static extern bool GetCursorPos(out POINT lpPoint);
121+
122+
[Obsolete]
116123
private static async void OnMouseDownExt(object sender, MouseEventArgs e)
117124
{
118125
if (e.Clicks != 1) return;
@@ -121,6 +128,8 @@ private static async void OnMouseDownExt(object sender, MouseEventArgs e)
121128
Application.Current.Windows
122129
.Cast<Window>()
123130
.LastOrDefault(window => window is IconPopup)?.Close();
131+
132+
GetCursorPos(out p);
124133
}
125134

126135
private static void OnMouseWheel(object sender, MouseEventArgs e)
@@ -130,10 +139,6 @@ private static void OnMouseWheel(object sender, MouseEventArgs e)
130139
.LastOrDefault(window => window is IconPopup)?.Close();
131140
}
132141

133-
[DllImport("user32.dll")]
134-
[Obsolete]
135-
private static extern bool GetCursorPos(out POINT lpPoint);
136-
137142
[Obsolete]
138143
private void OnMouseDragFinished(object sender, MouseEventArgs e)
139144
{
@@ -154,8 +159,6 @@ private void OnMouseDragFinished(object sender, MouseEventArgs e)
154159

155160
//if (Clipboard.ContainsText())
156161

157-
GetCursorPos(out var p);
158-
159162
try
160163
{
161164
var transform = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice;

0 commit comments

Comments
 (0)