Пример #1
0
        /// <summary>Used by the Paste verb to do the paste in this case</summary>
        public static void Paste(Transaction transaction, EditableView pnlView)
        {
            DataObject data = (DataObject)Clipboard.GetDataObject();

            byte[] buffer = (byte[])data.GetData("Splash presentation", false);
            if (buffer == null)
            {
                Debug.Fail("Deserialisation failed");
                return;
            }
            using (MemoryStream stream = new MemoryStream(buffer, false))
                using (DataReader reader = new DataReader(stream, (FileMarkers)Shape.Shapes.SAWItem))
                {
                    Item copied = (Item)reader.ReadData((FileMarkers)Shape.Shapes.SAWItem);
                    copied.UpdateReferencesObjectsCreated(CurrentDocument, reader);
                    //copied.UpdateReferencesIDsChanged(hashIDChanges, Globals.Root.CurrentDocument);
                    foreach (Shape target in CurrentPage.SelectedShapes)
                    {
                        Item itemTarget = (Item)((target as Scriptable)?.Element ?? target);                 // unwraps the Scriptable if that was selected
                        transaction.Edit(itemTarget);
                        if (string.IsNullOrEmpty(itemTarget.LabelText))
                        {
                            itemTarget.LabelText = copied.LabelText;
                        }
                        itemTarget.FillStyle?.CopyFrom(copied.FillStyle);
                        itemTarget.LineStyle?.CopyFrom(copied.LineStyle);
                        itemTarget.TextStyle?.CopyFrom(copied.TextStyle);
                        itemTarget.CopyPresentationFrom(copied, true);
                        Scriptable scriptableTarget = target as Scriptable ?? (Scriptable)(target as Item).Parent;
                        scriptableTarget.CopyPresentationFrom((Scriptable)copied.Parent, true);
                    }
                }
            pnlView.InvalidateData(CurrentPage.SelectedRefreshBoundary(), StaticView.InvalidationBuffer.All);
        }