本文整理汇总了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); }
}
示例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); }
}
}
}