Click here to Skip to main content
15,895,667 members
Articles / Operating Systems / Windows

Applications Traffic Watcher Lite

Rate me:
Please Sign up or sign in to vote.
4.41/5 (6 votes)
14 Jul 20062 min read 54K   3.3K   47  
Applications Traffic Watcher is a small utility to get costs of the internet traffic consumed by different applications
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using AppTrafficMonitor;
using IpHlpApidotnet;


namespace AppTraffMonLite
{
    public partial class DetailsWindow : Form
    {
        private const int CS_NOCLOSE = 0x200;

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
                return cp;
            }
        }

        private void Form1_Load(object sender, System.EventArgs e)
        {
        }

        public DetailsWindow()
        {
            InitializeComponent();
            //DisableCloseButton(this);
        }

        public int FindItemByName(string item)
        {
            foreach (ListViewItem lvi in listView3.Items)
            {
                if (String.Compare(lvi.SubItems[colProcessProc.Index].Text, item, true) == 0)
                    return lvi.Index;
            }
            return -1;
        }

        public void UncheckAll()
        {
            foreach (ListViewItem lvi in listView3.Items)
            {
                lvi.Checked = false;
            }
        }

        private ConnectionsWatcher conns = null;
        public ConnectionsWatcher ConnectionsWatcher
        {
            get { return conns; }
            set { conns = value; }
        }

        public ListView ListView
        {
            get { return listView3; }
        }

        private void DetailsWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
            //e.Cancel = true;
        }

        private void DetailsWindow_Resize(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.Visible = false;
            }
            //else
            //{
            //    this.Visible = true;
            //}
        }

        public void SelectAll(bool IsSelect)
        {
            foreach (ListViewItem item in listView3.Items)
            {
                item.Checked = IsSelect;
            }
        }

        private void clearValuesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView3.SelectedIndices[0] != -1)
            {
                conns.MonitoredApplications[listView3.SelectedIndices[0]].ClearValues();
                conns.MonitoredApplications.ItemChangedEventHandler(null, listView3.SelectedIndices[0]);
            }
        }

        private void resetAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.SelectAll(false);
        }

        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.SelectAll(true);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
I am a CIO in Nizhny Novgorod, Russia.

Comments and Discussions