Пример #1
0
 /// <summary>
 /// Returns a div alert box element with the options specified
 /// </summary>
 /// <param name="text">Sets the text to display</param>
 /// <param name="style">Sets style of alert box [Default | Success | Warning | Info ]</param>
 /// <param name="hideCloseButton">Sets the close button visibility</param>
 /// <param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param>
 public AlertBox(string text, AlertStyle style, bool hideCloseButton = false, object htmlAttributes = null)
 {
     this.text = text;
     this.alertStyle = style;
     this.hideCloseButton = hideCloseButton;
     this.htmlAttributes = htmlAttributes;
 }
Пример #2
0
 public void Show(string text, AlertStyle style = AlertStyle.Error)
 {
     if (_grid != null)
     {
         _grid.Children.Add(CreateBorder(text, style));
     }
 }
Пример #3
0
 public void ShowAlertBox(AlertStyle mystyle, string str, int interval)
 {
     _style            = mystyle;
     Text              = str;
     Visible           = true;
     _mytimer.Interval = interval;
     _mytimer.Enabled  = true;
 }
 public static AlertBox Alert(this HtmlHelper html,
     string text,
     AlertStyle alertStyle = AlertStyle.Default,
     bool hideCloseButton = false,
     object htmlAttributes = null
     )
 {
     return new AlertBox(text, alertStyle, hideCloseButton, htmlAttributes);
 }
Пример #5
0
 /// <summary>
 /// Generates an Alert message
 /// </summary>
 public static AlertBox Alert(this HtmlHelper html,
                              string text,
                              AlertStyle alertStyle = AlertStyle.Default,
                              bool hideCloseButton  = false,
                              object htmlAttributes = null
                              )
 {
     return(new AlertBox(text, alertStyle, hideCloseButton, htmlAttributes));
 }
Пример #6
0
        /// <summary>
        /// Shows an alert to the user composed of a set of options for the user to choose from.
        /// </summary>
        /// <param name="message">The message to display to the user.</param>
        /// <param name="title">An optional title for the alert.</param>
        /// <param name="options">A set of options for the alert.</param>
        /// <param name="alertStyle">Identifies the style for the alert.</param>
        public void ShowAlertWithOptions(
            string message,
            string title,
            IEnumerable <AlertOption> options,
            AlertStyle alertStyle)
        {
            if (options == null || options.Count() < 2)
            {
                throw new ArgumentException("At least 2 options must be specified.", nameof(options));
            }

            UIAlertControllerStyle alertControllerStyle;

            if (alertStyle == AlertStyle.Dialog)
            {
                alertControllerStyle = UIAlertControllerStyle.Alert;
            }
            else if (alertStyle == AlertStyle.ActionSheet)
            {
                alertControllerStyle = UIAlertControllerStyle.ActionSheet;
            }
            else
            {
                throw new ArgumentException("Unexpected alert style (" + alertStyle + ").", nameof(alertStyle));
            }

            UIAlertController alert = UIAlertController.Create(title, message, alertControllerStyle);

            foreach (AlertOption option in options)
            {
                UIAlertActionStyle style;

                if (option.AlertOptionType == AlertOptionType.Standard)
                {
                    style = UIAlertActionStyle.Default;
                }
                else if (option.AlertOptionType == AlertOptionType.Destructive)
                {
                    style = UIAlertActionStyle.Destructive;
                }
                else if (option.AlertOptionType == AlertOptionType.Cancel)
                {
                    style = UIAlertActionStyle.Cancel;
                }
                else
                {
                    throw new InvalidOperationException("Unexpected AlertOptionType (" + option.AlertOptionType + ").");
                }

                alert.AddAction(UIAlertAction.Create(option.Text, style, _ => option.Callback()));
            }

            this.getPresentingController().PresentViewController(alert, true, null);
        }
Пример #7
0
        // Strongly typed
        /// <summary>
        /// Generates an Alert message
        /// </summary>
        public static AlertBox AlertFor <TModel, TTextProperty>(this HtmlHelper <TModel> html,
                                                                Expression <Func <TModel, TTextProperty> > expression,
                                                                AlertStyle alertStyle = AlertStyle.Default,
                                                                bool hideCloseButton  = false,
                                                                object htmlAttributes = null
                                                                )
        {
            var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);

            return(new AlertBox((string)metadata.Model, alertStyle, hideCloseButton, htmlAttributes));
        }
Пример #8
0
        public static void AddAlert(this ITempDataDictionary tempData, AlertStyle style, string message)
        {
            if (style == null || message == null)
            {
                throw new ArgumentNullException($"{nameof(style)} {nameof(message)}");
            }

            var deserializeAlertList = tempData.GetAlert();

            deserializeAlertList.Add(new Alert(style, message));
            tempData[Alerts] = SerializeAlerts(deserializeAlertList);
        }
        private int GetIndex(AlertStyle style)
        {
            var index = 0;

            for (var i = 0; i < _updateInformation.options.Length; i++)
            {
                if (_updateInformation.options[i].style == style)
                {
                    index = i;
                }
            }

            return(index);
        }
        private static void CallNativeAlertMessage(AlertStyle alertStyle, string title, string message, params AlertButton[] buttons)
        {
            // creating unique id for buttons
            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i].m_Id = buttons[i].Title + i;
            }

            // cache current alert buttons
            m_CurrentAlertButtons = buttons;

#if !UNITY_EDITOR
            // call native ios function
            _IOSShowAlertMsg((int)alertStyle, title, message, buttons.Select(x => x.Title).ToArray(), buttons.Select(x => (int)x.Style).ToArray(), buttons.Length);
#endif
        }
Пример #11
0
        private static void AddAlert(ITempDataDictionary tempData, AlertStyle alertStyle, string message, string header, bool dismissable)
        {
            var alerts = tempData.ContainsKey(Alert.TempDataKey)
                ? JsonConvert.DeserializeObject <List <Alert> >(tempData[Alert.TempDataKey].ToString())
                : new List <Alert>();

            alerts.Add(new Alert
            {
                AlertStyle   = alertStyle,
                AlertHeading = header,
                AlertMessage = message,
                Dismissable  = dismissable
            });

            tempData.Put <List <Alert> >(Alert.TempDataKey, alerts);
        }
Пример #12
0
        internal override void SelectFirmwareUpdateOption(int index)
        {
            // If a connection is not in process and waiting for a firmware update response, then this method
            // was called in error. Abort, so as not to restart the state machine halfway through.
            if (ConnectionStatus != ConnectionStatus.FirmwareUpdateRequired &&
                ConnectionStatus != ConnectionStatus.FirmwareUpdateAvailable)
            {
                return;
            }

            AlertStyle style = _updateInformation.options[index].style;

            if (style == AlertStyle.Affirmative)
            {
                // In a real flow, the user would be taken to the Bose app and the firmware updated.
                // Here, all we can do is spit out a warning and cancel the attempt.
                Debug.LogWarning(WearableConstants.DebugProviderFirmwareUpdateWarning);
                SetConnectionPhase(ConnectionPhase.Cancelled);
            }
            else
            {
                if (ConnectionStatus == ConnectionStatus.FirmwareUpdateRequired)
                {
                    // The cancelled firmware update was mandatory; connection must fail.
                    if (_verbose)
                    {
                        Debug.LogError(WearableConstants.DebugProviderSkippedRequiredUpdate);
                    }

                    SetConnectionPhase(ConnectionPhase.Failed);
                }
                else
                {
                    // The cancelled firmware update was optional, so we can move on and finalize the connection.
                    if (_verbose)
                    {
                        Debug.Log(WearableConstants.DebugProviderSkippedOptionalUpdate);
                    }

                    SetConnectionPhase(ConnectionPhase.Succeeded);
                }
            }
        }
Пример #13
0
        private void AddAlert(AlertStyle alertStyle, string message, bool dismissable)
        {
            switch (alertStyle)
            {
            case AlertStyle.Success:
                TempData["SuccessNotification"] = message;
                break;

            case AlertStyle.Information:
                TempData["InformationNotification"] = message;
                break;

            case AlertStyle.Warning:
                TempData["WarningNotification"] = message;
                break;

            case AlertStyle.Danger:
                TempData["ErrorNotification"] = message;
                break;

            default:
                break;
            }
        }
Пример #14
0
        private Border CreateBorder(string text, AlertStyle style = AlertStyle.Error)
        {
            var border = new Border
            {
                BorderThickness = new Thickness(0),
                CornerRadius    = new CornerRadius(5),
                Opacity         = 0
            };
            var shadow = new DropShadowEffect
            {
                BlurRadius  = 5,
                ShadowDepth = 0
            };

            if (style == AlertStyle.Error)
            {
                border.Background = new SolidColorBrush(Colors.Red);
                shadow.Color      = Colors.Red;
            }
            if (style == AlertStyle.Info)
            {
                shadow.Color      = Colors.LawnGreen;
                border.Background = new SolidColorBrush(Colors.LawnGreen);
            }
            if (style == AlertStyle.Warinng)
            {
                shadow.Color      = Colors.DodgerBlue;
                border.Background = new SolidColorBrush(Colors.DodgerBlue);
            }

            border.Effect = shadow;
            var borderGrid = new Grid();

            borderGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            borderGrid.RowDefinitions.Add(new RowDefinition());
            var txt1 = new TextBlock
            {
                Margin     = new Thickness(5, 5, 0, 0),
                FontFamily = new FontFamily("Webdings"),
                FontSize   = 10,
                Foreground = new SolidColorBrush(Colors.White),
                Text       = "i"
            };

            Grid.SetRow(txt1, 0);

            var txt2 = new TextBlock
            {
                Margin              = new Thickness(0, 5, 5, 0),
                FontFamily          = new FontFamily("Webdings"),
                HorizontalAlignment = HorizontalAlignment.Right,
                FontSize            = 10,
                Foreground          = new SolidColorBrush(Colors.White),
                Text = "r"
            };

            Grid.SetRow(txt2, 0);

            var txtWarn = new TextBlock
            {
                Margin       = new Thickness(5),
                FontSize     = 13,
                Foreground   = new SolidColorBrush(Colors.White),
                TextTrimming = TextTrimming.CharacterEllipsis,
                TextWrapping = TextWrapping.Wrap,
                Text         = text,
                ToolTip      = text
            };

            Grid.SetRow(txtWarn, 1);

            var sbArr = CreateAnimation(border);

            txt2.MouseDown     += (o, e) => { sbArr[1]?.Begin(); txt2.IsEnabled = false; };
            sbArr[1].Completed += (o, e) =>
            {
                sbArr[0]?.Stop();
                sbArr[1]?.Stop();
                sbArr[0] = null;
                sbArr[1] = null;
                _grid.Children.Remove(border);
            };
            borderGrid.Children.Add(txt1);
            borderGrid.Children.Add(txt2);
            borderGrid.Children.Add(txtWarn);
            border.Child = borderGrid;
            return(border);
        }
Пример #15
0
 public void ShowAlert(string message, string title = null, AlertStyle style = AlertStyle.Ok, Action okAction = null, Action cancelAction = null)
 {
     throw new NotImplementedException();
 }
Пример #16
0
 public IAlertFluent Danger()
 {
     _style = AlertStyle.Danger;
     return(new AlertFluent(this));
 }
Пример #17
0
 /// <summary>
 /// Sets the display style to Warning
 /// </summary>
 /// <returns></returns>
 public IAlertBoxFluentOptions Warning()
 {
     alertStyle = AlertStyle.Warning;
     return new AlertBoxFluentOptions(this);
 }
Пример #18
0
 public IAlertFluent Info()
 {
     _style = AlertStyle.Info;
     return(new AlertFluent(this));
 }
Пример #19
0
 /// <summary>
 /// Sets the display style to Success
 /// </summary>
 public IAlertBoxFluentOptions Success()
 {
     alertStyle = AlertStyle.Success;
     return new AlertBoxFluentOptions(this);
 }
Пример #20
0
 /// <summary>
 /// Sets the display style to Info
 /// </summary>
 /// <returns></returns>
 public IAlertBoxFluentOptions Info()
 {
     alertStyle = AlertStyle.Info;
     return new AlertBoxFluentOptions(this);
 }
Пример #21
0
 public IAlertFluent Success()
 {
     _style = AlertStyle.Success;
     return(new AlertFluent(this));
 }
Пример #22
0
 public IAlertFluent Warning()
 {
     _style = AlertStyle.Warning;
     return(new AlertFluent(this));
 }
Пример #23
0
 private void ShowMessage(string message, AlertStyle alertStyle)
 {
     MessageLabel.Text     = message;
     MessagePanel.CssClass = $"alert alert-{alertStyle} alert-dismissible";
     MessagePanel.Visible  = true;
 }