Пример #1
0
 protected void InvokeStatusChanged()
 {
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(this, new EventArgs());
     }
 }
Пример #2
0
        public void ResumeLoggingIfApplicable()
        {
            CheckDisposed();
            object loggingEnabled;

            if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME, out loggingEnabled) == false)
            {
                ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true;
                loggingEnabled = ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME];
            }

            if (loggingEnabled is bool && (bool)loggingEnabled == true)
            {
                StartLogging();
            }

            object LogFileGeneratedBeforeSuspendObject;

            if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME, out LogFileGeneratedBeforeSuspendObject) && LogFileGeneratedBeforeSuspendObject != null && LogFileGeneratedBeforeSuspendObject is string)
            {
                if (StatusChanged != null)
                {
                    StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGeneratedAtSuspend, (string)LogFileGeneratedBeforeSuspendObject));
                }
                ApplicationData.Current.LocalSettings.Values[LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME] = null;
            }
        }
 private void UpdateStatus(string msg)
 {
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(msg);
     }
 }
Пример #4
0
 public void ChangeStatus(string status)
 {
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(status);
     }
 }
Пример #5
0
        /// <summary>
        /// Toggle the enabled/disabled status of logging.
        /// </summary>
        /// <returns>True if the resulting new status is enabled, else false for disabled.</returns>
        public bool ToggleLoggingEnabledDisabled()
        {
            CheckDisposed();

            IsBusy = true;

            try
            {
                bool enabled;
                if (session != null)
                {
                    session.Dispose();
                    session = null;
                    ApplicationData.Current.LocalSettings.Values["LoggingEnabled"] = false;
                    enabled = false;
                }
                else
                {
                    StartLogging();
                    ApplicationData.Current.LocalSettings.Values["LoggingEnabled"] = true;
                    enabled = true;
                }

                if (StatusChanged != null)
                {
                    StatusChanged.Invoke(this, new LoggingScenarioEventArgs(enabled));
                }

                return(enabled);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #6
0
 protected void StatusOnChanged(PedidoEventArgs e)
 {
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(this, e);
     }
 }
        /// <summary>
        /// This is called when the app is either resuming or starting.
        /// It will enable logging if the app has never been started before
        /// or if logging had been enabled the last time the app was running.
        /// </summary>
        public void ResumeLoggingIfApplicable()
        {
            CheckDisposed();

            object loggingEnabled;

            if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGGING_ENABLED_SETTING_KEY_NAME, out loggingEnabled) == false)
            {
                ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true;
                loggingEnabled = ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME];
            }

            if (loggingEnabled is bool && (bool)loggingEnabled == true)
            {
                StartLogging();
            }

            // When the sample suspends, it retains state as to whether or not it had
            // generated a new log file at the last suspension. This allows any
            // UI to be updated on resume to reflect that fact.
            object LogFileGeneratedBeforeSuspendObject;

            if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGFILEGEN_BEFORE_SUSPEND_SETTING_KEY_NAME, out LogFileGeneratedBeforeSuspendObject) &&
                LogFileGeneratedBeforeSuspendObject != null &&
                LogFileGeneratedBeforeSuspendObject is string)
            {
                if (StatusChanged != null)
                {
                    StatusChanged.Invoke(this,
                                         new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGeneratedAtSuspend,
                                                                      (string)LogFileGeneratedBeforeSuspendObject));
                }
                ApplicationData.Current.LocalSettings.Values[LOGFILEGEN_BEFORE_SUSPEND_SETTING_KEY_NAME] = null;
            }
        }
Пример #8
0
 protected virtual void OnStatusChanged()
 {
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(this, EventArgs.Empty);
     }
 }
Пример #9
0
        public void AddCode(string key, string status)
        {
            var existed = _codes.Find(item => item.Code == key);

            if (existed != null)
            {
                existed.LastEditTime = GetTime();
                existed.Status       = status;
                if (StatusChanged != null)
                {
                    StatusChanged.Invoke(null, new CodeInfoEventArgs {
                        Code = existed.Code, Status = status
                    });
                }
            }
            else
            {
                _codes.Add(new CodeInfo {
                    Code = key, Status = status, LastEditTime = GetTime()
                });
            }
            var sorted = _codes.OrderByDescending(item => item.LastEditTime).ToList();

            _codes = sorted;
            CheckTooMuchCodes();
        }
Пример #10
0
 private void OnModuleFileChanged(FileSystemWatcher w)
 {
     this.Status = this.CheckItemStatus();
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(this, new ModuleStatusEventArgs(this.Status));
     }
 }
Пример #11
0
 public static void RaiseStatusEvent(string msg)
 {
     //Console.WriteLine(_statusMessage);
     if (StatusChanged != null)
     {
         StatusChanged.Invoke(null, new StatusChangedEventArgs(msg));
     }
 }
Пример #12
0
        private async void LogFileGenerateHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args)
        {
            StorageFolder sampleAppDefinedLogFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(APP_LOG_FILE_FOLDER_NAME, CreationCollisionOption.OpenIfExists);

            string newLogFileName = "Log-" + GetTimeStamp() + ".etl";
            await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName);

            if (IsPreparingForSuspend == false)
            {
                if (StatusChanged != null)
                {
                    string newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, newLogFileName);
                    StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGenerated, newLogFileFullPathName));
                }
            }
        }
Пример #13
0
        /// <summary>
        /// This handler is called by the FileLoggingSession instance when a log
        /// file reaches a size of 256MB. When FileLoggingSession calls this handler,
        /// it's effectively giving the developer a chance to own the log file.
        /// </summary>
        /// <param name="sender">The IFileLoggingSession to the session which has generated a new file.</param>
        /// <param name="args">The LogFileGeneratedEventArgs instance which contains a StorageFile field LogFileGeneratedEventArgs.File representing the new log file.</param>
        private async void LogFileGeneratedHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args)
        {
            LogFileGeneratedCount++;
            StorageFolder sampleAppDefinedLogFolder =
                await ApplicationData.Current.LocalFolder.CreateFolderAsync(OUR_SAMPLE_APP_LOG_FILE_FOLDER_NAME,
                                                                            CreationCollisionOption.OpenIfExists);

            string newLogFileName = string.Format("{0}-{1}.etl", LOG_FILE_BASE_FILE_NAME, GetTimeStamp());
            await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName);

            if (IsPreparingForSuspend == false)
            {
                if (StatusChanged != null)
                {
                    string newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, newLogFileName);
                    StatusChanged.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGenerated, newLogFileFullPathName));
                }
            }
        }
Пример #14
0
    public void SetStatus(Status status, TargetedAction action)
    {
        Current = status;

        if (Current == Status.None && _statusEffect != null)
        {
            Destroy(_statusEffect.gameObject);
        }
        else if (action != null)
        {
            _statusEffect = action;
            _statusEffect.SetReciever(_character);
        }

        if (StatusChanged != null)
        {
            StatusChanged.Invoke(new StatusChangeEvent(_character, status));
        }
    }
Пример #15
0
        public async Task <bool> ToggleLoggingEnabledDisabledAsync()
        {
            CheckDisposed();
            IsBusy = true;

            try
            {
                bool enabled;

                if (session != null)
                {
                    string finalLogFilePath = await CloseSessionSaveFinalLogFile();

                    session.Dispose();
                    session = null;
                    if (StatusChanged != null)
                    {
                        StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGeneratedAtDisable, finalLogFilePath));
                    }
                    ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = false;
                    enabled = false;
                }

                else
                {
                    StartLogging();
                    ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true;
                    enabled = true;
                }

                if (StatusChanged != null)
                {
                    StatusChanged.Invoke(this, new FileLogEventArgs(enabled));
                }

                return(enabled);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #16
0
        } // ShowSettingsEditor

        #region Events

        protected virtual void OnStatusChanged(object sender, ListStatusChangedEventArgs e)
        {
            StatusChanged?.Invoke(sender, e);
        } // OnStatusChanged
Пример #17
0
        public bool PlayerControl(Keys keyData)
        {
            switch (keyData)
            {
            case Keys.Left:
                if (PositionX > 50)
                {
                    PositionX     -= 10;
                    changePosition = true;
                }
                else
                {
                    changePosition = false;
                }
                break;

            case Keys.Up:
                if (PositionY > 45)
                {
                    PositionY     -= 10;
                    changePosition = true;
                }
                else
                {
                    changePosition = false;
                }
                break;

            case Keys.Right:
                if (PositionX + 50 < (form.ClientSize.Width - 50))
                {
                    PositionX     += 10;
                    changePosition = true;
                }
                else
                {
                    changePosition = false;
                }
                break;

            case Keys.Down:
                if (PositionY + 50 < (form.ClientSize.Height - 45))
                {
                    PositionY     += 10;
                    changePosition = true;
                }
                else
                {
                    changePosition = false;
                }
                break;

            case Keys.Escape:

            default:
                changePosition = false;
                break;
            }
            if (changedLocalPLayer != null)
            {
                changedLocalPLayer.Invoke();
            }

            if (changePosition)
            {
                SendChange();
            }

            return(changePosition);
        }
Пример #18
0
 protected virtual void OnStatusChanged(EventArgs args)
 {
     StatusChanged?.Invoke(this, args);
 }
Пример #19
0
 private void OnStatusChanged()
 {
     StatusChanged?.Invoke(this, EventArgs.Empty);
 }
Пример #20
0
 private void ConnectionStatusChanged(object sender, string s)
 {
     StatusChanged?.Invoke(this, s);
 }
Пример #21
0
 public void SendEventMessage(LogAdpType adapterType, string message)
 {
     StatusChanged?.Invoke(adapterType, message);
 }
Пример #22
0
 /// <summary>
 /// Raises <see cref="StatusChanged"/> event.
 /// </summary>
 protected void OnStatusChanged()
 {
     StatusChanged?.Invoke(this);
     OnWorkerResourcesChanged(WorkerResource.Status, increased: Status == WorkerNodeStatus.Running);
 }
Пример #23
0
 /// <summary>
 /// Evento que notifica a mudança de status
 /// </summary>
 /// <param name="_par_objEventArgs">Argumentos do evento</param>
 public static void OnStatusChanged(StatusChangedEventArgs _par_objEventArgs)
 {
     StatusChanged?.Invoke(null, _par_objEventArgs);
 }
Пример #24
0
 public override void Stop()
 {
     StatusChanged.Invoke(this, false);
     _dumpFile = null;
 }
Пример #25
0
 // This is called when we want to raise the StatusChanged event
 public static void OnStatusChanged(string status)
 {
     StatusChanged.Invoke(status);
 }
Пример #26
0
        public override void Start()
        {
            _dumpFile = new System.IO.StreamReader(_filePath);

            StatusChanged.Invoke(this, true);
        }
Пример #27
0
        /// <summary>
        /// The logging scenario. Log messages in a loop until 3 log files are created.
        /// </summary>
        /// <returns>The task.</returns>
        public async Task DoScenarioAsync()
        {
            CheckDisposed();

            IsBusy = true;

            try
            {
                await Task.Run(async() =>
                {
                    const int NUMBER_OF_LOG_FILES_TO_GENERATE = 3;
                    int messageIndex   = 0;
                    int lastDelay      = 0;
                    int lastAppError   = 0;
                    int startFileCount = LogFileGeneratedCount;

                    //
                    // Log large messages until the current log file hits the maximum size.
                    // When the current log file reaches its maximum size, LogFileGeneratedHandler
                    // will be called.
                    //

                    while (LogFileGeneratedCount - startFileCount < NUMBER_OF_LOG_FILES_TO_GENERATE)
                    {
                        try
                        {
                            // Since the channel is added to the session at level Warning,
                            // the following is logged because it is logged at level LoggingLevel.Critical.
                            channel.LogMessage(
                                string.Format("Message={0}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ligula nisi, vehicula nec eleifend vel, rutrum non dolor. Vestibulum ante ipsum " +
                                              "primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur elementum scelerisque accumsan. In hac habitasse platea dictumst.",
                                              ++messageIndex),
                                LoggingLevel.Critical);

                            // Since the channel is added to the session at level Warning,
                            // the following is *not* logged because it is logged at LoggingLevel.Information.
                            channel.LogMessage(
                                string.Format("Message={0}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ligula nisi, vehicula nec eleifend vel, rutrum non dolor. Vestibulum ante ipsum " +
                                              "primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur elementum scelerisque accumsan. In hac habitasse platea dictumst.",
                                              ++messageIndex),
                                LoggingLevel.Information);

                            int value = 1000000;                                                                                          // one million, 7 digits, 4-bytes as an int, 14 bytes as a wide character string.
                            channel.LogMessage("Value #" + (++messageIndex).ToString() + "  " + value.ToString(), LoggingLevel.Critical); // value is logged as 14 byte wide character string.
                            channel.LogValuePair("Value #" + (++messageIndex).ToString(), value, LoggingLevel.Critical);                  // value is logged as a 4-byte integer.

                            //
                            // Pause every once in a while to simulate application
                            // activity outside of logging.
                            //

                            if (messageIndex - lastDelay > 100)
                            {
                                lastDelay = messageIndex;
                                await Task.Delay(10);
                            }

                            //
                            // Every once in a while, simulate an application error
                            // which causes the app to save the current snapshot
                            // of logging events in memory to a disk ETL file.
                            //

                            if (messageIndex - lastAppError >= 25000)
                            {
                                lastAppError = messageIndex;

                                // Before simulating an application error, demonstrate LoggingActivity.
                                // A LoggingActivity outputs a pair of begin and end messages to the channel.
                                using (new LoggingActivity("Add two numbers.", channel, LoggingLevel.Critical))
                                {
                                    int oneNumber     = 100;
                                    int anotherNumber = 200;
                                    int total         = oneNumber + anotherNumber;
                                    channel.LogMessage(string.Format("Message={0}: The result of adding two numbers: {1}", ++messageIndex, total), LoggingLevel.Critical);
                                } // The LoggingActivity instance will log the second message at this scope exit.

                                // Simulate an application error.
                                throw new AppException("Some bad app error occurred.");
                            }
                        }
                        catch (AppException e)
                        {
                            // Log the exception string.
                            channel.LogMessage("Exception occurrred: " + e.ToString(), LoggingLevel.Error);

                            // Save the memory log buffer to file.
                            Task <string> op = SaveLogInMemoryToFileAsync();
                            op.Wait();
                            if (op.IsFaulted)
                            {
                                throw new Exception("After an app error occurred, there was a failure to save the log file.", op.Exception);
                            }
                            LogFileGeneratedCount++;
                            // For the sample, update the UI to show a log file has been generated.
                            if (StatusChanged != null)
                            {
                                StatusChanged.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGenerated, op.Result));
                            }
                        }
                    }
                });
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #28
0
 private void OnStatusValueChaned(string value)
 {
     StatusChanged?.Invoke(this, new ParserEventArgs(value));
 }
Пример #29
0
 protected virtual void OnStatusChanged()
 {
     StatusChanged?.Invoke(this, EventArgs.Empty);
 }
 protected virtual void OnStatusChanged(StatusChangedEventArgs e)
 {
     StatusChanged?.Invoke(this, e);
 }