在将位置存储到sqlite数据库时创建地理围栏

时间:2015-12-26 05:14:18

标签: c# sqlite windows-phone-8 windows-phone-8.1 geofencing

我正在开发Windows移动应用程序。我想在将位置存储到sqlite数据库时创建地理围栏以在进入地理围栏时生成SMS警报。我正在通过地图将位置加载到文本框中。

这是到目前为止的代码

private void Load_Location(object sender, RoutedEventArgs e)
{
    LattxtBx.Text = String.Format("{0}", AddLocation.Center.Position.Latitude);
    LongtxtBx.Text = String.Format("{0}", AddLocation.Center.Position.Longitude);
}

private async void AddContact_Click(object sender, RoutedEventArgs e)
{
    DatabaseHelperClass Db_Helper = new DatabaseHelperClass();//Creating object for DatabaseHelperClass.cs from ViewModel/DatabaseHelperClass.cs 
    if (NametxtBx.Text != "" & AgetxtBx.Text != "" & AddresstxtBx.Text != "" & SchooltxtBx.Text != "" & GardienttxtBx.Text != "" & PhonetxtBx.Text != "" & LattxtBx.Text != "" & LongtxtBx.Text != "")
    {
        Db_Helper.Insert(new Contacts(NametxtBx.Text, AgetxtBx.Text, AddresstxtBx.Text, SchooltxtBx.Text, GardienttxtBx.Text, PhonetxtBx.Text, LattxtBx.Text, LongtxtBx.Text));
        Frame.Navigate(typeof(ReadContactList));//after add contact redirect to contact listbox page 
    }
    else
    {
        MessageDialog messageDialog = new MessageDialog("Please fill all fields");//Text should not be empty 
        await messageDialog.ShowAsync();
    }
}

1 个答案:

答案 0 :(得分:0)

Jan编写了一个算法来检查纬度/长度是否在栅栏内(纬度/长度列表)参见{{3}}