ARTEM®
Description

This is a page describing my programming project, called Artem. Artem is a tool which provides you functionality of making web photo albums.

Used resources:

Download: Artem (needs the MS Visual Studio installed)

Albums made with Artem:
Florida
Winter Holidays
Autumn 2007
Winter 2007–2008

To-do list
Jan 12 2008
Project ability

Ok. I wanna add ability to save&load photo album projects. It is going to have the following data:

I'm probably going to use XML, but I have no idea how to.

However there is another problem. My scheme of plugin and picture list interaction is built in a way that they are independent. They are even in different assemblies. So, if I want to save project properties I have to use its properties. And simultaneously I need to store pictures' properties. So, where to place the functionality: inside the plugin, or inside the GUI application?

Considering the second variant I can simply save all the options (both plugin's properties and picture comments). But how can I make my plugin able to allow me loading that project file?

I heard something about actions, not properties in C#. I might put those two actions to the plugin and use 'em from property viewer.

Dec 15 2007
Image thumbnails preview

Here is the question:

«where to place the image preview area?»
I can make it like a property of the picture class, and when we select an image it starts to generate the thumbnail and then shows right in the property grid field. Difficulty of this approach is that I should invent a way how to display this field. Another difficulty is that if make it like an implicit property it will be executed each time I call it or GUI call it. But the execution does take time. So, it's gonna be retarded if made implicitly.

Another way is to leave some place on the form just for the preview image. It is much easier, because nothing to invent — just insert and use it. The question is: where the fuck to place?

Have designed it like that: put all three controls into TableLayout:

Now when the previeableCheckBox is checked then previewPictureBox is shown. When I uncheck it — the picturebox dissappears and corresponding cell dissappears too, cause it is auto-sized. Simultaneously the third cell increases it's absolute size since it is percent-sized to 100% of free space.

 ----------- 
| Property  |
|  grid     |
|           |
|           |
|           |
|           |
|           |
 ----------- 
 |         |
 |         |
 |         |
 V         V
  _________________________
 |                         V
 ___________               ___________ 
|v CheckBox |             |o CheckBox |
-------------             -------------
| Picture   |             | Property  |
|   preview |      =>     |  grid     |
-------------             |           |
| Property  |             |           |
|  grid     |             |           |
 -----------               ----------- 

Nov 23 2007
Conversion to black&white

Scaling colors ms-help://MS.MSDNQTR.2005JAN.1033/cpguide/html/_gdiplus_Scaling_Colors_usecsharp.htm

What I did finally is just added all R, G and B components together and divided them by 3.

Nov 21 2007
Attributes + PropertyGrid (finally)

Thanks to Sergey Babin and rsdn article I've finally performed that dream about properties separations by categories (using System.ComponentModel.CategoryAttribute). Also I've applied DisplayName and Description attributes for the displaying name of a property and for detailed description at the bottom of the grid accordingly.

Nov 17 2007
Property grid properties separation

Having a lot of functional plugins that are to be loaded to your application and — properties of those plugins that are to be shown in a PropertyGrid by calling PropertyGrid.SelectedObject it becomes looking like a big heap of trash. Especially if some plugins contain another ones or — inherit 'em.

One way to improve the situation is to set a number of attribute classes to the PropertyGrid.BrowsableAttributes that are to be displayed by the grid if the object owns those attributes.

Nov 17 2007
Still not completely satisfied by resizing quality

Now the resize plugin works very simple. It declares a hidden field that represents the value of the biggest image side size which is threshold: if requiring side size is bigger than the threshold value we call first procedure to resize the picture and if less — procedure number 2. But what is the most interesting is that no actually work about resizing made by myself (no code written).

The first procedure uses Image.GetThumbnail() method. The second one just creates new Bitmap using constructor providing new sides sizes for the Bitmap.

So, it's not a surprise why the quality is so poor. Well, it's actually even more poor if only one of the former procedures used for both size ranges, but at the same time I wanna get nice pictures.

The offer is to use GDI+ Graphics class, that can be constructed from a Image instance. Then I resize the Graphics and unload it to some file.

Then, why this method is gonna bring me nice pictures, is because the Graphics provides some custom parameters:

You see I can set interpolation and smoothing modes that really does improve the quality. The second note is that two smoothing modes antialias and highquality seem to be the same.

Nov 16 2007
HTML generator

Want to design a class that generates html file.

It works like that:


HTMLGenerator g = new HTMLGenerator( "./index.html" );
g.Head.Title.value = "This is a title for this file";
g.Head.Style.src = "./css/mystyle.css";
g.Head.Style.add( "#container{ margin: 0; padding: 0; width: 100%; height: 100%; border: none; }" );
g.Head.Generate();

g.Body.Style.backgroundColor = "gray";
g.Body.Style.border = "none";
g.Body.rawAdd( "<div id="container"><h1>Hi, people</h1></div>" );
g.Body.Generate();

g.Finish();

Nov 9 2007
DirectX investigations

I'm gonna write a separate class manipulating on images that are used in Artem. So it's goona be no need to inherit a lot of classes inside another ones just to have the same ability to manipulate on pictures.

I want that class to be able returning

Nov 7 2007
Wrap2Html plugin
I have a question about how am I going to present the choice of html template (style) of the result html page. I mean that I can prepare some templates right inside the source code (using or not using embedded css file technique. Or I can declare some rules are to be performed by a user who wants to make one's own template and generate some intermediate html, carrying a link to the custom css style file.

But that shit seems to be too complicated at least for the most typical user that isn't so a nerd html-writer as I am %).

So, at first I'm going to implement some predefined set of html-styles. Somewhat like enumerable property of the plugin class.

Nov 6 2007
Thumbnail plugin

It works but works not as well as I want it to: (1) low quality result pictures and (2) very slow on big files.

First problem, probably could be solved by use of DirectX library.

Second problem could be solved by applying technique called lazy allocation: allocate memory exactly at the moment when the object is gonna be used. And moreover, after usage I can free the memory manually so as not to eat so much brains of my poor laptop :).

Some pleasant results

Nov 5 2007
 

Gosh, it feels much better when you stop programming every 40 minutes and just make some physical exercises and look out the window (do you have one at your workplace or cubicle? ).

Plugin execution mechanism (using toolbar)

(25K)

 

BasePicture

It's ultimately slow on large files to include the System.Drawing.Image instance into BasePicture class.

Desirable plugins to design

(17K)

Thumbnail

MSDN example

Nov 4 2007
 

Ok. We have plugins to be added dynamically. And we gonna add some GUI control, that provides us ability to add clickable controls, delegating execution to the plugin that is just added. I.e. we claim that the plugin should own an EventHandler method.

But, if I delegate execution to IFunction.handler() and at the same time it doesn't know anything about picture it's supposed to work on. But we can first call method of this plugin that sets the picture on what it's gonna work.

It works, but I had to add direct reference to the plugin library, because I had to cast object to Function.IFunctionPlugin when I was constructing a delegate:



foreach( Type t in pluginTypes )
{
   object o = Activator.CreateInstance(t);
   // Object o should own a handler suitable for 
   //   EventHandler delegate, so we put that
   //   handler inside MenuItem constructor
   MethodInfo Shortname = (t.GetProperty("Shortname")).GetGetMethod();
   MethodInfo handler = t.GetMethod("handler");

   mi.MenuItems.Add(
   new MenuItem(
         (string) Shortname.Invoke(o, null),
         new EventHandler(((FunctionPlugin.IFunctionPlugin)o).handler)
         )
       );
}

The aim

I want each plugin to be tunable over the System.Windows.Forms.PropertyGrid control which actually uses accessible properties of the object i.e. plugin. So when I click or select or whatever (i'm looking for the control I should use for the plugins in the GUI form) first I should set the properties and then has another way to execute the plugin.

So use of button isn't suitable: when you click the button - you expect that it's gonna work out, show some function, but instead of that you get the properties of the plugin. Seems stupid for me.

System.Windows.Forms.ListBox seems a good solution. To put an item into the listbox the item is supposed supporting System.ComponentModel.IComponent. So we derive our plugins from System.Windows.Forms.Control (which implements IComponent) and then we can just put instances of our plugins directly to the listbox.

Tried to generate ToolStrip by the studio, then paying a lot of attention looked what it generated and now I'm gonna try to repeat that by myself having written class ToolBarGenerator. private void InitializeComponent() performs the following:

Wooooooooooooooooooooooooow, it works! O_o :)

Handlers

How to handle the button click on my toolbar? I'm sure a plugin corresponding to a button should not know anything about GUI it works under. We should catch that click inside some GUI class and then, having understood which plugin was called, do some stuff.
Somewhat like that
Ok, I gotta go buy some stuff to eat :)

Picture List

I want the following about the list: as the program designed to make photoalbums I should display the pictures in a way that it's not a big deal to mark out several pictures from it and make a group operation: like to make an album, or just make an thumbnails. It means that all these plugins should operate over the groups of pictures - not a single picture. All of 'em.

Yep, CheckedListBox seems very very convenient.

Mechanism of the program and plugin communication

Since we don't know what does any plugin produce (don't know the bussiness logic of any plugin, because some foreign one can write a new plugin) we assume the following scheme:

Thus, if any plugin gets null as a selected pictures inside the listbox, but following by the business logic of the plugin this list of pictures should not be empty, it just retunrs null, meaning that it has got nothing to do. And then the program just does nothing. User should check some pictures before call this method. That's it. Very simple.

Ivan Yurlagin,