- Posted by miketeye on July 2, 2009
[AddHeaderFile:http://www.levitical.org/themes/nonzero/s3sliderMain.css;SLIDERCSS]
If you are viewing this post in the post list, you will not see the animation. Click the title of the post to be taken to the actual page where you will see the animation.
JQuery S3Slider Plugin Demo
Recently I stumbled on the S3Slider JQuery plugin and liked the look and feel of the transition animations and the behaviour of the overlayed text.
So I set out to try an implementation of the S3Slider slide show in blogengine. The good news is that there is a very good JQuery Extension for blogengine by John Callaway of http://www.internetblu.com.
This extension in my opinion provided a very good approach to deploying jQuery on BlogEngine and had done 99% of the job, In the sense that once installed you are able to load jQuery plus any other jQuery plugin on Posts and Pages.
The 1% involved calling JQuery functions or Plugin functions after the DOM has been loaded. In keeping with the BlogEngine tradition of doing add-on tasks via Extensions and widgets rather than modifying the core .aspx files, I decided to write two Extensions to help solve the 1% left to achieve the objective.
EXTENSION 1: Add Header File
The Add Header File Extension does what it says, It allows you to load a .css style sheet or a javascript file with full or partial path into a post or page.
The syntax is of the form:
[--AddHeaderFile:filename.css|filename.js;SCRIPTID]. Without the double dashes (--). The SCRIPTID parameter is used to prevent duplication of the script if there
is an attempt to load the same script again onto the page.
EXTENSION 2: Add Script
The add script extension allows you to call JQuery and plugin functions from within the post or page. The Syntax is of the form:
[--AddScript:javascriptcode]
Without the double dashes (--)
With the above 2 Extensions and the JQuery Extension for blog Engine, I was able to achieve the S3Slider plugin effect in BlogEngine with the Code segment below:
[--AddHeaderFile:http://www.levitical.org/themes/nonzero/s3sliderMain.css;SLIDERCSS]
[--AddScript:$j=jQuery.noConflict();$j(document).ready(function(){$j('#slider').s3Slider({timeOut: 3000}); });]
The two dashes (--) are obviously not included in the code. The remainder is just Html markup in the form of an unordered list (ul) in a container div with id=slider. This container is the object we initialise the s3Slider script on in the AddScript Extension code above. The html markup code is listed below:
Hope you find it imformative.
You may download the two Extensions from the archive link below. Upon extracting the files, drop the two extension files,
AddHeaderFile.cs and InjectJsCsriptToHeader.cs into the App_Code/Extensions folder and you are ready to roll. Please post any bugs, comments or feedback.
- Posted by miketeye on June 25, 2009
Recently I developed a site which used the JW Player to play some video content hosted by a free video hosting service provider. I hit a brick wall when it was necessary to play an intro clip to each of the movies. The challenge is that although the JW player plays many a variety of xml playlist formats (asx,rss,atom,xspf,smil etc), It does not provide any mechanism for playing a specific intro clip to all entries in the playlist.
I tried to find a solution by going down the line of nested playlists, where I could create a sub playlist if you like, with the intro clip as first entry for each track in the main playlist, but had no joy. Although a few people said the JW Player could play nested xspf playlists, I just didn't have any luck with it.

Free Video Joiner in Action
Finally, I had to go down the route of finding easy to use tools to merge (or prepend as it were) the intro video to the main entries in the playlist before uploading to the hosting provider. At least that works OK and the problem is solved. You might think Windows Movie Maker will be a good candidate software for the task, but I quickly dropped it out of the list because, WMM always re-encoded the final movie into a totally new movie and in the process results in a loss of quality. There was a very helpful tool called free video joiner I used to easily merge the videos, you may download it from the link below:
Download Free Video Joiner
However, as good and easy to use as the above tool is, it does not support merging flvs. Flvs are however the preferred format for video hosting and streaming online, since 95% of all machines and browsers are flash ready. So if you need to merge flvs, are you stuck ? No. You are still in luck (Not like I believe in luck though, but that's a different subject for another day). As it happens, there is Andy's flv Joiner for the task of simply merging multiple flv files into one.

You may Download Andy's flv joiner from here.
I needed to do similar with mp3 audios where I needed to prepend an intro and outro mp3 to the beginning and end respectively of the main clip, the tool that came in handy for the mp3 merger is Free Mp3/WMA/Ogg Converter. You may download the tool from the link below:

Download Free MP3/WMA/OGG Converter
If you want a bit more control at editing and merging mp3 files and want an open source alternative to industry tools like Steinberg's wavelab, then you could try audacity, by downloading it from here.
If you have to rip DVD video from a Disk to your hard drive or change video enconding from say WMV to FLV, then you might want to try eRightSoft's SUPER
Download eRightSoft's Super from here
Hope this helps.
- Posted by miketeye on March 17, 2009
A while ago, I wrote a blog post on how to implement an asp.net ajax zooming system. If you haven't read that post as yet, you may read it here. The approach was at the time very promising with the release of asp.net AJAX, but at this point in time, there are far more superior technologies such as silverlight and WPF for achieving rich content in the browser and also powerful javascript libraries such as jQuery,MooTools and scriptaculous. However, I did promise in that article to post actual implementation code once I got to a point in the project which was a basic implementation of the concepts. I have been busy for a long time and hardly found time to finish this up. There have been quite a few people reading the post and expressing disappointment at the end due to the absence of a code sample, so in keeping with the promise, I have whipped up some code to demonstrate the concepts enumerated in that post.
The fig below shows the demo in action:

You may preview and engage a live demo from here.
The resizing of the image on the fly is accomplished through the ImageResize class. The main method of the ImageResize class which does the heavy lifting is GetThumbNail and is listed below:
Public Overridable Overloads Function GetThumbnail() As System.Drawing.Image
' check whether a new image is required
Dim recalc As Boolean = False
Dim new_width As Double = Width
Dim new_height As Double = Height
' Check if there is a cached source image available.
' check if imagepath was defined if not use the image in the Image member
If Not CheckIsSameSourceImage(_cachedImage) Then
If _imagePath.Length > 0 Then
' Load via stream rather than Image.FromFile to release the file
If Not IsNothing(_sourceImage) Then
_sourceImage.Dispose()
End If
' To ensure the handle gets closed when the object goes out of scope
' wrap the filestream in a "using" directive
Using _stream As Stream = New FileStream(_imagePath, FileMode.Open, FileAccess.Read)
_sourceImage = System.Drawing.Image.FromStream(_stream)
End Using
recalc = True
End If
End If
'Check whether the required destination image properties have changed
If Not CheckIsSameDestinationImage(_cachedImage) Then
' Yes, so we need to recalculate.
' If you opted to specify width and height as percentages of the original
' image's width and height, compute these now
If (UsePercentages) Then
If (Width <> 0) Then
new_width = Double.Parse(_sourceImage.Width) * Width / 100
If (PreserveAspectRatio) Then
new_height = new_width * _sourceImage.Height / Double.Parse(_sourceImage.Width)
End If
End If
If (Height <> 0) Then
new_height = Double.Parse(_sourceImage.Height) * Height / 100
If (PreserveAspectRatio) Then
new_width = new_height * _sourceImage.Width / Double.Parse(_sourceImage.Height)
End If
End If
Else
' If you specified an aspect ratio and absolute width or height, then calculate this
' now; if you accidentally specified both a width and height, ignore the
' PreserveAspectRatio flag
If (PreserveAspectRatio) Then
If (Width <> 0 And Height = 0) Then
new_height = (Width / Double.Parse(_sourceImage.Width)) * _sourceImage.Height
ElseIf (Height <> 0 And Width = 0) Then
new_width = (Height / (Double.Parse(_sourceImage.Height)) * _sourceImage.Width)
End If
End If
End If
recalc = True
End If
If (recalc) Then
' Calculate the new image
If Not IsNothing(_destinationImage) Then
_destinationImage.Dispose()
_graphics.Dispose()
End If
'Create a square bitmap as canvas
Dim _bitmap As System.Drawing.Bitmap
If new_width > new_height Then
_bitmap = New Bitmap(Double.Parse(new_width), Double.Parse(new_width), PixelFormatType)
Else : _bitmap = New Bitmap(Double.Parse(new_height), Double.Parse(new_height), PixelFormatType)
End If
'Initialise graphics with In-Memory bitmap
_graphics = Graphics.FromImage(_bitmap)
'If there is a background Image setting, use it for the background
If Not String.IsNullOrEmpty(_backgroundImageUrl) Then
Dim backgroundimage As System.Drawing.Bitmap
Using _stream As Stream = New FileStream(HttpContext.Current.Server.MapPath(_backgroundImageUrl), FileMode.Open, FileAccess.Read)
backgroundimage = System.Drawing.Bitmap.FromStream(_stream)
End Using
If Not IsNothing(backgroundimage) Then
_graphics.DrawImage(backgroundimage, 0, 0, _bitmap.Width, _bitmap.Height)
End If
Else
'Else Set graphics canvas color to the set CanvasColor
_graphics.FillRectangle(_canvasColor, 0, 0, _bitmap.Width, _bitmap.Height)
End If
'Set various properties for Resizing
_graphics.InterpolationMode = InterpolationType
_graphics.SmoothingMode = SmoothingType
_graphics.CompositingMode = CompositingModeType
_graphics.CompositingQuality = CompositingQualityType
Dim NewHeight As Integer = CType(new_height, Integer)
Dim NewWidth As Integer = CType(new_width, Integer)
'If AutoPositioning then center image vertically or
'horizontally depending on which dimension is larger
'Resize proportionately
If AutoPositioning Then
If new_width > new_height Then
_graphics.DrawImage(_sourceImage, PositionX, CType((NewWidth - NewHeight) / 2, Integer), NewWidth, NewHeight)
Else : _graphics.DrawImage(_sourceImage, CType((NewHeight - NewWidth) / 2, Integer), PositionY, NewWidth, NewHeight)
End If
Else ' Not AutoPositioning
'Dim srcRect As New Rectangle(PositionX, PositionY, NewWidth, NewHeight)
'Dim destRect As New Rectangle(PositionX, PositionY, 300, 300)
'_graphics.DrawImage(_sourceImage, destRect, srcRect, GraphicsUnit.Pixel)
_graphics.RenderingOrigin() = New Point(NewWidth / 2, NewHeight / 2)
_graphics.DrawImage(_sourceImage, PositionX, PositionY, NewWidth, NewHeight)
End If
'Apply watermarks
If Not String.IsNullOrEmpty(_watermarkImageUrl) Then
Dim watermarkimage As Bitmap
Using _stream As Stream = New FileStream(HttpContext.Current.Server.MapPath(_watermarkImageUrl), FileMode.Open, FileAccess.Read)
watermarkimage = System.Drawing.Image.FromStream(_stream)
End Using
'Draw at the top left corner
If NewWidth > NewHeight Then
_graphics.DrawImage(watermarkimage, 0, 0) 'NewWidth - 15)
Else : _graphics.DrawImage(watermarkimage, 0, 0) 'NewHeight - 15)
End If
End If
If Not String.IsNullOrEmpty(_watermarkText) Then
'Draw at the top left corner
If NewWidth > NewHeight Then
_graphics.DrawString(_watermarkText, _watermarkFont, _watermarkBrush, 0, 0) 'NewWidth - 15)
Else : _graphics.DrawString(_watermarkText, _watermarkFont, _watermarkBrush, 0, 0) 'NewHeight - 15)
End If
End If
_destinationImage = _bitmap
' Put the image in the Cache
'_cachedImage = CType(Me.MemberwiseClone(), ImageResize)
End If
Return _destinationImage
End Function
The code for the generic handler class (ImageZoomHandler.ashx) which feeds the asp.net image control's ImageUrl property is listed below:
Imports System.IO
Imports System
Imports System.Web
Public Class ImageSizeHandler : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
'Read in the image filename to create a thumbnail of
Dim imageUrl As String = context.Request.QueryString("img")
If imageUrl.StartsWith("../") Then
imageUrl = imageUrl.Replace("../", "")
End If
'Read in the dimensions
Dim width As Integer = context.Request.QueryString("w")
Dim height As Integer = context.Request.QueryString("h")
Dim xPos As Integer = 0
Dim yPos As Integer = 0
If Not String.IsNullOrEmpty(context.Request.QueryString("x")) Then
xPos = Integer.Parse(context.Request.QueryString("x"))
End If
If Not String.IsNullOrEmpty(context.Request.QueryString("y")) Then
yPos = Integer.Parse(context.Request.QueryString("y"))
End If
'create a new instance of the resizer class and set necessary properties
Dim imgResizer As Commerce.Common.ImageResize = New Commerce.Common.ImageResize
imgResizer.ImagePath = context.Server.MapPath("~/" + imageUrl)
If width < 400 And height < 400 Then
imgResizer.Width = width
imgResizer.Height = height
imgResizer.PositionX = xPos
imgResizer.PositionY = yPos
ElseIf width >= 400 Or height >= 400 Then
Dim OriginX As Integer = 0
Dim OriginY As Integer = 0
If width >= 400 Then
OriginX = (400 - width) / 2
OriginY = (400 - height) / 2
Else
OriginX = (400 - height) / 2
OriginY = (400 - height) / 2
End If
imgResizer.Width = width
imgResizer.Height = height
imgResizer.PositionX = OriginX + xPos
imgResizer.PositionY = OriginY + yPos
End If
imgResizer.PreserveAspectRatio = True
imgResizer.AutoPositioning = False
imgResizer.UsePercentages = False
'Initialise response stream
context.Response.Clear()
context.Response.BufferOutput = True
context.Response.ContentType = "image/jpeg"
context.Response.AppendHeader("content-disposition", "filename=ProductImage.jpg")
'create new image and render to Output Stream of Response.
imgResizer.GetThumbnail().Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
context.Response.End()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
As you may have realised from the downloaded project, the system is no where near perfect. My objective for posting it here is for someone to pick it up, fine tune it and add some icing on it, so we can all use it sometime in the future.
Please post any comments below.
Cheers!
You may download the visual studio project for the demo as a zip archive by clicking the link below:
ImageZoom.zip (321.98 kb)
- Posted by miketeye on March 16, 2009
I just felt like contributing to the visibility of these constants on the web. If you try to port VBA code from VB 6.0 to the .Net environment using VS 2003/5/8 interop assemblies for Excel, you will quickly find out that the Excel constants (typically with prefix Xl and format Xlxxxxx) no longer have global visibility. Each set of constants have been grouped into a type.
It is a pain sometimes trying to figure out the appropriate type for the constant. Luckily an MSDN page lists all the types. The page is at:
http://msdn.microsoft.com/en-us/library/aa221100(office.11).aspx#
Hope this helps.
Cheers!
- Posted by miketeye on August 22, 2008
I had a desktop application developed in asp.net 2003 which deployed some crystal reports with the built in Crytal Reports .Net edition.
I have always wanted to deploy the application for network use, to make it easier to roll-out maintenance and upgrades to the core program. I have however always had difficulty in doing so because of Crystal Descisions keycodeV2.dll file which by default is at the location C:\Program Files\Common Files\Crystal Decisions\1.0\Bin.
If I then run the program from a server network share, the program launches on the workstation alright, but anytime, I access any of the embedded crystal reports, the program brings up an error that it "cannot find keycodev2.dll or invalid keycode". I therefore had to put up with creating a setup project after every update and uninstalling and re-installing the program on all client workstations after evry modification to the program.
Today I found a way out. How?, well it turns out, it is possible to place a copy of the valid keycodev2.dll from the directory above into the same share location from which you launch the program. Is that the fix?, no not yet, in addition to that, you need to launch the .Net framework configuration tool from control panel\Administration tools\Microsoft.Net framework 1.1 Configuration and perform the following step:
1. click Configure code access security policy
2. click Increase Assembly Trust
3. Choose Make Changes to this computer or Make changes for the current user only depending on your needs
4.Click Next
5. Click Browse and select the .dll or .exe file for your program and click Next
6. Drag the slider to Full if you TRUST your program
7. Click Next and then Click Finish
If all went well, you should be able to create a shortcut to the .Net program fom the Network share and run the program without any permission errors and also have Crystal reports use the keycodev2.dll file from the share location.
HTH.
- Posted by miketeye on July 17, 2008
I had an Integration services package which I scheduled as an SQL server Job in SQL Server Management Studio and was working fine. A while later, I did some folder organisation on the server drive containing the ODBC Database in use by the IS Package (In this particular case, it was a Sage Line 50 ODBC Datasource). In my re-arranging files to mirror the structure on another server, I created fileshares which pointed to actual folders mapped then to drives using 'net share' command in login script.
Well, I discovered the scheduled IS packages were no longer running to success but failing. I was able to run them from SSBIDS (SQL Server Business Intelligence Development Studio), but they failed to execute from Management Studio as a job. I tried all tricks and it simply would fail.
To cut a long story short, I decided to simply try changing the ODBC Data Source path and not use the mapped drive and shared folder, but use the actual physical path to the package, and BINGO, It started working again. So if you have a similar problem, might not necessarily be an exact fix, but I hope this will point you in the right direction or at least give you another possible solution to try.
Cheers!
- Posted by miketeye on July 4, 2008
Because SBS 2k3 runs more services on one box than a normal win 2k3 server, memory usage is crucial and one cannot afford to have a single service process hogging all available memory on the SBS 2k3 box. If you are like me, you've noticed and watch in horror, while store.exe uses over 500MB of memory (as per task manager) and googled for ideas with no joy. The reason I decided to amplify this solution I came across was because most of the articles I found online suggested more or less to live with it or increase RAM on the box. I however stumbled on this blog post by JIM McBee which provided a way of limiting the Store.exe memory. The article was written for Exchange 2007 but worked equally well for me running Exchange 2003 on SBS 2k3 R2. There is no use duplicationg the steps as they are ellaborately presented in that blog post.
Hope it saves somebody the headache.
- Posted by miketeye on July 4, 2008
This was such a life saver, I had to quickly document it here to save someone else the trouble. To begin with I am surprised, there are not that many hits on google about this particular setting in the aspnet.config file which can continously crash your server over and over.
This is the issue, I maintain an Asp.Net 2.0 web application which runs in its own application pool on a 64 bit multi-processor virtual server hosting space. The KEY here is the multi-processor bit. Apparently, the .Net Common Language Runtime (CLR) uses a server garbage collector in such environments which allocates a separate garbage collector instance for each processor's separate memory heap. This can very quickly result in excessive memory usage during garbage collection and eaily bring the server down and start displaying Server Unavailable messages to clients.
Well, that is the issue, what of the solution?. As it happens, there is a very simple solution. To workaround this behavior, configure the CLR to use the Workstation garbage collector:1. Open the Aspnet.config file in Notepad.exe. The file is located at %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\Aspnet.config for .NET Framework 2.0 and at %SystemRoot%\Microsoft.NET\Framework\v1.1.4322\Aspnet.config for .NET Framework 1.1.2. In the section httpRuntime, add <<gcServer="false" />> (only one set of angle brackets!!) 3. Save the Aspnet.config file.
- Posted by miketeye on July 4, 2008
If you run SBS 2k3 R2 like I do and have the premium version, ISA server 2004 will be installed by default (OEM). On such a box, I noticed high memory usage by an sqlserver process in task manager. Problem is because there are no process ID's in task manager, it is difficult to tell which instance of sqlserver was the culprit. To solve that mystery, I had to rely on the tool set developed by Mark Russinovich and his buddies at SysInternals. Among the toolset is a utility called Process Explorer (procexp.exe). I run this program and double clicked on all the sqlserver instances running and was able to view the process image by clicking the image tab on the properties dialog. I was then able to identify the sqlserver instance using up to 500Meg on the SBS box as MSSQL$MSFW, which is the MSDE instance for ISA server logging.
After identifying the culprit, the second stage is dealing with the high memory usage. For that, since it's a SQL server instance, I was able to use SQL server Management Studio (You could also use Enterprise Manager Or even Management Studio express) to connect to the database instance, right click on the instance icon, select properties. In the properties dialog, select the Memory tab/link either at the left side or at the top of the dialog. In the memory settings, Change the "Maximum server memory (in MB) setting from the default high figure to say 256. Click OK.
NB: You will have to play with the settings to see what value works well for other services running on the box. In my case 256 did the trick. May be different figure in your case, but the solution remains the same.
Also, note that if you set this too low, ISA server will not function properly and might affect network connectivity. As a side issue, this presented itself in my case where Remote Web Desktop Connection built into SBS stopped working. I could connect to workstations using normal Remote Desktop Connection (RDC), but not via the RWW interface. I then adjusted the memory setting upwards and restarted ISA Service, then bingo, the RDC via RWW started working again.
- Posted by miketeye on June 26, 2008
I found very little information available online on the subject and so felt the need to write a few lines to save someone else the agony.
The problem occurs with Sage Line 50 using data files running off a mapped server drive. In such a setup, if a user on a workstation for whatever reason looses connection with the server, the users session (linked to the particular workstation ID) is kept open in the user session database file. This stranded user session then prevents access to major maintenance tasks and backups.
If the user wasn't updating any files at the time of disconnection, then it is possible to logon to any workstation as the sage user and re-connect to the stranded session, and thereby terminate it. If however the user was updating files when the disconnect happened, then in most cases it is possible to logon to the specific workstation concerned (provided it is available and the workstation ID has not changed) and re-connect to the session.
Consider a scenario where for some reason, the workstation ID changes (due to domain migration or upgrade), or the workstation is de-commissioned and is no longer available. This was the situation I faced. The situation was triggered by Microsoft's WSUS system which pushes volumes of windows updates onto the Server and Workstations. After such an update rollout and reboot, some workstation IDs changed for Sage line 50 (I don't know why and would value any info on how sage deduces its workstation IDs) and I was unable to log back into a session in order to terminate it. I searched online for some options or fixes for the situation but found no way to do this. I then had to hunt through the Sage data files in the ACCDATA folder to find a data file holding the data. I tried a few without joy, and then finally with some stroke of ingenuity, I replaced the QUEUE.DTA file with a copy from a fresh sage install, fired up sage and the stranded user was gone!!
I definitely hope it saves someone the headache, especially when working with impatient users.