Archive for June, 2010

Manage Your Code Snippets With DropBox

Friday, June 25th, 2010

I regularly work on a number of different development machines and always find it annoying when I haven’t got my latest and greatest code snippet installed. That’s where DropBox is great. The free package gives you a 2gb allowance which once you install there client software creates a DropBox folder on your machine any files placed in that folder are automatically synchronized with any other machines that you use and that have DropBox installed on.

This means that if you point your CodeSnippets folder at a folder in your DropBox they will all be magically kept up to date across multiple machines.

 

I’m going to do the same with my Resharper Template as well!!

Nunit Code Snippet

Thursday, June 24th, 2010

Here is a useful code snippet that I use all the time to create an empty unit test.

To use it go to your My Code Snippets folder, go to the snippet manager in Visual Studio (Ctrl K + Ctrl B) to get the file path if you don’t know it. Create a new text file with and appropriate name and rename the extension to .snippet and cut and paste the following xml into the file and save it.

 

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>
                NUnit Test
            </Title>
        </Header>
        <Snippet>
            <References>
                <Reference>
                    <Assembly>nunit.framework.dll</Assembly>
                </Reference>
            </References>
            <Declarations>
                <Literal>
                    <ID>Test_Name</ID>
                    <ToolTip>Replace with test method name</ToolTip>
                    <Default>Test_Name</Default>
                </Literal>
            </Declarations>
            <Code Language="CSharp">
            <![CDATA[]]>
            [Test]
            public void $Test_Name$()
            {
            }
            <![CDATA[]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets> 
 
And Bob’s your uncle it should appear in your code snippet shortcuts..Ctrl K Ctrl S to access.

CodeBurner Firebug extension

Wednesday, June 23rd, 2010

I just found this nice add in for Firebug called CodeBurner. Essentially it adds in a lot of HTML & CSS reference documentation. The nice thing about it is that when your browsing your HTML or CSS within Firebug you can right click an element and either get a description and get an example of its usage see the screenshot below.

.

image

 

Or you can get information within which browsers that particular element is supported.

 

image

 

Quite useful…

Visual Studio Rename Shortcut

Wednesday, June 16th, 2010

This is more for me than anything else as I can never remember the keyboard short cut to use the build in “Rename” functionality that is built into Visual Studio 2008, and probably 2010 though I haven’t tested it.

Anyway its Shift + Alt + F10

Programatically Creating a UIButton with MonoTouch

Tuesday, June 15th, 2010

This is probably a really basic post but as I am a still learning the MonoTouch Framework and I couldn’t find anywhere on the Internet explaining how to do it. Anyway today I was trying to programmatically create a UIButton in MonoTouch and set the button type.

 

There is a ButtonType property on the instantiated UIButton object but its read only and I couldn’t see any constructor that took a buttontype.

 

In the end the answer was quite simple there is a static factory method on the UIButton class that you use to instantiate a new button. The code looks something like this.

 

   1: var button = UIButton.FromType(UIButtonType.RoundedRect);

   2: button.frame = new RectangleF(100f, 100f, 100f, 100f);

   3: button.SetTitle("click me", UIControlState.Normal);

 

Technorati Tags: