Duplicate line command for Visual Studio

.NET, Visual Studio 3 Comments »

Visual Studio 2005One of the things I'm missing in Visual Studio is a keyboard shortcut to duplicate a line of code. I use this command alot in Eclipse/FDT (Ctrl+Shift+D) and once you get used to it, you can't live without it. After googling around for a moment, I found this VB code that does just that. The great thing is that in Visual Studio you can create your own macro and attach it to a keyboard shortcut.

Visual Basic:
  1. Imports System
  2. Imports EnvDTE
  3. Imports EnvDTE80
  4. Imports System.Diagnostics
  5.  
  6. Public Module DuplicateLastLineModule
  7. Sub DuplicateLine()
  8. Dim line As String
  9. DTE.ActiveDocument.Selection.StartOfLine(0)
  10. DTE.ActiveDocument.Selection.EndOfLine(True)
  11. line = DTE.ActiveDocument.Selection.Text
  12. DTE.ActiveDocument.Selection.EndOfLine()
  13. DTE.ActiveDocument.Selection.NewLine()
  14. DTE.ActiveDocument.Selection.StartOfLine(0)
  15. DTE.ActiveDocument.Selection.Text = line
  16. End Sub
  17. End Module

To create the macro, just go to the macro explorer ("Tools->Macros->Macro Explorer" or Alt+F8) and copy paste the code in a new module.

Now just assing a keyboard shortcut to it:

  1. go to Tools->Options...
  2. under Environment, click Keyboard
  3. in the "Show Commands Containing" textbox, enter "duplicate" (this according to the name you gave the module.)
  4. you should now see the macro in the list below
  5. choose "Text Editor" from the "Use new shortcut in" list
  6. set focus in the "Press shortcut keys" textbox and hit the combination on the keyboard you whish to use for it (Ctrl+Shift+D in my case)
  7. hit the "Assign" button
  8. you should now see the shortcut in the "Shortcuts for selected command" textbox
  9. hit the OK button

And that's it. Enjoy !


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Multi-Mania review and presentation slides

General No Comments »

I had a great time at Multi-Mania last thursday. A lot of people showed up and it's good to see that the Belgian crowd is really interested in multimedia and its surrounding technologies.

In my session at the Fortis arena I talked about some of the concepts of AS2lib and how we use them in our homebrewn Eduma-Tic framework for building e-learning applications. Although this was very technical at some point, most of the people got the basic ideas behind it. The slides are available for download here. If you were on the presentation and have some questions left, then don't hesitate to mail me.

After my session, I ran to the main conference room where Aral "Peeing Dog" Balkan was about to present. Unfortunately there were some technical difficulties that forced him to do his session on another laptop, ending up in a different presentation than the one he had planned. All in all he did very well and even managed to draw the most abstract peeing dog I had seen in my life! The crowd also seemed to enjoy it.

We then sat together with the OSFlash panelists (Peter, Serge, Edwin and myself) to decide Serge had to be the bad guy in the discussion, being the one that was against OSFlash and open-source in general. Aral did a great job moderating it. He even got the crowd to ask questions and participate in the debate which is very hard in Belgium. I think we covered some interesting topics. The bottom line was that you shouldn't be black or white in choosing open-source software. Find the combination that best suits your needs, be it with commercial tools and/or open-source tools.

Aral then had the chance to do his presentation over in another conference room without technical difficulties. ARP was the topic covered and he showed how ARP is there to be used in Flash, Flex and Mtasc development. He even made an ARP3 announcement which should be in the public repository soon.

I hope you all enjoyed the conference and hope to see you again next year !


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Flash vs. audio markers

General 5 Comments »

I was challenged today to find out how we could read the audio markers from a mp3 file in a Flash movie. The markers were added using SoundForge and are crucial for the application we are building.

Since there is no way in Flash to read those markers, I had to find another way.

A possible solution was to write an xml file with the marker information and load it into the Flash Player when the sound was being loaded. I found this cumbersome because of the 2 files and the problems that would arise when updating the markers and to keep the files synchronised.

After taking a deeper look into the SoundForge documentation, I found out that it is actually possible to write your own scripts, in c# for instance, that can be run from within SoundForge. To create your own scripts, you need the SoundForge 8 Script Developers Kit, which is available for free download. The API allows you to read all files that are opened in SoundForge and then enables you to edit them by code. Reading the markers was pretty trivial given that the API itself is very straight forward and there is some good documentation available in NDoc format.

I decided to write the markers into the "comment" field of the ID3 information. This was also pretty easy to do and best of all, it can be read by the Flash Player. The markers are in a format like "10_23_76", which means there are markers on seconds 10, 23 and 76.

The ActionScript part is not done yet, but this shouldn't be a problem. The most important thing was to get the markers into our Flash movies.

The script (C# sourcecode) is available for download if you are interested. To run it, just open SoundForge, go to Tools -> Scripting -> Run Script... and then browse for the script. You can also put the script in the "Script Menu" folder inside the SoundForge installation folder. Doing so, the script will be available in the Scripting panel.

Have fun and be sure to let me know if you find any bugs or other weird things.


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Watch the World Cup live…in ascii

General 1 Comment »

Oh man, this is simply amazing. The coolest graphical ascii application ever !

Wanna see it ? Just open a console (Windows: Start->run...->type "cmd" and enter) and type "telnet ascii-wm.net 2006". After the football field appears, you should see the game. There are comments at the bottom of the screen.

If you're having trouble with the server, try one of these mirrors:
- diego.ascii-wm.net 2006
- pinguin.eikon2.fs.ei.tum.de 2006

Enjoy !


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

i += i++ + ++i;

General No Comments »

Test your brain and ActionScript programming insight with this simple question: What's the output of the following trace statement?

Actionscript:
  1. var i = 1;
  2. i += i++ + ++i;
  3. trace("i=" + i);


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login