public MainWindow()
        {
            InitializeComponent();



            this.Closed += (a, b) =>
            {
                this.notifyIcon.Visible = false;
                FlowMonitor.GetMonitor().Close();
            };

            MakeIcon();


            if (!AutoRun.isHaveKey())
            {
                AutoRun.Set(System.Windows.Forms.Application.ExecutablePath);
            }



            timer.Elapsed += timer_Elapsed;

            // 统计
            analyticsBrowser.Navigate(new Uri("http://flowmonitor.jd-app.com/"));
        }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (fm == null)
     {
         fm = FlowMonitor.GetMonitor();
     }
     MainTimer.Enabled = true;  //start the timer
 }
Пример #3
0
        public void A_flow_monitor_should_monitor_the_flow()
        {
            FlowMonitor monitor = new FlowMonitor(typeof(Counter_Specs), "Test");

            monitor.IncrementWrite(64);
            monitor.IncrementWrite(64);
            monitor.IncrementRead(128);
            monitor.IncrementRead(128);

            Assert.AreEqual(2, monitor.WriteCount);
            Assert.AreEqual(128, monitor.BytesWritten);
            Assert.AreEqual(2, monitor.ReadCount);
            Assert.AreEqual(256, monitor.BytesRead);
        }
        public FlowMonitorWindow()
        {
            InitializeComponent();

            // 数据源与后台数据连接。
            datagrid.ItemsSource = FlowMonitor.GetMonitor().GetViewData();

            // 新建提醒对象
            Remind remind = new Remind();

            remind.Init();

            double lastRate = 0;

            // 新建定时器
            Timer FMTimer = new Timer(1000);

            FMTimer.Elapsed += (s, e) =>
            {
                remind.Refresh();

                System.Windows.Application.Current.Dispatcher.Invoke(new Action(delegate
                {
                    // 刷新[今日流量使用情况]
                    UInt32 a    = FlowMonitor.GetMonitor().GetTheDayFlow()[0];
                    UInt32 b    = remind.GetWarningALL();
                    double rate = (b - a) * 1.0 / b;
                    if (rate - lastRate > 0.0001)
                    {
                        lastRate = rate;
                        this.probar.Goto(rate);
                    }

                    this.max.Content  = "流量警告线:" + Flow.ChangeFlow(b);
                    this.rest.Content = "还剩:" + Flow.ChangeFlow(b - a);
                }));
            };

            FMTimer.Start();
        }