<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Virtual Earth 3D team blog : Windows Forms</title><link>http://blogs.msdn.com/virtualearth3d/archive/tags/Windows+Forms/default.aspx</link><description>Tags: Windows Forms</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Information Pop-ups in WinForms</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/11/24/information-pop-ups-in-winforms.aspx</link><pubDate>Tue, 25 Nov 2008 00:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9139174</guid><dc:creator>NikolaiF</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9139174.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9139174</wfw:commentRss><description>&lt;P&gt;We've had several questions about how to do a pop-up form in WinForms, similar to the one on the website.&amp;nbsp; The website pop-up is implemented entirely within the browser, using an IFrame.&amp;nbsp; Therefore, the functionality does not exist by default in the managed code alone.&amp;nbsp; However, the events you need are provided, and creating your own pop-up is not difficult.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Html rendered pop-up" style="WIDTH: 603px; HEIGHT: 510px" height=510 alt="Html rendered pop-up" src="http://www.veteam.members.winisp.net/Spaceland/blog/html.jpg" width=603 mce_src="http://www.veteam.members.winisp.net/Spaceland/blog/html.jpg"&gt;&lt;/P&gt;
&lt;P&gt;The event you need is EngineEvents.OnHover, accessed via the CommunicationManager.&amp;nbsp; It will fire when the mouse hovers over any GeometryManager object that has hit detection on.&amp;nbsp; The event arguments (CommunicationParameters) tell you which item was hovered and where on the screen it is.&amp;nbsp; I used the Tag property on WorldGeometry to hold the name and description I wish to display, so when I get the hover event I retrieve the item back again and pass the tag to my Popup form.&lt;/P&gt;
&lt;P&gt;The next step is to render the form.&amp;nbsp; There are two behaviors we want:&amp;nbsp; first, the auto-closing.&amp;nbsp; This was pretty simple to do using a Timer.&amp;nbsp; When you get an OnHoverEnd (another EngineEvent), start a timer.&amp;nbsp; If the mouse moves into the popup, stop the timer.&amp;nbsp; When the mouse leaves it, start the timer again.&amp;nbsp; The second behavior is rendering HTML.&amp;nbsp; This was trivial on the website, but a little tricker in winforms.&amp;nbsp; Fortunately Windows ships with mshtml, which has a ready-made browser window.&amp;nbsp; I based my work on &lt;A class="" href="http://blog.monstuff.com/archives/000052.html" target=_blank mce_href="http://blog.monstuff.com/archives/000052.html"&gt;this&lt;/A&gt;, and had it working in just a few minutes.&lt;/P&gt;
&lt;P&gt;I'm certain all of this could be done more attractively and elegantly, but it should get you started.&amp;nbsp; I updated the main samples package to have the new HtmlForm project.&amp;nbsp; Just grab the zip file again and pull out that project directory.&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx"&gt;Get the code!&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;P.S.&amp;nbsp; If you want to open an ERO from a plug-in without having to go through the JS API first, do this:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;CommunicationParameterSet set = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; CommunicationParameterSet(8);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"layerId"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"pushpinId"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"rX1"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, p.X);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"rY1"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, p.Y);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"rX2"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, p.X);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"rY2"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, p.Y);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"header"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, name);&lt;BR&gt;set.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"content"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, desc == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ? &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Empty : desc);&lt;BR&gt;Host.CommunicationManager.FireEvent(EngineEvents.Group, EngineEvents.OnHover, set);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;p is the location on the screen you want it, name is the title, and desc is your html content.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9139174" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/VE3D/default.aspx">VE3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Windows+Forms/default.aspx">Windows Forms</category></item><item><title>Creating the most basic Windows Form</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/04/19/creating-the-most-basic-windows-form.aspx</link><pubDate>Sat, 19 Apr 2008 22:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8410366</guid><dc:creator>Heptazane</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/8410366.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=8410366</wfw:commentRss><description>&lt;P&gt;Note:&amp;nbsp;&amp;nbsp;this entry references code for an older version of VE3D.&amp;nbsp; The newest code samples are &lt;A class="" href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The samples that can be downloaded below demonstrate creating a basic Windows&amp;nbsp;Application&amp;nbsp;with&amp;nbsp;a VE3D control on it (SimpleForm), however, I&amp;nbsp;wanted to go over the most basic steps.&amp;nbsp; The sample does not use&amp;nbsp;the&amp;nbsp;Toolbox,&amp;nbsp;but I will.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; Make sure the VE3D control is installed by visiting &lt;A href="http://maps.live.com/" mce_href="http://maps.live.com/"&gt;http://maps.live.com&lt;/A&gt; and switching to 3D.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; Select Tools-&amp;gt;Choose Toolbox Items...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 3:&lt;/STRONG&gt; Make sure GlobeControl is checked in .NET Framework Components tab.&amp;nbsp; The version should be 2.0.711.13001.&amp;nbsp; GlobeControl should now show up in your Toolbox under the General section with a gear icon next to it.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Choose Toobox Items dialog" style="WIDTH: 573px; HEIGHT: 405px" height=405 alt="Choose Toobox Items dialog" src="http://veteam.members.winisp.net/Images/ToolboxItems.png" width=573 align=middle mce_src="http://veteam.members.winisp.net/Images/ToolboxItems.png"&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 4:&lt;/STRONG&gt; Create a new C# Windows Application in Visual Studio 2005.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 5:&lt;/STRONG&gt; Select GlobeControl from your Toolbox and drop it onto your form.&amp;nbsp; It should show up with just a big, grey dot in the middle and "GlobeControl" written across it.&amp;nbsp; This is just the designer view.&amp;nbsp; If you run the application at this point, you'll see the globe in 3D, but only with the outer most model and if you zoom in you'll just get fuzzy green.&amp;nbsp; The reason is that we haven't set up any data sources yet, so...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 6:&lt;/STRONG&gt; Make sure your form is selected (not the GlobeControl) and add a Load event (select the lightening bolt for events in the Properties pane, find Load and double click on it).&amp;nbsp; Make sure it looks like this:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Form1_Load(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;object&lt;/FONT&gt;&lt;FONT size=2&gt; sender, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;EventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;&lt;FONT size=2&gt;.globeControl1.Host.DataSources.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataSourceLayerData&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Elevation"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Elevation"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;@"http://maps.live.com//Manifests/HD.xml"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataSourceUsage&lt;/FONT&gt;&lt;FONT size=2&gt;.ElevationMap));&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;&lt;FONT size=2&gt;.globeControl1.Host.DataSources.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataSourceLayerData&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Texture"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Texture"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;@"http://maps.live.com//Manifests/HT.xml"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataSourceUsage&lt;/FONT&gt;&lt;FONT size=2&gt;.TextureMap));&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;&lt;FONT size=2&gt;.globeControl1.Host.DataSources.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataSourceLayerData&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Models"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Models"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;@"http://maps.live.com//Manifests/MO.xml"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataSourceUsage&lt;/FONT&gt;&lt;FONT size=2&gt;.Model));&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;STRONG&gt;Step 7:&lt;/STRONG&gt; To use the DataSource classes, you'll need to right-click on your project's references and select Add Reference..., select the Browse tab and browse to "C:\Program Files\Virtual Earth 3D".&amp;nbsp; Select "Microsoft.MapPoint.Data" and "Microsoft.MapPoint.Rendering3D.Utility" and hit OK.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 8:&lt;/STRONG&gt; Run your application and enjoy! &lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;FONT color=#800080&gt;&lt;IMG style="WIDTH: 450px; HEIGHT: 306px" height=306 src="http://veteam.members.winisp.net/Images/FinalApp.png" width=450 align=middle mce_src="http://veteam.members.winisp.net/Images/FinalApp.png"&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Definitely look at the samples for more goodness, but these are the basic steps to get started.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8410366" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Virtual+Earth+3D/default.aspx">Virtual Earth 3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Windows+Forms/default.aspx">Windows Forms</category></item></channel></rss>