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


C# TaskbarIcon.SetBinding方法代码示例

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


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

示例1: UpdateUI

        private void UpdateUI()
        {
            if (Account.Account.Overcharge > 0)
            {
                imgAlert.Source = new BitmapImage(new Uri(@"pack://application:,,,/CIV;component/Images/Alert-Quota.png"));
                imgAlert.Visibility = System.Windows.Visibility.Visible;
            }
            else if (Account.AlertAchieved)
            {

                imgAlert.Source = new BitmapImage(new Uri(@"pack://application:,,,/CIV;component/Images/Alert-User.png"));
                imgAlert.Visibility = System.Windows.Visibility.Visible;
            }
            else
                imgAlert.Visibility = System.Windows.Visibility.Collapsed;

            // Gestion de l'icône dans la barre système
            try
            {
                if (_account.SystrayDisplay)
                {
                    if (MyNotifyIcon == null)
                    {

                        MyNotifyIcon = new TaskbarIcon()
                        {
                            Name = "MyNotifyIcon",
                            VerticalAlignment = System.Windows.VerticalAlignment.Top,
                            ContextMenu = new ContextMenu()
                        };

                        MyNotifyIcon.DoubleClickCommand = new DashboardShowCommand();
                        MyNotifyIcon.DoubleClickCommandParameter = this.Parent;

                        MyNotifyIcon.SetBinding(Hardcodet.Wpf.TaskbarNotification.TaskbarIcon.ToolTipTextProperty,
                                                new Binding("Account.DisplayName") { Source = _account });

                        // Menu
                        MenuItem menu = new MenuItem()
                        {
                            Icon = new System.Windows.Controls.Image()
                            {
                                Source = new BitmapImage(new Uri("pack://application:,,,/CIV;component/Images/Exit.png", UriKind.RelativeOrAbsolute)),
                                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                                VerticalAlignment = System.Windows.VerticalAlignment.Center,
                                Stretch = Stretch.None
                            }
                        };
                    }
                    else
                        MyNotifyIcon.Icon.Dispose();

                    UsagePieChart pie = new UsagePieChart(_account.Account, ProgramSettings.Instance.CombinedColor.GetColor(), System.Drawing.Color.White);
                    MyNotifyIcon.Icon = pie.GenerateIcon();
                }
                else
                {
                    if (MyNotifyIcon != null)
                    {
                        MyNotifyIcon.Icon.Dispose();
                        MyNotifyIcon.Dispose();
                    }
                }
            }
            catch (Exception e) { LogEngine.Instance.Add(e, false); }
        }
开发者ID:kleopatra999,项目名称:CIV,代码行数:66,代码来源:ClientDashboard.xaml.cs

示例2: CreateSystrayIcon

        private void CreateSystrayIcon()
        {
            if (ProgramSettings.Instance.SystrayDisplay)
            {
                if (MyNotifyIcon == null)
                {
                    try
                    {
                        MyNotifyIcon = new TaskbarIcon()
                            {
                                Name = "MyNotifyIcon",
                                VerticalAlignment = System.Windows.VerticalAlignment.Top,
                                Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/CIV;component/Icons/Application.ico")).Stream),
                                ContextMenu = new ContextMenu()
                            };

                        MyNotifyIcon.DoubleClickCommand = new DashboardShowCommand();
                        MyNotifyIcon.DoubleClickCommandParameter = this;

                        MyNotifyIcon.SetBinding(Hardcodet.Wpf.TaskbarNotification.TaskbarIcon.ToolTipTextProperty,
                                                new Binding("Text.Dashboard_Title") { Source = new CIVResourceManager() });

                        // Menu
                        MenuItem menu = new MenuItem()
                            {
                                Icon = new Image()
                                {
                                    Source = new BitmapImage(new Uri("pack://application:,,,/CIV;component/Images/Exit.png", UriKind.RelativeOrAbsolute)),
                                    HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                                    VerticalAlignment = System.Windows.VerticalAlignment.Center,
                                    Stretch = Stretch.None
                                }
                            };
                        menu.Click += miExit_Click;
                        menu.SetBinding(MenuItem.HeaderProperty,
                                        new Binding("Text.Dashboard_miExit") { Source = new CIVResourceManager() });

                        MyNotifyIcon.ContextMenu.Items.Add(menu);

                        // Contenu
                        Style style = new Style(typeof(ToolTip), null);
                        style.Setters.Add(new Setter(ContentControl.TemplateProperty,
                                          new ControlTemplate(typeof(ToolTip)) { VisualTree = new FrameworkElementFactory(typeof(ContentPresenter)) }));

                        ToolTip tip = new ToolTip()
                            {
                                Style = style,
                                Content = new QuickStats()
                            };

                        MyNotifyIcon.TrayToolTip = tip;

                    }
                    catch (Exception e) { LogEngine.Instance.Add(e, false); }
                }
            }
            else
            {
                if (MyNotifyIcon != null)
                {
                    try
                    {
                        MyNotifyIcon.Icon.Dispose();
                        MyNotifyIcon.Dispose();
                        MyNotifyIcon = null;
                    }
                    catch (Exception e) { LogEngine.Instance.Add(e, false); }
                }
            }
        }
开发者ID:kleopatra999,项目名称:CIV,代码行数:70,代码来源:Dashboard.xaml.cs


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