Пример #1
0
        /// <summary>
        /// Clears the status of a channels category.
        /// </summary>
        /// <remarks>
        /// Does not send a ClearStatus, if this was sent already previously.
        /// </remarks>
        /// <param name="channel">The channel.</param>
        /// <param name="sender">The sender.</param>
        /// <param name="category">The category.</param>
        public static void ClearStatus(string channel, object sender, string category)
        {
            var lastStatus = GetChannelStatus(channel);

            if (lastStatus == null || !lastStatus.ClearStatus)
            {
                SetChannelStatus(channel, sender, StatusUpdateEventArgs.CreateClearStatusEventArgs(category));
            }
        }
Пример #2
0
        /// <summary>
        /// Sets the current channel status.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="status">The <see cref="StatusUpdateEventArgs"/> instance containing the event data.</param>
        private static void SetChannelStatus(string channel, object sender, StatusUpdateEventArgs status)
        {
            if (!LastChanneledStatus.ContainsKey(channel))
            {
                LastChanneledStatus.Add(channel, status);
            }
            else
            {
                LastChanneledStatus[channel] = status;
            }

            var evt = GetChannel(channel);

            if (evt != null)
            {
                evt(sender, status);
            }
        }
Пример #3
0
 /// <summary>
 /// Updates the status data.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="sender">The sender.</param>
 /// <param name="data">The data.</param>
 public static void UpdateStatusData(string channel, object sender, object data)
 {
     SetChannelStatus(channel, sender, StatusUpdateEventArgs.CreateDataStatusEventArgs(data));
 }
Пример #4
0
 /// <summary>
 /// Updates the status text.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="sender">The sender.</param>
 /// <param name="statusCategory">The status category.</param>
 /// <param name="statusText">The status text.</param>
 public static void UpdateStatusText(string channel, object sender, string statusCategory, string statusText)
 {
     SetChannelStatus(channel, sender, StatusUpdateEventArgs.CreateStatusUpdateEventArgs(statusCategory, statusText));
 }
Пример #5
0
 /// <summary>
 /// Shows the progress.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="sender">The sender.</param>
 /// <param name="percent">The percent.</param>
 public static void ShowProgress(string channel, object sender, double percent)
 {
     SetChannelStatus(channel, sender, StatusUpdateEventArgs.CreatePercentStatusEventArgs(percent));
 }
Пример #6
0
 /// <summary>
 /// Signals the idle status of the sender.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="sender">The sender.</param>
 public static void SignalIdle(string channel, object sender)
 {
     SetChannelStatus(channel, sender, StatusUpdateEventArgs.CreateIdleStatusEventArgs());
 }
Пример #7
0
        /// <summary>
        /// Called by the <see cref="StatusTextBroker"/> when the status of the channel has been updated
        /// </summary>
        /// <remarks>
        /// The channel is NOT updated if the owning dispatcher is currently being shut down.
        /// </remarks>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="StatusUpdateEventArgs"/> instance containing the event data.</param>
        internal void OnStatusUpdate(object sender, StatusUpdateEventArgs e)
        {
            if (this.myDispatcher.HasShutdownStarted)
            {
                return;
            }

            //Helper.DispatcherHelper.InvokeIfRequired(this.myDispatcher, () =>
            //    {
            switch (e.StatusUpdateType)
            {
            case StatusUpdateType.UpdateStatusText:
                if (string.IsNullOrEmpty(e.Category))
                {
                    if (e.ClearStatus)
                    {
                        this.StatusText = this.NoStatusText;
                    }
                    else
                    {
                        this.StatusText = e.StatusText;
                    }
                }
                else
                {
                    if (e.ClearStatus)
                    {
                        this.CategoryStatusText[e.Category] = this.NoStatusText;
                    }
                    else
                    {
                        this.CategoryStatusText[e.Category] = e.StatusText;
                    }

                    this.OnPropertyChanged("CategoryStatusText");
                }
                break;

            case StatusUpdateType.UpdateBusyIdle:
                this.IsBusy = e.IsBusy;
                if (this.isBusy)
                {
                    this.SignalBusy(sender);
                }
                else
                {
                    this.SignalIdle(sender);
                }

                break;

            case StatusUpdateType.UpdatePercent:
                this.Percent = e.Percent;
                break;
            }

            // Das Ereignis auch weiterleiten (wobei der ursprüngliche sender behalten wird!)

            Helper.DispatcherHelper.InvokeOnAppDispatcher(() =>
            {
                if (this.StatusUpdated != null)
                {
                    this.StatusUpdated(sender, e);
                }
            });
            //});
        }