コード例 #1
0
 public static void DeletefavoriteLine(JrhLine jrhLine)
 {
     if (userConfigData.FavoriteLineString.Any(line => line == jrhLine.GetName()))
     {
         userConfigData.FavoriteLineString.Remove(jrhLine.GetName());
         SaveUserConfig();
     }
 }
コード例 #2
0
 public static bool AddfavoriteLine(JrhLine jrhLine)
 {
     if (!userConfigData.FavoriteLineString.Any(line => line == jrhLine.GetName()))
     {
         userConfigData.FavoriteLineString.Add(jrhLine.GetName());
         SaveUserConfig();
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.TrainPosition);
            Window.SetStatusBarColor(new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)));

            var line = Intent.GetStringExtra("Line");

            jrhLine = JrhLineCreater.FromString(line);

            trainPostionLinearLayout = FindViewById <LinearLayout>(Resource.Id.TrainpositionLinearLayout);
            var backButton = FindViewById <ImageView>(Resource.Id.BackButton);

            favoriteButton = FindViewById <ImageView>(Resource.Id.FavoriteButton);
            var TitleTextView = FindViewById <TextView>(Resource.Id.ToolbarText);

            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh);
            GettedTimeTextView = FindViewById <TextView>(Resource.Id.GetedTimeTextView);

            favoriteButton.Click       += FavoriteButton_Click;
            backButton.Click           += BackButton_Click;
            TitleTextView.Text          = jrhLine.GetName();
            swipeRefreshLayout.Refresh += SwipeRefreshLayout_Refresh;

            IsFavorited = UserConfigManager.IsFavoriteLine(jrhLine);
            favoriteButton.SetImageResource(IsFavorited ? Resource.Drawable.FavoritedIcon : Resource.Drawable.AddFavoriteIcon);

            RenderData(jrhLine);
        }
コード例 #4
0
 private void FavoriteButton_Click(object sender, EventArgs e)
 {
     if (IsFavorited)
     {
         UserConfigManager.DeletefavoriteLine(jrhLine);
         var toast = Toast.MakeText(this, $"{jrhLine.GetName()}を削除しました", ToastLength.Short);
         toast.SetGravity(GravityFlags.Bottom, 0, 0);
         toast.Show();
         IsFavorited = false;
     }
     else
     {
         UserConfigManager.AddfavoriteLine(jrhLine);
         var toast = Toast.MakeText(this, $"{jrhLine.GetName()}を追加しました", ToastLength.Short);
         toast.SetGravity(GravityFlags.Bottom, 0, 0);
         toast.Show();
         IsFavorited = true;
     }
     favoriteButton.SetImageResource(IsFavorited ? Resource.Drawable.FavoritedIcon : Resource.Drawable.AddFavoriteIcon);
 }
コード例 #5
0
        /// <summary>
        /// 路線を指定して駅データをCSVに書き出します。
        /// </summary>
        /// <param name="jrhLine"></param>
        /// <returns></returns>
        public static string ToCsvData(JrhLine jrhLine)
        {
            var stringBuilder = new StringBuilder();

            foreach (var station in LineDataReader.GetStations(jrhLine))
            {
                stringBuilder.Append($"{station.StationId},{station.Name},{station.HiraName},{station.KataName},{station.EnglishName},{station.IsEndStation},{station.StationArea},{jrhLine.GetName()},{station.Position[jrhLine]}\n");
            }

            return(stringBuilder.ToString());
        }
コード例 #6
0
 public static bool IsFavoriteLine(JrhLine jrhLine)
 {
     return(userConfigData.FavoriteLineString.Contains(jrhLine.GetName()));
 }