public RealmFriendshipTimerPage() { InitializeComponent(); RFEnv.LoadValues(); if (Device.RuntimePlatform is not Device.UWP) { _buttonPressTimer = new(500) { AutoReset = false }; _buttonPressTimer.Elapsed += delegate { _isRunReset = true; if (Preferences.Get(SettingConstants.QUICKCALC_VIBRATION, true)) { Vibration.Vibrate(100); } ResetRF(); }; } _calcTimer = new(CalcNowRF, new AutoResetEvent(false), TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)); }
private void ResetRF() { DateTime now = DateTime.Now; int count = RFEnv.MaxRF / RFEnv.RFRate; count += (RFEnv.MaxRF % RFEnv.RFRate) == 0 ? 0 : 1; RFEnv.LastInputTime = now.ToString(AppEnv.DTCulture); #if TEST RFEnv.EndTime = now.AddMinutes(count); #else RFEnv.EndTime = now.AddHours(count); #endif RFEnv.Bounty = 0; RFEnv.AddCount = 0; RFEnv.SaveValue(); if (Preferences.Get(SettingConstants.NOTI_ENABLED, false)) { new RealmFriendshipNotiManager().UpdateNotisTime(); } }
protected override void OnDisappearing() { base.OnDisappearing(); RFEnv.SaveValue(); _calcTimer.Change(Timeout.Infinite, Timeout.Infinite); }
private void CalcNowRF(object statusInfo) { try { RFEnv.CalcRF(); MainThread.BeginInvokeOnMainThread(RefreshInfo); } catch (Exception ex) { #if DEBUG DependencyService.Get <IToast>().Show(ex.ToString()); #endif } }
public RealmFriendshipNoti(int percentage) { Percentage = percentage; NotiId = RealmFriendshipNotiManager.ID_PREINDEX + Percentage; try { UpdateTime(); } catch { RFEnv.LoadValues(); UpdateTime(); } }
private void ApplySetting() { RealmEnv.RealmRank = (RealmEnv.RealmRankEnum)RealmRankPicker.SelectedIndex; RealmEnv.TrustRank = TrustRankPicker.SelectedIndex + 1; switch (type) { case RealmEnv.RealmType.Currency: RCEnv.CalcEndTime(); RCEnv.SaveValue(); break; case RealmEnv.RealmType.Friendship: RFEnv.CalcEndTime(); RFEnv.SaveValue(); break; } UpdateNotis(); Navigation.PopAsync(); }
internal override void ApplyValue() { base.ApplyValue(); if (int.TryParse(SfUpDown.Text, out int inputValue)) { RFEnv.LastInputTime = DateTime.Now.ToString(AppEnv.DTCulture); RFEnv.Bounty = inputValue; //Convert.ToInt32((double)SfUpDown.Value); RFEnv.AddCount = 0; RFEnv.CalcEndTime(); RFEnv.CalcRF(); RFEnv.SaveValue(); notiManager.UpdateNotisTime(); notiManager.UpdateScheduledNoti <RealmFriendshipNoti>(); } else { DependencyService.Get <IToast>().Show(AppResources.ValueEdit_ValueError_Message); } }
public RealmFriendshipHomeItem() { RFEnv.LoadValues(); RFEnv.CalcRF(); }