示例#1
0
        private void SetUI()
        {
            DataContext = Client;

            Refresh();

            spMainContainer.Children.Clear();

            foreach (DisplayInfoTypes element in ProgramSettings.Instance.DisplaySystray)
            {
                spMainContainer.Children.Insert(spMainContainer.Children.Count, DisplayInfoFactory.Create(element, Client));
            }
        }
示例#2
0
 private void OnDownloadHistoryEnd(Object sender, EventArgs e)
 {
     Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new ThreadStart(delegate
     {
         for (int i = 0; i < spMainContainer.Children.Count; i++)
         {
             if (spMainContainer.Children[i] is WindowsFormsHost)
             {
                 spMainContainer.Children.RemoveAt(i);
                 spMainContainer.Children.Insert(i, DisplayInfoFactory.Create(DisplayInfoTypes.HistoryGraph, Account));
             }
         }
     }));
 }
示例#3
0
        public ClientDashboard(CIVAccount account)
        {
            InitializeComponent();

            DataContext = account;

            // Construction de l'interface
            foreach (DisplayInfoTypes element in ProgramSettings.Instance.Display)
            {
                spMainContainer.Children.Insert(spMainContainer.Children.Count,
                                                DisplayInfoFactory.Create(element, account));
            }

            IsWorking = false;

            Messages = new ObservableCollection <ScreenMessage>();

            ApiClient = new XmlClient(ProgramSettings.Instance.UserLanguage,
                                      account.Account.Token,
                                      account.Account.Username);

            ApiClient.OnReadDailyWiredUsage += ReadDailyWiredUsage;
            ApiClient.OnError              += ApiClientError;
            ApiClient.OnDownloadData       += OnDownloadData;
            ApiClient.OnDownloadDataEnd    += OnDownloadDataEnd;
            ApiClient.OnDownloadHistory    += OnDownloadHistory;
            ApiClient.OnDownloadHistoryEnd += OnDownloadHistoryEnd;

            // Déclenche le rafraichissement du UI
            Account = account;

            if (Account.Account.LastUpdate == DateTime.MinValue)
            {
                // Mettre un délai aléatoire
                LaunchUpdate(false);
            }
            else
            {
                ShowLastUpdate();
            }

            if (ProgramSettings.Instance.EmailSMTP.Active &&
                Account.SendMail &&
                !String.IsNullOrEmpty(Account.MailSubject) &&
                !String.IsNullOrEmpty(Account.MailTemplate))
            {
                btnSendMail.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                btnSendMail.Visibility = System.Windows.Visibility.Collapsed;
            }


            if (DataBaseFactory.Instance.IsAvailable)
            {
                List <DailyUsageBO> usages = DailyUsageDAO.Instance.UsageByPeriod(account.Account.Username, DateTime.Now.Date, DateTime.Now.Date);

                if (usages.Count > 0)
                {
                    Account.Account.CurrentDayUpload   = usages[0].Upload;
                    Account.Account.CurrentDayDownload = usages[0].Download;
                }
            }
        }