运行无形通知用户控制? [英] Run Formless Notification User Control?

查看:111
本文介绍了运行无形通知用户控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的codeI需要,而不显示任何形式我怎么能做到这一点跑通知控制?我只是添加此code到Program.cs的主线程,但它不工作,请帮助我?

in my code i need to run notification control without showing any form how can i do it? i just add this code to program.cs main thread but it's not working please help me with this?

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run();
        TaskbarIcon tb = new TaskbarIcon();
        var balloon = new Warning();
        tb.ShowCustomBalloon(balloon, PopupAnimation.Fade, 12000);

警告用户控件

warning is a user control

推荐答案

我会建议调用Application.Run()用的ApplicationContext作为参数的实例:

I would recommend calling Application.Run() with an instance of ApplicationContext as parameter:

class Kernel : ApplicationContext
{
    private TaskbarIcon tb = new TaskbarIcon();

    public void Show()
    {
        var ballon = new Warning();
        tb.ShowCustomBalloon(balloon, PopupAnimation.Fade, 12000);
    }

    /// <summary>
    /// Closes the application.
    /// </summary>
    public void Close()
    {
        Application.Exit();
    }
}

Programm.cs:

Programm.cs:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

using(var kernel = new Kernel())
{
    Application.Run(kernel);
}

此方式,它适用于默认的.NET的NotifyIcon。

This way it works with the default .NET NotifyIcon.

这篇关于运行无形通知用户控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆