public virtual void Update() { for (int i = Overlays.Count - 1; i >= 0; i--) { Overlays[i].Update(); } for (int i = Toasts.Count - 1; i >= 0; i--) { BaseToast toast = Toasts[i]; toast.Update(); if (toast.IsComplete()) { Toasts.RemoveAt(i); } } for (int i = Widgets.Count - 1; i >= 0; i--) { Widget widget = Widgets[i]; if (widget.Visible) { widget.Update(); } } }
private void StartBackgroundRefresh() { _shouldContinue = true; var refreshInterval = SyncManager.GetSyncFrequencyInMinutes(); Device.StartTimer(new TimeSpan(0, refreshInterval, 0), () => { // if the process is to be cancelled then honour that if (!_shouldContinue) { return(_shouldContinue); } Task.Run(async() => { // pull latest data var service = new CryptoStatsService(); var coins = await service.GetAllStatsAsync(); Device.BeginInvokeOnMainThread(() => { BindDataToUi(coins.Data); Toasts.DisplayInfo("Crypto data refreshed."); }); }); // return true to keep the timer running. return(_shouldContinue); }); }
public void Add(ToastType type, string message, string title, Action <ToastOptions> configure) { if (message.IsEmpty()) { return; } message = message.Trimmed(); title = title.Trimmed(); var options = new ToastOptions(type, Configuration); configure?.Invoke(options); var toast = new Toast(title, message, options); ToastLock.EnterWriteLock(); try { if (Configuration.PreventDuplicates && ToastAlreadyPresent(toast)) { return; } toast.OnClose += Remove; Toasts.Add(toast); } finally { ToastLock.ExitWriteLock(); } OnToastsUpdated?.Invoke(); }
public void ShowToastPressed() { text.text = "Show Toast Pressed"; Debug.Log("Show Toast Pressed"); // Toasts. Toasts.ShowToast(ToastTemplateType.ToastText01, new string[] { "toasting to good life." }, null); }
public void Init(string newTitle, int rows, int columns, string[] newTabularData) { ClearTable(); title.text = newTitle; pageNumber.text = $"{ currentPage + 1 }"; tabularData = newTabularData; if (newTabularData != null && newTabularData.Length > 0) { currentRows = rows; currentColumns = columns; maxPages = Mathf.CeilToInt((float)currentRows / MAXROWSPAGE); } else { Toasts.AddToast(5, "File is corrupt"); return; } SetButtonStates(); PopulateTable(); SetRowNumbers(); tabularDataWrapper.GetComponent <GridLayoutGroup>().constraintCount = currentColumns; float cellSizeX = Mathf.Max(tabularDataWrapper.rect.width / currentColumns, MIN_GRID_SIZE_X); float cellSizeY = Mathf.Max(tabularDataWrapper.rect.height / currentRows, MIN_GRID_SIZE_Y); tabularDataWrapper.GetComponent <GridLayoutGroup>().cellSize = new Vector2(cellSizeX, cellSizeY); }
private void importCSVWithData(string data) { UserInteraction(); data = data.Replace("\r\n", "\n"); var s = data.Split('\n').ToList(); s = s.Select(x => x.NoControlAndTrim()).ToList(); int i; try { i = csvImport(s); } catch (Exception ex) { i = 0; DialogService.ShowError(ex, AppResources.SettingsViewModel_exportData_Error, AppResources.SettingsViewModel_exportData_OK, null); } if (i > 0) { Toasts.Notify(ToastNotificationType.Success, AppResources.SettingsViewModel_importCSVWithData_Import_succeed, string.Format(AppResources.SettingsViewModel_importCSVWithData__0__sheets_have_been_imported_, i), TimeSpan.FromSeconds(3)); } if (i < 1) { Toasts.Notify(ToastNotificationType.Info, AppResources.SettingsViewModel_importCSVWithData_No_data_imported, AppResources.SettingsViewModel_importCSVWithData_No_data_have_been_imported_, TimeSpan.FromSeconds(3)); } }
public void Remove(Toast toast) { toast.OnClose -= Remove; Toasts.Remove(toast); OnToastsUpdated?.Invoke(); toast.Dispose(); }
private bool ToastAlreadyPresent(string message, string title, ToastType type) { return(Toasts.Any(toast => message.Equals(toast.Message) && title.Equals(toast.Title) && type.Equals(toast.State.Options.Type) )); }
protected override void IncomingCommand(string commandName, object context) { if (commandName == Utils.GlobalMessages.CopyToClipbard.ToString()) { CrossShare.Current.SetClipboardText(Generated, AppResources.GeneratePwViewModel_IncomingCommand_My_Stash_generated_password); } Toasts.Notify(ToastNotificationType.Success, AppResources.GeneratePwViewModel_GeneratePwViewModel_Copy_to_clipboard, AppResources.GeneratePwViewModel_GeneratePwViewModel_Generated_password_copied_to_the_clipboard, TimeSpan.FromSeconds(2)); }
public void Remove(string par1) { var item = Toasts.Where(x => x.Titel == par1).FirstOrDefault(); Toasts.Remove(item); OnToastsUpdated?.Invoke(); }
private bool ToastAlreadyPresent(Toast newToast) { return(Toasts.Any(toast => newToast.Message.Equals(toast.Message) && newToast.Title.Equals(toast.Title) && newToast.Options.Type.Equals(toast.State.Options.Type) )); }
public void Add(string par1) { var t = new ToastItem(); t.Titel = par1; Toasts.Add(t); OnToastsUpdated?.Invoke(); }
private void ChangeTheme(object sender, EventArgs e) { if (GetCurrentThemeIndex() != cmbTheme.SelectedIndex) { var theme = (ThemeManager.Themes)(cmbTheme.SelectedIndex); ThemeManager.ChangeTheme(theme); Toasts.DisplaySuccess($"{theme.ToString()} theme set successfully."); } }
private void SendSampleToastExecute(object obj) { Notification n = new Notification(); n.Type = "EXAMPLE"; n.Date = 0; n.Link = "http:\\google.com"; Toasts.ShowToast(n); }
private void OnShowToast(ShowToastMessage showToastMessage) { var toast = new ToastViewModel(showToastMessage, _chatDocumentCreator(), _bus, _activator); Toasts.Add(toast); toast.Closed.SubscribeOnceUI(_ => { Toasts.Remove(toast); toast.Dispose(); }); }
private void exportData(bool sql = false) { UserInteraction(); if (DataService.GetInfoSheetCount(InfoSheet.CategoryFilter.All, InfoSheet.ProFilter.All).Item1 < 1) { Toasts.Notify(ToastNotificationType.Warning, AppResources.SettingsViewModel_exportData_No_data, AppResources.SettingsViewModel_exportData_No_data_to_export, TimeSpan.FromSeconds(3)); return; } try { var list = originalData; if (EncryptedData) { list = (from insh in originalData select insh.ToCryptedSheet()).ToList(); } ExportBase <InfoSheet> exp; if (sql) { exp = new ExportClipboardSql <InfoSheet>(); } else { exp = new ExportClipboardCsv <InfoSheet>() { TitleRow = true } }; exp.Source = list; foreach (var fi in exp.FieldsInformation) { fi.Value.IsExported = false; } exp.FieldsInformation["Id"].IsExported = exp.FieldsInformation["Title"].IsExported = exp.FieldsInformation["IsPro"].IsExported = exp.FieldsInformation["Note"].IsExported = exp.FieldsInformation["CreatedOn"].IsExported = exp.FieldsInformation["ModifiedOn"].IsExported = exp.FieldsInformation["UrlOrName"].IsExported = exp.FieldsInformation["Login"].IsExported = exp.FieldsInformation["Password"].IsExported = exp.FieldsInformation["Category"].IsExported = exp.FieldsInformation["Crypting"].IsExported = true; exp.Destination = ShareOnExport ? Destination.Share : Destination.Clipboard; exp.Execute(); Toasts.Notify(ToastNotificationType.Success, (sql ? "SQL" : "CSV") + " " + AppResources.SettingsViewModel_exportData_Export, AppResources.SettingsViewModel_exportData_Data_are_in_the_clipboard, TimeSpan.FromSeconds(2)); } catch (Exception ex) { DialogService.ShowError(ex, AppResources.SettingsViewModel_exportData_Error, AppResources.SettingsViewModel_exportData_OK, null); } }
private static async Task <T> PullDataWithRetriesAsync <T>(string url) { return(await Policy .Handle <Exception>(x => x.IsInternetConnectionException()) .WaitAndRetryAsync ( 3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(3, retryAttempt)), (ex, time) => { Toasts.DisplayError("An error occurred while retrieving data. Retrying..."); } ) .ExecuteAsync(async() => await PullDataAsync <T>(url))); }
/// <summary> /// Resets values. /// </summary> public static void ResetValues() { DebugEx.Verbose("Assets.Common.ResetValues()"); Fonts.ResetValues(); Cursors.ResetValues(); Windows.ResetValues(); DockWidgets.ResetValues(); Popups.ResetValues(); Tooltips.ResetValues(); Toasts.ResetValues(); }
private async Task Show(ToastOption option) { Toasts.Add(option, new RenderFragment(builder => { var index = 0; builder.OpenComponent <ToastBox>(index++); builder.AddAttribute(index++, nameof(ToastBox.Category), option.Category); builder.AddAttribute(index++, nameof(ToastBox.Title), option.Title); builder.AddAttribute(index++, nameof(ToastBox.Content), option.Content); builder.AddAttribute(index++, nameof(ToastBox.IsAutoHide), option.IsAutoHide); builder.AddAttribute(index++, nameof(ToastBox.Delay), option.Delay); builder.CloseComponent(); })); await InvokeAsync(StateHasChanged); }
void OnExportInit() { if (UnsavedChangesTracker.Instance.unsavedChanges) { if (!Editor.Instance.SaveProject()) { Toasts.AddToast(5, "File save failed, try again."); } } explorerPanel = Instantiate(UIPanels.Instance.explorerPanel, Canvass.main.transform, false).GetComponent <ExplorerPanel>(); explorerPanel.InitSaveAs("", ".zip", "*.zip", "Enter a file name"); exportButton.interactable = false; }
private void RemoveAllToasts(IEnumerable <Toast> toasts) { if (Toasts.Count == 0) { return; } foreach (var toast in toasts) { toast.OnClose -= Remove; toast.Dispose(); } Toasts.Clear(); }
public void Login() { var username = loginUsername.text; var password = loginPassword.text; loginError.color = errorColor; if (String.IsNullOrEmpty(username)) { loginError.text = "Please fill in a username"; return; } if (String.IsNullOrEmpty(password)) { loginError.text = "Please fill in a password"; return; } if (loginRemember.isOn) { using (var file = File.CreateText(loginDataPath)) { file.WriteLine(username); file.WriteLine(password); } } else { File.Delete(loginDataPath); } var response = SendLoginRequest(username, password); if (response.Item1 == 401) { loginError.text = "Username does not exist, or password is wrong"; return; } if (response.Item1 != 200) { loginError.text = "An error happened in the server. Please try again later"; return; } answered = true; answerToken = response.Item2; Toasts.AddToast(5, "Logged in"); }
private bool isSheetOkVerbose() { try { if (Sheet == null) { return(false); } if (string.IsNullOrWhiteSpace(Sheet.Title)) { Toasts.Notify(ToastNotificationType.Warning, AppResources.EditViewModel_isSheetOkVerbose_Enter_a_title, AppResources.EditViewModel_isSheetOkVerbose_Title_is_mandatory, TimeSpan.FromSeconds(2)); return(false); } if (Sheet.Category == InfoSheet.CategoryFilter.All) { Toasts.Notify(ToastNotificationType.Warning, AppResources.EditViewModel_isSheetOkVerbose_Select_a_category, AppResources.EditViewModel_isSheetOkVerbose_A_category_must_be_selected, TimeSpan.FromSeconds(2)); return(false); } if (Sheet.Category == InfoSheet.CategoryFilter.Login) { if (string.IsNullOrWhiteSpace(Sheet.Login)) { Toasts.Notify(ToastNotificationType.Warning, AppResources.EditViewModel_isSheetOkVerbose_Login_is_empty, AppResources.EditViewModel_isSheetOkVerbose_Enter_a_Login_name, TimeSpan.FromSeconds(2)); return(false); } // ReSharper disable once InvertIf if (string.IsNullOrWhiteSpace(Sheet.Password)) { Toasts.Notify(ToastNotificationType.Warning, AppResources.EditViewModel_isSheetOkVerbose_Password_is_empty, AppResources.EditViewModel_isSheetOkVerbose_Enter_a_password, TimeSpan.FromSeconds(2)); return(false); } return(true); } // ReSharper disable once InvertIf if (string.IsNullOrWhiteSpace(Sheet.Note)) { Toasts.Notify(ToastNotificationType.Warning, AppResources.EditViewModel_isSheetOkVerbose_Note_is_empty, AppResources.EditViewModel_isSheetOkVerbose_Enter_something_in_Note_field, TimeSpan.FromSeconds(2)); return(false); } return(true); } finally { // ReSharper disable once ExplicitCallerInfoArgument RaisePropertyChanged(nameof(IsSheetOk)); } }
public void Init(string newTitle, string fullPath) { if (Player.hittables != null) { GetComponentInChildren <Hittable>().enabled = true; } if (!File.Exists(fullPath)) { Toasts.AddToast(5, "Corrupted audio, ABORT ABORT ABORT"); return; } this.fullPath = fullPath; title.text = newTitle; dirty = true; }
//Makes the background grow redder if you lose. Enter lose screen. IEnumerator ChangeLight() { #if UNITY_WSA_10_0 && NETFX_CORE Toasts.ShowToast(ToastTemplateType.ToastImageAndText01, new string[] { "Try again! Your score was: " + gameController.getScore() }, "Assets/StoreLogo.scale-400.png"); #endif GameObject light = GameObject.FindGameObjectWithTag("Light"); Light backgroundLight = light.GetComponent <Light>(); while (backgroundLight.color.b > 0 && backgroundLight.color.g > 0) { backgroundLight.color = new Color(backgroundLight.color.r, backgroundLight.color.b - .10f, backgroundLight.color.g - .10f); yield return(new WaitForSeconds(.05f)); } gameController.done = true; gameController.over = false; gameController.Reset(); SceneManager.LoadScene("Game_Over"); }
public virtual void Remove() { for (int i = Overlays.Count - 1; i >= 0; i--) { Overlays[i].Remove(); } Overlays.Clear(); for (int i = Toasts.Count - 1; i >= 0; i--) { Toasts[i].Remove(); } Toasts.Clear(); for (int i = Widgets.Count - 1; i >= 0; i--) { Widgets[i].Remove(); } Widgets.Clear(); }
public GeneratePwViewModel() { GenerateCommand = new Command(() => { UserInteraction(); generate(); }, () => LettersDown || LettersUp || Numbers || Symbols); CopyToClipboardCommand = new Command(() => { UserInteraction(); CrossShare.Current.SetClipboardText(Generated ?? string.Empty); Toasts.Notify(ToastNotificationType.Success, AppResources.GeneratePwViewModel_GeneratePwViewModel_Copy_to_clipboard, AppResources.GeneratePwViewModel_GeneratePwViewModel_Generated_password_copied_to_the_clipboard, TimeSpan.FromSeconds(2)); }, () => !string.IsNullOrWhiteSpace(Generated)); ModalDismissCommand = new Command(() => Navigation.ModalDismiss()); leetLevels = (from ls in LeetMaker.LeetStrengthStr select new Tuple <LeetMaker.LeetStrength, string>(ls.Key, ls.Value)).ToList(); selectedStrength = leetLevels[2]; }
public void Login() { var email = loginEmail.text; var password = loginPassword.text; loginError.color = errorColor; if (String.IsNullOrEmpty(email)) { loginError.text = "Please fill in a username"; return; } if (String.IsNullOrEmpty(password)) { loginError.text = "Please fill in a password"; return; } if (loginRemember.isOn) { using (var file = File.CreateText(loginDataPath)) { file.WriteLine(email); file.WriteLine(password); } } else { File.Delete(loginDataPath); } var(success, response) = SendLoginRequest(email, password); if (!success) { loginError.text = response; return; } answered = true; Toasts.AddToast(5, "Logged in"); }
public void NewStop(string title) { isNew = false; SetIndex(files.Count - 1); var projectFolder = Path.Combine(Application.persistentDataPath, files[selectedIndex].guid); if (!Directory.Exists(projectFolder)) { try { Directory.CreateDirectory(projectFolder); File.Create(Path.Combine(projectFolder, SaveFile.editableFilename)).Close(); Directory.CreateDirectory(Path.Combine(projectFolder, SaveFile.extraPath)); Directory.CreateDirectory(Path.Combine(projectFolder, SaveFile.miniaturesPath)); } catch (Exception e) { Toasts.AddToast(5, "Something went wrong while creating a new project"); Debug.LogError(e.StackTrace); } var data = new SaveFileData { meta = new Metadata { version = SaveFile.VERSION, title = files[selectedIndex].title, description = "", guid = new Guid(files[selectedIndex].guid), } }; SaveFile.WriteFile(projectFolder, data); } else { Debug.LogError("Guid collision"); } }
public void Remove(Toast toast) { toast.Dispose(); toast.OnClose -= Remove; ToastLock.EnterWriteLock(); try { var index = Toasts.IndexOf(toast); if (index < 0) { return; } Toasts.RemoveAt(index); } finally { ToastLock.ExitWriteLock(); } OnToastsUpdated?.Invoke(); }