2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2019-01-02 20:43:52 +13:00
|
|
|
|
Copyright (c) 2007-2019 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib.Properties;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.HelpersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public partial class ClipboardContentViewer : Form
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-01-13 19:54:36 +13:00
|
|
|
|
public bool IsClipboardContentValid { get; private set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public bool DontShowThisWindow { get; private set; }
|
2018-10-30 13:37:58 +13:00
|
|
|
|
public EClipboardContentType ClipboardContentType { get; private set; }
|
|
|
|
|
public object ClipboardContent { get; private set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
public ClipboardContentViewer(bool showCheckBox = false)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-02-26 09:55:54 +13:00
|
|
|
|
Icon = ShareXResources.Icon;
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
cbDontShowThisWindow.Visible = showCheckBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClipboardContentViewer_Load(object sender, EventArgs e)
|
2016-01-13 19:54:36 +13:00
|
|
|
|
{
|
|
|
|
|
IsClipboardContentValid = CheckClipboardContents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool CheckClipboardContents()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
pbClipboard.Visible = txtClipboard.Visible = lbClipboard.Visible = false;
|
|
|
|
|
|
|
|
|
|
if (Clipboard.ContainsImage())
|
|
|
|
|
{
|
2015-12-30 00:26:22 +13:00
|
|
|
|
using (Image img = ClipboardHelpers.GetImage())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-01-13 19:54:36 +13:00
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2018-10-30 13:37:58 +13:00
|
|
|
|
ClipboardContentType = EClipboardContentType.Image;
|
|
|
|
|
ClipboardContent = img.Clone();
|
2016-01-13 19:54:36 +13:00
|
|
|
|
pbClipboard.LoadImage(img);
|
|
|
|
|
pbClipboard.Visible = true;
|
|
|
|
|
lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__Image__Size___0_x_1__, img.Width, img.Height);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Clipboard.ContainsText())
|
|
|
|
|
{
|
|
|
|
|
string text = Clipboard.GetText();
|
2016-01-13 19:54:36 +13:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(text))
|
|
|
|
|
{
|
2018-10-30 13:37:58 +13:00
|
|
|
|
ClipboardContentType = EClipboardContentType.Text;
|
|
|
|
|
ClipboardContent = text;
|
2016-01-13 19:54:36 +13:00
|
|
|
|
txtClipboard.Text = text;
|
|
|
|
|
txtClipboard.Visible = true;
|
|
|
|
|
lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__Text__Length___0__, text.Length);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else if (Clipboard.ContainsFileDropList())
|
|
|
|
|
{
|
|
|
|
|
string[] files = Clipboard.GetFileDropList().OfType<string>().ToArray();
|
2016-01-13 19:54:36 +13:00
|
|
|
|
|
|
|
|
|
if (files.Length > 0)
|
|
|
|
|
{
|
2018-10-30 13:37:58 +13:00
|
|
|
|
ClipboardContentType = EClipboardContentType.Files;
|
|
|
|
|
ClipboardContent = files;
|
2016-01-13 19:54:36 +13:00
|
|
|
|
lbClipboard.Items.AddRange(files);
|
|
|
|
|
lbClipboard.Visible = true;
|
|
|
|
|
lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__File__Count___0__, files.Length);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2016-01-13 19:54:36 +13:00
|
|
|
|
|
|
|
|
|
lblQuestion.Text = Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_is_empty_or_contains_unknown_data_;
|
|
|
|
|
return false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClipboardContentViewer_Shown(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-10 05:37:54 +13:00
|
|
|
|
this.ForceActivate();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbDontShowThisWindow_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DontShowThisWindow = cbDontShowThisWindow.Checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|