Monday, October 26, 2009

Paint Application [C#]

Greetings. I wrote a Paint Application in C#, here is a summary of it:

It is a Multiple-Document Interface application - The Image forms are MdiChildren of the Main application form.
According to this, the main menu is merged with a non-visible MenuStrip on the Image form.
The various tool windows are owned by the Main application form.

The featured tools are: Select, Pencil (1px free-draw), Brush, Eraser, Rectangle, Circle, Fill and Pipette (color picker).

The different parameters for each tool are displayed in the Tool Options window.
Each tool's options are arranged on a dedicated panel on this form. When a tool is chosen, its' options panel toggles to the only visible panel.

The edited image is displayed inside a PictureBox control.
All drawing actions are done in the course of the MouseDown, MouseMove and MouseUp events of that PictureBox.
A boolean named isDragging is turned true on MouseDown event, and false on MouseUp event, thus enabling continuous drawing actions.

Selection definition, dragging and dropping is done in a similar way, based on four selection states listed in an enum.

The algorithm for the flood fill tool is taken from this tutorial.

Two image filters are available from the Image menu - Brightness and Invert, and can also be applied to selections.
Brightness also features a dialog for setting the filter level, with a small preview of its' effect.

The data for the multiple undo and redo features is stored in Stacks.

Image files can be loaded and saved in the various ImageFormats provided by .NET.

Here are a couple of screenshots:

And here is the code for the Image form:

Monday, October 5, 2009

VBScript Editor [C#]

Hi there. I wrote a simple VBScript Editor in C#, here is a summary of it:

It is a Multiple-Document Interface application, the main menu is merged with a non-visible MenuStrip on the Document form.

Syntax coloring and letter casing is done live, based on the lines affected by the change in the text. The keywords for each color are stored in a regular expression.

Line numbers and column ruler are achieved by RichTextBoxes moved on separate panels. Line and column markers are updated according to the caret's position.

The data for the multiple undo and redo features is stored in Stacks.

Printing is available using the RichTextBoxPrintCtrl from Microsoft.

The tool windows, 'Find\Replace' and 'Jump to line' are always owned by the current active Document.

Here is the code for the Document form:

Wednesday, September 16, 2009

Auto Links Rename [InDesign JavaScript]

Here's my recipe for links renaming in Adobe InDesign.
The following script will rename all linked images in the defined page-sequence, with a padded page number and the user entered prefix. For pages featuring more than one image a letter counter is added, seperated by an underscore.

Page numbers are padded according to the total number of pages in the document. The prefix is checked not to contain any digits or space characters. If the letter counter passes the letter 'z' it resolves to continue with numbers.

The script was written for version CS4, but I assume it should also work on CS3.

Wednesday, July 22, 2009

Search and Log using SQL

Good evening. The following is an SQL-based version of the Search and Log script.

Here the search is done with the '.Global' parameter turned to false, and so the SQL also takes care of finding the number of instances per file. The logging starts after the search is done, and non-matching folders aren't listed.

SQL usage details: The script creates a temporary table called 'search_log'. My default database is the Northwind sample database, and the connection string is suited to windows authentication mode.

Saturday, July 18, 2009

Search and Log [VBScript]

Greetings. I wrote a script that Searches for a string in file names and Logs the results in a text file. It has the following neat features:

* Search results refer also to the number of instances the searched string appears in the file name.

* While the process is running, search data is written to a ~.tmp file, and on successful completion the file is renamed to .log.
File names summarize the target of the search, and cannot be overridden.

* If the selected folder for search contains subfolders, the user is prompted to include them in the search. By calling the search sub procedure from itself, the search drills down into deepest subfolders.

* For searches that include subfolders, a short summary of the search results is featured in the end of the log file, including a list of the file types for the matching files, in descending order.

Saturday, July 4, 2009

Convert Footnotes to Regular Text [Word VBScript]

The next script for Word converts all footnotes and their references to regular text. The footnotes are inserted at the end of the document.

Find, Replace and Comment [Word VBScript]

Hi there. I wrote a Find and Replace script for Word, which also adds a Comment for each replacement. Note: It works only on the 'body' of the text, since comments are not available on footnotes / endnotes.