コード例 #1
0
 public void Log(String toLog, LogMode logMode, AlertMode alertMode, String msg = null, String userDirectory = null)
 {
     worker.Enqueue(() =>
     {
         ReLog(toLog, logMode, alertMode);
     }, reseter);
 }
コード例 #2
0
        private static void OnModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != e.OldValue)
            {
                AlertMode       mode  = (AlertMode)e.NewValue;
                SolidColorBrush brush = null;
                switch (mode)
                {
                case AlertMode.Accent:
                    brush = Application.Current.Resources["SystemAccentColor"] as SolidColorBrush;
                    break;

                case AlertMode.Success:
                    brush = Application.Current.Resources["PrimaryBrush"] as SolidColorBrush;
                    break;

                case AlertMode.Warning:
                    brush = Application.Current.Resources["WarningBrush"] as SolidColorBrush;
                    break;

                case AlertMode.Danger:
                    brush = Application.Current.Resources["DangerBrush"] as SolidColorBrush;
                    break;
                }
                var control = d as Alert;
                control.BorderBrush = brush;
                var backgroundBrush = new SolidColorBrush(brush.Color)
                {
                    Opacity = .1
                };
                control.Background = backgroundBrush;
            }
        }
コード例 #3
0
 public void Log(Exception toLog, LogMode logMode, AlertMode alertMode, String msg = null, String userDirectory = null)
 {
     worker.Enqueue(() =>
     {
         ReLog("Message: " + toLog.Message + "\nStacktrace: " + toLog.StackTrace, logMode, alertMode);
     }, reseter);
 }
コード例 #4
0
    protected override void OnOpened()
    {
        base.OnOpened();
        UIAlertBoxContext tContext = _context as UIAlertBoxContext;

        if (tContext == null)
        {
            _mode = AlertMode.OkCancel;
            CloseSelf();
            return;
        }
        _mode           = tContext.mode;
        _content        = tContext.content;
        titleTxt.text   = tContext.title;
        contentTxt.text = tContext.content.Replace(" ", "\u00A0");;
        if (tContext.mode == AlertMode.Ok)
        {
            cancelBtn.gameObject.SetActive(false);
        }
        else
        {
            cancelBtn.gameObject.SetActive(true);
        }
        if (!string.IsNullOrEmpty(tContext.okBtnContent))
        {
            okBtnTxt.text = tContext.okBtnContent;
        }
        if (!string.IsNullOrEmpty(tContext.cancelBtnContent))
        {
            cancelBtnTxt.text = tContext.cancelBtnContent;
        }
    }
コード例 #5
0
ファイル: DialogView.xaml.cs プロジェクト: Nootus/Fabric
        private void InitializeAlertToast(AlertMode mode, string message)
        {
            InitializeDialog();
            HideAllStacks();
            AlertStack.IsVisible = true;
            switch (mode)
            {
            case AlertMode.Error:
                AlertIcon.Source       = SvgIcon.GetSvgImageSource("Kheling.Mobile.Resources.error.svg", 32, 32, Color.Red);
                AlertMessage.TextColor = Color.Red;
                break;

            case AlertMode.Warning:
                AlertIcon.Source       = SvgIcon.GetSvgImageSource("Kheling.Mobile.Resources.warning.svg", 32, 32, Color.Yellow);
                AlertMessage.TextColor = Color.Black;
                break;

            case AlertMode.Info:
                AlertIcon.Source       = SvgIcon.GetSvgImageSource("Kheling.Mobile.Resources.info.svg", 32, 32, Color.Green);
                AlertMessage.TextColor = Color.Black;
                break;
            }

            AlertMessage.Text = message;
        }
コード例 #6
0
ファイル: Logger.cs プロジェクト: antoinecronier/C-Lessons
 private void UpdateDatas(LogMode logMode, AlertMode alertMode, object data, bool haveToBeSend, string path)
 {
     this.logMode      = logMode;
     this.haveToBeSend = haveToBeSend;
     this.path         = path;
     this.alertMode    = alertMode;
     this.data         = data;
 }
コード例 #7
0
 public UIAlertBoxContext(string title, string content, AlertMode mode, string okContent = "", string cancelContent = "")
 {
     this.title       = title;
     this.content     = content;
     this.mode        = mode;
     okBtnContent     = okContent;
     cancelBtnContent = cancelContent;
 }
コード例 #8
0
ファイル: DialogService.cs プロジェクト: Nootus/Fabric
        public async void DisplayToast(AlertMode mode, string message)
        {
            dialogView.InitializeToast(mode, message);
            dialog.Window.ClearFlags(WindowManagerFlags.DimBehind);
            dialog.Show();
            await Task.Delay(2000);

            Hide();
        }
コード例 #9
0
 public Logger2(string name = "Logger", LogMode logMode = LogMode.NONE, AlertMode alertMode = AlertMode.NONE)
 {
     this.name      = name + ": ";
     this.logMode   = logMode;
     this.alertMode = alertMode;
     reseter        = new ManualResetEvent(false);
     worker         = new CommandWorker(this.name);
     worker.Start();
 }
コード例 #10
0
ファイル: UIManager.cs プロジェクト: hjj0416/Demo
    public void Alert(string title, string msg, AlertMode mode, Action <AlertResult> cb = null)
    {
        UIAlertBoxContext context = new UIAlertBoxContext(title, msg, mode);

        Instance.ShowWindow(WindowID.UIAlertBox, context, (w) =>
        {
            UIAlertBox win = w as UIAlertBox;
            win.OnCommit   = cb;
        });
    }
コード例 #11
0
        private void ReLog(string toLog, LogMode logMode, AlertMode alertMode)
        {
            AlertMode tempAlert = this.alertMode;
            LogMode   tempLog   = this.logMode;

            this.alertMode = alertMode;
            this.logMode   = logMode;
            this.Log(toLog);
            this.alertMode = tempAlert;
            this.logMode   = tempLog;
        }
コード例 #12
0
 public static void AddResultAlert(this IDictionary <string, object> data, AlertMode mode, Result result, string returnUrl = null,
                                   string returnText = null, string cancelUrl = null, string cancelText = null)
 {
     if (result.Success)
     {
         data.AddAlert(mode, AlertType.Success, result.Message, null, returnUrl, returnText, cancelUrl, cancelText);
     }
     else
     {
         data.AddAlert(mode, AlertType.Error, result.Message);
     }
 }
        protected internal virtual async Task <string> GetHeadingAsync(AlertMode mode)
        {
            await Task.CompletedTask;

            return(mode switch
            {
                AlertMode.Danger => "Error",
                AlertMode.Info => "Information",
                AlertMode.Success => "Confirmation",
                AlertMode.Warning => "Warning",
                _ => "Unknown"
            });
コード例 #14
0
ファイル: Logger.cs プロジェクト: antoinecronier/C-Lessons
        public void Log(object msg, LogMode logMode = LogMode.NONE, AlertMode alertMode = AlertMode.NONE, object data = null, Boolean haveToBeSend = false, String path = "")
        {
            LogMode   logModeBkp      = this.logMode;
            Boolean   haveToBeSendBkp = this.haveToBeSend;
            String    pathBkp         = this.path;
            AlertMode alertModeBkp    = this.alertMode;
            object    dataBkp         = this.data;

            UpdateDatas(logMode, alertMode, data, haveToBeSend, path);
            Log(msg);
            UpdateDatas(logModeBkp, alertModeBkp, dataBkp, haveToBeSendBkp, pathBkp);
        }
コード例 #15
0
ファイル: Logger.cs プロジェクト: antoinecronier/C-Lessons
 public Logger(string tag = "Logger", LogMode logMode = LogMode.NONE, AlertMode alertMode = AlertMode.NONE, object data = null, Boolean haveToBeSend = false, String path = "")
 {
     this.tag          = tag;
     this.logMode      = logMode;
     this.haveToBeSend = haveToBeSend;
     this.path         = path;
     this.alertMode    = alertMode;
     this.data         = data;
     commandWorker     = new CommandWorker("Logger");
     commandWorker.Start();
     manualResetEvent = new ManualResetEvent(false);
     cancellationTS   = new CancellationTokenSource();
     locker           = new object();
     Console(INIT);
 }
コード例 #16
0
        public static void AddAlert(this IDictionary <string, object> data, AlertMode mode, AlertType type,
                                    string message, string title = null, string returnUrl = null,
                                    string returnText            = null, string cancelUrl = null, string cancelText = null)
        {
            var alerts = data.TryGetValue(AlertDataKey, out object alertsJson) ? alertsJson.ToString().ToJsonObject <List <Alert> >() : new List <Alert>();

            alerts.Add(new Alert()
            {
                Mode       = mode,
                Type       = type,
                Message    = message,
                Title      = title,
                ReturnUrl  = returnUrl,
                ReturnText = returnText,
                CancelUrl  = cancelUrl,
                CancelText = cancelText
            });

            data[AlertDataKey] = alerts.ToJsonString();
        }
コード例 #17
0
        public void Log(String toLog, String msg = null, String userDirectory = null)
        {
            if (msg == null)
            {
                msg = toLog;
            }

            if (userDirectory == null)
            {
                userDirectory = Path.GetTempPath() + "\\" +
                                Application.Current.ToString().Split('.')[0];
            }

            switch (this.LogMode)
            {
            case LogMode.NONE:
                break;

            case LogMode.CONSOLE:
                Console.WriteLine(msg);
                break;

            case LogMode.EXTERNAL:
                SaveToFile(toLog, userDirectory);
                break;

            case LogMode.CURRENT_FOLDER:
                SaveToFile(toLog, AppDomain.CurrentDomain.BaseDirectory);
                break;

            case LogMode.TEMP_FOLDER:
                String directory = Path.GetTempPath() + "\\" +
                                   Application.Current.ToString().Split('.')[0];
                SaveToFile(toLog, directory);
                break;

            default:
                break;
            }

            switch (this.AlertMode)
            {
            case AlertMode.NONE:
                break;

            case AlertMode.CONSOLE:
                break;

            case AlertMode.MESSAGE_BOX:
                //MessageBox.Show(msg);
                MessageBoxResult result = MessageBox.Show(msg, "Attention", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (result == MessageBoxResult.Yes)
                {
                    this.AlertMode = AlertMode.NONE;
                    LogMode temp = this.LogMode;
                    this.LogMode = LogMode.CURRENT_FOLDER;
                    this.Log(toLog);
                    this.AlertMode = AlertMode.MESSAGE_BOX;
                    this.LogMode   = temp;
                }
                break;

            default:
                break;
            }
        }
コード例 #18
0
 public void HighAlert()
 {
     CancelCountdown();
     this.currentMode = AlertMode.HIGH_ALERT;
 }
コード例 #19
0
 public void Alerted()
 {
     CancelCountdown();
     this.currentMode = AlertMode.ALERTED;
     countdown        = StartCoroutine("StartCountdown");
 }
コード例 #20
0
ファイル: DialogService.cs プロジェクト: Nootus/Fabric
 public void DisplayAlert(AlertMode mode, string message)
 {
     dialogView.InitializeAlert(mode, message);
     dialog.Window.AddFlags(WindowManagerFlags.DimBehind);
     dialog.Show();
 }
コード例 #21
0
 public void Patrol()
 {
     this.currentMode = AlertMode.PATROLLING;
 }
        protected internal virtual async Task <Alert> CreateAlertAsync(string information, AlertMode mode, string heading = null, IEnumerable <string> details = null)
        {
            var alert = await Task.FromResult(new Alert
            {
                Heading     = heading ?? await this.GetHeadingAsync(mode),
                Information = information,
                Mode        = mode
            });

            foreach (var item in details ?? Enumerable.Empty <string>())
            {
                alert.Details.Add(item);
            }

            return(alert);
        }
コード例 #23
0
 public Logger(LogMode logMode, AlertMode alertMode)
 {
     this.logMode   = logMode;
     this.alertMode = alertMode;
 }
コード例 #24
0
ファイル: DialogView.xaml.cs プロジェクト: Nootus/Fabric
 public void InitializeToast(AlertMode mode, string message)
 {
     ParentStack.VerticalOptions = new LayoutOptions(LayoutAlignment.End, true);
     AlertButton.IsVisible       = false;
     InitializeAlertToast(mode, message);
 }