Пример #1
0
 private void UpdateCircles()
 {
     if (_useOpacity)
     {
         for (var i = 0; i < _circles.Length; i++)
         {
             _circles[i].Opacity = 1 - ((i + _offset) % _circles.Length) * 0.11;
         }
         _offset = (_offset + 1) % _circles.Length;
     }
     else
     {
         _rotateTransform.Angle = (_rotateTransform.Angle + 36) % 360;
     }
     Canvas1.InvalidateVisual();
 }
Пример #2
0
        private void Canvas1_TouchDown(object sender, TouchEventArgs e)
        {
            var pt = e.GetTouchPoint(Canvas1);

            // 縦線を作ります。
            var lineV = new Line();
            lineV.X1 = lineV.X2 = pt.Position.X;
            lineV.Y1 = 0;
            lineV.Y2 = ActualHeight;
            lineV.Stroke = Brushes.Red;
            Canvas1.Children.Add(lineV);
            lineVList[e.TouchDevice] = lineV;

            // 横線を作ります。
            var lineH = new Line();
            lineH.X1 = 0;
            lineH.X2 = ActualWidth;
            lineH.Y1 = lineH.Y2 = pt.Position.Y;
            lineH.Stroke = Brushes.Red;
            Canvas1.Children.Add(lineH);
            lineHList[e.TouchDevice] = lineH;

            // 円を作ります。
            var ellipse = new Ellipse();
            ellipse.Width = 50;
            ellipse.Height = 50;
            ellipse.Fill = Brushes.Blue;
            ellipse.RenderTransform
                = new TranslateTransform(pt.Position.X - ellipse.RenderSize.Width / 2,
                                           pt.Position.Y - ellipse.RenderSize.Height / 2);
            Canvas1.Children.Add(ellipse);
            ellipseList[e.TouchDevice] = ellipse;

            // idを表すラベルを作ります。
            var label = new Label();
            label.Foreground = Brushes.White;
            label.FontSize = 36;
            label.Content = e.TouchDevice.Id;
            label.RenderTransform = new TranslateTransform(pt.Position.X - label.RenderSize.Width / 2,
                                           pt.Position.Y - label.RenderSize.Height / 2);
            Canvas1.Children.Add(label);
            labelList[e.TouchDevice] = label;

            Canvas1.InvalidateVisual();

            Canvas1.CaptureTouch(e.TouchDevice);
        }