Added some boilerplate to clipboard operations.

This commit is contained in:
MaxED 2016-05-06 08:47:30 +00:00
parent 133c2fce34
commit 751e2dd3e3
7 changed files with 51 additions and 22 deletions

View file

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Actions;
using CodeImp.DoomBuilder.Config;
@ -248,8 +249,19 @@ namespace CodeImp.DoomBuilder.Editing
ClipboardStreamWriter writer = new ClipboardStreamWriter(); //mxd
writer.Write(copyset, memstream);
// Set on clipboard
Clipboard.SetData(CLIPBOARD_DATA_FORMAT, 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
memstream.Dispose();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -163,9 +163,9 @@ namespace CodeImp.DoomBuilder.Windows
// pictureBox4
//
this.pictureBox4.Image = global::CodeImp.DoomBuilder.Properties.Resources.MLogo;
this.pictureBox4.Location = new System.Drawing.Point(289, 6);
this.pictureBox4.Location = new System.Drawing.Point(291, 6);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(88, 80);
this.pictureBox4.Size = new System.Drawing.Size(86, 88);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pictureBox4.TabIndex = 16;
this.pictureBox4.TabStop = false;
@ -187,9 +187,9 @@ namespace CodeImp.DoomBuilder.Windows
//
// copyversion
//
this.copyversion.Location = new System.Drawing.Point(269, 97);
this.copyversion.Location = new System.Drawing.Point(291, 95);
this.copyversion.Name = "copyversion";
this.copyversion.Size = new System.Drawing.Size(108, 25);
this.copyversion.Size = new System.Drawing.Size(81, 25);
this.copyversion.TabIndex = 13;
this.copyversion.Text = "Copy Version";
this.copyversion.UseVisualStyleBackColor = true;
@ -199,7 +199,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.version.AutoSize = true;
this.version.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.version.Location = new System.Drawing.Point(11, 102);
this.version.Location = new System.Drawing.Point(14, 102);
this.version.Name = "version";
this.version.Size = new System.Drawing.Size(150, 13);
this.version.TabIndex = 11;

View file

@ -17,6 +17,7 @@
#region ================== Namespaces
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
#endregion
@ -60,7 +61,14 @@ namespace CodeImp.DoomBuilder.Windows
// This copies the version number to clipboard
private void copyversion_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(Application.ProductVersion, true, 5, 200); //mxd
try //mxd
{
Clipboard.SetDataObject(Application.ProductVersion, true, 5, 200);
}
catch(ExternalException)
{
General.Interface.DisplayStatus(StatusType.Warning, "Failed to perform a Clipboard operation...");
}
}
}
}

View file

@ -138,7 +138,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
try
{
Clipboard.SetDataObject(str.ToString(), true);
Clipboard.SetDataObject(str.ToString(), true, 5, 200);
}
catch(ExternalException)
{

View file

@ -613,11 +613,11 @@ namespace CodeImp.DoomBuilder.Windows
// label1
//
label1.AutoSize = true;
label1.Location = new System.Drawing.Point(45, 171);
label1.Location = new System.Drawing.Point(41, 171);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(143, 13);
label1.Size = new System.Drawing.Size(145, 13);
label1.TabIndex = 20;
label1.Text = "Texture and Flats brightness:";
label1.Text = "Textures and flats brightness:";
label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label18
@ -667,9 +667,9 @@ namespace CodeImp.DoomBuilder.Windows
label29.AutoSize = true;
label29.Location = new System.Drawing.Point(90, 356);
label29.Name = "label29";
label29.Size = new System.Drawing.Size(94, 13);
label29.Size = new System.Drawing.Size(93, 13);
label29.TabIndex = 38;
label29.Text = "Edge Anti-aliasing:";
label29.Text = "Edge anti-aliasing:";
label29.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// keyusedlabel
@ -1716,11 +1716,11 @@ namespace CodeImp.DoomBuilder.Windows
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(45, 134);
this.label32.Location = new System.Drawing.Point(44, 134);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(143, 13);
this.label32.Size = new System.Drawing.Size(139, 13);
this.label32.TabIndex = 44;
this.label32.Text = "Hidden Things transparency:";
this.label32.Text = "Hidden things transparency:";
this.label32.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.toolTip1.SetToolTip(this.label32, "Sets transparency of things hidden \r\nby Things Filter in Things mode");
//

View file

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Editing;
@ -747,12 +748,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Get results
StringBuilder sb = new StringBuilder();
foreach(ErrorResult result in results.SelectedItems) sb.AppendLine(result.ToString());
try
{
//mxd. Set on clipboard
Clipboard.SetDataObject(sb.ToString(), true, 5, 200);
// Set on clipboard
Clipboard.SetDataObject(sb.ToString(), true, 5, 200); //mxd
// Inform the user
General.Interface.DisplayStatus(StatusType.Info, "Analysis results copied to clipboard.");
// Inform the user
General.Interface.DisplayStatus(StatusType.Info, "Analysis results copied to clipboard.");
}
catch(ExternalException)
{
// Inform the user
General.Interface.DisplayStatus(StatusType.Warning, "Failed to perform a Clipboard operation...");
}
}
private void results_KeyUp(object sender, KeyEventArgs e)