Esempio n. 1
0
 public async void DrawAsync(Canvas canvas, Press.Pressed pressed)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
         Draw(canvas.Name, pressed);
         CalculateInputDelay(canvas.Name);
     });
 }
Esempio n. 2
0
        public void Draw(string canvasName, Press.Pressed pressed)
        {
            double ymin  = 7;
            double ymax  = Buttons[canvasName].Canvas.Height - ymin;
            double hit_y = (ymax - ymin);

            if (Buttons[canvasName].Polyline.Points.Count == Buttons[canvasName].Canvas.Width)
            {
                ButtonData button = Buttons[canvasName];
                button.Polyline.Points.Clear();
                button.LastPressed  = new Point();
                Buttons[canvasName] = button;
            }

            Point point;

            Press.DIRECTION where = pressed(controller);
            if (where == Press.DIRECTION.NONE)
            {
                point = new Point(Buttons[canvasName].Polyline.Points.Count, hit_y);
            }
            else
            {
                point = new Point(Buttons[canvasName].Polyline.Points.Count, hit_y * Press.Direction(where));

                ButtonData button = Buttons[canvasName];

                if (point.X > button.LastPressed.X + 10)
                {
                    button.LastPressed = point;
                }

                Buttons[canvasName] = button;
            }

            if (!Paused)
            {
                Buttons[canvasName].Polyline.Points.Add(point);
            }

            if (!InputDelayMarkers)
            {
                Buttons[canvasName].Label.Text = Press.DirectionString(where);
            }

            Buttons[canvasName].Polyline.Stroke = Press.DirectionBrush(where);

            if (Buttons[canvasName].Canvas.Children.Contains(Buttons[canvasName].Polyline))
            {
                Buttons[canvasName].Canvas.Children.Remove(Buttons[canvasName].Polyline);
            }

            Buttons[canvasName].Canvas.Children.Add(Buttons[canvasName].Polyline);
        }
Esempio n. 3
0
        public ButtonData(Canvas canvas, Press.Pressed pressed, TextBlock label)
        {
            this.canvas = canvas;

            this.Pressed         = pressed;
            this.Label           = label;
            this.Polyline        = new Polyline();
            this.LastPressed     = new Point();
            this.LastLastPressed = new Point();

            this.Delay = 0;

            this.InputDelayPaths            = new List <Path>();
            this.InputDelayMarkerXPositions = new List <double>();

            this.Polyline.StrokeThickness = GlobalSettings.StrokeThickness;

            this.canvas.CacheMode = new BitmapCache();
        }