Example #1
0
        public DoubleAnimation MoveRightAnimation(RobotControl robotControl, double fromX, double toX, TimeSpan ts)
        {
            var animation = new DoubleAnimation {
                From = fromX, To = toX, Duration = ts
            };

            Storyboard.SetTargetProperty(animation, new PropertyPath("(Canvas.Top)"));
            Storyboard.SetTarget(animation, robotControl);
            return(animation);
        }
Example #2
0
        private void CreateRobot(string ownerName, Position position)
        {
            var control = new RobotControl();

            control.BackgroundPanel.Fill = new SolidColorBrush(ColorsFactory.OwnerColors[ownerName]);
            RobotGrid.Children.Add(control);
            control.BackgroundPanel.Height = CellWidth;
            control.BackgroundPanel.Width  = CellWidth;
            SetPosition(control, position);
            SetValue(Panel.ZIndexProperty, 0);
            RobotPlace.Add(position, control);
        }
Example #3
0
        public void SetAnimation(RobotControl robotControl, Position from, Position to, bool isLast)
        {
            currentAnimation = new Storyboard();
            TimeSpan ts = TimeSpan.FromMilliseconds(_speed);

            currentAnimation.Children.Add(MoveLeftAnimation(robotControl, from.X * CellWidth, to.X * CellWidth, ts));
            currentAnimation.Children.Add(MoveRightAnimation(robotControl, from.Y * CellWidth, to.Y * CellWidth, ts));
            if (isLast)
            {
                currentAnimation.Completed += ViewUpdatedChanged;
            }
            currentAnimation.Begin();
        }
Example #4
0
 private void SetPosition(RobotControl control, Position position)
 {
     control.Top  = position.Y * CellWidth;
     control.Left = position.X * CellWidth;
 }