Exemple #1
0
        protected override void OnPointerMoved(PointerRoutedEventArgs e)
        {
            base.OnPointerMoved(e);
            PointerPoint point = e.GetCurrentPoint(this);
            Crossline    line  = points.Find(s => s.Tag == point.PointerId);

            if (line == null)
            {
                return;
            }
            line.Point = point;
            if (PointerDictionary.ContainsKey(point.PointerId))
            {
                //PointerDictionary[point.PointerId].Points.Add(new Point(point.Position.X,point.Position.Y-Config.TOUCH_Y_OFFSET));
                PointerDictionary[point.PointerId].Points.Add(new Point(point.Position.X, point.Position.Y));
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = textBlocks.Find(s => Convert.ToUInt16(s.Tag) == point.PointerId);
                if (textBlock != null)
                {
                    textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock) + 1, point.Position.X * Config.scaleFactor,
                                                   point.Position.Y * Config.scaleFactor);
                }
            }
        }
        protected override void OnPointerExited(PointerRoutedEventArgs e)
        {
            base.OnPointerExited(e);
            PointerPoint point = e.GetCurrentPoint(this);

            if (!points.Exists(s => s.Tag == point.PointerId))
            {
                return;
            }
            Crossline line = points.Find(s => s.Tag == point.PointerId);

            if (line == null)
            {
                return;
            }
            this.CanvasLine.Children.Remove(line.HorizontalPath);
            this.CanvasLine.Children.Remove(line.VerticalPath);
            points.Remove(line);
            if (!Config.isReserveTrace.Value)
            {
                if (LineDictionary.ContainsKey(point.PointerId))
                {
                    CanvasLine.Children.Remove(LineDictionary[point.PointerId]);
                    LineDictionary.RemoveValue(point.PointerId);
                }
            }
            else
            {
                if (LineDictionary.ContainsKey(point.PointerId))
                {
                    Polyline polyline = LineDictionary[point.PointerId];
                    LineDictionary.Remove(point.PointerId);
                    lines.Add(polyline);
                }
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = textBlocks.Find(s => Convert.ToUInt16(s.Tag) == point.PointerId);
                if (textBlock != null)
                {
                    StackPanelCoords.Children.Remove(textBlock);
                    textBlocks.Remove(textBlock);
                }
            }
            ResetMenu();
        }
Exemple #3
0
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            base.OnPointerPressed(e);
            if (this.cVsCover.Visibility == Visibility.Visible)
            {
                this.cVsCover.Visibility = Visibility.Collapsed;
            }
            PointerPoint point = e.GetCurrentPoint(this);
            var          line  = new Crossline(Colors.White, point);

            line.Tag = point.PointerId;
            Color color = colors[random.Next(0, colors.Count - 1)];

            line.LineColor = color;
            CanvasLine.Children.Add(line.HorizontalPath);
            CanvasLine.Children.Add(line.VerticalPath);
            points.Add(line);
            if (points.Count > Config.supportMaxTouchs.Value)
            {
                Config.supportMaxTouchs.Value = points.Count;
            }
            if (Config.isNeedShowTrace.Value)
            {
                //var pointForTrace = new Point(point.Position.X, point.Position.Y - Config.TOUCH_Y_OFFSET);
                var pointForTrace = new Point(point.Position.X, point.Position.Y);
                var polyline      = new Polyline();
                polyline.Stroke          = new SolidColorBrush(color);
                polyline.StrokeThickness = Config.TraceThickness.Value;
                CanvasLine.Children.Add(polyline);
                PointerDictionary.AddValue(point.PointerId, polyline);
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = new TextBlock();
                textBlock.TextWrapping = TextWrapping.Wrap;
                textBlock.Width        = StackPanelCoords.Width;
                textBlock.Height       = 40;
                textBlock.Tag          = point.PointerId;
                textBlock.Foreground   = new SolidColorBrush(color);
                textBlocks.Add(textBlock);
                textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock) + 1, point.Position.X * Config.scaleFactor,
                                               point.Position.Y * Config.scaleFactor);
                StackPanelCoords.Children.Add(textBlock);
            }
        }
 protected override void OnPointerPressed(PointerRoutedEventArgs e)
 {
     base.OnPointerPressed(e);
     if (this.cVsCover.Visibility == Visibility.Visible)
         this.cVsCover.Visibility = Visibility.Collapsed;
     PointerPoint point = e.GetCurrentPoint(this);
     var line = new Crossline(Colors.White, point);
     line.Tag = point.PointerId;
     Color color = colors[random.Next(0, colors.Count - 1)];
     line.LineColor = color;
     CanvasLine.Children.Add(line.HorizontalPath);
     CanvasLine.Children.Add(line.VerticalPath);
     points.Add(line);
     if (points.Count > Config.supportMaxTouchs.Value)
     {
         Config.supportMaxTouchs.Value = points.Count;
     }
     if (Config.isNeedShowTrace.Value)
     {
         //var pointForTrace = new Point(point.Position.X, point.Position.Y - Config.TOUCH_Y_OFFSET);
         var pointForTrace = new Point(point.Position.X, point.Position.Y);
         var polyline = new Polyline();
         polyline.Stroke = new SolidColorBrush(color);
         polyline.StrokeThickness = Config.TraceThickness.Value;
         CanvasLine.Children.Add(polyline);
         PointerDictionary.AddValue(point.PointerId, polyline);
     }
     if (Config.isShowCoord.Value)
     {
         TextBlock textBlock = new TextBlock();
         textBlock.TextWrapping = TextWrapping.Wrap;
         textBlock.Width = StackPanelCoords.Width;
         textBlock.Height = 40;
         textBlock.Tag = point.PointerId;
         textBlock.Foreground = new SolidColorBrush(color);
         textBlocks.Add(textBlock);
         textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock)+1, point.Position.X*Config.scaleFactor,
             point.Position.Y*Config.scaleFactor);
         StackPanelCoords.Children.Add(textBlock);
        
     }
    
 }
Exemple #5
0
        protected override void OnPointerReleased(PointerRoutedEventArgs e)
        {
            base.OnPointerReleased(e);
            PointerPoint point = e.GetCurrentPoint(this);
            Crossline    line  = points.Find(s => s.Tag == point.PointerId);

            if (line == null)
            {
                return;
            }
            this.CanvasLine.Children.Remove(line.HorizontalPath);
            this.CanvasLine.Children.Remove(line.VerticalPath);
            points.Remove(line);
            if (!Config.isReserveTrace.Value)
            {
                if (PointerDictionary.ContainsKey(point.PointerId))
                {
                    CanvasLine.Children.Remove(PointerDictionary[point.PointerId]);
                    PointerDictionary.RemoveValue(point.PointerId);
                }
            }
            if (Config.isReserveTrace.Value)
            {
                this.AppBarButtonClear.Visibility = Visibility.Visible;
                if (PointerDictionary.Count > 0)
                {
                    BarButtonBack.Visibility = Visibility.Visible;
                }
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = textBlocks.Find(s => Convert.ToUInt16(s.Tag) == point.PointerId);
                if (textBlock != null)
                {
                    StackPanelCoords.Children.Remove(textBlock);
                    textBlocks.Remove(textBlock);
                }
            }
        }
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            Debug.WriteLine(e.OriginalSource.GetType().Name);
            Debug.WriteLine("The Poine Id is :" + e.Pointer.PointerId);
            if (e.OriginalSource is Grid)
            {
                Debug.WriteLine((e.OriginalSource as Grid).Name);
            }
            base.OnPointerPressed(e);
            if (this.gridCover.Visibility == Visibility.Visible)
            {
                if (gridSetting.Visibility == Visibility.Visible)
                {

                  //  if (e.OriginalSource is Grid){
                        //  Debug.WriteLine((e.OriginalSource as Grid).Name);
                        if ((e.OriginalSource as FrameworkElement).Name == "layoutRoot")
                        {
                            Config.TraceThickness.Value = (float)this.SliderTraceThickness.Value;
                            Config.isNeedShowTrace.Value = this.SwitchShowTrace.IsOn;
                            Config.isReserveTrace.Value = this.SwitchKeepTrace.IsOn;
                            Config.isShowCoord.Value = this.SwitchShowCoord.IsOn;
                            this.gridSetting.Visibility = Visibility.Collapsed;
                            this.gridCover.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            return;
                        }

                  //  }

                }
                else
                {
                    this.gridCover.Visibility = Visibility.Collapsed;
                }

            }
            PointerPoint point = e.GetCurrentPoint(this);
            var line = new Crossline(Colors.White, point);
            line.Tag = point.PointerId;
            Color color = colors[random.Next(0, colors.Count - 1)];
            line.LineColor = color;
            CanvasLine.Children.Add(line.HorizontalPath);
            CanvasLine.Children.Add(line.VerticalPath);
            points.Add(line);
            if (points.Count > Config.supportMaxTouchs.Value)
            {
                Config.supportMaxTouchs.Value = points.Count;
            }
            if (Config.isNeedShowTrace.Value)
            {
                //var pointForTrace = new Point(point.Position.X, point.Position.Y - Config.TOUCH_Y_OFFSET);
                var pointForTrace = new Point(point.Position.X, point.Position.Y);
                var polyline = new Polyline();
                polyline.Stroke = new SolidColorBrush(color);
                polyline.StrokeThickness = Config.TraceThickness.Value;
                CanvasLine.Children.Add(polyline);
                LineDictionary.AddValue(point.PointerId, polyline);
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = new TextBlock();
                textBlock.TextWrapping = TextWrapping.Wrap;
                textBlock.Width = StackPanelCoords.Width;
                textBlock.Height = 60;
                textBlock.Tag = point.PointerId;
                textBlock.Foreground = new SolidColorBrush(color);
                textBlocks.Add(textBlock);
                textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock) + 1, point.Position.X * Config.scaleFactor,
                    point.Position.Y * Config.scaleFactor);
                StackPanelCoords.Children.Add(textBlock);
            }
            ResetMenu();
        }
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            Debug.WriteLine(e.OriginalSource.GetType().Name);
            Debug.WriteLine("The Poine Id is :" + e.Pointer.PointerId);
            if (e.OriginalSource is Grid)
            {
                Debug.WriteLine((e.OriginalSource as Grid).Name);
            }
            base.OnPointerPressed(e);
            if (this.gridCover.Visibility == Visibility.Visible)
            {
                if (gridSetting.Visibility == Visibility.Visible)
                {
                    //  if (e.OriginalSource is Grid){
                    //  Debug.WriteLine((e.OriginalSource as Grid).Name);
                    if ((e.OriginalSource as FrameworkElement).Name == "layoutRoot")
                    {
                        Config.TraceThickness.Value  = (float)this.SliderTraceThickness.Value;
                        Config.isNeedShowTrace.Value = this.SwitchShowTrace.IsOn;
                        Config.isReserveTrace.Value  = this.SwitchKeepTrace.IsOn;
                        Config.isShowCoord.Value     = this.SwitchShowCoord.IsOn;
                        this.gridSetting.Visibility  = Visibility.Collapsed;
                        this.gridCover.Visibility    = Visibility.Collapsed;
                    }
                    else
                    {
                        return;
                    }


                    //  }
                }
                else
                {
                    this.gridCover.Visibility = Visibility.Collapsed;
                }
            }
            PointerPoint point = e.GetCurrentPoint(this);
            var          line  = new Crossline(Colors.White, point);

            line.Tag = point.PointerId;
            Color color = colors[random.Next(0, colors.Count - 1)];

            line.LineColor = color;
            CanvasLine.Children.Add(line.HorizontalPath);
            CanvasLine.Children.Add(line.VerticalPath);
            points.Add(line);
            if (points.Count > Config.supportMaxTouchs.Value)
            {
                Config.supportMaxTouchs.Value = points.Count;
            }
            if (Config.isNeedShowTrace.Value)
            {
                //var pointForTrace = new Point(point.Position.X, point.Position.Y - Config.TOUCH_Y_OFFSET);
                var pointForTrace = new Point(point.Position.X, point.Position.Y);
                var polyline      = new Polyline();
                polyline.Stroke          = new SolidColorBrush(color);
                polyline.StrokeThickness = Config.TraceThickness.Value;
                CanvasLine.Children.Add(polyline);
                LineDictionary.AddValue(point.PointerId, polyline);
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = new TextBlock();
                textBlock.TextWrapping = TextWrapping.Wrap;
                textBlock.Width        = StackPanelCoords.Width;
                textBlock.Height       = 60;
                textBlock.Tag          = point.PointerId;
                textBlock.Foreground   = new SolidColorBrush(color);
                textBlocks.Add(textBlock);
                textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock) + 1, point.Position.X * Config.scaleFactor,
                                               point.Position.Y * Config.scaleFactor);
                StackPanelCoords.Children.Add(textBlock);
            }
            ResetMenu();
        }