Canguro.Commands.Model.ScaleCmd.Run C# (CSharp) Method

Run() public method

Executes the command. Moves the joint according to a given scale factor and pivot point.
public Run ( Canguro services ) : void
services Canguro CommandServices object to interact with the system
return void
        public override void Run(Canguro.Controller.CommandServices services)
        {
            List<Canguro.Model.Joint> selection = new List<Canguro.Model.Joint>();
            List<Item> selectedItems = services.GetSelection();
            if (selectedItems.Count == 0)
                return;

            foreach (Item item in selectedItems)
            {
                if (item is Joint)
                    selection.Add((Joint)item);
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    if (!selection.Contains(l.I))
                        selection.Add(l.I);
                    if (!selection.Contains(l.J))
                        selection.Add(l.J);
                }
            }

            Microsoft.DirectX.Vector3 piv;
            float scale = services.GetSingle(Culture.Get("getScale"));

            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("pivotScalePoint"));
            if (m == null) return;
            piv = m.SnapPosition;

            foreach (Canguro.Model.Joint j in selection)
            {
                j.X = (j.X - piv.X) * scale + piv.X;
                j.Y = (j.Y - piv.Y) * scale + piv.Y;
                j.Z = (j.Z - piv.Z) * scale + piv.Z;
            }
        }
ScaleCmd