Exemplo n.º 1
0
 public void Add(UDStatistic statistics, DateTime date)
 {
     Data.Total.Download += statistics.download;
     Data.Total.Upload   += statistics.upload;
     HowGetNew(date);
     Now.Download += statistics.download;
     Now.Upload   += statistics.upload;
     ChengEvent?.Invoke(this, "Total");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Update GUI components for the network interfaces
        /// </summary>
        private void UpdateUi(UDStatistic item, double timeSpan)
        {
            //MessageBox.Show(cmbInterface.Items.Count.ToString());
            if (cmbInterface.Items.Count >= 1)
            {
                // Grab NetworkInterface object that describes the current interface
                NetworkInterface nic = goodAdapters[cmbInterface.SelectedIndex];
                // Grab the stats for that interface
                //IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics();
                // Update the labels
                lblInterfaceType.Content = nic.NetworkInterfaceType.ToString();


                //All Trafic
                lblBytesSent.Content = Tool.ToString(App._History.Data.Total.Upload);

                lblBytesReceived.Content = Tool.ToString(App._History.Data.Total.Download);

                //Now Trafic
                lblUpload.Content   = Tool.GetNetSpeedString(item.upload, timeSpan);
                lblDownload.Content = Tool.GetNetSpeedString(item.download, timeSpan);
                //update try Balloon
                _trayIcon.BalloonTipText("▲ " + lblUpload.Content + "▼ " + lblDownload.Content);


                if (!isEdgeHide)
                {//Byte to kB/s
                    Chart1.Downloaded(item.download / 1024);
                    Chart1.Uploaded(item.upload / 1024);
                }

                UnicastIPAddressInformationCollection ipInfo = nic.GetIPProperties().UnicastAddresses;

                foreach (UnicastIPAddressInformation Info in ipInfo)
                {
                    if (Info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        labelIPAddress.Content = Info.Address.ToString();
                        //uniCastIPInfo = item;
                        break;
                    }
                }
            }
            else
            {
                lblInterfaceType.Content = "-";
                lblDownload.Content      = 0;
                lblUpload.Content        = 0;
                lblBytesReceived.Content = 0;
                lblBytesSent.Content     = 0;
                labelIPAddress.Content   = "0.0.0.0";
            }
        }
Exemplo n.º 3
0
        //private void PinAllVirtualDesktop()
        //{
        //       var appId = ApplicationHelper.GetAppId(GetForegroundWindow());
        //    if (!VirtualDesktop.IsPinnedApplication(appId))
        //    {
        //       VirtualDesktop.PinApplication(appId);
        //    }
        //    //(VirtualDesktop.IsPinnedApplication(appId) ? VirtualDesktop.UnpinApplication : (Action<string>)VirtualDesktop.PinApplication)(appId);
        //}
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            UDStatistic statistics = udMap.NextStatistic(10, portProcessMap);

            Dispatcher.Invoke(new Action(() =>
            {
                mainWindow.NewData(statistics);

                _History.Add(statistics, DateTime.Now);
                if (index == 300)//5 minet
                {
                    index = -1;
                    _History.Save();
                }
                index++;
            }));
        }
Exemplo n.º 4
0
        public void NewData(UDStatistic statistics)
        {
            //Detaile windows
            if (detailWindow?.Visibility == Visibility.Visible)
            {
                detailWindow.NewData(statistics.items, statistics.timeSpan);
            }
            //MonitorProcess
            View.Monitor.MonitorProcess.Me?.NewData(statistics.items, statistics.timeSpan);
            if (!isEdgeHide && refresh > 10)
            {
                InitializeNetworkInterface();
                refresh = -1;
            }
            refresh++;
            //update Ui
            UpdateUi(statistics, statistics.timeSpan);
            State = statistics;
            //set max download
            if (statistics.download > MaxDownload)
            {
                SetMaxDownload(statistics.download);
                TrayIcon.ShowNotification("Traffic Watch", $"Max Download : {Tool.GetNetSpeedString(statistics.download, statistics.timeSpan) }");
            }
            //Mid = (MaxDownload / 8) * limited;
            if (statistics.download >= Mid)
            {
                ListMaxDownload.Add(new ItemMaxDownload(statistics.download, DateTime.Now));
                ShowToster($"Download : {Tool.GetNetSpeedString(statistics.download, statistics.timeSpan) }");
                //index += 1;
            }
            //else
            //{

            //}
        }