当前位置: 首页>>代码示例>>C#>>正文


C# System.Windows.Forms.NotifyIcon.Dispose方法代码示例

本文整理汇总了C#中System.Windows.Forms.NotifyIcon.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.NotifyIcon.Dispose方法的具体用法?C# System.Windows.Forms.NotifyIcon.Dispose怎么用?C# System.Windows.Forms.NotifyIcon.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.NotifyIcon的用法示例。


在下文中一共展示了System.Windows.Forms.NotifyIcon.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupTrayIcon

        private static void SetupTrayIcon(string logFileName)
        {
            // Create tray icon
            var components = new System.ComponentModel.Container();

            var notifyIcon = new System.Windows.Forms.NotifyIcon(components);
            notifyIcon.Text = "Paradox Connection Router";
            notifyIcon.Icon = Properties.Resources.Logo;
            notifyIcon.Visible = true;
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu();

            if (!string.IsNullOrEmpty(logFileName))
            {
                var showLogMenuItem = new System.Windows.Forms.MenuItem("Show &Log");
                showLogMenuItem.Click += (sender, args) => OnShowLogClick(logFileName);
                notifyIcon.ContextMenu.MenuItems.Add(showLogMenuItem);

                notifyIcon.BalloonTipClicked += (sender, args) => OnShowLogClick(logFileName);
            }

            var openConsoleMenuItem = new System.Windows.Forms.MenuItem("Open Console");
            openConsoleMenuItem.Click += (sender, args) => OnOpenConsoleClick((System.Windows.Forms.MenuItem)sender);
            notifyIcon.ContextMenu.MenuItems.Add(openConsoleMenuItem);

            var exitMenuItem = new System.Windows.Forms.MenuItem("E&xit");
            exitMenuItem.Click += (sender, args) => OnExitClick();
            notifyIcon.ContextMenu.MenuItems.Add(exitMenuItem);

            GlobalLogger.GlobalMessageLogged += (logMessage) =>
            {
                System.Windows.Forms.ToolTipIcon toolTipIcon;
                switch (logMessage.Type)
                {
                    case LogMessageType.Debug:
                    case LogMessageType.Verbose:
                    case LogMessageType.Info:
                        toolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
                        break;
                    case LogMessageType.Warning:
                        toolTipIcon = System.Windows.Forms.ToolTipIcon.Warning;
                        break;
                    case LogMessageType.Error:
                    case LogMessageType.Fatal:
                        toolTipIcon = System.Windows.Forms.ToolTipIcon.Error;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }

                // Display notification (for one second)
                notifyIcon.ShowBalloonTip(2000, "Paradox Connection Router", logMessage.ToString(), toolTipIcon);
            };

            System.Windows.Forms.Application.ApplicationExit += (sender, e) =>
            {
                notifyIcon.Visible = false;
                notifyIcon.Icon = null;
                notifyIcon.Dispose();
            };
        }
开发者ID:ItayGal2,项目名称:paradox,代码行数:60,代码来源:Program.cs

示例2: SetupTrayIcon

        private static void SetupTrayIcon(string logFileName)
        {
            // Create tray icon
            var components = new System.ComponentModel.Container();

            var notifyIcon = new System.Windows.Forms.NotifyIcon(components);
            notifyIcon.Text = "Xenko Connection Router";
            notifyIcon.Icon = Properties.Resources.Logo;
            notifyIcon.Visible = true;
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu();

            if (!string.IsNullOrEmpty(logFileName))
            {
                var showLogMenuItem = new System.Windows.Forms.MenuItem("Show &Log");
                showLogMenuItem.Click += (sender, args) => OnShowLogClick(logFileName);
                notifyIcon.ContextMenu.MenuItems.Add(showLogMenuItem);

                notifyIcon.BalloonTipClicked += (sender, args) => OnShowLogClick(logFileName);
            }

            var openConsoleMenuItem = new System.Windows.Forms.MenuItem("Open Console");
            openConsoleMenuItem.Click += (sender, args) => OnOpenConsoleClick((System.Windows.Forms.MenuItem)sender);
            notifyIcon.ContextMenu.MenuItems.Add(openConsoleMenuItem);

            var exitMenuItem = new System.Windows.Forms.MenuItem("E&xit");
            exitMenuItem.Click += (sender, args) => OnExitClick();
            notifyIcon.ContextMenu.MenuItems.Add(exitMenuItem);

            GlobalLogger.GlobalMessageLogged += (logMessage) =>
            {
                // Log only warning, errors and more
                if (logMessage.Type < LogMessageType.Warning)
                    return;

                var toolTipIcon = logMessage.Type < LogMessageType.Error ? System.Windows.Forms.ToolTipIcon.Warning : System.Windows.Forms.ToolTipIcon.Error;

                // Display notification (for two second)
                notifyIcon.ShowBalloonTip(2000, "Xenko Connection Router", logMessage.ToString(), toolTipIcon);
            };

            System.Windows.Forms.Application.ApplicationExit += (sender, e) =>
            {
                notifyIcon.Visible = false;
                notifyIcon.Icon = null;
                notifyIcon.Dispose();
            };
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:47,代码来源:Program.cs

示例3: InitializeNotifyIcon

 private void InitializeNotifyIcon()
 {
     NotifyIcon = new System.Windows.Forms.NotifyIcon
     {
         Text = "Patchy",
         Icon = new System.Drawing.Icon(Application.GetResourceStream(
             new Uri("pack://application:,,,/Patchy;component/Images/patchy.ico" )).Stream),
         Visible = true
     };
     NotifyIcon.DoubleClick += NotifyIconClick;
     NotifyIcon.BalloonTipClicked += NotifyIconBalloonTipClicked;
     var menu = new System.Windows.Forms.ContextMenu();
     menu.MenuItems.Add("Add Torrent", (s, e) => ExecuteNew(null, null));
     menu.MenuItems.Add("Exit", (s, e) =>
     {
         NotifyIcon.Dispose();
         AllowClose = true;
         Close();
     });
     NotifyIcon.ContextMenu = menu;
 }
开发者ID:headdetect,项目名称:Patchy,代码行数:21,代码来源:MainWindow.xaml.cs

示例4: Dispose

 private void Dispose(bool disposing)
 {
     if (!disposed)
     {
         disposed = true;
         var notifyIcon = this.notifyIcon;
         this.notifyIcon = null;
         if (notifyIcon != null)
         {
             notifyIcon.Dispose();
         }
         GC.SuppressFinalize(this);
     }
 }
开发者ID:wilson0x4d,项目名称:Mubox,代码行数:14,代码来源:AppWindow.xaml.cs


注:本文中的System.Windows.Forms.NotifyIcon.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。