Exemplo n.º 1
0
        private void PlaceBone(JointVM firstJoint, JointVM secondJoint)
        {
            var bone   = new Bone(firstJoint.Model, secondJoint.Model);
            var boneVM = new BoneVM(bone);

            if (CanvasVM.Creature.CreatureStructureVM.BoneCollectionVM.Any(b =>
            {
                if (b.FirstJoint.Model.Tracker == firstJoint.Model.Tracker &&
                    b.SecondJoint.Model.Tracker == secondJoint.Model.Tracker)
                {
                    return(true);
                }
                if (b.FirstJoint.Model.Tracker == secondJoint.Model.Tracker &&
                    b.SecondJoint.Model.Tracker == firstJoint.Model.Tracker)
                {
                    return(true);
                }
                return(false);
            }))
            {
                var infoMessage = new InfoMessage("Bone already placed between those joints", TimeSpan.FromSeconds(2), Brushes.Red);
                InfoMessageCollection.AddInfoMessageWithoutTracking(infoMessage);
                return;
            }

            var changeOperation = new ChangeOperation(c => { c.Creature.CreatureStructureVM.BoneCollectionVM.Add(boneVM); },
                                                      c => { c.Creature.CreatureStructureVM.BoneCollectionVM.Remove(boneVM); });

            CanvasVM.HistoryStack.AddOperation(changeOperation);
            Reset();
            FirstJoint = secondJoint;
            CanvasVM.PreviewBone.From = FirstJoint.Position;
        }
Exemplo n.º 2
0
        public void Position_SetSameValueTest_ReturnsSameValueTrue()
        {
            var joint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var jointVM = new JointVM(joint);

            jointVM.Position = jointVM.Position;

            double actual = jointVM.Position.Length;

            Assert.AreEqual(joint.Position.Length, actual);
        }
Exemplo n.º 3
0
        public void Position_SetDifferentValueTest_ReturnsFirstValueFalse()
        {
            var joint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var jointVM = new JointVM(joint)
            {
                Position = new Vector2(3, 10)
            };

            double actual = jointVM.Position.Length;

            Assert.AreNotEqual(new Vector2(5, 10).Length, actual);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public override bool OnCanvasMouseDown(MouseInfo mouseInfo, CreatureStructureEditorCanvasVM canvasVM, ModifierKeys modifierKeys)
        {
            CanvasVM = CanvasVM ?? canvasVM;
            if (base.OnCanvasMouseDown(mouseInfo, canvasVM, modifierKeys))
            {
                return(true);
            }

            var jointVM = new JointVM(new Joint {
                Position = canvasVM.PreviewJoint.Position
            });
            var changeOperation = new ChangeOperation(c => c.Creature.CreatureStructureVM.JointCollectionVM.Add(jointVM),
                                                      c => c.Creature.CreatureStructureVM.JointCollectionVM.Remove(jointVM));

            canvasVM.HistoryStack.AddOperation(changeOperation);
            return(true);
        }