Download
You can download the installer from here.Following is the brief instructions manual.
I will mostly post cool trick and tips of Visual Studio here.
I wanted to see the network activity other than in the system tray network icon, so I thought of using the keyboard's CAPS LOCK, SCROLL LOCK, and NUM key LEDs to display the network activity. TrafficLights is a simple application which blinks keyboard lights based on the network traffic on your computer. You can configure which light should blink on send or receive packets. It silently sits on your system tray. You can right click on TrafficLights' system tray icon to configure the LEDs or shut it down.
This is just to learn how to trap network traffic and control keyboard LEDs in .NET.
There are basically two parts to this application:
The code below is used to initialize the PerformanceCounter
class instances - one for send and one for receive (namely m_performanceCounterSent
and m_performanceCounterReceive
). They are initialized like so:
//
m_performanceCounterCategory = new PerformanceCounterCategory("Network Interface");
string instance = m_performanceCounterCategory.GetInstanceNames()[0]; // 1st NIC !
m_performanceCounterSent = new PerformanceCounter("Network Interface",
"Bytes Sent/sec", instance);
m_performanceCounterReceived = new PerformanceCounter("Network Interface",
"Bytes Received/sec", instance);
A background thread keeps running in the application, and it keeps on checking on the performance counter to check any network activity. And when an activity is detected, it blinks the configured keyboard LED.
float fSentValue = m_performanceCounterSent.NextValue() / 1024;
float fReceivedValue = m_performanceCounterReceived.NextValue() / 1024;
if (fSentValue > 0)
{
keybd_event((byte)m_sendLED, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event((byte)m_sendLED, 0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
}
if (fReceivedValue > 0)
{
keybd_event((byte)m_receiveLED, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event((byte)m_receiveLED, 0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
}
As I mentioned earlier, it's a very simple application, but the intention was to learn how to trap network traffic in ।NET.
Concluding the Keyboard Shortcuts posted here before.
Edit | |
Edit.CollapseTo-Definitions | CTRL + M, O |
Edit.ToggleAllOutlining | CTRL + M, L |
Edit.ToggleOutliningExpansion | CTRL + M, M |
Edit.StopOutlining | CTRL + M, P |
Edit.CommentSelection | CTRL + K, C or CTRL + E, C |
Edit.UncommentSelection | CTRL + K, U or CTRL + E, U |
Edit.FormatDocument | CTRL + K, D or CTRL + E, D |
Edit.FormatSelection | CTRL + K, F or CTRL + E, F |
Edit.InsertSnippet | CTRL + K, X |
Edit.SurroundWith | CTRL + K, S |
Edit.InvokeSnippetFromShortcut | TAB |
Edit.CycleClipboardRing | CTRL + SHIFT + V |
Edit.Replace | CTRL + H |
Edit.ReplaceInFiles | CTRL + SHIFT + H |
View.ShowSmartTag | CTRL + . Or SHIFT + ALT + F10 |
File | |
File.NewProject | CTRL + SHIFT + N |
File.OpenProject | CTRL + SHIFT + O |
Project.AddClass | SHIFT + ALT + C |
Project.AddExistingItem | SHIFT + ALT + A |
Project.AddNewItem | CTRL + SHIFT + A |
Window.ShowEzMDIFileList | CTRL + ALT + DOWN ARROW |
Edit.OpenFile | CTRL + O |
Intellisense | |
Edit.CompleteWord | CTRL + SPACE or CTRL + K, W |
Edit.ListMembers | CTRL + J or CTRL + K, L |
Edit.QuickInfo | CTRL + K, I |
Edit.ParameterInfo | CTRL + SHIFT + SPACE or CTRL K, P |
Make Completion List Transparent | CTRL |
Navigation | |
Edit.FindAllReferences | SHIFT + F12 or CTRL + K, R |
Edit.GoToBrace | CTRL + ] |
Edit.GoToDefinition | F12 |
Edit.GoToNextLocation | F8 |
Edit.IncrementalSearch | CTRL + I |
View.ClassViewGo-ToSearch, Combo | CTRL + K, CTRL + V |
View.ForwardBrowseContext | CTRL + SHIFT + 7 |
View.PopBrowseContext | CTRL + SHIFT + 8 |
View.NavigateBackward | CTRL + MINUS SIGN (-) |
View.NavigateForward | CTRL + SHIFT + MINUS SIGN (-) |
Edit.FindInFiles | CTRL + SHIFT + F |
Edit.FindSymbol | ALT + F12 |
View.ViewCode | F7 |
View.ViewDesigner | SHIFT + F7 |
View.ViewMarkup | SHIFT + F7 |
Window.MoveToNavigationBar | CTRL + F2 |
Edit.Find | CTRL + F |
Edit.GoTo | CTRL + G |
Edit.GoToFindCombo | CTRL + / |
Window | |
View.ClassView | CTRL + W, C |
View.CodeDefinitionWindow | CTRL + W, D |
View.Command-Window | CTRL + W, A |
View.ErrorList | CTRL + W, E |
View.ObjectBrowser | CTRL + W, J |
View.Output | CTRL + W, O |
View.PropertiesWindow | CTRL + W, P |
View.SolutionExplorer | CTRL + W, S |
View.TaskList | CTRL + W, T |
View.Toolbox | CTRL + W, X |
View.ServerExplorer | CTRL + W, L |
Window.CloseToolWindow | SHIFT + ESC |
Data.ShowDataSources | SHIFT + ALT + D |
Window.CloseDocument, Window | CTRL + F4 |
Window.NextDocument, WindowNav | CTRL + TAB |
Refactor | |
Refactor.EncapsulateField | CTRL + R, E |
Refactor.ExtractInterface | CTRL + R, I |
Refactor.ExtractMethod | CTRL + R, M |
Refactor.PromoteLocalVariabletoParameter | CTRL + R, P |
Refactor.RemoveParameters | CTRL + R, V |
Refactor.Rename | CTRL + R, R or F2 |
Refactor.ReorderParameters | CTRL + R, O |
Debugging | |
Debug.Autos | CTRL + D, A |
Debug.CallStack | CTRL + D, C |
Debug.Immediate | CTRL + D, I |
Debug.Locals | CTRL + D, L |
Debug.QuickWatch | CTRL + D, Q |
Debug.Start | F5 |
Debug.StartWithoutDebugging | CTRL + F5 |
Debug.StepInto | F11 |
Debug.StepOut | SHIFT + F11 |
Debug.StepOver | F10 |
Debug.StopDebugging | SHIFT + F5 |
Debug.ToggleBreakpoint | F9 |
Debug.Watch | CTRL + D, W |
Debug.EnableBreakpoint | CTRL + F9 |
Make Datatip Transparent | [CTRL] |
Build | |
Build.BuildSolution | F6 or CTRL + SHIFT + B |
Build.BuildSelection | SHIFT + F6 |