You would need a reference to your Main
form, which would need to be passed to your class (probably in the constructor):
public class MyClass
{
private Form Main { get; set; }
public MyClass(Form main, ...)
{
Main = main;
}
}
Then you'd call the item from your class:
private method DoSomething(...)
{
Main.TaskbarIcon.ShowBalloonTip(...);
}
However, as you mentioned, it's better to put something between your class and the actual object.
Edit: You could also pass a delegate to invoke that will make the changes for you, or you could pass a reference to the item (again, not recommended). However, make sure you're doing this all on the same thread.
Edit2: Building on the link, your interface could look like this:
interface IYourForm
{
void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon);
}
Your form would then implement the interface:
class YourForm : Form, IYourForm
And the method:
public void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon)
{
TaskbarIcon.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon);
}
This would then change your DoSomething method to look like this:
private method DoSomething(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon)
{
Main.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon);
}
Again, make sure this is all on the same thread. Otherwise, this needs to be handled differently.