Elentok's Blog

About me
WPF Pan, Zoom & Rotate Control

In the past few days I have been working on an image viewer control that allows the user to pan (via scrollbars and by dragging the mouse), zoom (by mouse wheel and by buttons) and rotate (by dragging the mouse in "rotate" mode).

I must say this was the funnest of all of my WPF experiences, I really love the elegance of WPF. The implementation ended up being a completely generic viewer that can contain whatever you want (not just images).

The viewer is actually two controls: ViewerControl and FullViewerControl.

WPF and KeyboardNavigation TabNavigation = "Local"

In my WPF projects I use a lot of data templates, and some of this templates require a custom tab order. To do this I set the TabIndex property on the relevant items inside the data template.

When I used the same template multiple times in the same page I noticed that the tab navigation didn't behave the way I wished it to (instead of jumping between indexes 1, 2, 3... in each template, and jumped between index 1 in every template, then index 2 and so forth).

Keyboard Friendly WPF Popup Control

A couple of weeks ago I talked about various tips for building more keyboard friendly WPF application, now I will I am going to focus about the WPF Popup control.

To make the popup control more keyboard friendly we need to make the following changes:

  1. When the popup opens, the keyboard focus should move to the contents of the popup.
  2. Lock the keyboard focus inside the popup until it closes.
Keyboard Friendly WPF Applications

Back in my Linux-only days I used the keyboard for everything, and I barely touched the mouse, but during the last five years, working full-time as a .NET developer on Windows systems, I started to use the mouse a lot more than I used to.

Recently, I have been trying to cut back on my mouse use and go back to keyboard-only. This made me notice that some of my WPF applications are not very keyboard friendly (keyboard shortcuts, weird tab order, etc...).

In my search for improving keyboard-support on my WPF applications I found a few tips that I would like to share:

Record a stream using VLC

To record a stream (mms for example) use the following command:

$ vlc mms://server/path \
  --sout #transcode{acodec=mp3}
  --run-time=<time to record (in seconds)>
Extract audio from video files using VLC

You can use the following command to extract audio from a video file using VLC:

$ vlc "Source File" \
    --sout #transcode{acodec=mp3}\

(Important!: The argument of "--sout" must have no spaces in it (except for in the "dst" attribute).

To only extract a segment of audio use the following command:

$ vlc "Source File" \
  --start-time=<start time (in seconds)> \
  --stop-time=<stop time (in seconds)> \
  --sout #transcode{acodec=mp3}\
Reset NTFS permissions

Every time I reinstall my computer and then try to access my external hard drives I keep getting security errors and it won't let me access some of the folders.

After some research I figured out the way to reset the permissions on the drive:

  • Right click a problematic folder in the drive and press Properties.
  • Under Security press Advanced
    • Under the Owner tab:
      • Press Edit
      • In Change owner to: select the new owner (your user).
      • Enable Replace owner on subcontainers and objects
      • Press OK.

In the past couple of months I have been working on an email archive manager called "AMail" which is written in WPF.

AMail is not an email client, it's only meant to store email messages in an encrypted zip files (using AES256 encryption).

Why not just use an email client?

How to select a WPF TreeViewItem from code

I've been breaking for a couple of hours now on how to select an tree view item properly by code. I'm using the ViewModel's "IsSelected" property which is databinded to the TreeViewItem's "IsSelected" property, but I've now realized that it's not enough...

How to use your iPod Touch as an alarm clock

One of the annoying features of the iPod Touch is the fact that you can't use music from the library as the alarm clock sound (the iPhone allows you to select ringtones but since the iPod Touch doesn't support ringtones it doesn't help).

I tried some alarm applications from AppStore but non of them worked (after the iPod is locked, 3rd-party applications can't activate it), the only method I found was to disable the iPod's auto-lock-after-X-minutes feature and just keep it on the whole night, but I didn't like it so I just gave up and kept using my cellphone as an alarm clock.