void AssignProperties()
 {
     icon.SetBinding(TaskbarIcon.IconSourceProperty, new Binding()
     {
         Path = new PropertyPath(Window.IconProperty), Source = AssociatedObject
     });
     InitalizeContextMenu();
     SubscribeEvetns();
 }
Beispiel #2
0
        private void UpdateUI()
        {
            if (Account.Account.Overcharge > 0)
            {
                imgAlert.Source     = new BitmapImage(new Uri(@"pack://*****:*****@"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); }
        }