Exemple #1
0
 private void TrafficStats_OnSpeedChanged(object sender, TrafficStatsChangedEventArgs e)
 {
     try
     {
         if (this.formLoaded)
         {
             this.Invoke(new Action(() =>
             {
                 this.Text = $"{I18N.GetString("TrafficFormTitle")}       " +
                             $"{I18N.GetString("CurrentSpeed")}: {e.Value}/s";
             }));
         }
     }
     catch { return; }
 }
Exemple #2
0
        private void TrafficdStats_OnDataChanged(object sender, TrafficStatsChangedEventArgs e)
        {
            try
            {
                if (this.formLoaded && this.IsHandleCreated)
                {
                    //校准月总量
                    string monthTotalText = Utils.ConvertToMiB(this.trafficStats.MonthTotal).Value.ToString();
                    if (!monthTotalText.Equals(this.textbox_total.Text))
                    {
                        this.Invoke(new Action(() =>
                        {
                            this.textbox_total.Text = monthTotalText;
                        }));
                    }

                    List <string> x = new List <string>()
                    {
                        I18N.GetString("MonthUsed"),
                        I18N.GetString("TodayUsed"),
                        I18N.GetString("CurrentUsed")
                    };

                    if (e.IsDownload)
                    {
                        List <double> downLoadValues = new List <double>()
                        {
                            Utils.ConvertToMiB(this.trafficStats.MonthDownload).Value,
                            Utils.ConvertToMiB(this.trafficStats.TodayDownload).Value,
                            Utils.ConvertToMiB(this.trafficStats.CurrentDownload).Value
                        };

                        this.Invoke(new Action(() =>
                        {
                            stats_chart.Series[I18N.GetString("Download")].Points.DataBindXY(x, downLoadValues);
                        }));
                    }
                    else
                    {
                        List <double> upLoadValues = new List <double>()
                        {
                            Utils.ConvertToMiB(this.trafficStats.MonthUpload).Value,
                            Utils.ConvertToMiB(this.trafficStats.TodayUpload).Value,
                            Utils.ConvertToMiB(this.trafficStats.CurrentUpload).Value
                        };

                        this.Invoke(new Action(() =>
                        {
                            stats_chart.Series[I18N.GetString("Upload")].Points.DataBindY(upLoadValues);
                        }));
                    }

                    this.Invoke(new Action(() =>
                    {
                        StatsItem statsItem    = Utils.ConvertToMiB(this.trafficStats.MonthUsed);
                        this.textbox_used.Text = statsItem.Value.ToString();
                        if (!this.label_used.Text.Equals(statsItem.Unit))
                        {
                            this.label_used.Text = statsItem.Unit;
                        }
                    }));
                }
            }
            catch { return; };
        }
Exemple #3
0
 private void TrafficStats_OnDataChanged(object sender, TrafficStatsChangedEventArgs e)
 {
     this.UpdateStatsText();
 }