shahrabiamir
Member
با سلام
ببخشید سوالاتم زیاد شده. من یک notify icon توی WPF طراحی کردم اما هر کاری میکنم توی ناحیه Notification area ویندوز Ballon Tip به من نشون نمیده. این هم کدش هست:
ببخشید سوالاتم زیاد شده. من یک notify icon توی WPF طراحی کردم اما هر کاری میکنم توی ناحیه Notification area ویندوز Ballon Tip به من نشون نمیده. این هم کدش هست:
کد:
using System;
using System.Windows.Media;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
private System.Windows.Forms.NotifyIcon icon;
private System.Windows.Forms.ContextMenu contextMenuTrayIcon;
private System.Windows.Forms.MenuItem menuItemShowForm;
private System.Windows.Forms.MenuItem menuItemExitForm;
private IContainer components;
public MainWindow()
{
InitializeComponent();
components = new Container();
contextMenuTrayIcon = new System.Windows.Forms.ContextMenu();
menuItemShowForm = new System.Windows.Forms.MenuItem();
menuItemShowForm.Text = "Show Form";
menuItemShowForm.Index = 0;
menuItemShowForm.Click += MenuItemShowForm_Click;
menuItemExitForm = new System.Windows.Forms.MenuItem();
menuItemExitForm.Text = "Exit";
menuItemExitForm.Index = 1;
menuItemExitForm.Click += MenuItemExitForm_Click;
icon = new System.Windows.Forms.NotifyIcon(this.components);
icon.Icon = new System.Drawing.Icon("Image/index.ico");
this.contextMenuTrayIcon.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { menuItemShowForm, menuItemExitForm });
this.icon.ContextMenu = contextMenuTrayIcon;
this.icon.Text = "WPF Application";
this.icon.Visible = true;
this.icon.DoubleClick += Icon_DoubleClick;
}
private void Icon_DoubleClick(object sender, EventArgs e)
{
this.Show();
}
private void MenuItemShowForm_Click(object sender, EventArgs e)
{
}
private void MenuItemExitForm_Click(object sender, EventArgs e)
{
Application.Current.Shutdown();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Hide();
this.icon.BalloonTipTitle = "Notify Ballon";
this.icon.BalloonTipText = "WPF app";
this.icon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.icon.ShowBalloonTip(5);
}
}
}