private void CreateToastView() { // Init parent of ToastView parentView[1] = new View(); parentView[1].Size = new Size(1920, 500); parentView[1].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(300, 0) }; root.Add(parentView[1]); // Create Toasts toast1_1 = Toast.FromText("Null parameter construction", 1000); toast1_1.Size = new Size(700, 132); toast1_1.Post(NUIApplication.GetDefaultWindow()); ToastStyle attr = new ToastStyle { Size = new Size(712, 132), BackgroundImage = CommonResource.GetFHResourcePath() + "12. Toast Popup/toast_background.png", BackgroundImageBorder = new Rectangle(64, 64, 4, 4), Duration = 3000 }; toast2_1 = new Toast(attr); toast2_1.Message = "Style parameter construction"; toast2_1.Post(NUIApplication.GetDefaultWindow()); // Create Buttons CreateBoardAndButtons(); }
private ToastModel BuildToastSettings(ToastStyle style, string message, string heading) { switch (style) { case ToastStyle.Info: return(new ToastModel { Title = (string.IsNullOrWhiteSpace(heading) ? "Info":heading), Content = message, CssClass = InfoClass, Icon = InfoIconClass, Width = Width, ShowCloseButton = ShowCloseButton, ShowProgressBar = ShowProgressBar, NewestOnTop = true }); case ToastStyle.Success: return(new ToastModel { Title = (string.IsNullOrWhiteSpace(heading) ? "Success" : heading), Content = message, CssClass = SuccessClass, Icon = SuccessIconClass, Width = Width, ShowCloseButton = ShowCloseButton, ShowProgressBar = ShowProgressBar, NewestOnTop = true }); case ToastStyle.Warning: return(new ToastModel { Title = (string.IsNullOrWhiteSpace(heading) ? "Warning" : heading), Content = message, CssClass = WarningClass, Icon = WarningIconClass, Width = Width, ShowCloseButton = ShowCloseButton, ShowProgressBar = ShowProgressBar, NewestOnTop = true }); case ToastStyle.Error: return(new ToastModel { Title = (string.IsNullOrWhiteSpace(heading) ? "Error" : heading), Content = message, CssClass = ErrorClass, Icon = ErrorIconClass, Width = Width, ShowCloseButton = ShowCloseButton, ShowProgressBar = ShowProgressBar, NewestOnTop = true }); } throw new InvalidOperationException(); }
public void ToastApplyStyle() { tlog.Debug(tag, $"ToastApplyStyle START"); var testingTarget = new Toast(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <Toast>(testingTarget, "Should return Toast instance."); ToastStyle style = new ToastStyle() { Text = new TextLabelStyle() { Size = new Size(80, 30) } }; try { testingTarget.ApplyStyle(style); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } testingTarget.Dispose(); tlog.Debug(tag, $"ToastApplyStyle END (OK)"); }
public void Activate() { Window window = Window.Instance; root = new View() { Size = new Size(1920, 1080), BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.6f), }; CreateBoardAndButtons(); toast1_1 = Toast.FromText("null parameter construction", 1000); toast1_1.Size = new Size(500, 132); toast1_1.Post(window); ToastStyle attr = new ToastStyle { Size = new Size(512, 132), BackgroundImage = CommonResource.GetFHResourcePath() + "12. Toast Popup/toast_background.png", BackgroundImageBorder = new Rectangle(64, 64, 4, 4), Duration = 3000 }; toast2_1 = new Toast(attr); toast2_1.Message = "attibute parameter construction"; toast2_1.Post(window); //root.Add(toast2_1); board.UpFocusableView = button1; window.Add(root); FocusManager.Instance.SetCurrentFocusView(button1); }
public void ToastStyleCopyFrom() { tlog.Debug(tag, $"ToastStyleCopyFrom START"); var testingTarget = new ToastStyle(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <ToastStyle>(testingTarget, "Should return TabStyle instance."); ToastStyle style = new ToastStyle() { Size = new Size(10, 20), }; try { testingTarget.CopyFrom(style); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } tlog.Debug(tag, $"ToastStyleCopyFrom END (OK)"); }
private void ShowToast(ToastStyle style, string message, string heading) { InvokeAsync(() => { var settings = BuildToastSettings(style, message, heading); ToastObj.Show(settings); }); }
public void ToastStyleConstructor() { tlog.Debug(tag, $"ToastStyleConstructor START"); var testingTarget = new ToastStyle(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <ToastStyle>(testingTarget, "Should return ToastStyle instance."); tlog.Debug(tag, $"ToastStyleConstructor END (OK)"); }
public void ToastStyleDuration() { tlog.Debug(tag, $"ToastStyleDuration START"); var testingTarget = new ToastStyle(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <ToastStyle>(testingTarget, "Should return ToastStyle instance."); testingTarget.Duration = 500; tlog.Debug(tag, "Duration :" + testingTarget.Duration); tlog.Debug(tag, $"ToastStyleDuration END (OK)"); }
public void ToastConstructor() { tlog.Debug(tag, $"ToastConstructor START"); ToastStyle style = new ToastStyle() { BackgroundColor = Color.Cyan, }; var testingTarget = new Toast(style); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <Toast>(testingTarget, "Should return Toast instance."); testingTarget.Dispose(); tlog.Debug(tag, $"ToastConstructor END (OK)"); }
public void ToastStyleText() { tlog.Debug(tag, $"ToastStyleText START"); var testingTarget = new ToastStyle(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <ToastStyle>(testingTarget, "Should return ToastStyle instance."); TextLabelStyle text = new TextLabelStyle() { Size = new Size(2, 18), PointSize = 15.0f }; testingTarget.Text = text; tlog.Debug(tag, "Text : " + testingTarget.Text); tlog.Debug(tag, $"ToastStyleText END (OK)"); }
public static string Toast(ToastStyle style, string mess) { if (mess.Length < 1) { mess = "Không có thông báo nào được hiển thị."; } Dictionary <string, string> html = null; switch (style) { case ToastStyle.Info: html.Add("class", "info"); html.Add("icon", "info-circle"); html.Add("title", "Info"); break; case ToastStyle.Error: html.Add("class", "danger"); html.Add("icon", "close"); html.Add("title", "Error"); break; case ToastStyle.Success: html.Add("class", "success"); html.Add("icon", "check"); html.Add("title", "Success"); break; case ToastStyle.Warning: html.Add("class", "warning"); html.Add("icon", "warning"); html.Add("title", "Warning"); break; } return(string.Format("<div class='alert alert-{0} alert-dismissable alert-view fade in' style='display: none;'>" + "<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>" + "<strong><i class='fa fa-{1}'></i> {2}:</strong>{3}</div>", html["class"], html["icon"], html["title"], mess)); }
/// <summary> /// Shows a toast using the supplied settings /// </summary> /// <param name="level">Toast style to display</param> /// <param name="message">Text to display on the toast</param> /// <param name="heading">The text to display as the toasts heading</param> public void ShowToast(ToastStyle style, string message, string heading = "") { OnShow?.Invoke(style, message, heading); }