mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 12:22:35 +00:00
For mono, put clipboard data in text/base64 form instead of relying on a memory stream
This commit is contained in:
parent
63b3766ae2
commit
a608ad71fa
1 changed files with 16 additions and 6 deletions
|
@ -254,10 +254,13 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
try
|
||||
{
|
||||
//mxd. Set on clipboard
|
||||
#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)
|
||||
{
|
||||
|
@ -267,9 +270,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
|
||||
// Done
|
||||
#if !MONO_WINFORMS // seems mono claimed ownership of the memory stream...
|
||||
memstream.Dispose();
|
||||
#endif
|
||||
General.Editing.Mode.OnCopyEnd();
|
||||
General.Plugins.OnCopyEnd();
|
||||
return true;
|
||||
|
@ -292,8 +293,13 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Check if possible to copy/paste
|
||||
if(General.Editing.Mode.Attributes.AllowCopyPaste)
|
||||
{
|
||||
#if !MONO_WINFORMS
|
||||
bool havepastedata = Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT); //mxd
|
||||
bool havedb2pastedata = Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT_DB2); //mxd
|
||||
#else
|
||||
bool havepastedata = Clipboard.ContainsText() && Clipboard.GetText().Length > CLIPBOARD_DATA_FORMAT.Length && Clipboard.GetText().Substring(0, CLIPBOARD_DATA_FORMAT.Length) == CLIPBOARD_DATA_FORMAT;
|
||||
bool havedb2pastedata = false;
|
||||
#endif
|
||||
|
||||
// Anything to paste?
|
||||
if(havepastedata || havedb2pastedata)
|
||||
|
@ -317,7 +323,11 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Read from clipboard
|
||||
if(havepastedata)
|
||||
{
|
||||
#if MONO_WINFORMS
|
||||
using(Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT))
|
||||
#else
|
||||
using(Stream memstream = new MemoryStream(Convert.FromBase64String(((string)Clipboard.GetData(DataFormats.Text)).Substring(CLIPBOARD_DATA_FORMAT.Length))))
|
||||
#endif
|
||||
{
|
||||
if (memstream == null) return;
|
||||
|
||||
|
@ -403,9 +413,9 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region ================== Actions
|
||||
#region ================== Actions
|
||||
|
||||
// This copies the current selection
|
||||
[BeginAction("copyselection")]
|
||||
|
@ -653,6 +663,6 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue