Smuxi.Frontend.Gnome.MainWindow.UpdateProgressBar C# (CSharp) Method

UpdateProgressBar() public method

public UpdateProgressBar ( ) : void
return void
        public void UpdateProgressBar()
        {
            var chats = ChatViewManager.Chats;
            var totalChatCount = chats.Count;
            var syncedChatCount = chats.Count(x => x.IsSynced);
            var fraction = (double) syncedChatCount / totalChatCount;
            if (totalChatCount == 0) {
                // x / 0d -> Infinity
                fraction = 0;
            }
            ProgressBar.Fraction = fraction;
            ProgressBar.Text = String.Format("{0} / {1}",
                                              syncedChatCount,
                                              totalChatCount);
            if (syncedChatCount >= totalChatCount) {
                ProgressBar.Hide();
            } else {
                ProgressBar.Show();
            }
        }

Usage Example

Beispiel #1
0
        public static void DisconnectEngineFromGUI(bool cleanly)
        {
            Trace.Call(cleanly);

            IsDisconnecting = true;
            MainWindow.ChatViewManager.IsSensitive = false;
            if (cleanly)
            {
                try {
                    // sync tab positions
                    if (!IsLocalEngine && !UseLowBandwidthMode)
                    {
                        _MainWindow.Notebook.SyncPagePositions();
                    }

                    if (_FrontendManager != null)
                    {
                        _FrontendManager.IsFrontendDisconnecting = true;
                    }
                    if (_Session != null)
                    {
                        _Session.DeregisterFrontendUI(_MainWindow.UI);
                    }
                } catch (System.Net.Sockets.SocketException) {
                    // ignore as the connection is maybe already broken
                } catch (System.Runtime.Remoting.RemotingException) {
                    // ignore as the connection is maybe already broken
                }
            }
            if (_FrontendManagerCheckerQueue != null)
            {
                _FrontendManagerCheckerQueue.Dispose();
            }
            _MainWindow.ChatViewManager.Clear();
            _MainWindow.UpdateProgressBar();
            // make sure no stray SSH tunnel leaves behind
            _MainWindow.EngineManager.Disconnect();
            _MainWindow.NetworkStatus = null;
            _MainWindow.Status        = _("Disconnected from engine.");

            _FrontendManager = null;
            Session          = null;
            IsDisconnecting  = false;
        }