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.ConnectedExitIP.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); } // Icon update if (StatusItem != null) { //string colorMode = GuiUtils.InterfaceColorMode (); string colorMode = Engine.Storage.Get("gui.osx.style"); if (Engine.IsConnected()) { StatusItem.Image = NSImage.ImageNamed("menubar_" + colorMode.ToLowerInvariant() + "_green.png"); //NSApplication.SharedApplication.DockTile. = DateTime.Now.ToString (); NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed("icon.png"); } else { StatusItem.Image = NSImage.ImageNamed("menubar_" + colorMode.ToLowerInvariant() + "_red.png"); //NSApplication.SharedApplication.DockTile.Description = DateTime.Now.ToString (); NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed("icon_gray.png"); } } 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("VpnConnectionStart"); TxtConnectedDownload.StringValue = Core.Utils.FormatBytes(Engine.ConnectedLastDownloadStep, true, false); TxtConnectedUpload.StringValue = Core.Utils.FormatBytes(Engine.ConnectedLastUploadStep, true, false); string msg = Engine.Instance.GetConnectedTrayText(true, true); string tmsg = Constants.Name + " - " + msg; this.Window.Title = tmsg; MnuTrayStatus.Title = "> " + msg; StatusItem.ToolTip = msg; StatusItem.Title = Engine.Instance.GetConnectedTrayText(Engine.Instance.Storage.GetBool("gui.osx.sysbar.show_speed"), Engine.Instance.Storage.GetBool("gui.osx.sysbar.show_server")); } } if ((mode == Engine.RefreshUiMode.Full)) { if (TableServersController != null) { TableServersController.RefreshUI(); } if (TableAreasController != null) { TableAreasController.RefreshUI(); } } } catch (Exception) { // TOFIX: OS X sometime throw an useless exception in closing phase } }
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 = LanguageManager.GetText("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 = LanguageManager.GetText("TopBarNotConnectedLocked"); } else { LblTopStatus.StringValue = LanguageManager.GetText("TopBarNotConnectedExposed"); } TabOverview.SelectAt(0); } } 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 = LanguageManager.FormatBytes(Engine.ConnectionActive.BytesLastDownloadStep, true, false); TxtConnectedUpload.StringValue = LanguageManager.FormatBytes(Engine.ConnectionActive.BytesLastUploadStep, true, false); } } if ((mode == Engine.RefreshUiMode.Full)) { if (TableServersController != null) { TableServersController.RefreshUI(); } if (TableAreasController != null) { TableAreasController.RefreshUI(); } CboKey.RemoveAllItems(); if ((Engine.Instance != null) && (Engine.Instance.AirVPN != null) && (Engine.Instance.AirVPN.User != null)) { foreach (XmlElement xmlKey in Engine.Instance.AirVPN.User.SelectNodes("keys/key")) { string keyName = xmlKey.GetAttribute("name"); CboKey.AddItem(keyName); } string currentKey = Engine.Instance.Storage.Get("key"); int currentIndex = (int)CboKey.IndexOfItem(currentKey); if (currentIndex != -1) { CboKey.SelectItem(currentIndex); } } } if ((mode == Engine.RefreshUiMode.MainMessage) || (mode == Engine.RefreshUiMode.Full)) { EnabledUI(); } } catch (Exception) { // TOFIX: macOS sometime throw an useless exception in closing phase } }
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 } }