Пример #1
0
        public void ShowConfirmationMessage(string message,
                                            Action yesConfirmation           = null,
                                            Action noConfirmation            = null,
                                            Action close                     = null,
                                            SolidColorBrush yesButtonColor   = null,
                                            SolidColorBrush noButtonColor    = null,
                                            string yesButtonText             = "",
                                            string noButtonText              = "",
                                            bool isYesButtonEnabled          = true,
                                            bool isNoButtonEnabled           = true,
                                            string thirdButtonText           = "",
                                            bool isThirdButtonVisible        = false,
                                            Action thirdButtonCommand        = null,
                                            SolidColorBrush thirdButtonColor = default(SolidColorBrush))
        {
            if (yesButtonText == "")
            {
                yesButtonText = ApplicationConstants.Yes;
            }
            if (noButtonText == "")
            {
                noButtonText = ApplicationConstants.No;
            }
            if (yesButtonColor == null)
            {
                yesButtonColor = ApplicationConstants.ButtonConfirmationColor;
            }
            if (noButtonColor == null)
            {
                noButtonColor = ApplicationConstants.ButtonWarningColor;
            }

            if (!PopupService.IsPopupOpen)
            {
                _yesConfirmation   = null;
                _noConfirmation    = null;
                _closeConfirmation = null;

                if (yesConfirmation != null)
                {
                    _yesConfirmation = new YesConfirmation(yesConfirmation);
                }
                if (noConfirmation != null)
                {
                    _noConfirmation = new NoConfirmation(noConfirmation);
                }
                if (close != null)
                {
                    _closeConfirmation = new CloseConfirmation(close);
                }
                if (thirdButtonCommand != null)
                {
                    _thirdButtonCommand = new ThirdButtonCommand(thirdButtonCommand);
                }
                PopupService.IsPopupOpen = true;
                var messageStyler = new AlertMessageFormatter();
                var messageStyle  = messageStyler.CreateMessage(message);
                PopupService.Message        = messageStyle.Message;
                PopupService.Title          = messageStyle.Title;
                PopupService.YesButtonText  = yesButtonText;
                PopupService.NoButtonText   = noButtonText;
                PopupService.YesButtonColor = yesButtonColor;
                PopupService.NoButtonColor  = noButtonColor;
                if (thirdButtonColor == null)
                {
                    PopupService.ThirdButtonColor = ApplicationConstants.ButtonFooterColor;
                }
                else
                {
                    PopupService.ThirdButtonColor = thirdButtonColor;
                }
                PopupService.IsConfirmationPopupOpen            = true;
                PopupService.IsYesbuttonEnabled                 = isYesButtonEnabled;
                PopupService.IsNoButtonEnabled                  = isNoButtonEnabled;
                PopupService.PopupInstance.IsThirdButtonVisible = isThirdButtonVisible;
                PopupService.PopupInstance.ThirdButtonText      = thirdButtonText;

                PopupService.YesConfirmationCommand = new RelayCommand(() =>
                {
                    PopupService.IsConfirmationPopupOpen = false;
                    PopupService.IsPopupOpen             = false;
                    if (_yesConfirmation != null)
                    {
                        _yesConfirmation();
                    }
                });

                PopupService.NoConfirmationCommand = new RelayCommand(() =>
                {
                    PopupService.IsConfirmationPopupOpen = false;
                    PopupService.IsPopupOpen             = false;
                    if (_noConfirmation != null)
                    {
                        _noConfirmation();
                    }
                });

                PopupService.CloseCommand = new RelayCommand(() =>
                {
                    PopupService.IsConfirmationPopupOpen = false;
                    PopupService.IsPopupOpen             = false;
                    if (_closeConfirmation != null)
                    {
                        _closeConfirmation();
                    }
                });

                PopupService.ThirdButtonCommand = new RelayCommand(() =>
                {
                    PopupService.IsConfirmationPopupOpen = false;
                    PopupService.IsPopupOpen             = false;
                    if (_thirdButtonCommand != null)
                    {
                        _thirdButtonCommand();
                    }
                });
            }
        }
Пример #2
0
        public void ShowNotification(string message,
                                     Action func,
                                     Action close,
                                     SolidColorBrush okButtonColor = null,
                                     string okText          = "",
                                     bool isOkButtonEnabled = true)
        {
            PopupService.CarwashCode = "";
            lock (_lock)
            {
                if (okText == "")
                {
                    okText = ApplicationConstants.Ok;
                }

                if (okButtonColor == null)
                {
                    okButtonColor = ApplicationConstants.ButtonWarningColor;
                }
                if (!PopupService.IsPopupOpen)
                {
                    _okConfirmation    = null;
                    _closeConfirmation = null;
                    if (func != null)
                    {
                        _okConfirmation = new OkConfirmation(func);
                    }
                    if (close != null)
                    {
                        _closeConfirmation = new CloseConfirmation(close);
                    }

                    var messageStyler = new AlertMessageFormatter();
                    var messageStyle  = messageStyler.CreateMessage(message);
                    PopupService.Message           = messageStyle.Message;
                    PopupService.IsAlertPopupOpen  = true;
                    PopupService.Title             = messageStyle.Title;
                    PopupService.Continue          = okText;
                    PopupService.OkButtonColor     = okButtonColor;
                    PopupService.IsOkButtonEnabled = isOkButtonEnabled;
                    PopupService.IsPopupOpen       = true;

                    PopupService.OkCommand = new RelayCommand(() =>
                    {
                        PopupService.IsAlertPopupOpen = false;
                        PopupService.IsPopupOpen      = false;
                        if (_okConfirmation != null)
                        {
                            _okConfirmation();
                        }
                    });

                    PopupService.CloseCommand = new RelayCommand(() =>
                    {
                        PopupService.IsAlertPopupOpen = false;
                        PopupService.IsPopupOpen      = false;
                        if (_closeConfirmation != null)
                        {
                            _closeConfirmation();
                        }
                    });
                }
            }
        }