메뉴 건너뛰기

app

[WP7] 앱 설정 tip 2가지와 현재 위치 가져오기

suritam92013.03.03 08:34조회 수 2070댓글 0

    • 글자 크기

1. 시스템 트레이 가리기로 풀 스크린 모드 사용


MainPage.xaml 에 


shell:SystemTray.IsVisible="False"


위의 부분을 설정해 준다.


기본적으로 True로 되어 있어서 배터리나 안테나 정보를 보여주는데 필요 없을 경우는 가려준다.


2. 기본 출력을 가로 모드로 하기


SupportedOrientations="Landscape" Orientation="Landscape"




현재 위치를 가져와 지도에 설정하는 방법은 아래와 같다.

using System.Device.Location;


        public MainPage()

        {


            InitializeComponent();

             // GPS init

                watcher = new GeoCoordinateWatcher();

                watcher.MovementThreshold = 20;

                watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);

                watcher.Start();

.......................

}


         void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)

            {

                //throw new NotImplementedException();

                // non-UI thread 에서 실행되므로 UI thread 와의 연동을 위해 Dispatcher를 사용

                Deployment.Current.Dispatcher.BeginInvoke(() => MyPositionChanged(e));

            }

     

            void MyPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)

            {

                // throw new NotImplementedException();

                Double a = e.Position.Location.Latitude;

                Double b = e.Position.Location.Longitude;


                GeoCoordinate mapCenter = new GeoCoordinate(a, b);

                bloodMap.SetView(mapCenter, 13);

                //MessageBox.Show("My lat long is:"+a+", "+b);

                watcher.Stop(); // for battery issue

            }

suritam9 (비회원)
    • 글자 크기

댓글 달기

suritam9
2013.08.23 조회 7110
suritam9
2013.08.23 조회 1661
suritam9
2013.06.28 조회 2166
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로