//public override void Run(Canguro.Controller.CommandServices services) //{ // List<Item> selection = GetSelection(services); // if (selection.Count == 0) // return; // Stream stream = new MemoryStream(); // try // { // BinaryFormatter bformatter = new BinaryFormatter(); // Magnet magnet = services.GetPoint("selectPivot"); // bformatter.Serialize(stream, magnet.SnapPosition); // bformatter.Serialize(stream, selection.Count); // foreach (Item item in selection) // { // bformatter.Serialize(stream, item); // item.IsSelected = true; // } // Clipboard.SetData("Canguro", stream); // } // finally // { // stream.Close(); // } //} /// <summary> /// Executes the command. /// Gets the selection and a pivot point, and adds them to the Clipboard with the key "Canguro" /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Dictionary <uint, Joint> joints = new Dictionary <uint, Joint>(); List <LineElement> lines = new List <LineElement>(); List <AreaElement> areas = new List <AreaElement>(); bool haveSelection = false; haveSelection = services.GetSelection(joints, lines, areas); if (!haveSelection) { services.GetMany(Culture.Get("selectItems")); haveSelection = services.GetSelection(joints, lines, areas); } if (haveSelection) { Magnet magnet = services.GetPoint(Culture.Get("selectPivot")); if (magnet != null) { Microsoft.DirectX.Vector3 pivot = magnet.SnapPosition; Clipboard.Clear(); object[] objs = new object[] { joints, lines, areas, pivot }; //// Test Serialization //System.IO.MemoryStream s = new MemoryStream(); //new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Serialize(s, objs); Clipboard.SetData("Canguro", objs); } } foreach (Item item in joints.Values) { if (item != null) { item.IsSelected = true; } } foreach (Item item in lines) { if (item != null) { item.IsSelected = true; } } foreach (Item item in areas) { if (item != null) { item.IsSelected = true; } } }