Click here to Skip to main content
13,352,408 members (60,107 online)
Click here to Skip to main content
Add your own
alternative version


82 bookmarked
Posted 14 Dec 2004

Photo Album in C#

, 14 Dec 2004
Rate this:
Please Sign up or sign in to vote.
An article describing how to make a photo album like program.

A compiled binary is included. Also, the program will make your photos into directories containing only files (=Images) or folders. Since the program will mess with your folder structure, recommend only running this program with a copy of your images (that you do not mind messing up). I can not be held responsible for any unintended consequences of this program, and any harm that it might cause your data.

Sample Image


The following is a description of the Photo Album program I am writing. It is designed to be a standalone photo viewing and editing application. As of now, it is able to load the images and display them as thumbnails. There is also a preview window. The program also lets the user change the image's metadata (or properties) that appear when you click Properties in Windows Explorer and go to the "Summary" tab.

Note that you need to be using the .NET framework version 2.0, as the project uses generics and other features that were only available in version 2.0.


The program currently includes a task pane (like the one in Windows Explorer). However, there are no commands on it yet. These will of course be updated. The taskpane was developed by Mathew Hall, whose article can be found on The Code Project here (great job!).

Using the code

Really, there is no code to re-use in this article. There are a few classes in the "Photo Album Helper Controls" project:

  • CloseButton -- Mimics the close button on a tool window (that is the type of window you get when you pull off one of the toolbars in Paint).
  • ToolWindowTitleBar -- Mimics the title bar of a tool window. One thing to mention here is that the visual styles (that are part of Windows) aren't quite up to snuff, and don't paint text correctly. If you look at a Windows tool window, you will see that the text is white; yet, when you try and paint it on with the following code, the text paints on black. (This is not a problem with .NET, but rather a problem with Windows.)
    protected override void OnPaint(PaintEventArgs e)
        VisualStyleRenderer vsr = new VisualStyleRenderer("Window", 2, state);
        vsr.DrawText(e.Graphics, new Rectangle(offset, 0, 
            Width - 3 * offset - h, Height),
            Caption, true, TextFormatFlags.EndEllipsis);

    Instead, I had to use the following code:

    protected override void OnPaint(PaintEventArgs e)
        e.Graphics.DrawString(Caption, SystemFonts.SmallCaptionFont,
            new RectangleF(offset, 
                (Height - (int)e.Graphics.MeasureString(Caption, 
                Width - 3 * offset - h, Height
  • ToolWindowGroup -- This combines the above two controls into a container control. It looks like a panel that has a title bar tool window header.

    One thing to note here is that when you add controls to it, and you dock them, you always want them to be in front (of the title bar, especially when you dock to fill). To accomplish this, I added the following code:

    protected override void OnControlAdded(ControlEventArgs e)
        // always send the titlebar to the back whenever a control is added.
  • CyclingProgressBar -- As the name suggests, this control mimics the progress bar controls, but instead of showing a percentage complete, it cycles. This control is actually an ownerdraw user control, which uses the new visual styles to render. This is actually quite a useful control.

Points of Interest

The code for this project is contained in three different projects. We already mentioned the "PhotoAlbumHelperControls", but in addition to that, there is also a library that mimics the folder tree. It dynamically updates the structure whenever a change occurs on the system. For my purposes however, I needed a set of classes that acted like the folder tree but kept track of images and albums. What is in this library is a result of that. The code in this library has not yet been cleaned up and is still a work in progress. Not every feature has been tested. An interesting thing to note here is that with these classes, you can update the metadata of an image file. Right now, there is only support for the date/time the picture was taken (which changed property number 306 and not the number that Windows uses) and the title of the image. Obviously, there are countless other properties and this is being worked on.

_Photo.Properties.Date.Value = DatePictureTakenDateTimePicker.Value;
// this is in the file EditablePropertiesControl.cs


  • 12/14/2004 - First release on The Code Project. Alpha release (really only a viewer).

Coming Features

  • Edit all image properties.
    • Including special editing of people in the picture, and interfacing with MS Outlook contacts.
  • Combining similar images into a multipage TIFF file.
  • Other layouts/views including "Slideshow view".
  • Image editing.
    • Crop
    • Red-eye
    • Rotate
  • Other suggestions welcome.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionMessage Closed Pin
16-May-14 17:47
memberali_gooly200116-May-14 17:47 
GeneralMy vote of 1 Pin
Akhil_Mittal16-May-14 9:31
mvpAkhil_Mittal16-May-14 9:31 
QuestionMessage Closed Pin
16-May-14 8:38
memberali_gooly200116-May-14 8:38 
GeneralMy vote of 1 Pin
morrisjames6-Nov-09 22:07
membermorrisjames6-Nov-09 22:07 
GeneralMy vote of 1 Pin
Wertugo5558-Dec-08 22:57
memberWertugo5558-Dec-08 22:57 
GeneralThis article should get 0 rating. Pin
debanjan.routh3-Dec-08 6:39
memberdebanjan.routh3-Dec-08 6:39 
GeneralThe referenced component 'XPCommonControls' could not be found. Pin
angels77723-Nov-07 19:43
memberangels77723-Nov-07 19:43 
hi i am having 2 missing references..
"The referenced component 'XPCommonControls' could not be found.
"The referenced component 'XPExplorerBar' could not be found.

where should i locate for these 2 things

GeneralRe: The referenced component 'XPCommonControls' could not be found. Pin
lehongquan18-Jan-11 18:41
memberlehongquan18-Jan-11 18:41 
Generali am new to this but no view Pin
claygorman24-Aug-07 10:39
memberclaygorman24-Aug-07 10:39 
QuestionCan not compile project Pin
piotrz23-Jul-07 7:34
memberpiotrz23-Jul-07 7:34 
Questionred eye reduction Pin
mileni_836-May-07 2:32
membermileni_836-May-07 2:32 
GeneralAdded Reference yet not building Pin
divvi13-Mar-07 3:25
memberdivvi13-Mar-07 3:25 
GeneralRe: Added Reference yet not building Pin
mapaxo24-Apr-07 21:04
membermapaxo24-Apr-07 21:04 
GeneralNeed Reference Pin
ATondtar28-Oct-06 4:28
memberATondtar28-Oct-06 4:28 
GeneralRe: Need Reference Pin
skibum1315-Feb-07 10:03
memberskibum1315-Feb-07 10:03 
GeneralRe: Need Reference Pin
nsimeonov14-Oct-07 6:52
membernsimeonov14-Oct-07 6:52 
General"you need windows xp to use this program" [modified] Pin
juwikuang21-Sep-06 7:02
memberjuwikuang21-Sep-06 7:02 
GeneralRe: "you need windows xp to use this program" Pin
Hamboeck20-May-07 4:41
memberHamboeck20-May-07 4:41 
GeneralRe: "you need windows xp to use this program" Pin
claygorman24-Aug-07 10:49
memberclaygorman24-Aug-07 10:49 
GeneralCannot build with .Net Framework 2.0 Pin
deeryezi18-Nov-05 23:34
memberdeeryezi18-Nov-05 23:34 
GeneralRe: Cannot build with .Net Framework 2.0 Pin
weixuan586-Dec-05 19:31
memberweixuan586-Dec-05 19:31 
GeneralRe: Cannot build with .Net Framework 2.0 Pin
skibum1315-Feb-07 10:44
memberskibum1315-Feb-07 10:44 
QuestionWhat is you editon of your visual I can't open the project? Pin
Hboyme25-Apr-05 6:00
memberHboyme25-Apr-05 6:00 
AnswerRe: What is you editon of your visual I can't open the project? Pin
whits20-May-05 9:39
memberwhits20-May-05 9:39 
AnswerRe: What is you editon of your visual I can't open the project? Pin
skibum1315-Feb-07 10:46
memberskibum1315-Feb-07 10:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 15 Dec 2004
Article Copyright 2004 by ebukiet2
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid