How can I create a small menu which pop-ups next to cursor in WPF with C#. This menu will work out of the application window. For example;
I move my cursor and stop it on the desktop. When it stops, there will be a small menu which is just next to the cursor and show up.
Thanks
The CODE:
static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
public void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
{
big.Visibility = Visibility.Hidden;
myTimer.Stop();
}
public void TimerEventProcessor2(Object myObject, EventArgs myEventArgs)
{
big.Visibility = Visibility.Visible;
myTimer.Stop();
}
public MainWindow()
{
InitializeComponent();
// Sets the timer interval to 5 seconds.
myTimer.Interval = 5000;
myTimer.Start();
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Start();
myTimer.Tick += new EventHandler(TimerEventProcessor2);
}
EDIT2
This is the part of the code. I created another dispatchertimer whish has a name hidingtimer. I defined the time as 3 seconds as you see on the code. And this timer calls deneme_Tick then I do the same things as HideWindow() in your code.
timer.Interval = new TimeSpan(0, 0, 0, 1);
timer.Tick += (sd, args) =>
{
movingCount++;
if (movingCount >= menuShowDelay)
{
this.Visibility = System.Windows.Visibility.Visible;
mouse.Enabled = false;
timer.Stop();
this.Left = mouseLeft;
this.Top = mouseTop;
this.Topmost = true;
hidingtimer.Interval = new TimeSpan(0, 0, 0, 3);
hidingtimer.Start();
hidingtimer.Tick += new EventHandler(deneme_Tick);
movingCount = 0;
}
};
(sorry for my bad english)
This is how I would do it:
If you need more details on how to acomplish those steps, let me know 🙂
EDIT 1
You can use the library to detect mouse movement like this: