public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { List <FreeText> shapes = CurrentPage.SelectedShapes.OfType <FreeText>().ToList(); // new copy so we don't have problems editing while iterating if (shapes.Count == 0) { return; } CurrentPage.DeleteSelected(transaction); List <Shape> newList = new List <Shape>(); foreach (FreeText shp in shapes) { TextLine textLine = TextLine.FromFreeText(shp); transaction.Create(textLine); newList.Add(textLine); CurrentPage.AddNew(textLine, transaction); } CurrentPage.SelectOnly(newList); }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { CurrentPage.DeleteSelected(transaction); }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { if (CurrentPage == null || CurrentPage.SelectedCount == 0) { return; } // the items to put on the clipboard // even if cutting, we put a different copy of the objects on the clipboard with different IDs (in case the user undoes which would restore the original objects) DatumList hash = Datum.CloneList(CurrentPage.SelectedShapes, Globals.Root.CurrentDocument); // copies shapes, changes IDs, updates links and includes references as needed // write the list of shapes into a byte buffer; this way we control the serialisation DataObject data = new DataObject(); using (MemoryStream buffer = new MemoryStream(1000)) { using (DataWriter writer = new DataWriter(buffer, FileMarkers.ShapeList)) { List <Datum> list = new List <Datum>(); list.AddRange(hash.Values); writer.WriteDatumList(list); data.SetData("Splash data", false, buffer.GetBuffer()); } } Bitmap bitmap = (Bitmap)pnlView.CreateImage(false, false, true); // will have white background - transparent gets lost somewhere within clipboard data.SetImage(bitmap); //objBitmap.Dispose()' doesn't work if this done // http://stackoverflow.com/questions/35045500/copy-svg-image-stored-as-xml-string-to-windows-clipboard-as-image-svgxml-mime-t try { var strSVG = pnlView.CreateSVG(false, true); // True) byte[] aBytes = Encoding.UTF8.GetBytes(strSVG); MemoryStream objStream = new MemoryStream(aBytes); data.SetData("image/svg+xml", objStream); //System.IO.File.WriteAllText("g:\temp\svg.svg", strSVG) } catch (UserException u) { Globals.Root.Log.WriteLine("Cannot copy as SVG: " + u.Message); } catch (Exception ex) { Utilities.LogSubError(ex); } //check for text string text = ""; foreach (Shape shape in CurrentPage.SelectedShapes) { if (shape.HasText(true) && !String.IsNullOrEmpty(shape.LabelText)) { text = shape.LabelText; break; // stop once valid text found } } if (!string.IsNullOrEmpty(text)) { data.SetText(text); } // store result on clipboard Clipboard.SetDataObject(data); if (IsCut) { CurrentPage.DeleteSelected(transaction); } }