Exemple #1
0
        protected void Paste()
        {
            string copyBuffer = Clipboard.GetData("FlowSharp")?.ToString();

            if (copyBuffer == null)
            {
                MessageBox.Show("Clipboard does not contain a FlowSharp shape", "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    GraphicElement el = Persist.DeserializeElement(canvas, copyBuffer);
                    el.Move(new Point(20, 20));
                    el.UpdateProperties();
                    el.UpdatePath();
                    canvasController.Insert(el);
                    canvasController.DeselectCurrentSelectedElement();
                    canvasController.SelectElement(el);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error pasting shape:\r\n" + ex.Message, "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }