internal override void TransferBone(BonesZone zoneTo, int index, bool isToEnd, bool isNeedToTransferMove, System.Windows.Point startPoint)
 {
     base.TransferBone(zoneTo, index, isToEnd, isNeedToTransferMove, startPoint);
     if (Bones.Count == 0)
     {
         RestGridHeight = "0*";
     }
 }
Exemple #2
0
        internal virtual void TransferBone(BonesZone zoneTo, int index, bool isToEnd, bool isNeedToTransferMove, System.Windows.Point startPoint)
        {
            BoneGraphics boneTmp = Bones[index];

            if (zoneTo.GetType() == BonesRepository.PlayedZone.GetType())
            {
                AddCountersInRepository(boneTmp.PointsQty1, boneTmp.PointsQty2);
            }
            RemoveAtIndex(index);
            StartAnimation(zoneTo, boneTmp, isToEnd, isNeedToTransferMove, startPoint);
            if (!isNeedToTransferMove)
            {
                zoneTo.AddBone(boneTmp, isToEnd);
            }
        }
        private protected override void StartAnimation(BonesZone zoneTo, BoneGraphics bone, bool isToEnd, bool isNeedToTransferMove, System.Windows.Point startPoint)
        {
            this.isNeedToTransferMove = isNeedToTransferMove;
            this.bone    = bone;
            this.zoneTo  = zoneTo;
            this.isToEnd = isToEnd;

            if (bone.AreHalfsEquil)
            {
                bone.State = StateOfBone.OpenVertical;
            }
            else
            {
                if (BonesRepository.PlayedZone.Bones.Count == 0)
                {
                    bone.State = StateOfBone.OpenHorizontal;
                }
                else
                {
                    if (isToEnd)
                    {
                        bone.State = BonesRepository.PlayedZone.PointsRightSide == bone.PointsQty1 ? StateOfBone.OpenHorizontal : StateOfBone.OpenHorizontalTransposed;
                    }
                    else
                    {
                        bone.State = BonesRepository.PlayedZone.PointsLeftSide == bone.PointsQty2 ? StateOfBone.OpenHorizontal : StateOfBone.OpenHorizontalTransposed;
                    }
                }
            }

            var windowPoint = mainWindow.PointFromScreen(new System.Windows.Point(0, 0));
            var borderPoint = mainWindow.border.PointFromScreen(new System.Windows.Point(0, 0));

            borderPoint.Y       -= mainWindow.borderRest.ActualHeight / 2.0;
            bone.BoneGrid.Margin = new Thickness(Math.Abs(startPoint.X) - Math.Abs(windowPoint.X), Math.Abs(startPoint.Y) - Math.Abs(windowPoint.Y) - 23, 0, 0);
            canvasForAnimation.Children.Add(bone.BoneGrid);

            Storyboard myStoryboard = new Storyboard();

            myStoryboard.Completed += MyStoryboard_Completed;
            ObjectAnimationUsingKeyFrames animation = new ObjectAnimationUsingKeyFrames();

            Storyboard.SetTarget(animation, bone.BoneGrid);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Margin"));

            System.Windows.Point target = BonesRepository.PlayedZone.GetTargetPoint(isToEnd, bone.AreHalfsEquil);
            if (target.X == -1 && target.Y == -1)
            {
                target = new System.Windows.Point(
                    Math.Floor(Math.Abs(borderPoint.X) + Math.Abs(mainWindow.border.ActualWidth / 2)) - Math.Min(bone.BoneGrid.Width, bone.BoneGrid.Height),
                    Math.Floor(Math.Abs(borderPoint.Y) + Math.Abs(mainWindow.border.ActualHeight / 2)) - Math.Min(bone.BoneGrid.Width, bone.BoneGrid.Height) * (bone.AreHalfsEquil ? 1 : 0.5));
            }

            double diffX = Math.Abs(startPoint.X) - target.X;
            double diffY = Math.Abs(startPoint.Y) - target.Y;

            for (int count = 1; count < 101; count++)
            {
                double left = bone.BoneGrid.Margin.Left - (diffX / 100.0 * count);
                double top  = bone.BoneGrid.Margin.Top - (diffY / 100.0 * count);
                DiscreteObjectKeyFrame keyFrame = new DiscreteObjectKeyFrame(new
                                                                             Thickness(left, top, 0, 0), TimeSpan.FromMilliseconds(0.01 * DelayInMs * count));
                animation.KeyFrames.Add(keyFrame);
            }
            myStoryboard.Children.Add(animation);
            myStoryboard.Begin();
        }
Exemple #4
0
 private protected virtual void StartAnimation(BonesZone zoneTo, BoneGraphics bone, bool isToEnd, bool isNeedToTransferMove, System.Windows.Point startPoint)
 {
 }