public static void GenerateClipBoardData(DataObjectCopyingEventArgs e, TextSelection selection) { string str; using (MemoryStream stream = new MemoryStream()) { TextRange range = new TextRange(selection.Start, selection.End); range.ClearAllProperties(); range.Save(stream, DataFormats.Xaml, true); stream.Flush(); stream.Position = 0L; using (StreamReader reader = new StreamReader(stream)) { str = reader.ReadToEnd(); } } if (!string.IsNullOrEmpty(str)) { string str2 = ReplaceControls.ReplaceGUIWithClipboardControl(str, selection.Start, selection.End); if (!string.IsNullOrEmpty(str2) && (str2 != str)) { e.DataObject.SetData(BamaDataFormat, str2); } } }
internal static bool PasteContentData(InputBox inputBox, IDataObject iDataObject) { TextData data = TryGetText(iDataObject); if (!data.ContainsData) { if (iDataObject.GetDataPresent(DataFormats.Bitmap, true)) { inputBox.Paste(iDataObject); return(true); } return(false); } inputBox.TempFlowDocument.Blocks.Clear(); TextRange range = null; if (data.Format == BamaDataFormat) { object obj2 = XamlReader.Parse(data.Data); if (obj2 is Block) { inputBox.TempFlowDocument.Blocks.Add(obj2 as Block); } else if (obj2 is Inline) { Span span = new Span(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd) { Inlines = { obj2 as Span } }; } range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd); range.ClearAllProperties(); inputBox.Selection.Text = ""; Span newspan = new Span(inputBox.Selection.Start, inputBox.Selection.End); ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, newspan); inputBox.CaretPosition = newspan.ElementEnd.GetInsertionPosition(LogicalDirection.Forward); } else { range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd); using (MemoryStream stream = new MemoryStream()) { using (StreamWriter writer = new StreamWriter(stream)) { writer.Write(data.Data); writer.Flush(); stream.Position = 0L; range.Load(stream, data.Format); } } range.ClearAllProperties(); inputBox.Selection.Text = ""; Span span3 = new Span(inputBox.Selection.Start, inputBox.Selection.End); ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, span3); inputBox.CaretPosition = span3.ElementEnd.GetInsertionPosition(LogicalDirection.Forward); } inputBox.TempFlowDocument.Blocks.Clear(); return(true); }
// Methods internal static UIElement CreateUserControl(ClipboardControl cc) { if (cc.ControlType == "Bama.Controls.ImageEx") { return(ReplaceControls.CreateImageExWithId(cc.ImagePath, cc.SysId)); } return(null); }