Exemplo n.º 1
0
        private void Api_OnStatusChanged(WechatAPIService sender, StatusChangedEvent e)
        {
            switch (sender.CurrentStatus)
            {
            case ClientStatusType.GetUUID:
                break;

            case ClientStatusType.GetQRCode:
                break;

            case ClientStatusType.Login:
                break;

            case ClientStatusType.QRCodeScaned:
                m_SyncContext.Post(UpdateInfo, "请在手机上点击\"登陆\"按钮");
                break;

            case ClientStatusType.WeixinInit:
                break;

            case ClientStatusType.SyncCheck:
                break;

            case ClientStatusType.WeixinSync:
                break;

            case ClientStatusType.None:
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Обновление статуса.
 /// </summary>
 /// <param name="statusEnum">Новое значение статуса.</param>
 public void UpdateStatus(ItemStatusEnum statusEnum, string comment = null)
 {
     if (Status == null || Status.StatusEnum != statusEnum)
     {
         Status = new ItemStatus(statusEnum, comment);
         StatusChangedEvent?.Invoke();
     }
 }
Exemplo n.º 3
0
 private void RaiseStatusChanged(ListenerStatus status)
 {
     if (Status != status)
     {
         Status = status;
         StatusChangedEvent?.Invoke(this, new StatusChangedEventArgs(Status));
     }
 }
Exemplo n.º 4
0
 public BusyCursor()
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         Interlocked.Increment(ref busyCount);
         StatusChangedEvent?.Invoke(this, EventArgs.Empty);
         Mouse.OverrideCursor = Cursors.Wait;
     });
 }
Exemplo n.º 5
0
 public BusyCursor()
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         Interlocked.Increment(ref BusyCount);
         StatusChangedEvent?.Invoke(null, EventArgs.Empty);
         Mouse.OverrideCursor = Cursors.Wait;
     });
 }
Exemplo n.º 6
0
        /// <summary>
        /// Event that is fired when the Process Status has changed.
        /// </summary>
        /// <param name="status"></param>
        protected virtual void OnStatusChangedEvent(string status)
        {
            var eventArgs = new ProcessChangedEventArgs
            {
                ProcessName = ProcessName,
                ProcessId   = _processId,
                Status      = status
            };

            StatusChangedEvent?.Invoke(this, eventArgs);
        }
Exemplo n.º 7
0
        public void Dispose()
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                Interlocked.Decrement(ref busyCount);
                StatusChangedEvent?.Invoke(this, EventArgs.Empty);

                if (busyCount == 0)
                {
                    Mouse.OverrideCursor = null;
                }
            });
        }
Exemplo n.º 8
0
        public void Dispose()
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                Interlocked.Decrement(ref BusyCount);
                StatusChangedEvent?.Invoke(null, EventArgs.Empty);

                if (BusyCount == 0)
                {
                    Mouse.OverrideCursor = null;
                }
            });
        }
Exemplo n.º 9
0
 private void OnStatusChanged(StatusChangedEvent e)
 {
     if (e != null && e.Statuses != null)
     {
         lock (statusLocker)
         {
             foreach (var newStatus in e.Statuses)
             {
                 var oldStatus = Statuses.FirstOrDefault(st => st.Equals(newStatus));
                 if (oldStatus != null)
                 {
                     oldStatus.Update(newStatus);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Sets the <see cref="IAuthableSession"/>s <see cref="IAuthToken"/> field <see cref="Token"/>
        /// if the token is valid.
        /// </summary>
        /// <param name="ticket">A valid authentication token.</param>
        /// <exception cref="ArgumentNullException">If the token is null.</exception>
        /// <exception cref="InvalidOperationException">If the token is in an invalid state.</exception>
        public void SetAuthenticationTicket(AuthTicketContainer ticket)
        {
#if DEBUG || DEBUGBUILD
            Debug.Log($"Successfully used oAuth token to authenticate on game servers.");
#endif
            Throw <ArgumentNullException> .If.IsNull(ticket)?.Now(nameof(ticket), $"Recieved a null {nameof(AuthTicket)} during auth token set.");

            AuthenticationTicketContainer = ticket;

            //There was no reason to reauth
            if (CurrentSessionState.HasFlag(SessionState.HasValidAuthTicket))
            {
                return;
            }

            CurrentSessionState = CurrentSessionState | SessionState.HasValidAuthTicket;

            //Call the event handler if it's not null
            StatusChangedEvent?.Invoke(CurrentSessionState);
        }
        /// <summary>
        /// Sets the <see cref="IAuthableSession"/>s <see cref="IAuthToken"/> field <see cref="Token"/>
        /// if the token is valid.
        /// </summary>
        /// <param name="token">A valid authentication token.</param>
        /// <exception cref="ArgumentNullException">If the token is null.</exception>
        /// <exception cref="InvalidOperationException">If the token is in an invalid state.</exception>
        public void SetAuthenticationToken(IAuthToken token)
        {
#if DEBUG || DEBUGBUILD
            Debug.Log($"Successfully authenticated and recieved valid oAuth.");
#endif
            Throw <ArgumentNullException> .If.IsNull(token)?.Now(nameof(token), $"Recieved a null {nameof(IAuthToken)} during auth token set.");

            if (!token.isValid)
            {
                Throw <InvalidOperationException> .If.Now();               //TODO: Add Easyception exception message
            }
            Token = token;

            //There was no reason to reauth
            if (CurrentSessionState.HasFlag(SessionState.Authenticated))
            {
                return;
            }

            CurrentSessionState = CurrentSessionState | SessionState.Authenticated;

            //Call the event handler if it's not null
            StatusChangedEvent?.Invoke(CurrentSessionState);
        }
Exemplo n.º 12
0
        public void UpdateStatus()
        {
            StatusEventArgs eventArgs = new StatusEventArgs(this.Status1, this.StatusDetails);

            StatusChangedEvent?.Invoke(this, eventArgs);
        }
Exemplo n.º 13
0
 private void RaiseStatusChangedEvent(StatusChanged status)
 {
     StatusChangedEvent?.Invoke(status);
 }