Tuesday, November 30, 2010

Force .NET controls to refresh their content

Often when doing a given task in a loop c# program did not bother updating the content of controls until the loop ends. So for example when the program has to update the text of a button at the end of each iteration to give the user a feedback about the advance in the process, it will not be done. This of course has been done for good reason, namely forcing the control the refresh will degrades the performance of the process but in certain case the display of the updated text could anyway be desirable. So to force the refresh write the following line in your code:

label1.Text = "Processing 1 of 10 ...";
Application.DoEvents(); 

 The DoEvent() function allow the form to execute all task in the task list, without wait for the last task to finish.

Thursday, November 18, 2010

MS visual studio - debug / release options

I am really a big fan of visual studio, but today I helped a friend installing visual studio express edition on his computer and we find out that the release/debug option beside the play button was disabled...strange. So we google the question. Thus we find out that turning back on the release/debug option was quite cumbersome.
The response was find on stackoverflow (http://stackoverflow.com/questions/2812423/how-to-switch-between-debug-release-in-visual-c-2010-express)

And reported here for your convenience:
"
  1. Enable Tools -> Settings -> Expert Settings.
  2. Go to Tools -> Options. In the dialog box, check the Show All Settings option in the bottom left.
  3. In the above dialog, now choose Projects and Solutions -> General. Check the option Show advanced build configurations. Click Okay.

"

Tuesday, November 16, 2010

Friday, November 12, 2010

CodeVisionAVR's contra-intuitive pin commmand

For Atmel micro controller programming people often use CodeVisionAVR (http://www.hpinfotech.ro/html/cvavr.htm) which is a good IDE for the development. I recently started to use it myself and I end up spending several hour trying to catch a bug in my code that do not exists. The problem was the following:

CodeVision c language libraries offers you the useful command PINx.y command, per example PINC.1 mean pin 1 of IO port C. But one should know that PINx.y command is meant to be used as read or toggle function only.

read function:
int a = PINC.1 //will assigned the logical value of pin 1 on port C to the variable a

toggle function
//assuming pin 1 of port C is low
PINC.1=1; //  toggle to high
PINC.1=1; //  toggle back to low

To actually write to the output the logical value you really want you should use the PORTx.y command:

PORTC.1=1;   //pin 1 of port C is set to 1
PORTC.1=1;  //pin 1 of port C is set to 1
PORTC.1=0;  //pin 1 of port C is set to0

Tuesday, November 9, 2010

synchronization of outlook and gmail calendar

Since recently I am the proud owner of a brand new Galaxy S running under Android 2.1. One of the issue I encounter is how to synchronize my oulook calendar with my Gmail one. Fortunatly Google make a very usefull tool available making all the work for you:

http://www.google.com/support/calendar/bin/answer.py?answer=89955


Wednesday, October 27, 2010

Alternative pdf readers

Many Internet pages nowadays advise there users to get Adobe pdf Reader before downloading a given .pdf document. Although there are a few alternative solution to the Adobe Software:
ReadersWindows MacOSX Free Operating Systems [1]
BePDF- - Download
ePDFView- - Download
gv- - Download
MuPDFDownloadDownloadDownload
Sumatra PDFDownload- -
Xpdf- DownloadDownload
Zathura- - Download
source: http://www.pdfreaders.org

Wednesday, October 13, 2010

Validate all the controls of a form in one step in c#

What I was trying to achieve was the following: I created a dialog with some options being entered in textboxes. The textboxes values are validaded using there respective "validated" event. And the user validate the dialog in two possible way: 1 using the "OK" button or, 2 using the "enter" key shortcut.

When implementing the "Enter" key shortcut to validate the entire dialog and close it, the last textbox do not lost focus and therefor do not trigger is validate event, which is annoying.

The solution is to trigger the validate event for all form's children at once before closing the dialog, using the " this.ValidateChildren()" command. Then the "OK" button event is also artificially triggered:

 private void MyControl_KeyDown(object sender, KeyEventArgs e)
        {
            EventArgs eee = new EventArgs();
            switch (e.KeyCode)
            {
                case Keys.Enter: //opens the Options
                    this.ValidateChildren();
                    OkButton_Click(OkButton, eee);
                    break;
            }
        }

 P.S. Do not forgot to set the "KeyPreview" parameter of your form to "true"  :

Thursday, October 7, 2010

Word 2007 - Hidden Equation Editor Features

Interesting enough the, to my opinion, most useful feature of Word 2007 concerning the scientific text editing has been hidden or at least not shown in an obvious way to the user.

In fact it is possible when editing with the new equation editor (i.e. using .docx document type) to use keyboard short cut to type the equations. The way the equations should be entered is very similar as latex.

As an example:
  • Type ALT + = , to enter the equation editor (you can customize this shortcut)
  • Type A + / + B then hit spacebar , and you will get a fraction
  • Type A + ^ + B then hit spacebar , and you will get A to the power B
  • Type \Omega  then hit spacebar , and you will get the greek uppercase Omega letter
  • Type \omega  then hit spacebar , and you will get the greek lowercase omega letter
Here is some unofficial documentation from the Microsoft engineers:
http://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v2.pdf 

An other tutorial I found:
http://www.chem.mtu.edu/~tbco/cm416/EquationEditor_main.pdf


Hope this helps.

Pascal

Wednesday, October 6, 2010

MS Onenote -> Multilanguage proofing

Despite MS Onenote is an excellent tool for taking note on an on going work. There is a very annoying issue when the user desire to take notes in an other language as is computer system language defined by is keyboard! In MS Word you can change the global proofing language for the whole document in a permanent fashion, but in MS Onenote for an obscure reason this option do not exists. The user is supposed to select the text to be proofed in an other language, then go to tab "review", select "language" and finally "proofing tool".

 Of course this is a very fastidious way to proceed.

The proposed approach is to find a way around  the limitation of MS Onenote, using the regional options of the computer. For this purpose we will take an example:
Lets say the computer is set to "French" with a "Swiss French" keyboard, but the user user desires to take notes in English. Simply changing the computer option to English is annoying because the keyboard will then be "American" and the user usually do not want to change is hardware. So the approach is to set the system to get per example "English" and "Swiss French" keyboard:

First get to Control Panel:
 Then go to Clock, And Region

Then click on "Change display languages":


Then click on "Change keyboards..."


Then click the "Add" button:


Then for our example, you need to select "English" and open the "keyboard" menu with the "+" under the "English" tree node as shown on the image below:



Once the "keyboard" submenu is open select "show more":


As next Select the desired keyboard, in our example "Swiss French"



To make this configuration, the default configuration of your computer select it under "Default input language":





To switch from one configuration to the other in a quick fashion the user can use the quick access bar shortcuts:


This finalize my first technical notes, if you have comments and/or suggestion please let me know.