Example #1
0
        public string ValToDesc(Int64 v)
        {
            string r = UtilsString.FormatBytes(v, true, true);

            return(r);
        }
Example #2
0
 public string ValToDesc(Int64 v)
 {
     return(UtilsString.FormatBytes(v, true, true));
 }
Example #3
0
        public void RefreshUi(Engine.RefreshUiMode mode)
        {
            try
            {
                if ((mode == Engine.RefreshUiMode.MainMessage) || (mode == Engine.RefreshUiMode.Full))
                {
                    if (Engine.CurrentServer != null)
                    {
                        ImgTopFlag.Image = NSImage.ImageNamed("flag_" + Engine.CurrentServer.CountryCode.ToLowerInvariant() + ".png");
                    }
                    else
                    {
                        ImgTopFlag.Image = NSImage.ImageNamed("notconnected.png");
                    }

                    LblWaiting1.StringValue = Engine.WaitMessage;

                    if (Engine.IsWaiting())
                    {
                        ImgProgress.StartAnimation(this);
                        ImgTopPanel.Image        = NSImage.ImageNamed("topbar_osx_yellow.png");
                        MnuTrayStatus.Image      = NSImage.ImageNamed("status_yellow_16.png");
                        LblTopStatus.StringValue = Engine.WaitMessage;

                        TabOverview.SelectAt(1);

                        CmdCancel.Hidden       = (Engine.IsWaitingCancelAllowed() == false);
                        CmdCancel.Enabled      = (Engine.IsWaitingCancelPending() == false);
                        MnuTrayConnect.Enabled = CmdCancel.Enabled;
                    }
                    else if (Engine.IsConnected())
                    {
                        ImgProgress.StopAnimation(this);
                        ImgTopPanel.Image        = NSImage.ImageNamed("topbar_osx_green.png");
                        MnuTrayStatus.Image      = NSImage.ImageNamed("status_green_16.png");
                        LblTopStatus.StringValue = MessagesFormatter.Format(MessagesUi.TopBarConnected, Engine.CurrentServer.DisplayName);

                        TabOverview.SelectAt(2);

                        LblConnectedServerName.StringValue = Engine.CurrentServer.DisplayName;
                        LblConnectedLocation.StringValue   = Engine.CurrentServer.GetLocationForList();
                        TxtConnectedExitIp.StringValue     = Engine.ConnectionActive.ExitIPs.ToString();
                        ImgConnectedCountry.Image          = NSImage.ImageNamed("flag_" + Engine.CurrentServer.CountryCode.ToLowerInvariant() + ".png");
                    }
                    else
                    {
                        ImgProgress.StopAnimation(this);
                        ImgTopPanel.Image   = NSImage.ImageNamed("topbar_osx_red.png");
                        MnuTrayStatus.Image = NSImage.ImageNamed("status_red_16.png");
                        if (Engine.Instance.NetworkLockManager.IsActive())
                        {
                            LblTopStatus.StringValue = MessagesUi.TopBarNotConnectedLocked;
                        }
                        else
                        {
                            LblTopStatus.StringValue = MessagesUi.TopBarNotConnectedExposed;
                        }

                        TabOverview.SelectAt(0);
                    }

                    EnabledUI();
                }

                if ((mode == Engine.RefreshUiMode.Log) || (mode == Engine.RefreshUiMode.Full))
                {
                    lock (Engine.LogsPending)
                    {
                        while (Engine.LogsPending.Count > 0)
                        {
                            LogEntry l = Engine.LogsPending[0];
                            Engine.LogsPending.RemoveAt(0);

                            Log(l);
                        }
                    }
                    LblWaiting2.StringValue = Engine.Logs.GetLogDetailTitle();
                }

                if ((mode == Engine.RefreshUiMode.Stats) || (mode == Engine.RefreshUiMode.Full))
                {
                    if (Engine.IsConnected())
                    {
                        TxtConnectedSince.StringValue = Engine.Stats.GetValue("VpnStart");

                        TxtConnectedDownload.StringValue = UtilsString.FormatBytes(Engine.ConnectionActive.BytesLastDownloadStep, true, false);
                        TxtConnectedUpload.StringValue   = UtilsString.FormatBytes(Engine.ConnectionActive.BytesLastUploadStep, true, false);
                    }
                }

                if ((mode == Engine.RefreshUiMode.Full))
                {
                    if (TableServersController != null)
                    {
                        TableServersController.RefreshUI();
                    }
                    if (TableAreasController != null)
                    {
                        TableAreasController.RefreshUI();
                    }
                }
            }
            catch (Exception)
            {
                // TOFIX: macOS sometime throw an useless exception in closing phase
            }
        }