Esempio n. 1
0
        private void buttonSearchStation_Click(object sender, RoutedEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }
            Mouse.OverrideCursor = Cursors.Wait;
            Stations foundStations = transport.GetStations(textBoxStartStation.Text);


            tabItemStationDisplayer.IsSelected = true;

            stackPanelStationDisplayer.Children.Clear();
            foreach (Station s in foundStations.StationList)
            {
                Button b = new Button();
                stackPanelStationDisplayer.Children.Add(b);
                b.Content = s.Name;
                Thickness margin = b.Margin;
                margin.Top    = 5;
                margin.Bottom = 5;
                margin.Left   = 20;
                margin.Right  = 20;
                b.Margin      = margin;
                b.Click      += buttonClickPutTextInStationField;
            }
            Mouse.OverrideCursor = null;
        }
Esempio n. 2
0
 private void updateTabControlls(bool atLeastOneFieldIs)
 {
     if (!InternetHelper.hasInternetConnection())
     {
         MessageBox.Show("Es ist keine Internetverbindung vorhanden");
         return;
     }
     if (atLeastOneFieldIs)
     {
         if (textBoxStartStation.isValidStation)
         {
             tabItemStationBoardButton.IsSelected = true;
             if (textBoxEndStation.isValidStation)
             {
                 tabItemSearchConnectionButton.IsSelected = true;
             }
         }
     }
     else
     {
         tabItemSearchStationButton.IsSelected = true;
         if (!textBoxStartStation.isValidStation)
         {
             tabItemStationNearbyButton.IsSelected = true;
         }
     }
 }
        private void textBoxInput_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                e.Handled = true;
                return;
            }

            if (containsIllegalChar(e.Text))
            {
                e.Handled = true;
                return;
            }
            isValidStation = false;
            string        newText         = textBoxInput.Text.Insert(textBoxInput.CaretIndex, e.Text);
            List <string> stillValidItems = new List <string>();

            if (_displayed != null && _displayed.Count > 0)
            {
                stillValidItems = getValidItems(_displayed, newText);
            }
            if (stillValidItems.Count >= 5 && notUpdatedFor < 3)
            {
                notUpdatedFor++;
                displayed = stillValidItems;
                return;
            }
            notUpdatedFor = 0;
            List <Station> foundStations = transport.GetStations(newText).StationList;

            lastQueryedStations = foundStations;
            List <string> newItems = new List <string>();

            foreach (string s in Favorit.FavoritHelper.Favorits)
            {
                if (s != null && s.Contains(newText))
                {
                    newItems.Add(s);
                }
            }
            foreach (Station s in foundStations)
            {
                if (!newItems.Contains(s.Name))
                {
                    newItems.Add(s.Name);
                }
            }
            displayed = newItems;
        }
        private void listBoxItemDisplay_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }
            var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem;

            if (item != null)
            {
                textBoxInput.Text = item.DataContext.ToString();
                textBoxInput_LostFocus(this, e);
            }
        }
        private void textBoxInput_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }

            switch (e.Key)
            {
            case Key.Up:
                if (0 <= listBoxItemDisplay.SelectedIndex - 1)
                {
                    listBoxItemDisplay.SelectedIndex -= 1;
                }
                break;

            case Key.Down:
                if (listBoxItemDisplay.Items.Count >= listBoxItemDisplay.SelectedIndex + 1)
                {
                    listBoxItemDisplay.SelectedIndex += 1;
                }
                break;

            case Key.Enter:
                if (listBoxItemDisplay.SelectedItem != null)
                {
                    textBoxInput.Text        = listBoxItemDisplay.SelectedItem.ToString();
                    currentlySelectedStation = lastQueryedStations.Find(x => x.Name.Equals(textBoxInput.Text)) ??
                                               transport.GetStations(textBoxInput.Text).StationList.Find(x => x.Name.Equals(textBoxInput.Text));// In Case a Favorit gets Selected
                    isValidStation = true;


                    var request = new TraversalRequest(FocusNavigationDirection.Next);
                    request.Wrapped = true;
                    textBoxInput.MoveFocus(request);
                }

                break;

            default:
                break;
            }
            if (listBoxItemDisplay.Height > 0 && listBoxItemDisplay.SelectedItem != null)
            {
                listBoxItemDisplay.ScrollIntoView(listBoxItemDisplay.SelectedItem);
            }
        }
Esempio n. 6
0
 private void textBoxAbfahrtszeit_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (!InternetHelper.hasInternetConnection())
         {
             MessageBox.Show("Es ist keine Internetverbindung vorhanden");
             return;
         }
         textBoxAbfahrtszeit_LostFocus(sender, e);
         if (textBoxStartStation.isValidStation && textBoxEndStation.isValidStation)
         {
             buttonSearchConnection_Click(sender, e);
         }
     }
 }
 private void buttonShowStationOnMap_Click(object sender, RoutedEventArgs e)
 {
     if (!InternetHelper.hasInternetConnection())
     {
         MessageBox.Show("Es ist keine Internetverbindung vorhanden");
         return;
     }
     if (isValidStation)
     {
         Coordinate c = currentlySelectedStation.Coordinate;
         InternetHelper.openLocation(
             c.XCoordinate.ToString(InternetHelper.numberFormatInfo),
             c.YCoordinate.ToString(InternetHelper.numberFormatInfo));
     }
     else
     {
         textBoxInput.Focus();
     }
 }
        private void textBoxInput_GotFocus(object sender, RoutedEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }
            isValidStation = false;
            List <string> newItems = new List <string>();

            foreach (string s in Favorit.FavoritHelper.Favorits)
            {
                if (s != null && s.Contains(textBoxInput.Text ?? ""))
                {
                    newItems.Add(s);
                }
            }
            updateListBox(_displayed);
        }
Esempio n. 9
0
        private void buttonSearchConnection_Click(object sender, RoutedEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }
            Mouse.OverrideCursor = Cursors.Wait;
            DateTime?dateTimeFromPicker = null;
            string   timeFromInput      = "";

            if (textBoxAbfahrtszeit.Text != "00:00" && timeRegex.IsMatch(textBoxAbfahrtszeit.Text))
            {
                timeFromInput      = textBoxAbfahrtszeit.Text;
                dateTimeFromPicker = datePickerAbfahrtszeit.SelectedDate;
            }
            Connections returnedConnections = transport.GetConnections(
                textBoxStartStation.currentlySelectedStation.Name,
                textBoxEndStation.currentlySelectedStation.Name,
                dateTimeFromPicker, timeFromInput);

            dataGridConnections.ItemsSource = null;
            connectionEntryListToDisplay.Clear();


            foreach (Connection c in returnedConnections.ConnectionList)
            {
                connectionEntryListToDisplay.Add(
                    new ConnectionEntry(
                        c.Duration,
                        c.From.Station.Name,
                        c.From.Platform,
                        convertDateTimeToString(c.From.Departure, "dd.MM.yy HH:mm"),
                        c.To.Station.Name,
                        convertDateTimeToString(c.To.Arrival, "HH:mm"),
                        c.Line.First()));
            }

            dataGridConnections.ItemsSource   = connectionEntryListToDisplay;
            tabItemShowConnections.IsSelected = true;

            Mouse.OverrideCursor = null;
        }
Esempio n. 10
0
        private void buttonClickPutTextInStationField(object sender, RoutedEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }
            Mouse.OverrideCursor = Cursors.Wait;
            if (sender is Button)
            {
                try
                {
                    textBoxStartStation.Text = ((Button)sender).Content.ToString();
                }
                catch (Exception) { }
            }

            Mouse.OverrideCursor = null;
        }
 private void butttonAddStationToFavorits_Click(object sender, RoutedEventArgs e)
 {
     if (!InternetHelper.hasInternetConnection())
     {
         MessageBox.Show("Es ist keine Internetverbindung vorhanden");
         return;
     }
     if (isValidStation)
     {
         if (Favorit.FavoritHelper.Favorits.Contains(currentlySelectedStation.Name))
         {
             Favorit.FavoritHelper.Favorits.Remove(currentlySelectedStation.Name);
             starIcon.Source = new BitmapImage(new Uri(@"/starOff.png", UriKind.Relative));
         }
         else
         {
             Favorit.FavoritHelper.Favorits.Add(currentlySelectedStation.Name);
             starIcon.Source = new BitmapImage(new Uri(@"/starOn.png", UriKind.Relative));
         }
     }
 }
Esempio n. 12
0
 private void buttonStationsNearby_Click(object sender, RoutedEventArgs e)
 {
     if (!InternetHelper.hasInternetConnection())
     {
         MessageBox.Show("Es ist keine Internetverbindung vorhanden");
         return;
     }
     if (this.geoLocationHandler.isLoading)
     {
         MessageBox.Show("Ihr Standort wird bereits ermittelt, bitte warten sie einen Moment");
         return;
     }
     else if (this.geoLocationHandler.mapWindow == null)
     {
         geoLocationHandler = new GeoLocationHandler(new GeoLocationHelper());
     }
     else
     {
         this.geoLocationHandler.mapWindow.Show();
     }
 }
        private void textBoxInput_LostFocus(object sender, RoutedEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                return;
            }
            listBoxItemDisplay.Height = 0;
            if (string.IsNullOrEmpty(textBoxInput.Text))
            {
                return;
            }
            try
            {
                Station match = lastQueryedStations.Find(x => x.Name.Equals(textBoxInput.Text));
                if (match != null)
                {
                    currentlySelectedStation = match;
                    isValidStation           = true;
                    return;
                }
            }
            catch (Exception) { }

            List <Station> matchingStations = transport.GetStations(textBoxInput.Text).StationList;

            if (matchingStations.Count <= 0)
            {
                return;
            }
            Station foundStation = matchingStations.Find(x => x.Name.Equals(textBoxInput.Text));

            if (foundStation != null)
            {
                currentlySelectedStation = foundStation;
                isValidStation           = true;
                return;
            }
        }
Esempio n. 14
0
 private void btnSendMail_Click(object sender, RoutedEventArgs e)
 {
     if (!InternetHelper.hasInternetConnection())
     {
         MessageBox.Show("Es ist keine Internetverbindung vorhanden");
         return;
     }
     try
     {
         if (tabItemShowConnections.IsSelected && dataGridConnections.SelectedCells.Count > 0)
         {
             foreach (DataGridCellInfo cellInfo in dataGridConnections.SelectedCells)
             {
                 ConnectionEntry ce = ((ConnectionEntry)cellInfo.Item);
                 System.Diagnostics.Process.Start(
                     "mailto:[email protected]" + "?subject=Verbindung nach "
                     + ce.Abfahrtsort + "&body=Von: " + ce.Abfahrtsort
                     + ", Nach: " + ce.Ankunftsort + ", Abfahrt: " + ce.Abfahrt
                     + " Ankunft: " + ce.Ankunft + ", Gleis: " + ce.Gleis
                     );
                 return;
             }
         }
         else if (tabItemShowStationBoard.IsSelected && dataGridStationBoard.SelectedCells.Count > 0)
         {
         }
         else
         {
             throw new Exception();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Für diese Funktion muss eine Verbindung markiert sein");
     }
 }
Esempio n. 15
0
        private void buttonStationBoard_Click(object sender, RoutedEventArgs e)
        {
            if (!InternetHelper.hasInternetConnection())
            {
                MessageBox.Show("Es ist keine Internetverbindung vorhanden");
                return;
            }
            Mouse.OverrideCursor = Cursors.Wait;
            Station          s   = textBoxStartStation.currentlySelectedStation;
            StationBoardRoot sbr = transport.GetStationBoard(s.Name, s.Id);

            tabItemShowStationBoard.IsSelected = true;
            dataGridStationBoard.ItemsSource   = null;
            stationBoardEntryListToDisplay.Clear();

            foreach (StationBoard sb in sbr.Entries)
            {
                StationBoardEntry stationBoardEntry = new StationBoardEntry(sb.Stop.Departure.ToString("HH:mm"), sb.Category + " " + sb.Number, sb.To);
                stationBoardEntryListToDisplay.Add(stationBoardEntry);
            }

            Mouse.OverrideCursor             = null;
            dataGridStationBoard.ItemsSource = stationBoardEntryListToDisplay;
        }