示例#1
0
        private void Btn_AddFavorite_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var sw = new SaveWindow();

            sw.Owner = this;

            if (sw.ShowDialog() == true)
            {
                sw.Show();
            }

            if (sw.RouteName != "" && sw.RouteName != null)
            {
                var routeName = sw.RouteName;
                var item      = (from f in _favoriteRoutes.FavoriteRoutesList where f.RouteName == routeName select f).FirstOrDefault();

                if (item == null)
                {
                    _favoriteRoutes.Add(routeName, TB_PointOfDeparture.Text, TB_PointOfDestination.Text);
                    LB_Favorite.Items.Add($"{routeName}");
                    LB_Favorite.Visibility = Visibility.Visible;

                    SerializeFavoriteRoutes();
                }
                else
                {
                    CallExceptionWindow("Маршрут с таким названием уже существует!");
                }
            }
        }
示例#2
0
 public static void AddFavoriteRoute(FavoriteRoutesNode node)
 {
     if (_favoriteRoutes == null)
     {
         _favoriteRoutes = new FavoriteRoutes();
     }
     _favoriteRoutes.Add(node.RouteName, node.PointOfDeparture, node.PointOfDestination);
 }