Pages

Saturday, October 25, 2008

how to trap "delete" key event in C#

"delete" key is a special, it has different function from other key. That's why we can't use ordinary key down / key press event. For example, I have richTextBox called "rtbInput", pictureBox called "picLine" and I want to update line number whenever user delete some text. This is my code to do that :

private void rtbInput_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
            if(e.KeyCode == Keys.Delete )                 
                LineNumber.DrawLineNumber(picLine.CreateGraphics(), rtbInput, picLine); 
    //this is my function to draw line number
}
note that function named "rtbInput_PreviewKeyDown" means I attached this handler to previewKeyDown event of the richTextBox.

Wednesday, October 15, 2008

manually create table of figures

You may want to include table of figures or table of tables but you cannot do automatically. This steps will show how to add table of figures (TOF for short).
  1. block the caption of your picture, on "insert" tab, click "bookmark". A bookmark dialog will shows up.
  2. add the bookmark name. Make sure to insert the name that represent the picture. Example : name "pic2_1" for picture 2.1, "pic2_11" for picture 2.11, "pic2_1_1" for picture 2.1.1
  3. click "add". this will insert your bookmark to the bookmark table ( until now, I can't find the way view that table). If you found "add" disabled, it means you insert wrong character for bookmark name
  4. set your tabs. right-click on your documents and select "paragraphs....", click "tabs". The "tabs" dialog will shown.
  5. add your tab stop. Insert position, set the alignment and leader, click set. Do this for each tab-stops. for example mine use 2,75 cm, left, leader : 1, and 15,5 cm, right, leader : 2. second tab is used for entering "......" between name and page number and to ensure the page number are "right aligned".
  6. you can insert page number for your table entry by clicking "cross-reference" at "insert" tab. This will show reference dialog. select "reference type" as bookmark and "insert reference to" as page number (you want to insert page number). Select bookmark and click insert. note that you must insert page number at the page where the bookmark located. if you're not, the number will not shown up.
  7. don't edit the page number manually because it will updated before printing and makes your editing useless.
  8. you can update manually by right-clicking near page number and select "update field".
This is my TOF entry for example, look for tab stops :




easy creating table of contents

If you writing a experiment report or something,
maybe you want to include table of contents (or TOC for short) for you report. I'l show you how..... First thing first, after everything is set, you must insert page number, don't forget that. This is my example. After do that, follow all steps below :
  1. block the word you want to use as entry word on TOC. Like below....
  2. on "references" tab, click "Add text"
  3. select the level you want. For example, in picture above, I'm using "chapter I" as level 1 in table of contents, "1.Subchapter" as level 2, "a. subchapter" as level 3.
  4. If you found the word you've selected changed. You can change manually. Or, you can modify "Heading 1 default" right-click on "heading1" at "home" tab. This is the default format for level 1 heading (you can change later after adding TOC).
  5. after you have entered all entry word, try to view your document map.
  6. If you see unwanted entry on your document map, just click on your map to jump on tha entry. Block that word, on "references" tab, click "Add text". You will found that corresponding level is cheked. Simple check "do not show in table of content". This will remove from entry. just check on your document map.
  7. If all set, jump to page you want the TOC to be inserted. On "references" tab, click "table of contents" and select "automatic table".
  8. After you've edit some pages, you may want to update your TOC. you can do this by clicking "update", it usually located at the top of your TOC.
  9. you can change the format of your table entry, but do this after you've update your entire table.
  10. You can change heading for your TOC by clicking "table of contents" on "references" tab and selecting "insert table of contents". this will show "TOC" dialog. Click "modify" button. Select the level you want, click "modify". On "style based on" you can select from heading if you've change the default heading or just simply edit the format.
thats all. Now you have a TOC.

how to insert page number with different format?

sometimes you want to insert different page number format, for example on several pages with format : i, ii, iii, and several pages with number like: 1,2,3. You can do that by following steps below :
  1. put your cursor at the end of page.
  2. select "page layout" tab, click "breaks", select "next page".
  3. on next page, double click header (and footer).
  4. unmark "link to previous". this make your header (and footer) not same as previous page.
  5. thus, changing page number in this page doesn't change page number in previous page .

Friday, September 05, 2008

How to create custom animation brush in the gimp

This time, I want to show how to create simple custom animation brush in the GIMP.
  1. Create new canvas, mine is 133x80 px. If you want the brush have independent color. Create canvas with RGB mode, fill with transparency. If you want the color of the brush depend from the brush dialog, use Grayscale mode, fill with white (not foreground or background).


  2. Create your image, maybe you want to create to another layer so you can edit later. Or, open example image as new layer. This image originally from deviant art, a photoshop brush. Then I convert into .png with some converter.
  3. Merge down this image's layer (right click - merge down).
  4. Create new layer. Like first layer, fill with transparency if you want color-independent brush. Or fill with white for color-dependent.

  5. Like step 3, merge down this last layer.

  6. The result is layer with image with white background.
  7. Repeat step 4 and 5 until all your image is inserted.
  8. Save as GIMP animation brush (.gih). Of course you can save as .xcf for later editing. This image right is just example (my work). Because mine has 7 image total (7 layer). I'm using ranks = 7 so that all 7 images will show when brush is used. Random means the images will show randomly as you move the brush.
  9. Is done! Just copy your new created brush to Brush folder and it's ready.
  10. Time to test your new brush. Click refresh in brush's dialog and your new brush will shows up.

This is my brush.

How to create custom static brush in the gimp

I'll show you how to create custom static brush for use with the GIMP.
  1. Create new canvas, mine use 375x50 px. If you want a brush that have own color, use RGB mode and fill the canvas with transparency. If you want a brush that have color depend from brush dialog, use grayscale mode and fill the canvas with white (not foreground or background) like image below

  2. Create your image, maybe you want to create to another layer so you can edit later. Or, open example image as new layer. This image originally from deviant art, a photoshop brush. Then I convert into .png with some converter.

  3. Save this image as GIMP brush (.gbr). When the dialog shows up, select flatten image and press export.
  4. Voila! and you're done. Just copy your new brush to brush folder and click refresh brush dialog.
  5. Your new brush will shown. It's time to test your new brush.

This is my resulting brush.