public void ShowDialog() { InputManager.CurrentInputManager.InputDeviceEvents[(int)InputManager.InputDeviceType.Touch].PreProcessInput += new PreProcessInputEventHandler(InputDeviceEvents_PreProcessInput); Visibility = Visibility.Visible; Buttons.Focus(this); TouchCapture.Capture(this, CaptureMode.SubTree); }
protected override void OnTouchDown(TouchEventArgs e) { if (IsEnabled) { TouchCapture.Capture(this); Invalidate(); } }
private void Exit() { TouchCapture.Capture(this, CaptureMode.None); Visibility = Visibility.Collapsed; InputManager.CurrentInputManager.InputDeviceEvents[(int)InputManager.InputDeviceType.Touch].PreProcessInput -= new PreProcessInputEventHandler(InputDeviceEvents_PreProcessInput); if (onClose != null) { onClose(this, EventArgs.Empty); } }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusDown(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchDown(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { // If the user tapped inside the same control that has the // touch captured, release the capture. if ((x >= 0) && (y >= 0) && (x <= text.ActualWidth) && (y <= text.ActualHeight)) { #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text, CaptureMode.None); #else TouchCapture.Capture(text, CaptureMode.None); #endif text.ForeColor = ColorUtility.ColorFromRGB(0, 0, 0); text.TextContent = "Capture Released."; } // Else, show the point as captured. else { text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; } } // Else, show the point as captured. else { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text); #else TouchCapture.Capture(text); #endif } }
public HomePage() : base(0, 0, DemoManager.Desktop.Width, DemoManager.Desktop.Height) { panelNavigation = new Panel(5, 5, DemoManager.Desktop.Width - 10, DemoManager.Desktop.Height - 10) { Background = new LinearGradientBrush(Color.Bisque, Color.Black, 0, 0, 1000, 1000, 120), Border = new Pen(Color.Black, 1) }; Children.Add(panelNavigation); header = new Panel(0, 0, panelNavigation.Width - 0, 25); header.Background = DemoManager.Bar; header.Children.Add(new Label(10, 5, DemoManager.FontCourierNew10, "Navigation") { ForeColor = Color.CornflowerBlue }); header.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(header); p = e.Point; }; header.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == header) { panelNavigation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } }; header.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == header) { TouchCapture.ReleaseCapture(); } }; panelNavigation.Children.Add(header); x = margin; w = panelNavigation.Width / 2 - 2 * margin; y = header.Height + margin; step = h + margin; AddButton("Level"); AddButton("ProgressBar"); AddButton("Image"); //AddButton("Panel"); //AddButton("Checkbox"); //AddButton("Button"); //AddButton("MultiImage"); //AddButton("Label"); //AddButton("RadioButton"); //AddButton("Slider"); //AddButton("TextBlock"); //AddButton(""); //AddButton(""); //AddButton(""); //AddButton(""); //AddButton(""); //AddButton(""); }
protected override void OnTouchDown(TouchEventArgs e) { if (IsEnabled && TouchCapture.Captured != this) { int x, y; e.GetPosition(this, 0, out x, out y); if (Utils.IsWithinRectangle(x, y, ActualWidth, ActualHeight)) { TouchCapture.Capture(this); pressed = true; Invalidate(); } } }
protected override void OnTouchMove(TouchEventArgs e) { if (pressed) { int x, y; e.GetPosition(this, 0, out x, out y); // uses UIElement.PointToClient if (!Utils.IsWithinRectangle(x, y, ActualWidth, ActualHeight)) { pressed = false; Invalidate(); TouchCapture.Capture(this, CaptureMode.None); } } }
protected override void OnTouchDown(TouchEventArgs e) { int x, y, w, h; GetLayoutOffset(out x, out y); GetRenderSize(out w, out h); x += _left; y += _top; TouchCapture.Capture(this); Microsoft.SPOT.Touch.Ink.SetInkRegion(0, x, y, x + w, y + h, _borderWidth, (int)_defaultDrawingAttributes.Color, 1, _bitmap); }
protected override void OnTouchDown(TouchEventArgs e) #endif { // Flag for the drawing state. _pressed = true; #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(this); #else TouchCapture.Capture(this); #endif // Trigger a redraw. Invalidate(); }
protected override void OnTouchUp(TouchEventArgs e) { if (pressed) { pressed = false; Invalidate(); TouchCapture.Capture(this, CaptureMode.None); int x, y; e.GetPosition(this, 0, out x, out y); if (Utils.IsWithinRectangle(x, y, ActualWidth, ActualHeight)) { OnClick(EventArgs.Empty); } } }
protected internal override void OnChildrenChanged(UIElement added, UIElement removed, int indexAffected) { base.OnChildrenChanged(added, removed, indexAffected); UIElementCollection logicalChildren = this.LogicalChildren; int index = logicalChildren.Count - 1; if (added != null && indexAffected == index && added.Visibility == Visibility.Visible) { Buttons.Focus(added); TouchCapture.Capture(added); } if (removed == null || !this.IsFocused || index < 0) { return; } Buttons.Focus(logicalChildren[index]); TouchCapture.Capture(logicalChildren[index]); }
protected override void OnTouchUp(TouchEventArgs e) #endif { // Flag for the drawing state. _pressed = false; #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(this, CaptureMode.None); #else TouchCapture.Capture(this, CaptureMode.None); #endif // Trigger a redraw. Invalidate(); // Fire a click event. EventArgs args = new EventArgs(); OnClick(args); }
protected override void OnTouchUp(TouchEventArgs e) { base.OnTouchUp(e); TouchCapture.Capture(this, CaptureMode.None); #endif int x; int y; // Get the position of the event. #if MF_FRAMEWORK_VERSION_V3_0 e.GetPosition(this, out x, out y); #else e.GetPosition(this, 0, out x, out y); #endif int r = 0; int c = 0; // Calculate the row and column. r = y / _itemHeight; c = x / _itemWidth; // Validate the row and column. if ((r >= 0) && (r < _row) && (c >= 0) && (c < _column)) { // Calculate the item. int item = c + r * _column; // Make sure the item is the same one that the touch down // event occurred on. if (item == _pressedItem) { // Trigger a palette event. PaletteEventArg arg = new PaletteEventArg(item); OnItemClick(arg); } } }
protected override void OnTouchDown(TouchEventArgs e) { base.OnTouchDown(e); TouchCapture.Capture(this); #endif int x; int y; // Get the position of the event. #if MF_FRAMEWORK_VERSION_V3_0 e.GetPosition(this, out x, out y); #else e.GetPosition(this, 0, out x, out y); #endif int r = 0; int c = 0; // Calculate the row and column. r = y / _itemHeight; c = x / _itemWidth; // Validate the row and column. if ((r >= 0) && (r < _row) && (c >= 0) && (c < _column)) { // Set the item pressed value. _pressedItem = c + r * _column; } else { // Reset the item pressed value. _pressedItem = -1; } Invalidate(); }
protected override void OnTouchDown(TouchEventArgs e) { Point pp = e.Point; PointToClient(ref pp); if (thumbArea.Contains(pp)) { TouchCapture.Capture(this); p = e.Point; } else if (trackArea.Contains(pp)) { if (orientation == Orientation.Horizontal) { if (pp.X < thumbArea.X) { Value -= largeChange; } else { Value += largeChange; } } else { if (pp.Y < thumbArea.Y) { Value += largeChange; } else { Value -= largeChange; } } } }