十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本文为大家分享了C#程序启动项的设置方法,供大家参考,具体内容如下
创新互联建站专业为企业提供洛龙网站建设、洛龙做网站、洛龙网站设计、洛龙网站制作等企业网站建设、网页设计与制作、洛龙企业网站模板建站服务,十余年洛龙做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。托盘图标设置
新建一个NotifyIcon,会在托盘处显示一个图标。
NotifyIcon.Icon可以直接设置一个ico图片,也可以延用原有程序的图标。
notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);
public partial class MainWindow : Window { private NotifyIcon notifyIcon; public MainWindow() { InitializeComponent(); SetNotifyIcon(); this.Hide(); } #region NotifyIcon private void SetNotifyIcon() { this.notifyIcon = new NotifyIcon(); this.notifyIcon.BalloonTipText = "磁盘清理工具"; this.notifyIcon.ShowBalloonTip(2000); this.notifyIcon.Text = "磁盘清理工具:每20天清理一次"; this.notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath); this.notifyIcon.Visible = true; //打开菜单项 MenuItem open = new MenuItem("打开"); open.Click += new EventHandler(Show); //退出菜单项 MenuItem exit = new MenuItem("退出"); exit.Click += new EventHandler(Close); //关联托盘控件 MenuItem[] childen = new MenuItem[] { open, exit }; notifyIcon.ContextMenu = new ContextMenu(childen); this.notifyIcon.MouseDoubleClick += new MouseEventHandler((o, e) => { if (e.Button == MouseButtons.Left) this.Show(o, e); }); } private void Show(object sender, EventArgs e) { this.Visibility = Visibility.Visible; this.ShowInTaskbar = true; this.Activate(); } private void Hide(object sender, EventArgs e) { this.ShowInTaskbar = false; this.Visibility = Visibility.Hidden; } private void Close(object sender, EventArgs e) { System.Windows.Application.Current.Shutdown(); } #endregion #region 窗口 private void MinimizeButton_OnClick(object sender, RoutedEventArgs e) { WindowState = WindowState.Minimized; } private void CloseButton_OnClick(object sender, RoutedEventArgs e) { this.Hide(); } private void HeaderGrid_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ButtonState == MouseButtonState.Pressed) { this.DragMove(); } } #endregion }
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。