2020-07-07 07:15:45 +12:00
|
|
|
|
// <copyright file="LabelNoCopy.cs" company="PlaceholderCompany">
|
|
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
|
|
// </copyright>
|
2020-03-28 12:42:32 +13:00
|
|
|
|
|
|
|
|
|
namespace SystemTrayMenu.UserInterface
|
|
|
|
|
{
|
2020-07-07 07:15:45 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
2020-07-07 09:37:55 +12:00
|
|
|
|
|
2020-03-28 12:42:32 +13:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Workaround class for "Clipboard" issue on .Net Windows Forms Label (https://github.com/Hofknecht/SystemTrayMenu/issues/5)
|
|
|
|
|
/// On Label MouseDoubleClick the framework will copy the title text into the clipboard.
|
|
|
|
|
/// We avoid this by overriding the Text atrribute and use own _text attribute.
|
|
|
|
|
/// Text will remain unset and clipboard copy will not take place but it is still possible to get/set Text attribute as usual from outside.
|
|
|
|
|
/// (see: https://stackoverflow.com/questions/2519587/is-there-any-way-to-disable-the-double-click-to-copy-functionality-of-a-net-l)
|
2020-07-07 07:15:45 +12:00
|
|
|
|
///
|
2020-03-28 12:42:32 +13:00
|
|
|
|
/// Note: When you have trouble with the Visual Studio Designer not showing the GUI properly, simply build once and reopen the Designer.
|
|
|
|
|
/// This will place the required files into the Designer's cache and becomes able to show the GUI as usual.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LabelNoCopy : Label
|
|
|
|
|
{
|
2020-07-07 09:37:55 +12:00
|
|
|
|
private string text;
|
|
|
|
|
|
2020-03-28 12:42:32 +13:00
|
|
|
|
public override string Text
|
|
|
|
|
{
|
2020-07-07 09:37:55 +12:00
|
|
|
|
get => text;
|
2020-03-28 12:42:32 +13:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
2020-07-07 07:15:45 +12:00
|
|
|
|
value = string.Empty;
|
2020-03-28 12:42:32 +13:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 09:37:55 +12:00
|
|
|
|
if (text != value)
|
2020-03-28 12:42:32 +13:00
|
|
|
|
{
|
2020-07-07 09:37:55 +12:00
|
|
|
|
text = value;
|
2020-03-28 12:42:32 +13:00
|
|
|
|
Refresh();
|
|
|
|
|
OnTextChanged(EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|