List of Windows 7 Shortcuts

by Edward 29 October 2009 18:08

As Windows 7 starts rolling out, and more people are starting to use it, I thought I would add a few Windows shortcuts.

The full list of keyboard shortcuts includes:

  • Win+Home: Clear all but the active window.
  • Win+Space: All windows become transparent so you can see through to the desktop.
  • Win+Up arrow: Maximize the active window.
  • Shift+Win+Up arrow: Maximize the active window vertically.
  • Win+Down arrow: Minimize the window/Restore the window if it's maximized.
  • Win+Left/Right arrows: Dock the window to each side of the monitor.
  • Shift+Win+Left/Right arrows: Move the window to the monitor on the left or right.


A list of shortcut combinations to launch the applications in their respective position on the taskbar:

  • Win+number (1-9): Starts the application pinned to the taskbar in that position, or switches to that program.
  • Shift+Win+number (1-9): Starts a new instance of the application pinned to the taskbar in that position.
  • Ctrl+Win+number (1-9): Cycles through open windows for the application pinned to the taskbar in that position.
  • Alt+Win+number (1-9): Opens the Jump List for the application pinned to the taskbar.
  • Win+T: Focus and scroll through items on the taskbar.
  • Win+B: Focuses the System Tray icons


A list of more advanced shortcuts:

  • Ctrl+Shift+N: Creates a new folder in Windows Explorer.
  • Alt+Up: Goes up a folder level in Windows Explorer.
  • Alt+P: Toggles the preview pane in Windows Explorer.
  • Shift+Right-Click on a file: Adds Copy as Path, which copies the path of a file to the clipboard.
  • Shift+Right-Click on a file: Adds extra hidden items to the Send To menu.
  • Shift+Right-Click on a folder: Adds Command Prompt Here, which lets you easily open a command prompt in that folder.
  • Win+P: Adjust presentation settings for your display.
  • Win+(+/-): Zoom in/out.
  • Win+G: Cycle between the Windows Gadgets on your screen.

Tags: , ,

Development Resources | Other | Technology

Cleanup your code - remove unused using statements

by Edward 20 October 2009 06:12

One of the annoying things I have been dealing with in Visual Studio 2008 and Framework 3.5, is the unnecessary "using" statements the IDE adds, when you add a new webpage to your project.

Visual Studio does give you the option to remove these unused using statements, but they do not "tell" you about it.

Here is a quick way of removing unused using statements.

From the Context Menu:

  1. 1) Right-click anywhere inside the code editor,
  2. 2) point to Organize Usings,
  3. 3) now click Remove Unused Usings.


Here is an example:


Before:

   1:  using System;
   2:  using System.Linq;
   3:  using System.Collections.Generic;
   4:  using System.Text;
   5:  using System;
   6:   
   7:  namespace ConsoleApplication1
   8:  {
   9:      class Program
  10:      {
  11:          static void Main(string[] args)
  12:          {
  13:              Console.WriteLine("DasCode.Net test page, removing 
unused using statements"
);
  14:          }
  15:      }
  16:  }


After:

   1:  using System;
   2:   
   3:  namespace ConsoleApplication1
   4:  {
   5:      class Program
   6:      {
   7:          static void Main(string[] args)
   8:          {
   9:              Console.WriteLine("DasCode.Net test page, removing 
unused using statements"
);
  10:          }
  11:      }
  12:  }

 

Tags: , ,

ASP.NET | Development Resources

out or ref, is there a difference?

by Jacobus 07 October 2009 19:15

Similarities

The ref and out keyword's pass a reference of a variable to a method, thus using the original variable and not a new instance. By default arguments are passed as value types, a copy of the variable is sent rather than the original variable itself. This is shown in the example below.

class Program
    {
        
public void ValueMethod(int i)
        {
            i +
25;
            
Console.WriteLine("Value Method: i value = {0}", i);
        


        
static void Main(string[] args)
        {
            var p 
= new Program();        
            int 
counter 1;

            
//passing a value type to the method by default
            
p.ValueMethod(counter);
            
Console.WriteLine("Main: Counter Value is: {0}", counter);
        
}
    }

Output:
Value Method: i value = 26
Main: Counter Value is: 1

A property is not a variable and cannot be passed as a ref/out parameter. If you try and use it like this;

p.ValueMethod(ref person.Age);

the compiler will give you the following error: 'ref' argument is not classified as a variable
Overloaded methods will be created if two methods are created with the same name and variables, but the ref/out keyword is used with one of them, for example

public void ValueMethod(int i)

public void ValueMethod(ref int i)

If the same is done, using ref and out in the signature the compiler will give an error: Member with the same signature is already used.

Differences
The ref keyword requires the variable to be initialized before passing it to the method, out does not require the variable to be initialized. If the ref parameter is not initialized, the compiler will give an error: Use of unassigned local variable, 'i'.

    class Program
    {
        
public void ValueMethod(int i)
        {
            i +
25;
            
Console.WriteLine("Value Method: i value = {0}", i);
        
}

        
public void RefMethod(ref int i)
        {
            i 
2;
        
}

        
public void OutMethod(out int i)
        {
            i 
5;
        
}

        
static void Main(string[] args)
        {
            var p 
= new Program();  
            int 
10;
            int 
x;

            
p.RefMethod(ref i);

            
p.OutMethod(out x);

            
Console.WriteLine("Main: x is: {0}", x);
        
}
    }

Another difference is, the out parameter must be assigned in the method, otherwise the compiler will give an error: The out parameter 'i' must be assigned to before control leaves the current method.

Example:

    public void OutMethod(out int i)
    {
        
int 5;
    
}

As you can see the difference is subtle, and always good to know.

Tags: ,

ASP.NET

JavaScript Exception Handling

by Edward 06 October 2009 06:16

Like any OOP (Object Oriented Programming), exception handling is also available in Javascript. The try/catch block in JavaScript is very much similar to the regular C# try/catch block, but you cannot handle the errors server side.

In the catch block you will get the object containing type and description of the exception, which you can then handle or write out to the screen, to see the error. You can also use the finally block in the same way as you use it in C#.

Here is a simple example:

window.onload = function()
{
    try
    {
        var x = 10;
        var calcvalue = x / y;
    }
    catch(err)
    {
        document.write("Error has been thrown:" + err.name + "<br /> Message: " + err.message + "<br />");
    }
    finally
    {
        alert('This is the finally block');
    }
}

Tags: ,

AJAX/JQuery

Retrieving the Name of the current Method

by Edward 01 October 2009 06:10

There might be times when you will need the name of the method that is throwing an error, or when logging errors, exceptions etc. The following example uses reflection and the System.Diagnostics namespace.

Example code:

using System.Diagnostics;

try
{
  //code here
}

catch(exception ex)
{

  // get call stack
  StackTrace stack = new StackTrace();

  // get calling method name
  // code here to log or write the error


  //custom error handling
  Error.LogError("An exception has been thrown", "Method: " + stack.GetFrame(1).GetMethod().Name, ex))

}

Tags: , ,

ASP.NET

About DasCode.Net

I'm a ASP.NET web developer and code enthusiast. Blogging about everything .Net related.

Code... that's .net

Month List