September 24th, 2007 by Chris
Ok, so I'm a geek and a programmer by profession. Now I have a few interests out of the office and one of them is video, I've been fascinated with everything video for a long time now and so I took it upon myself to start playing around with .NET and video, namely AVI files. Now I found some really good resources that helped me build a very simple AVI reader and allow me to render frames one at a time to a window. This is of course a very simplistic approach but it can be expanded now thanks to the list of resources I found searching the web.
These resources have proven to be valuable to me in building my program, however ironically as it sounds, they don't all cover what I accomplished, that's going to be for another post.
Technorati Tags: AVI, c#, vb.net, .net, programming
Posted in Miscellaneous | No Comments »
June 14th, 2007 by Chris
This is a very simple tip that I figured I should post. Its a common thing to want to launch a web browser from your application when a user clicks on a link, or presses a button. The simplest way to perform this is to use the following line of code, that's right, its one single line of code to do it.
C#:
-
System.Diagnostics.Process.Start("http://www.microsoft.com")
Now the benefits of using the above line of code, it will use the users default browser, so if the user has their default browser set to Firefox, then Firefox is launched, if Internet Explorer is the default, then it is used. The key to making sure this works however is to always include the protocol portion of the URL.
Technorati Tags: .net, C#
Posted in Windows Forms | No Comments »
June 12th, 2007 by Chris
As many programmers have come across, sometimes you want to prevent your app being launched more than once. This is a desirable function for many reasons. This can be used when you're app relies on writing or reading from files, and to prevent locking of files and possible corruption, you only want your app to run once. If you're writing something that is going to be only useful in a single instance, you can check and prevent multiple instances being run. The code snippet below details how to perform this check at the launch of your app.
C#:
-
using System;
-
using System.Windows.Forms;
-
public partial class MainDesktop : System.Windows.Window
-
{
-
public MainDesktop()
-
{
-
if (System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length == 1)
-
{
-
/// App initilization code here
-
}
-
else
-
{
-
this.Close();
-
}
-
}
-
}
Put this code in the main method of your app. This way when it runs, it checks and if finds another process with the same name, causes the new app to close instantly.
Technorati Tags: C#, Windows.Forms, .NET
Posted in Windows Forms | 1 Comment »
June 12th, 2007 by Chris
I've been developing now for the last few months my first WPF application. During this development I've searched for lots of information on how to implement WPF and some of the quirks and workarounds needed to make my app function. My goal is to post some useful links as well as some useful articles of my own to help those with WPF development.
Josh Smith on WPF (A good blog on WPF and some useful articles)
WPF Wonderland (Another good blog on WPF)
WPF Wiki (A wiki for WPF)
MSDN WPF Forums (MSDN forums for WPF discussion)
IRhetoric - Karsten Januszewski (Another WPF blog)
The links above are just a small selection of WPF information out there, since its still a new technology more and more information becomes available, you're best bet is to use these links as a launching platform into the world of WPF.
Technorati Tags: wpf, windows presentation foundation, Microsoft.NET 3.0
Posted in WPF | 1 Comment »
February 13th, 2007 by Chris
This nice tip allows the addition of a drop shadow to any form you want. The drop shadow is a nice effect that comes standard with Windows XP and Vista. It just gives the form a little mode depth and a nicer more modern look.

As you can see above, the difference is slight, but in the right hand image you can see a drop shadow around the form.
To implement this feature, you need to add in the following code to your forms.
C#:
-
using System;
-
using System.Windows.Forms;
-
using System.Security;
-
using System.Security.Permissions;
-
-
namespace System.Windows.Forms
-
{
-
public class DropShadowForm : Form
-
{
-
private const int CS_DROPSHADOW = 0x00020000;
-
-
public DropShadowForm()
-
{
-
}
-
-
protected override CreateParams CreateParams
-
{
-
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
-
get
-
{
-
CreateParams parameters = base.CreateParams;
-
-
if (DropShadowSupported)
-
{
-
parameters.ClassStyle = (parameters.ClassStyle | CS_DROPSHADOW);
-
}
-
return parameters;
-
}
-
}
-
-
public static bool DropShadowSupported
-
{
-
get { return IsWindowsXPOrAbove; }
-
}
-
-
public static bool IsWindowsXPOrAbove
-
{
-
get
-
{
-
OperatingSystem system = Environment.OSVersion;
-
bool runningNT = system.Platform == PlatformID.Win32NT;
-
-
return runningNT &&
system.
Version.
CompareTo(new Version
(5,
1,
0,
0))>=
0;
-
}
-
}
-
}
-
}
Posted in Windows Forms | 1 Comment »
February 13th, 2007 by Chris
Welcome to my new .NET tips and tricks site, my focus of this site is to provide a wealth of information in relation to .NET development, deployment and use as well as some of the more trickier side of the .NET world.
Posted in Site | No Comments »