Occasionally I pair program with a developer who uses a Mac keyboard with his Windows machine. In order to use the Mac keyboard accurately, his default keyboard language is English (US). Although there's also a regular UK windows keyboard plugged in and ready to use, it requires time and effort to navigate the mouse to the language bar and swap to UK layout. This breaks the flow required to successfully pair program.
Good news - the language bar allows keyboard shortcuts to switch between languages. The default key combination SHIFT + LEFT ALT will loop through all the installed keyboard languages, in this instance toggling between US and UK keyboard layouts. But you can also set key combinations that will jump to a specific language.
From the Control Panel or the Start Menu, open the Region and Language settings page, navigate to the Keyboards and Languages tab and click the "Change keyboards" button:
On the Advanced Key Settings tab of the keyboards form, you can see the current settings for keyboard shortcuts:
To set up a shortcut combination to jump to a specific language, select the language (in the above case, English (UK), and click the Change Key Sequence button. This shows the following dialog box which can be used to define the keystroke required to jump directly to that keyboard language:
Stuff - mainly geek, a little diabetes, some rant. Possibly all three in the same post. Basically anything I find interesting and/or worth sharing. These are my personal views, unless I've been hacked.
Sunday, 16 September 2012
Thursday, 13 September 2012
Treat Warnings as Errors: Exclude specifics warnings
As every Visual Studio user knows, you should build your project with the "Treat warnings as errors" switched on. This gives you very quick feedback when your project has problems that could otherwise get ignored.
This setting is toggled on the Build tab of the project's properties page:
As it says on the tin, this causes any problem that would normally be reported as a warning to be reported as an error, and prevent the project building:
If there are warnings that you don't want to break your build, you can suppress them specifically. You'll need the warning number, which will be reported in the Output window:
This number, without the CS prefix, needs to be entered in the "Suppress warnings" box, on the Build tab. Multiple warnings can be suppressed, by separating multiple warning codes with a comma.
Victory!
Alternatively, you can use a #pragma compiler directive in the code to suppress your warning:
This setting is toggled on the Build tab of the project's properties page:
If there are warnings that you don't want to break your build, you can suppress them specifically. You'll need the warning number, which will be reported in the Output window:
This number, without the CS prefix, needs to be entered in the "Suppress warnings" box, on the Build tab. Multiple warnings can be suppressed, by separating multiple warning codes with a comma.
Victory!
Alternatively, you can use a #pragma compiler directive in the code to suppress your warning:
Labels:
.Net,
VisualStudio
Sunday, 2 September 2012
Double Buffering Windows DataGridView
Years ago I wrote a WinForms application, that I still use every day. I tinker with the source code pretty much every day too. One of my recent issues to address was the rendering speed of the DataGridView controls; they'd take, roughly, forever to display around 30 items.
I did what I could think of to speed up the rendering (mainly around optimising data access) but couldn't get the rendering time down. Then I Googled it, and it appears that I'm not the first developer to have this problem; the DataGridView is notoriously slow to render. The annoying part is that the problem is so easy to fix - set the grid's DoubleBuffered property on.
This property is protected, so you need to either use Reflection to set it on your grid instance, or create a specialised DataViewGrid. I created a DoubleBufferedDataGridView:
When I use this in place of the DataGridView, the results are pretty good. A test app shows the time taken (ms) to render a sample datasource of 16 items on a standard DataGridView, versus a DoubleBufferedDataGridView.
It's so easy to fix, it seems odd that DoubleBuffered is not set to true by default, but hey.
The code for the sample form above is available as a GitGist
I did what I could think of to speed up the rendering (mainly around optimising data access) but couldn't get the rendering time down. Then I Googled it, and it appears that I'm not the first developer to have this problem; the DataGridView is notoriously slow to render. The annoying part is that the problem is so easy to fix - set the grid's DoubleBuffered property on.
This property is protected, so you need to either use Reflection to set it on your grid instance, or create a specialised DataViewGrid. I created a DoubleBufferedDataGridView:
It's so easy to fix, it seems odd that DoubleBuffered is not set to true by default, but hey.
The code for the sample form above is available as a GitGist
Labels:
.Net
Saturday, 25 August 2012
Project Template Locations in VS2012
Adding a Project Template
If you've seen my post on creating a console application in VS Express 2012 for Web, you'll be thinking "why doesn't he create a template?" Well I did, via the Export Template Wizard in visual studio (File -> Export Template...)This wizard creates a zip file of all the items in the current project. When this is copied to the correct location on your machine, it can be used to create a new project with all your previous goodness. The location to copy it to is [Visual Studio 2012 folder]\Templates\ProjectTemplates\Visual C# or[Visual Studio 2012 folder]\Templates\ProjectTemplates\Visual Basic
This allows you to select your template in the New Project dialog box
Specifying the Project Type
If you want the template to appear under one of the project types, e.g. Windows, put the .zip file into a directory of that name, e.g. [Visual Studio 2012 folder]\Templates\ProjectTemplates\Visual C#\Windows
Can I Have it in Both?
If you want it in both locations, Visual C# and Windows, you need to edit your template. Open the .zip file and there'll be a .vstemplate file; this is the definition of the project template. You need to add an element NumberOfParentCategoriesToRollUp. This tells VS to show the template in the project subtype (Windows) and its parent (Visual C#). Here's an example:
Labels:
VisualStudio
Creating a Console App in Visual Studio Express 2012 for Web
I've installed and am using Visual Studio Express 2012 for Web as my primary IDE for C#. There isn't a template for a console application, so if you want 1980s goodness, create a new class library and on the Properties page, setting Output Type to Console Application, like this
This then allows you to create a class with a Main method
and run the app with a push of F5
**UPDATE** I have created a project template that creates a console application, it's available on github, here with instructions on how to install it.
This then allows you to create a class with a Main method
and run the app with a push of F5
**UPDATE** I have created a project template that creates a console application, it's available on github, here with instructions on how to install it.
Labels:
VisualStudio
Sunday, 19 August 2012
Creating a VisualizerObjectSource
I did a quick introduction talk on Visual Studio Debugger Visualisers the other day, and one question I was asked was [something like] "Do you have to serialise the object to be visualised? Could you pass it to the visualiser and have it read the properties via reflection?"
The answer is yes and no. You do have to serialise the object to a stream, but you can implement your own method of serialisation. I'll try to explain that; the data to be visualised must pass between the process boundaries of the running process and the debugger process via a System.IO.Stream. The contents of this stream can be whatever you want, as long as the visualiser knows how to interpret it. Here's an example:
** If you haven't seen debugger visualisers before, check out my previous post here to give some background **
This is the object to be visualised:
Note the second argument to the DebuggerVisualiser attribute - this is vital to ensure that the correct class is used to provide the object to be visualised.
As the object is not marked as serialisable, it can't be provided to the visualiser via the normal GetObject method of the IVisualObjectProvider (the GetObject method relies on serialisation). However, what you can do is create a custom implementation of VisualizerObjectSource, to be used by the objectProvider. VisualiserObjectSource has a virtual method, GetData, with two parameters. The first parameter is an object, which will be the object to be visualised. The second parameter is a stream, which needs to be populated with the visualisation data for the object:
In this example, I'm passing an integer which represents the Argb value of the object's colour.
When the Show method on the visualiser is called, it's passed an instance of IVisualizerObjectProvider. With XML serialisable objects you would normally obtain the object to be visualised via the objectProvider.GetObject method. When the object is not serialisable, you need to call the GetData() method instead; the objectProvider calls the GetData method of the VisualizerObjectSource, and returns the contents of its outgoingStream argument. This can then be used to visualise the object:
When this is all put together, the visualiser looks like this:
The code from this example is on GitHub: https://github.com/orangutanboy/Visualiser-Demo-With-Custom-ObjectSource
The answer is yes and no. You do have to serialise the object to a stream, but you can implement your own method of serialisation. I'll try to explain that; the data to be visualised must pass between the process boundaries of the running process and the debugger process via a System.IO.Stream. The contents of this stream can be whatever you want, as long as the visualiser knows how to interpret it. Here's an example:
** If you haven't seen debugger visualisers before, check out my previous post here to give some background **
This is the object to be visualised:
Note the second argument to the DebuggerVisualiser attribute - this is vital to ensure that the correct class is used to provide the object to be visualised.
As the object is not marked as serialisable, it can't be provided to the visualiser via the normal GetObject method of the IVisualObjectProvider (the GetObject method relies on serialisation). However, what you can do is create a custom implementation of VisualizerObjectSource, to be used by the objectProvider. VisualiserObjectSource has a virtual method, GetData, with two parameters. The first parameter is an object, which will be the object to be visualised. The second parameter is a stream, which needs to be populated with the visualisation data for the object:
In this example, I'm passing an integer which represents the Argb value of the object's colour.
When the Show method on the visualiser is called, it's passed an instance of IVisualizerObjectProvider. With XML serialisable objects you would normally obtain the object to be visualised via the objectProvider.GetObject method. When the object is not serialisable, you need to call the GetData() method instead; the objectProvider calls the GetData method of the VisualizerObjectSource, and returns the contents of its outgoingStream argument. This can then be used to visualise the object:
When this is all put together, the visualiser looks like this:
The code from this example is on GitHub: https://github.com/orangutanboy/Visualiser-Demo-With-Custom-ObjectSource
Labels:
.Net,
c#,
Debugger,
VisualStudio
Tuesday, 10 July 2012
Tomorrow's Retrospective Experiment
I stumbled over a videoblog on YouTube over the weekend, Improve your Team Agility in 10 minutes. The main idea on how to improve agility is...(drum roll)... have a retrospective.
One idea that the presenter suggests is this: print out the agile manifesto and the principles of the manifesto. During your retrospective, talk through them, then give each member of the team 2 red dots and 2 green dots. Get the team to swarm the printout of the principles, adding a green dot for what the team does well and a red for what the team needs to improve. Then analyse the results and see if there are any ideas for improvement.
Some rules that I'll be using are:
* I tweeted about this experiment today, and it sounded like it was to root out an individual in the team who wasn't agile enough and do away with him/her, like Piggy in Lord of the Flies. The point of the experiment is to improve the team by making the team realise what it needs to do better, not by culling its weakest member!
One idea that the presenter suggests is this: print out the agile manifesto and the principles of the manifesto. During your retrospective, talk through them, then give each member of the team 2 red dots and 2 green dots. Get the team to swarm the printout of the principles, adding a green dot for what the team does well and a red for what the team needs to improve. Then analyse the results and see if there are any ideas for improvement.
Some rules that I'll be using are:
- We need to read and think about the principles before the retrospective;
- The green and red dots are to represent what the team does well/badly, not any individual within the team *;
- We should at least try to explain why we chose to dot a particular principle;
- The dotting is done en masse, so nobody is influenced by previous dots;
- We don't have to use all 4 dots.
* I tweeted about this experiment today, and it sounded like it was to root out an individual in the team who wasn't agile enough and do away with him/her, like Piggy in Lord of the Flies. The point of the experiment is to improve the team by making the team realise what it needs to do better, not by culling its weakest member!
Subscribe to:
Posts (Atom)




















