Я пытаюсь создать NotifyIcon, который может быть унаследован, чтобы я мог добавить свои собственные свойства и т. Д.Посмотрев на класс компонента, который кто-то написал, я добился некоторого прогресса, как видно ниже, и компонент можно перетащить в форму.Честно говоря, я мало представляю, что я делаю, и в Интернете, похоже, нет учебных пособий, которые бы вообще пригодились.
В методе PrepareIcon
, который вы видите,всплывающее окно сообщения выглядит пустым, хотя я попытался изменить значение по умолчанию для конструктора notifyIconInheritable1
.Я видел, как NotifyIcon появлялся в конструкторе, поэтому я был совершенно сбит с толку тем, как это работает.
Вопрос в том;что не так с этим или что я делаю не так, и я трачу свое время и не должен пытаться это делать вообще?
namespace AwesomeNotifyIcon
{
[DefaultProperty("Text"), DefaultEvent("Click"), Description("Displays an icon in the notification area, on the right side of the Windows taskbar, during run time")]
public partial class NotifyIconInheritable : Component
{
private NotifyIcon notifyIcon;
public NotifyIconInheritable()
{
//PrepareIcon();
InitializeComponent();
}
public NotifyIconInheritable(IContainer container)
{
if (container != null)
{
container.Add(this);
}
PrepareIcon();
InitializeComponent();
}
[Category("Appearance"), Description("The icon to associate with the balloon ToolTip."), DefaultValue(ToolTipIcon.None)]
public ToolTipIcon BalloonTipIcon { get; set; }
[Category("Appearance"), Description("The text to associate with the balloon ToolTip.")]
public string BalloonTipText { get; set; }
[Category("Appearance"), Description("The title of the balloon ToolTip.")]
public string BalloonTipTitle { get; set; }
[Category("Appearance"), Description("The icon to display in the system tray.")]
public Icon Icon { get; set; }
[Category("Appearance"), Description("The text that will be displayed when the mouse hovers over the icon.")]
public string Text { get; set; }
[Category("Behaviour"), Description("The shortcut menu to show when the user right-clicks the icon.")]
public ContextMenuStrip ContextMenuStrip { get; set; }
[Category("Behaviour"), Description("Determines whether the control is visible or hidden."), DefaultValue(false)]
public bool Visible { get; set; }
[Category("Data"), Description("User-defined data associated with the object.")]
public object Tag { get; set; }
[Category("Action"), Description("Occurs when the component is clicked.")]
public event EventHandler Click;
private void PrepareIcon()
{
notifyIcon = new NotifyIcon();
notifyIcon.Dispose();
MessageBox.Show(this.Text);
if (Click != null)
notifyIcon.Click += Click;
}
}
}
Вот свойства, как видно в конструкторе:
http://cl.ly/1vIF/content http://cl.ly/1vIF/content