public override CopyDataObject Copy(bool removeSelection) { CopyDataObject temp = base.Copy(removeSelection); DataObject data = new DataObject(); data.SetImage(temp.Image); XElement rootElement = new XElement(this.GetType().Name); rootElement.Add(new XElement("SessionId", sessionString)); rootElement.Add(textManager.Serialize()); rootElement.Add(new XElement("payload", temp.XElement)); MathEditorData med = new MathEditorData { XmlString = rootElement.ToString() }; data.SetData(med); //data.SetText(GetSelectedText()); if (temp.Text != null) { data.SetText(temp.Text); } Clipboard.SetDataObject(data, true); if (removeSelection) { DeSelect(); AdjustCarets(); } return(temp); }
public bool PasteFromClipBoard() { bool success = false; MathEditorData data = null; string text = ""; for (int i = 0; i < 3; i++) { try { if (Clipboard.ContainsData(typeof(MathEditorData).FullName)) { data = Clipboard.GetData(typeof(MathEditorData).FullName) as MathEditorData; break; } else if (Clipboard.ContainsText()) { text = Clipboard.GetText(); break; } } catch { Thread.Sleep(100); } } try { if (data != null) { XElement element = XElement.Parse(data.XmlString, LoadOptions.PreserveWhitespace); Paste(element); success = true; } else if (!string.IsNullOrEmpty(text)) { ConsumeText(text); success = true; } } catch { success = false; } return(success); }
public override CopyDataObject Copy(bool removeSelection) { CopyDataObject temp = base.Copy(removeSelection); DataObject data = new DataObject(); data.SetImage(temp.Image); XElement rootElement = new XElement(this.GetType().Name); rootElement.Add(new XElement("SessionId", sessionString)); rootElement.Add(textManager.Serialize()); rootElement.Add(new XElement("payload", temp.XElement)); MathEditorData med = new MathEditorData { XmlString = rootElement.ToString() }; data.SetData(med); //data.SetText(GetSelectedText()); if (temp.Text != null) { data.SetText(temp.Text); } Clipboard.SetDataObject(data, true); if (removeSelection) { DeSelect(); AdjustCarets(); } return temp; }