Esempio n. 1
0
        public static void ToGingerHelper(eGingerHelperMsgKey messageKey, object btnHandler = null, params object[] messageArgs)
        {
            GingerHelperMsg messageToShow     = null;
            string          messageContent    = string.Empty;
            string          orgMessageContent = string.Empty;

            try
            {
                // TODO: use TryGet

                //get the message from pool
                if ((GingerHelperMsgsPool != null) && GingerHelperMsgsPool.Keys.Contains(messageKey))
                {
                    messageToShow = GingerHelperMsgsPool[messageKey];
                }
                if (messageToShow == null)
                {
                    // We do want to pop the error message so below is just in case...
                    string mess = "";
                    foreach (object o in messageArgs)
                    {
                        mess += o.ToString() + " ";
                    }
                    ToUser(eUserMsgKeys.StaticErrorMessage, "Cannot find MessageKey: " + messageKey);
                    ToLog(eLogLevel.WARN, "The Ginger Helper message with key: '" + messageKey + "' was not found! and won't show to the user!");
                }
                orgMessageContent = messageToShow.MsgContent;
                //enter message args if exist
                if (messageArgs.Length > 0)
                {
                    messageToShow.MsgContent = string.Format(messageToShow.MsgContent, messageArgs);
                }

                if (CurrentAppLogLevel == eAppReporterLoggingLevel.Debug)
                {
                    ToLog(eLogLevel.INFO, "Showing User Message (GingerHelper): " + messageContent);
                }
                else if (AddAllReportingToConsole)
                {
                    ToConsole(eLogLevel.DEBUG, "Showing User Message (GingerHelper): " + messageContent);
                }

                mLastStatusTime.Start();
                WorkSpaceReporter.ToStatus(messageToShow.MessageType, orgMessageContent);
            }
            catch (Exception ex)
            {
                ToLog(eLogLevel.ERROR, "Failed to show the Ginger Helper message with the key: " + messageKey, ex);
            }
        }
Esempio n. 2
0
        public static void HideStatusMessage()
        {
            if (bClosing)
            {
                return;
            }
            bClosing = true;

            Task t = new Task(() => {
                while (mLastStatusTime.ElapsedMilliseconds < 1000)  // let the message show for at least one second
                {
                    Task.Delay(100);
                }
                WorkSpaceReporter.ToStatus(eStatusMsgType.INFO, null);
                mLastStatusTime.Reset();
                bClosing = false;
            });

            t.Start();
        }
Esempio n. 3
0
 private static void HideMessage_Event(object sender, ElapsedEventArgs e)
 {
     WorkSpaceReporter.ToStatus(eStatusMsgType.INFO, null);
     mLastStatusTime.Reset();
     bClosing = false;
 }