Wednesday, August 25, 2010

Code: FullText Search in SQL Server 2008 Express

In order to do full text search in SQL Server 2008 Express (Original or R2) you have to install the "Advanced Services". You can find the download for original here or R2 here.

After upgrading your current instance (or installing the new instance) you also need to make sure the Full Text service is enabled

You can then follow this guide to add a full text catalog and index.

If you are using SSMS and want the full text index scripts to be generated when you generate the create script for a table, you'll need to modify a setting.  Go to  Tools | Options - Scripting page and then scroll down to table options and select "Script full-text indexes". This will script the full-text indexes with the table definition.

If you are using the scripts then in a Visual Studio Database project, don't forget to set the Build Action property of the file to "Build", otherwise it will drop the indexes when it deploys

Tuesday, August 17, 2010

Code: Silverlight Navigation from a UserControl

For some reason Silverlight does not provide the ability to access a page's NavigationService from a user control, so in order to navigate correctly you have to manually walk the control tree. See the method below to use as a helper class.

public static class NavigationHelper
        public static void Navigate(Uri url, UserControl control)
            Page pg = GetDependencyObjectFromVisualTree(control, typeof(Page)) as Page;

        private static DependencyObject GetDependencyObjectFromVisualTree(DependencyObject startObject, Type type)
            //Walk the visual tree to get the parent(ItemsControl)
            //of this control
            DependencyObject parent = startObject;
            while (parent != null)
                if (type.IsInstanceOfType(parent))
                    parent = VisualTreeHelper.GetParent(parent);
            return parent;

Monday, August 2, 2010

Code: Create Thumbnail from Video using VLC command line

If you want to create a thumbnail from a video, you can use VLC and its command line arguments as seen below. This was tested using VLC 1.1.2

C:\Users\amiller.NG>"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --video-filter scene -V dummy --scene-width=80 --scene-format=jpeg --scene-replace --scene-ratio 24 --start-time=6 --stop-time=7 --scene-path=D:\ --scene-prefix=thumb D:\1.mp4 vlc://quit

--scene-path is the output directory
--scene-prefix is the output filename
--scene-format can be jpeg, jpg, or png
--start-time is the location in the video (in seconds) to grab the image from
--stop-time tells the vlc to stop playing the video at that point
--scene-width specifies the output width of the thumbnail in pixels, you can optionally include --scene-height, but the image will be stretched to fit that dimension.