WP8.1 Development Tutorial Two: Mapcontrol View control and animation animation instance application

Source: Internet
Author: User
WP8.1 Development Tutorial 2:mapcontrol Application


Mapcontrol corresponds to the Data view in ArcMap, which encapsulates the map object and provides additional properties, methods, and events for:

Manage the appearance, display properties, and map properties of the control;
Add and manage the data layer in the control;
Load the map document (. mxd) into the control
Drag and drop data from other applications into the control;
Tracking shapes and drawing to the display

Each control in ArcGIS has properties that can be set and can be edited in a visual environment. After you drag and drop controls onto a form, users can right-click and choose the Properties menu to edit these properties, allowing users to quickly build a GIS application without writing a single line of code.


The overall interface layout is as follows:



Its XAML code is as follows:

The code is as follows Copy Code
<Grid>
<Grid.RowDefinitions>
<rowdefinition height= "450"/>
<rowdefinition height= "*"/>
</Grid.RowDefinitions>

<maps:mapcontrol grid.row= "0" name= "Mymap"/>

<stackpanel grid.row= "1" >
<textblock name= "Slidertextblock" horizontalalignment= "Center" style= "{Themeresource Controlheadertextblockstyle} "/>
<slider name= "Mapslider" valuechanged= "mapslider_valuechanged" maximum= "" minimum= "0"/>
<stackpanel orientation= "Horizontal" >
<button name= "Getpositionbutton" content= "Get" click= "Getpositionbutton_click"/>
<button name= "Setpositonbutton" content= "Set" click= "Setpositonbutton_click"/>
</StackPanel>
<textblock name= "Showmaptextblock"/>

</StackPanel>
</Grid>

The corresponding main C # code is as follows:

The code is as follows Copy Code
Protected async override void Onnavigatedto (NavigationEventArgs e)
{
var locator = new Geolocator ()//open position
Locator. Desiredaccuracyinmeters = 50;//Set Location service accuracy of 50 meters

var position = await locator. Getgeopositionasync (); Get the current position
Await Mymap.trysetviewasync (position. coordinate.point,18d)//Mapcontrol control displays the current position (point is latitude and longitude; 18D is the current precision)
Mapslider.value = Mymap.zoomlevel;

}

private void Getpositionbutton_click (object sender, RoutedEventArgs e)
{
Showmaptextblock.text = string. Format ("{0},{1}", MyMap.Center.Position.Longitude, MyMap.Center.Position.Latitude);
}

Private async void Setpositonbutton_click (object sender, RoutedEventArgs e)
{
var setposition = new Windows.Devices.Geolocation.BasicGeoposition ();
SetPosition. latitude=47;
SetPosition. longitude=-122;
var mypoint=new Windows.Devices.Geolocation.Geopoint (setposition);
if (await Mymap.trysetviewasync (MyPoint, 18D))
{
//
}
}


private void Mapslider_valuechanged (object sender, Rangebasevaluechangedeventargs e)
{
if (mymap!=null)
{
Mymap.zoomlevel = E.newvalue;
Double TT;
tt = E.NEWVALUE/18 * 100;
Slidertextblock.text = string. Format ("{0}%", (int) TT);
}
}
}


Also note that the position function is opened in the package file, and the corresponding steps are as follows:

Application of animation in WP8.1 study3:wp8.1

WP8.1 on the Animation animation API and win8/win8.1 on the similar, online can find a lot of information, and can go to MSDN to see the official documents.

The following is my reference to some information, write out examples, hope to be useful in the future.

The XAML code is as follows:

The code is as follows Copy Code
<Grid>
<StackPanel>
<StackPanel.Resources>
<!--doubleanimation-->
<storyboard x:name= "ShowAnimation" >
<doubleanimation storyboard.targetname= "Animatedimage"
Storyboard.targetproperty= "Opacity"
from= "0"
to= "1"
duration= "0:0:2"/>
</Storyboard>
<storyboard x:name= "Hideanimation" >
<doubleanimation storyboard.targetname= "Animatedimage"
Storyboard.targetproperty= "Opacity"
from= "1"
to= "0"
duration= "0:0:2"/>
</Storyboard>
<!--fadetheanimation-->
<storyboard x:name= "Fadeinanimation" >
<fadeinthemeanimation storyboard.targetname= "Animatedrectangle"
Fillbehavior= "Holdend"
Speedratio= "8"
duration= "0:0:4"/>
</Storyboard>
<storyboard x:name= "Fadeoutanimation" >
<fadeoutthemeanimation storyboard.targetname= "Animatedrectangle"
Speedratio= "0.1"
duration= "0:0:4"/>
</Storyboard>
<!--coloranimation-->
<storyboard x:name= "ColorAnimation" >
<coloranimation storyboard.targetname= "Animatedellipse"
Storyboard.targetproperty= "(Ellipse.fill). (Solidcolorbrush.color) "
From= "Red"
To= "Blue."
duration= "0:0:2"/>
</Storyboard>
<!--
Pointerdownthemeanimation-Animation of the mouse (finger) when pressed on the control
-->
<storyboard x:name= "Storyboardpointerdown" >
<pointerdownthemeanimation storyboard.targetname= "Border"/>
</Storyboard>

<!--
Pointerupthemeanimation-Animation of the mouse (finger) when it is raised on the control
-->
<storyboard x:name= "Storyboardpointerup" >
<pointerupthemeanimation storyboard.targetname= "Border"/>
</Storyboard>

</StackPanel.Resources>

<!--control-->
<button name= "Show" content= "Show" width= "" height= "click=" Show_click
<button name= "Hide" content= "Hide" width= "" "height=" click= "Hide_click"/>
<image name= "Animatedimage"
Source= "Blue.png"
opacity= "0"
Width= "100"
height= "100"
imageopened= "animatedimage_imageopened"/>
<rectangle name= "Animatedrectangle" fill= "Rosybrown" width= "a" height= "
<ellipse name= "Animatedellipse" fill= "Red" width= "a" height= "
<border name= "Border" borderthickness= "5" borderbrush= "Red" background= "Blue" cornerradius= "ten" width= "the" Height = "Horizontalalignment=" "Left" >
<Border.Child>
<textblock text= "I am the content of Border" fontsize= "24.667" textalignment= "center" verticalalignment= "center"/>
</Border.Child>
</Border>
</StackPanel>

</Grid>



The main C # code for the current page is as follows:

The code is as follows Copy Code
private void Show_click (object sender, RoutedEventArgs e)
{
Showanimation.begin ();
Fadeinanimation.begin ();
ColorAnimation. Begin ();
Storyboardpointerup.begin ();
}

private void Hide_click (object sender, RoutedEventArgs e)
{
Hideanimation.begin ();

Fadeoutanimation.begin ();
Storyboardpointerdown.begin ();
}

private void Animatedimage_imageopened (object sender, RoutedEventArgs e)
{

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.