Using the SplitContainer in .NET

February 19th, 2008

A very useful control: The SplitContainer allows to define two or more areas in your form and to add sliders between these areas. Thus the user can change the areas’ size with simple click & drag.

This is exactly what I need for InstantHTML. Up to now the textarea and the browser control had a fixed size. However it would be useful sometimes to resize the textarea to show more source code.

It was really easy to implement. I simply added a SplitContainer to my application form. After that I used cut and paste to insert the textarea and the browser control in each of the two SplitContainer panels.

After pasting I had to adjust the SplitContainer’s size as well as the textarea and browser control. It was pretty easy to do by setting the anchor property of all three controls to “Top, Bottom, Left, Right”.

Read more:
- ViewHTMLNow: View HTML instantly in webBrowser Control
- ViewHTMLNow is now “InstantHTML” – and it needs IE 7
- Copy bitmap to clipboard
- C#: Do not show form in taskbar
- Abandoning foreconv

ViewHTMLNow is now “InstantHTML” – and it needs IE 7

February 19th, 2008

Some time ago I renamed my HTML viewer “ViewHTMLNow” to “InstantHTML”. I think it was because there already existed something called ViewHTMLNow.

I actually wanted to use my tool during a CSS training I held in January 2008. Since I did not know, which platform was installed on the training computers I downloaded .NET Framework an put it on an USB stick together with my tool.

The PCs had an old Windows XP running – no Framework. After installing it I wanted to start InstantHTML and begin teaching CSS. However: InstantHTML did not work. Seems as if it would have needed IE 7 too.

Next thin to do is implementing a check wheter IE 7 is installed on a system.

Read more:
- ViewHTMLNow: View HTML instantly in webBrowser Control
- Using the SplitContainer in .NET
- Copy bitmap to clipboard
- Moving a form fires ResizeEnd
- hst2ve next generation

Abandoning foreconv

February 19th, 2008

It has been a long time since my last posting in this blog. Now it is time to resume it.

I’ve just reinstalled Visual Studio .NET 2005 and now I’m trying to resume work on some of my projects.

First of all, I’ve decided to abandon foreconv, my popular converter for the Garmin Forerunner. The application allowed to display GPS data recorded with the Forerunner in Google Earth. With the latest release Garmin implemented that feature into their Training Center software. Thus my tool has no use anymore.

Never mind – I had a lot of fun programming foreconv. Now it is time to head to other projects.

Read more:
- Moving a form fires ResizeEnd
- hst2ve: Display data from Garmin Forerunner Virtual Earth
- hst2ve next generation
- ViewHTMLNow is now “InstantHTML” – and it needs IE 7
- Using the SplitContainer in .NET

hst2ve works with Garmin Edge too

August 7th, 2006

A user provided me with some code generated by Garmin’s Trainingcenter for the Garmin Edge 205. This is a cycling computer that tracks GPS data too.

I read these data with hst2ve and they display correctly. So feel encouraged to use hst2ve to display data from Garmin Edge computers in Microsoft Virtual Earth.

Any feedback is much appreciated.

Read more:
- It was Tim Huckaby…
- hst2ve: Display data from Garmin Forerunner Virtual Earth
- hst2ve next generation
- Copy bitmap to clipboard
- Moving a form fires ResizeEnd

hst2ve next generation

July 24th, 2006

Ok, this software is not old enough to be redesigned and to be called “Next Generation”. However I started to rewrite a part of hst2ve. The goal is to separate HTML/JScript data from the program.

With C# and .NET Framework 2.0 you can start JScript and other Scripts from within your application. All you need is the InvokeScript method provided by the HtmlDocument class.

I put all the HTML and JScript code into a separate file and added a method to populate an array with polygon data. That seems to work pretty fine.

Using the array I can start JScript routines to invoke the map and to plot the data.

I’ll post more about that in the next few days. Also I’ll release a new beta.

Read more:
- hst2ve: Display data from Garmin Forerunner Virtual Earth
- Moving a form fires ResizeEnd
- Copy bitmap to clipboard
- hst2ve works with Garmin Edge too
- It was Tim Huckaby…

Generate a newline in XSL

July 23rd, 2006

Working on my program foreconv I needed to know how to insert a newline in a XSL stylesheet. It is quite simple.

Just put a newline into -Tags like this:

The entity will generate the newline.

Read more:
- Abandoning foreconv

Copy bitmap to clipboard

July 9th, 2006

hst2ve has a feature to copy the complete map to the clipboard. Using C# in .NET 2.0 it was not very difficult to realize this.

To copy bitmap data to the clipboard, you’ll need to know:
- top left and top right coordinates of the bitmap area
- width and heighth of the bitmap area

With these data you simply set up da new bitmap with

bmpScreenshot = new Bitmap(screenshotSize.Width, screenshotSize.Height, PixelFormat.Format32bppArgb);

This is where you already need width and height of the area.

Using the bitmap you create a new Graphics object:

gfxScreenshot = Graphics.FromImage(bmpScreenshot);

The Graphics object provides a method CopyFromScreen. I like that method :-)

gfxScreenshot.CopyFromScreen(screenshotStartX, screenshotStartY, 0, 0, screenshotSize, CopyPixelOperation.SourceCopy);

This is where you need the x and y coordinates of the area’s top left corner. These coordinates are relative to the desktops top left corner. The method takes the pixel data from the screen and stores them in the bitmap object. From there you can copy the data to the clipboard:

Clipboard.SetImage(bmpScreenshot);

This is the complete code:

private void copyMapToClipboard()
{
Bitmap bmpScreenshot;
Graphics gfxScreenshot;
Size screenshotSize = new Size();
int screenshotStartX = hst2veForm.ActiveForm.Left + SystemInformation.BorderSize.Width + webBrowserMap.Location.X;
int screenshotStartY = hst2veForm.ActiveForm.Top + SystemInformation.CaptionHeight + webBrowserMap.Location.Y;
screenshotSize.Height = webBrowserMap.Height;
screenshotSize.Width = webBrowserMap.Width;
bmpScreenshot = new Bitmap(screenshotSize.Width, screenshotSize.Height, PixelFormat.Format32bppArgb);
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(screenshotStartX, screenshotStartY, 0, 0, screenshotSize, CopyPixelOperation.SourceCopy);
Clipboard.SetImage(bmpScreenshot);
}

Read more:
- Moving a form fires ResizeEnd
- hst2ve next generation
- hst2ve: Display data from Garmin Forerunner Virtual Earth
- Using the SplitContainer in .NET
- ViewHTMLNow: View HTML instantly in webBrowser Control

It was Tim Huckaby…

July 4th, 2006

Tim Huckaby inspired me to write hst2ve. He seems to be a fan of foreconv and mentioned my tool in .NET Rocks.

Tim is a Microsoft evangelist and Regional Director for Southern California. And he is like me a runner and mountain biker who loves his Forerunner. He asked me to do something like foreconv for VE.

Since VE is not an application like Google Earth it was a bit more complicated to convert data. All geodata have to be written into a Javascript function. This function plots the data to a VE map.

The new webBrowser control in .NET 2.0 is a big help. It allows me to display the data and to control the output.

Read more:
- hst2ve next generation
- hst2ve: Display data from Garmin Forerunner Virtual Earth
- hst2ve works with Garmin Edge too
- Moving a form fires ResizeEnd
- Copy bitmap to clipboard

hst2ve: Display data from Garmin Forerunner Virtual Earth

July 4th, 2006

Ever wanted to display your data from Garmin Forerunner 201/301/205/305 in Microsoft Virtual Earth?

There you go: hst2ve opens your Garmin history file and lets you choose any of your runs. Right after selecting a run a browser control will connect to Microsoft’s Virtual Earth server and load map data.

A run plotted to Microsoft Virtual Earth

A right click onto one of the entries will reveal more data about your run, for example, length, duration, altimeters and so on.

Display run details from Garmin Forerunner

This is a preview version and it still is beta. Please drop me a mail, if you find a bug or if you like to see more features.

Download hst2ve Preview

Read more:
- hst2ve next generation
- Copy bitmap to clipboard
- Moving a form fires ResizeEnd
- It was Tim Huckaby…
- hst2ve works with Garmin Edge too

ViewHTMLNow: View HTML instantly in webBrowser Control

July 4th, 2006

This is a little tool I wrote while programming hst2ve. Simply enter some text in the left textbox and it will instantly be displayed in the webbrowser window on the right.

This software is great for educational purposes or for demos: You instantly see the results while typing in HTML tags.

ViewHTMLNow Screenshot

The core of this program is one simple event handler:

private void textBox1_TextChanged(object sender, EventArgs e)
{
webBrowser1.DocumentText = textBox1.Text;
}

Everytime you type something into the textbox the event will update the webBrowser control.

I added functionality to load and save files and to select the source code. Also I added the basic structure of a HTML file. Simply type in your HTML code and see what happens. You can also add CSS and Javascript.

Download ViewHTMLNow

This tool requires .NET-Framework 2.0

Read more:
- Using the SplitContainer in .NET
- ViewHTMLNow is now “InstantHTML” – and it needs IE 7
- Moving a form fires ResizeEnd
- hst2ve: Display data from Garmin Forerunner Virtual Earth
- Abandoning foreconv