It seems that .NET Framework does not provide built-in support for stylus "hold-down" other than associating a context menu with a control, which menu gets displayed when the stylus is pressed and hold over the control. This action however doesn't really count as a mouse action as it seems. The control itself is never notified of this action and the Calendar events are not fired as a result.
The following scenario supplies a workaround for this limiation and provides you with the ability to control whether and when to display the context menu.
1. Create a timer object (make it a member of the form, which contains the Calendar control).
private Timer timer;
// ...
// Somewhere during initialization
timer = new Timer();
timer.Interval = 500;
timer.Enabled = false;
timer.Tick += new EventHandler(OnTick);
2. Declare another member variable of type Point. We will use this variable to store the position of the mouse when the user initiates a click within the control.
private Point mouse;
3. Handle the MouseDown, MouseMove and MouseUp events of the Calendar control. The following source code illustrates the contents of each of the event handlers.
MouseDown handler contents:
// Remember the mouse position
mouse = new Point(e.X, e.Y);
// Start the timer
timer.Enabled = true;
MouseMove handler contents:
// Since the user has moved the mouse, we can
// assume it is not a "hold-down" action.
// Stop the timer then
timer.Enabled = false;
MouseUp handler contents:
// Stop the timer as well
timer.Enabled = false;
Implement the Timer.Tick event handler. The event handler should be invoked 0.5s after the timer has been started, i.e. 0.5s after the user has pressed the stylus, holding it down without moving it. We presume that the 'calendar' variable identifies the PocketPlanner instance and that there is a context menu referenced by the 'contextMenu' variable.
private void OnTick(object sender, EventArgs e)
{
// Stop the timer (to avoid this event being raised more than once)
timer.Enabled = false;
// Cancel the current drag operation within the Calendar
calendar.ResetDrag();
// Make any necessary checks here. For example
// you can check whether the mouse is positioned
// over an item by calling Calendar.GetItemAt and
// passing 'mouse' to it. You can enable or disable
// various items in the context menu as a result of the checks here
// Finally display the context menu
contextMenu.Show(calendar, mouse);
}
I hope this helps.
Meppy