Ejemplo n.º 1
0
        private void SetActiveClient(Client client)
        {
            try
            {
                ClientLock.AcquireWriterLock(15 * 1000);
                Client = client;
            }
            catch (ApplicationException exception)
            {
                C.WriteLine("============================================================================");
                C.WriteLine("DeadLock? ConsoleUiMediator::SetActiveClient(Client) AcquireWriterLock");
                C.WriteLine("============================================================================");
                return;
            }
            finally
            {
                ClientLock.ReleaseWriterLock();
            }

            if (CurrentView.GetType() == typeof(IClientView))
            {
                ((IClientView)CurrentView).SetActiveClient(Client);
            }

            // MainView also takes care of client interaction
            if (CurrentView == MainView)
            {
                MainView.SetActiveClient(Client);
            }
        }
Ejemplo n.º 2
0
    private static void OnBack(object o)
    {
        if (CurrentView == null)
        {
            return;
        }
        if (CurrentView.GetType() == typeof(UIMainView))
        {
            return;
        }

        var prevViewType = PrevViewTypes[PrevViewTypes.Count - 1];

        if (_inClose)
        {
            return;
        }

        CurrentView.Close(() =>
        {
            if (prevViewType == typeof(UIMainView))
            {
                UIMainView.Show(false);
            }
            else
            {
                UiManager.ShowUIFromBack(prevViewType, null);
            }
            PrevViewTypes.Remove(prevViewType);
            _inClose = false;
        });
        _inClose = true;
        Sound.PlayUiAudioOneShot(1003);
    }
Ejemplo n.º 3
0
        public void OnClientDisconnected(Client client)
        {
            try
            {
                ClientLock.AcquireWriterLock(15 * 1000);

                if (Client == client)
                {
                    Client = null;
                    if (CurrentView.GetType() == typeof(ClientView))
                    {
                        ((ClientView)CurrentView).SetActiveClient(null);
                        CurrentView = MainView;
                        C.WriteLine("Current interacting user has disconnected");
                        CurrentView.PrintBanner();
                    }
                }
            }
            catch (ApplicationException exception)
            {
                C.WriteLine("============================================================================");
                C.WriteLine("DeadLock? ConsoleUiMediator::OnClientDisconnected(Client) AcquireReaderLock");
                C.WriteLine("============================================================================");
            }
            finally
            {
                ClientLock.ReleaseWriterLock();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Mark the right NavItem as selected.
        /// </summary>
        private void SelectionUpdate()
        {
            string viewclass = CurrentView.GetType().Name;

            foreach (var item in NavItems)
            {
                //Deselected the old selected navitem
                if (item.IsSelected == true && item.ClassName != CurrentView.GetType().Name)
                {
                    item.IsSelected = false;
                }

                //Mark the new selected navitem
                if (item.IsSelected == false && item.ClassName == CurrentView.GetType().Name)
                {
                    item.IsSelected = true;
                }
            }
        }
Ejemplo n.º 5
0
    //记录上一个选择的界面
    protected override void OnFullViewShow(bool fromBack)
    {
        _bOpening = true;

        if (GetType() != typeof(UIMainView))
        {
            Animator.Play("Open");
        }

        if (CurrentView != null)
        {
            if (!fromBack)
            {
                PrevViewTypes.Add(CurrentView.GetType());
            }
            CurrentView.Close();
        }

        CurrentView = this;
    }
Ejemplo n.º 6
0
 private void RefreshCurrentView()
 {
     Messenger.Default.Send(new RefreshMessage(CurrentView.GetType()));
     GetConnectionStatus();
 }