/// <summary> /// Returns the latest position of the pointer relative to the current window /// </summary> public static Point GetPosition(this Pointer pointer) { // Even though docs for the Position property say it is in screen-coordinates, // it's actually in window coordinates. // That's fine though... one less transform we need to do return(PointerPoint.GetCurrentPoint(pointer.PointerId).Position); }
private static void CheckPointer() { try { if (pointerId == 0) { return; } var pointerPoint = PointerPoint.GetCurrentPoint(pointerId); Queue.Enqueue(pointerPoint); if (Queue.Count() == QueueLimit && Queue.All(pp => pp.IsInContact)) { var maxY = Queue.Max(pp => pp.Position.Y); var minY = Queue.Min(pp => pp.Position.Y); var firstPosition = Queue.First().Position.X; var lastPosition = Queue.Last().Position.X; if (Math.Abs(maxY - minY) < YTollerance && Math.Abs(firstPosition - lastPosition) > XSwipethreshold) { SwipeMessage message = firstPosition - lastPosition > XSwipethreshold ? SwipeMessage.Left as SwipeMessage : SwipeMessage.Right as SwipeMessage; Messenger.Default.Send(message); Queue.Clear(); } } } catch { // TODO add logger } }
async void CreateMod(Canvas p) { bi = new BitmapImage(); memoryStream = new InMemoryRandomAccessStream(); datawriter = new DataWriter(memoryStream.GetOutputStreamAt(0)); CreateBitmap(); HSVTemplate(0, ref map); datawriter.WriteBytes(map); await datawriter.StoreAsync(); bi.SetSource(memoryStream); img = new Image(); img.Source = bi; img.Width = 256; img.Height = 256; img.PointerReleased += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); pp = e.GetCurrentPoint(o as UIElement); int x = (int)pp.RawPosition.X; int y = 255 - (int)pp.RawPosition.Y; int index = y * 768 + x * 3 + 54; CB = map[index]; index++; CG = map[index]; index++; CR = map[index]; SR.Value = CR; SG.Value = CG; SB.Value = CB; }; p.Children.Add(img); datawriter.Dispose(); }
static void ProgressChange(object sender, PointerRoutedEventArgs e) { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); X = pp.Position.X; Jump(); }
private void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs args) { PointerPoint currentPoint = args.CurrentPoint; press = PointerPoint.GetCurrentPoint(currentPoint.PointerId); //Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(currentPoint.PointerId); }
// Called when rotate by mousewheel. private void Left_PointerWheelChanged(object sender, PointerRoutedEventArgs e) { bool shift = (e.KeyModifiers & VirtualKeyModifiers.Shift) == VirtualKeyModifiers.Shift; bool ctrl = (e.KeyModifiers & VirtualKeyModifiers.Control) == VirtualKeyModifiers.Control; if (shift && ctrl) { var delta = PointerPoint.GetCurrentPoint(e.Pointer.PointerId).Properties.MouseWheelDelta; // With my mouse, delta is a multiple of 30. this.LeftRotateTransform.Angle -= delta / 15; } }
private void OverlayPressed(object sender, PointerRoutedEventArgs e) { Pointer ptr = e.Pointer; var point = PointerPoint.GetCurrentPoint(ptr.PointerId); var position = point.Position; var x = (int)(position.X / 37) - 1; var y = (int)(position.Y / 44) - 6; Marker.Visibility = Visibility.Visible; Marker.Margin = new Thickness(x * 37, y * 44, 0, 0); }
static void PointerOperation(object sender, PointerRoutedEventArgs e) { PointerPoint p = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); DX_Input.CopyPointer(p); if ((sender as SwapChain).EventToSubThread) { ThreadManage.AsyncDelegate(() => { (sender as SwapChain).CheckEvent(); }); } else { (sender as SwapChain).CheckEvent(); } }
private void CoreWindow_PointerReleased(CoreWindow sender, PointerEventArgs args) { var currentPoint = args.CurrentPoint; release = PointerPoint.GetCurrentPoint(currentPoint.PointerId); double dx = release.Position.X - press.Position.X; double dy = release.Position.Y - press.Position.Y; if (Math.Abs(dx) > Math.Abs(dy)) { if (dx > 5) { direction = DIRECTION.RIGHT; } else if (dx < -5) { direction = DIRECTION.LEFT; } else { direction = DIRECTION.INVALID; } } else { if (dy < -5) { direction = DIRECTION.UP; } else if (dy > 5) { direction = DIRECTION.DOWN; } else { direction = DIRECTION.INVALID; } } update(); }
void PointerReleasd(object o, PointerRoutedEventArgs e) { speed = 1; pressbor.Background = unpressd; if (!playing) { return; } var pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); float x = (float)(pp.Position.X - pressbor.Margin.Left - 50); float y = (float)(pressbor.Margin.Top + 50 - pp.Position.Y); if (x * x + y * y > 2500) { return; } float a = atan(x, y); if (a < 45) { MoveUp(); } else if (a < 135) { MoveLeft(); } else if (a < 225) { MoveDown(); } else if (a < 315) { MoveRight(); } else { MoveUp(); } }
async void CreateModA(Canvas p) { biA = new BitmapImage(); memoryStreamA = new InMemoryRandomAccessStream(); datawriterA = new DataWriter(memoryStreamA.GetOutputStreamAt(0)); CreateHTemp(); HTemplate(ref temp); datawriterA.WriteBytes(temp); await datawriterA.StoreAsync(); biA.SetSource(memoryStreamA); rta = new Rectangle(); ImageBrush ib = new ImageBrush(); rta.Fill = ib; rta.Width = 20; rta.Height = 256; rta.PointerReleased += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); pp = e.GetCurrentPoint(o as UIElement); float y = (float)pp.RawPosition.Y; y = (256 - y) * 1.40625f; ChangeTemplate(y); }; rta.PointerMoved += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); if (pp.IsInContact) { pp = e.GetCurrentPoint(o as UIElement); float y = (float)pp.RawPosition.Y; y = (256 - y) * 1.40625f; ChangeTemplate(y); } }; ib.ImageSource = biA; p.Children.Add(rta); datawriterA.Dispose(); }
void PointerPressd(object o, PointerRoutedEventArgs e) { speed = 2; if (playing) { var pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); float x = (float)(pp.Position.X - pressbor.Margin.Left - 50); float y = (float)(pressbor.Margin.Top + 50 - pp.Position.Y); if (x * x + y * y > 2500) { return; } float a = atan(x, y); if (a < 45) { (pressbor.RenderTransform as RotateTransform).Angle = 0; } else if (a < 135) { (pressbor.RenderTransform as RotateTransform).Angle = 270; } else if (a < 225) { (pressbor.RenderTransform as RotateTransform).Angle = 180; } else if (a < 315) { (pressbor.RenderTransform as RotateTransform).Angle = 90; } else { (pressbor.RenderTransform as RotateTransform).Angle = 0; } pressbor.Background = pressd; } }
// Phase 1: // Every time user select (or not) a new property we sotre it for its own unique stylus id private void OnConfigButtonPointerEntered(object sender, PointerRoutedEventArgs e) { this.activePointerId = this.GetUniqueStylusId(PointerPoint.GetCurrentPoint(e.Pointer.PointerId)); }
static void CreateBar(Canvas p) { if (PSB.canA != null) { return; } Canvas can = new Canvas(); PSB.canA = can; p.Children.Add(can); can = new Canvas(); p.Children.Add(can); PSB.canB = can; can.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)); can.Width = screenW; can.Height = 70; can.Margin = new Thickness(0, screenH - 70, 0, 0); ProgressBar pb = new ProgressBar(); pb.PointerReleased += ProgressChange; pb.Background = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0)); pb.Foreground = new SolidColorBrush(Color.FromArgb(128, 0, 250, 18)); pb.Width = screenW; pb.Height = 5; pb.Margin = new Thickness(0, 20, 0, 0); can.Children.Add(pb); PSB.progress = pb; SymbolIcon flag = new SymbolIcon(); flag.Symbol = Symbol.Flag; flag.Foreground = new SolidColorBrush(Colors.OrangeRed); can.Children.Add(flag); PSB.flag = flag; SymbolIcon si = new SymbolIcon(); si.Symbol = Symbol.Pause; si.PointerPressed += Pause; PSB.play = si; can.Children.Add(si); Thickness tk = new Thickness(); tk.Top = 30; tk.Left = 10; tk.Top = 40; si.Margin = tk; si = new SymbolIcon(); si.Symbol = Symbol.Volume; si.PointerReleased += volume_released; PSB.volume = si; can.Children.Add(si); tk.Left += 30; si.Margin = tk; Slider s = new Slider(); s.Visibility = Visibility.Collapsed; s.ValueChanged += slider_change; s.Width = 100; PSB.slider = s; can.Children.Add(s); s.Margin = tk; TextBlock tb = new TextBlock(); tb.Foreground = Component.title_brush; tk.Left += 80; tb.Margin = tk; can.Children.Add(tb); PSB.title = tb; can = new Canvas(); p.Children.Add(can); can.Background = Component.trans_brush; PSB.bor = can; can.Width = screenW; can.Height = screenH; can.PointerPressed += (o, e) => { time = DateTime.Now.Ticks; PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); sx = pp.Position; sst = PSB.flag.Margin.Left; }; can.PointerMoved += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); if (pp.IsInContact) { double ox = pp.Position.X - sx.X; Thickness t = PSB.flag.Margin; t.Left = sst + ox; if (t.Left < 0) { t.Left = 0; } if (t.Left > screenX) { t.Left = screenX; } PSB.flag.Margin = t; } }; can.PointerReleased += (o, e) => { if (DateTime.Now.Ticks - time < presstime) { if (PSB.canB.Visibility == Visibility.Visible) { PSB.canB.Visibility = Visibility.Collapsed; PSB.bor.Width = screenW; PSB.bor.Height = screenH; } else { PSB.canB.Visibility = Visibility.Visible; PSB.bor.Width = screenW; PSB.bor.Height = screenH - 70; } } else { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); double ox = pp.Position.X - sx.X; X = sst + ox; if (X < 0) { X = 0; } if (X > screenX) { X = screenX; } Jump(); } }; }
static void CreateBar(Canvas p) { if (PSB.canA != null) { return; } Canvas can = new Canvas(); PSB.canA = can; p.Children.Add(can); can = new Canvas(); p.Children.Add(can); PSB.canB = can; can.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)); can.Width = screenW; can.Height = 70; can.Margin = new Thickness(0, screenH - 70, 0, 0); ProgressBar pb = new ProgressBar(); pb.PointerReleased += ProgressChange; pb.Background = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0)); pb.Foreground = new SolidColorBrush(Color.FromArgb(128, 0, 250, 18)); pb.Width = screenW; pb.Height = 5; pb.Margin = new Thickness(0, 20, 0, 0); can.Children.Add(pb); PSB.progress = pb; SymbolIcon flag = new SymbolIcon(); flag.Symbol = Symbol.Flag; flag.Foreground = new SolidColorBrush(Colors.OrangeRed); can.Children.Add(flag); PSB.flag = flag; SymbolIcon si = new SymbolIcon(); si.Symbol = Symbol.Pause; si.PointerPressed += Pause; PSB.play = si; can.Children.Add(si); Thickness tk = new Thickness(); tk.Top = 30; tk.Left = 10; tk.Top = 40; si.Margin = tk; si = new SymbolIcon(); si.Symbol = Symbol.Volume; si.PointerReleased += volume_released; PSB.volume = si; can.Children.Add(si); tk.Left += 30; si.Margin = tk; Slider s = new Slider(); s.Visibility = Visibility.Collapsed; s.ValueChanged += slider_change; s.Width = 100; PSB.slider = s; can.Children.Add(s); s.Margin = tk; ComboBox cb = new ComboBox(); cb.SelectionChanged += (o, e) => { ChangeSharp((o as ComboBox).SelectedIndex); }; PSB.sharp = cb; can.Children.Add(cb); tk.Left += 140; cb.Margin = tk; cb = new ComboBox(); cb.SelectionChanged += (o, e) => { ChangSite((o as ComboBox).SelectedIndex); }; PSB.site = cb; can.Children.Add(cb); tk.Left += 80; cb.Margin = tk; TextBlock tb = new TextBlock(); tb.Foreground = title_brush; tk.Left += 80; tb.Margin = tk; can.Children.Add(tb); PSB.title = tb; can = new Canvas(); p.Children.Add(can); can.Background = trans_brush; PSB.bor = can; can.Width = screenW; can.Height = screenH; can.PointerPressed += (o, e) => { time = DateTime.Now.Ticks; PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); sx = pp.Position; ss = PSB.flag.Margin.Left; }; can.PointerMoved += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); if (pp.IsInContact) { double ox = pp.Position.X - sx.X; Thickness t = PSB.flag.Margin; double x = ss + ox; if (x < 0) { x = 0; } if (x > screenX) { x = screenX; } t.Left = x; PSB.flag.Margin = t; x /= screenX; x *= vic.alltime; int h = (int)x / 3600; int se = (int)x % 3600; int min = se / 60; se %= 60; string st = h.ToString() + ":" + min.ToString() + ":" + se.ToString(); Main.Notify(st, font_brush, trans_brush, 1000); } }; can.PointerReleased += (o, e) => { if (DateTime.Now.Ticks - time < presstime) { if (PSB.canB.Visibility == Visibility.Visible) { PSB.canB.Visibility = Visibility.Collapsed; PSB.bor.Width = screenW; PSB.bor.Height = screenH; } else { PSB.canB.Visibility = Visibility.Visible; PSB.bor.Width = screenW; PSB.bor.Height = screenH - 70; } } else { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); double ox = pp.Position.X - sx.X; X = ss + ox; if (X < 0) { X = 0; } if (X > screenX) { X = screenX; } Jump(); } }; }