// This performs the copy. Returns false when copy was cancelled. private bool DoCopySelection(string desc) { // Check if possible to copy/paste if (General.Editing.Mode.Attributes.AllowCopyPaste) { // Let the plugins know if (General.Plugins.OnCopyBegin()) { // Ask the editing mode to prepare selection for copying. // The edit mode should mark all vertices, lines and sectors that need to be copied. if (General.Editing.Mode.OnCopyBegin()) { General.MainWindow.DisplayStatus(StatusType.Action, desc); // Copy the marked geometry // This links sidedefs that are not linked to a marked sector to a virtual sector MapSet copyset = General.Map.Map.CloneMarked(); // Write data to stream using (MemoryStream memstream = new MemoryStream()) { ClipboardStreamWriter.Write(copyset, memstream); try { //mxd. Set on clipboard DataObject copydata = new DataObject(); copydata.SetData(CLIPBOARD_DATA_FORMAT, memstream); Clipboard.SetDataObject(copydata, true, 5, 200); } catch (ExternalException) { General.Interface.DisplayStatus(StatusType.Warning, "Failed to perform a Clipboard operation..."); return(false); } } // Done General.Editing.Mode.OnCopyEnd(); General.Plugins.OnCopyEnd(); return(true); } } } else { // Copy not allowed General.MessageBeep(MessageBeepType.Warning); } // Aborted return(false); }
// This performs the copy. Returns false when copy was cancelled. public static bool DoCopySelection(string desc) { // Check if possible to copy/paste if (General.Editing.Mode.Attributes.AllowCopyPaste) { // Let the plugins know if (General.Plugins.OnCopyBegin()) { // Ask the editing mode to prepare selection for copying. // The edit mode should mark all vertices, lines and sectors // that need to be copied. if (General.Editing.Mode.OnCopyBegin()) { bool oldmapischanged = General.Map.IsChanged; General.MainWindow.DisplayStatus(StatusType.Action, desc); // Copy the marked geometry // This links sidedefs that are not linked to a marked sector to a virtual sector MapSet copyset = General.Map.Map.CloneMarked(); // Convert flags and activations to UDMF fields, if needed if (!(General.Map.FormatInterface is UniversalMapSetIO)) { copyset.TranslateToUDMF(General.Map.FormatInterface.GetType()); } // Write data to stream MemoryStream memstream = new MemoryStream(); ClipboardStreamWriter writer = new ClipboardStreamWriter(); //mxd writer.Write(copyset, memstream); try { #if !MONO_WINFORMS DataObject copydata = new DataObject(); copydata.SetData(CLIPBOARD_DATA_FORMAT, memstream); Clipboard.SetDataObject(copydata, true, 5, 200); #else Clipboard.SetText(CLIPBOARD_DATA_FORMAT + Convert.ToBase64String(memstream.ToArray())); #endif } catch (ExternalException) { General.Interface.DisplayStatus(StatusType.Warning, "Failed to perform a Clipboard operation..."); memstream.Dispose(); return(false); } // General.Map.Map.CloneMarked will set General.Map.IsChanged to true, since it recreated the map. But since this // creation happens in another MapSet, the currently opened map is actually not changed. Force the IsChanged property // to false if the map wasn't changed before doing the copying if (oldmapischanged == false) { General.Map.ForceMapIsChangedFalse(); } // Done memstream.Dispose(); General.Editing.Mode.OnCopyEnd(); General.Plugins.OnCopyEnd(); return(true); } } } else { // Copy not allowed General.MessageBeep(MessageBeepType.Warning); } // Aborted return(false); }
// This performs the copy. Returns false when copy was cancelled. public static bool DoCopySelection(string desc) { // Check if possible to copy/paste if (General.Editing.Mode.Attributes.AllowCopyPaste) { // Let the plugins know if (General.Plugins.OnCopyBegin()) { // Ask the editing mode to prepare selection for copying. // The edit mode should mark all vertices, lines and sectors // that need to be copied. if (General.Editing.Mode.OnCopyBegin()) { General.MainWindow.DisplayStatus(StatusType.Action, desc); // Copy the marked geometry // This links sidedefs that are not linked to a marked sector to a virtual sector MapSet copyset = General.Map.Map.CloneMarked(); // Convert flags and activations to UDMF fields, if needed if (!(General.Map.FormatInterface is UniversalMapSetIO)) { copyset.TranslateToUDMF(General.Map.FormatInterface.GetType()); } // Write data to stream MemoryStream memstream = new MemoryStream(); ClipboardStreamWriter writer = new ClipboardStreamWriter(); //mxd writer.Write(copyset, memstream); try { //mxd. Set on clipboard DataObject copydata = new DataObject(); copydata.SetData(CLIPBOARD_DATA_FORMAT, memstream); Clipboard.SetDataObject(copydata, true, 5, 200); } catch (ExternalException) { General.Interface.DisplayStatus(StatusType.Warning, "Failed to perform a Clipboard operation..."); memstream.Dispose(); return(false); } // Done #if !MONO_WINFORMS // seems mono claimed ownership of the memory stream... memstream.Dispose(); #endif General.Editing.Mode.OnCopyEnd(); General.Plugins.OnCopyEnd(); return(true); } } } else { // Copy not allowed General.MessageBeep(MessageBeepType.Warning); } // Aborted return(false); }