示例#1
0
        private async void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
        {
            if (addFavePressed == false)
            {
                addFavePressed = true;
                OCDirection direction = OCDirection.newOCDirection(int.Parse(routeNumber.Text), routeName.Text, "", "", 0);

                direction.FromStopNumber  = stopID;
                direction.FromStopName    = fromStopName;
                direction.DirectionalName = "TO " + this.direction.ToUpper();
                int result = await OCTranspoStopsData.addFavouriteStop(direction);

                if (result > 0)
                {
                    MessageBox.Show("Your favourite stop was succesfully added.");
                    ApplicationBarIconButton button = (ApplicationBarIconButton)sender;
                    button.IsEnabled = false;
                    favourite        = true;
                }
                else
                {
                    MessageBox.Show("There was an error adding your favourite stop, please try again.");
                    addFavePressed = favourite = false;
                }
            }
        }
示例#2
0
        public static async Task <int> deleteFavourite(OCDirection direction)
        {
            String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
            String Query  = "DELETE from OCDirection WHERE routeNo=" + direction.RouteNo + " AND FromStopNumber=" + direction.FromStopNumber + ";";
            int    result = await conn.DeleteAsync(direction);

            return(result);
        }
示例#3
0
 public static OCDirection newOCDirection(int routeNo, String routeLabel, String direction, String procTime, int Id)
 {
     OCDirection dir = new OCDirection();
     dir.RouteNo = routeNo;
     dir.RouteLabel = routeLabel;
     dir.Direction = direction;
     dir.ProcTime = procTime;
     dir.Id = Id;
     return dir;
 }
示例#4
0
    public static OCDirection newOCDirection(int routeNo, String routeLabel, String direction, String procTime, int Id)
    {
        OCDirection dir = new OCDirection();

        dir.RouteNo    = routeNo;
        dir.RouteLabel = routeLabel;
        dir.Direction  = direction;
        dir.ProcTime   = procTime;
        dir.Id         = Id;
        return(dir);
    }
        // Favourites

        public static async Task<int> addFavouriteStop(OCDirection direction)
        {
            int result = 0;
            String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
            await conn.InsertAsync(direction).ContinueWith((t) =>
           {
               result = t.Result;
           });
            return result;
        }
示例#6
0
        // Favourites

        public static async Task <int> addFavouriteStop(OCDirection direction)
        {
            int    result = 0;
            String path   = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
            await conn.InsertAsync(direction).ContinueWith((t) =>
            {
                result = t.Result;
            });

            return(result);
        }
示例#7
0
        private async void deleteFavourite_Click(object sender, RoutedEventArgs e)
        {
            var         menItem = (MenuItem)sender;
            OCDirection dir     = (OCDirection)menItem.DataContext;
            int         result  = await OCTranspoStopsData.deleteFavourite(dir);

            if (result > 0)
            {
                favourites.Remove(dir);
            }
            else
            {
                MessageBox.Show("There was an issue deleting your favourite.");
            }
        }
示例#8
0
        //Routes List Methods***********************************************************************************************************************************************************//

        private void routesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedItem = ((LongListSelector)sender).SelectedItem;

            if (selectedItem is OCDirection)
            {
                OCDirection stop = (OCDirection)selectedItem;
                Navigation.NavigateToStopRoute(stop.RouteNo.ToString(), stop.RouteLabel);
            }
            else if (selectedItem is OCStop)
            {
                OCStop stop = (OCStop)selectedItem;
                Navigation.NavigateToStopRoute(stop.stop_code.ToString(), stop.stop_name);
            }
            ((LongListSelector)sender).SelectedItem = null;
        }
示例#9
0
    private static List <OCDirection> makeDirection(XElement routeDir)
    {
        List <OCDirection> dirs = new List <OCDirection>();
        int      routeNo;
        String   routeLabel, direction, procTime;
        XElement trips;

        foreach (XElement dir in routeDir.Elements())
        {
            routeNo    = int.Parse(dir.Element("RouteNo").Value);
            routeLabel = dir.Element("RouteLabel").Value;
            direction  = dir.Element("Direction").Value;
            procTime   = dir.Element("RequestProcessingTime").Value;
            trips      = dir.Element("Trips");
            dirs.Add(OCDirection.newOCDirection(routeNo, routeLabel, direction, procTime, 0));
        }

        return(dirs);
    }
示例#10
0
        private async void refreshFavourites()
        {
            if (refreshingFavs == false)
            {
                refreshingFavs = true;
                favourites     = await OCTranspoStopsData.getFavourites();

                this.routesList.ItemsSource = routes;
                foreach (OCDirection stop in favourites)
                {
                    OCDirection stop2 = await stop.fetchTimes(stop.FromStopNumber.ToString());

                    stop.fourArrivalTimes = stop2.fourArrivalTimes;
                    stop.nextTimes        = stop2.nextTimes;
                }
                this.favouritesList.ItemsSource = favourites;
                setFavouriteErrorMessage(false, favourites.Count > 0);
                refreshingFavs = false;
            }
        }
示例#11
0
        private async void addFavourite_Click(object sender, RoutedEventArgs e)
        {
            var         menItem   = (MenuItem)sender;
            OCApiRoute  apiRoute  = (OCApiRoute)menItem.DataContext;
            OCDirection direction = OCDirection.newOCDirection(apiRoute.RouteNumber, apiRoute.RouteHeading, apiRoute.Direction, "", 0);

            direction.FromStopName    = stopName.Text;
            direction.FromStopNumber  = int.Parse(stopID.Text);
            direction.DirectionalName = "TO " + apiRoute.RouteHeading.ToUpper();
            int result = await OCTranspoStopsData.addFavouriteStop(direction);

            if (result > 0)
            {
                MessageBox.Show("Your favourite stop was succesfully added.");
            }
            else
            {
                MessageBox.Show("There was an error adding your favourite stop, please try again.");
            }
        }
 public static async Task<int> deleteFavourite(OCDirection direction)
 {
     String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
     SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
     String Query = "DELETE from OCDirection WHERE routeNo=" + direction.RouteNo + " AND FromStopNumber=" + direction.FromStopNumber + ";";
     int result = await conn.DeleteAsync(direction);
     return result;
 }