protected override void OnViewAttached(object view, object context) { _view = view as ButtonsPopupView; for (int i = 0; i < Buttons.Count; i++) { var btn = new Controls.MenuButton() { Text = Buttons[i] }; _view.btnsContainer.Children.Add(btn); controls.Add(btn); } if (controls.Count > 0) { controls.First().ButtonBackground = GameUIConstants.PopupSelectedBtnBackground; } _view.Height = 120 + Buttons.Count * 70; }
public void Handle(GameKeyEvent message) { if (!IsShowing) { return; } if (message.PlayerAction == PlayerAction.Left || message.PlayerAction == PlayerAction.Right) { _selectedBtn.ButtonBackground = GameUIConstants.PopupBtnBackground; _selectedBtn = _selectedBtn == _view.btnYes ? _view.btnNo : _view.btnYes; _selectedBtn.ButtonBackground = GameUIConstants.PopupSelectedBtnBackground; } else if (message.PlayerAction == PlayerAction.Enter || message.PlayerAction == PlayerAction.Back) { _eventAggregator.Publish(new ClosingPopupEvent() { YesSelected = (message.PlayerAction == PlayerAction.Enter && _selectedBtn == _view.btnYes) }); } }
public void Handle(GameKeyEvent message) { if (!IsShowing) { return; } if (message.PlayerAction == PlayerAction.Up || message.PlayerAction == PlayerAction.Down) { _selectedBtn.ButtonBackground = GameUIConstants.PopupBtnBackground; _selectedBtn = _selectedBtn == _view.btnPlayAgain ? _view.btnExit : _view.btnPlayAgain; _selectedBtn.ButtonBackground = GameUIConstants.PopupSelectedBtnBackground; } else if (message.PlayerAction == PlayerAction.Enter) { _eventAggregator.Publish(new GameOverPopupEvent() { PlayAgainSelected = _selectedBtn == _view.btnPlayAgain }); } }
public void LoadPhase() { m_lockCoordUpdate = true; SetStyle(ControlStyles.SupportsTransparentBackColor, true); MinimumSize = new Size(m_windowMinimumWidth, m_windowMinimumHeight); KeyPreview = true; // 2.10.1 m_formReady = false; Visible = false; //base.OnLoad(e); CommonInit(""); if (Platform.Instance.IsTraySupported()) { m_notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); m_notifyIcon.Icon = this.Icon; m_notifyIcon.Text = "AirVPN"; m_notifyIcon.Visible = true; m_notifyIcon.BalloonTipTitle = Constants.Name; m_notifyIcon.MouseDoubleClick += new MouseEventHandler(notifyIcon_MouseDoubleClick); //m_notifyIcon.Click += new EventHandler(notifyIcon_Click); m_notifyIcon.ContextMenuStrip = mnuMain; } m_tabMain = new TabNavigator(); m_tabMain.ImportTabControl(tabMain); if (m_tabMain.Pages.Count != 0) { m_tabMain.Pages[0].Icon = "maintab_overview"; m_tabMain.Pages[1].Icon = "maintab_servers"; m_tabMain.Pages[2].Icon = "maintab_countries"; m_tabMain.Pages[3].Icon = "maintab_speed"; m_tabMain.Pages[4].Icon = "maintab_stats"; m_tabMain.Pages[5].Icon = "maintab_logs"; m_tabMain.TabsFont = Skin.FontBig; m_tabMain.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; m_tabMain.TabSwitch += tabMain_TabSwitch; this.Controls.Add(m_tabMain); } m_imgProgressInfinite = new ProgressInfinite(); this.pnlWaiting.Controls.Add(m_imgProgressInfinite); // Controls initialization mnuDevelopers.Visible = Engine.Instance.DevelopmentEnvironment; mnuTools.Visible = Engine.Instance.DevelopmentEnvironment; chkRemember.BackColor = Color.Transparent; if (Platform.IsWindows()) { // TOFIX: Under Mono crash... m_toolTip = new Controls.ToolTip(); Controls.Add(m_toolTip); } m_pnlCharts = new ChartSpeed(); m_pnlCharts.Left = holSpeedChart.Left; m_pnlCharts.Top = holSpeedChart.Top; m_pnlCharts.Width = holSpeedChart.Width; m_pnlCharts.Height = holSpeedChart.Height; m_pnlCharts.Anchor = holSpeedChart.Anchor; holSpeedChart.Visible = false; if (m_tabMain.Pages.Count != 0) m_tabMain.Pages[3].Controls.Add(m_pnlCharts); m_cmdMainMenu = new MenuButton(); m_cmdMainMenu.Left = 0; m_cmdMainMenu.Top = 0; m_cmdMainMenu.Click += cmdMenu_Click; Controls.Add(m_cmdMainMenu); m_listViewServers = new ListViewServers(); m_listViewServers.ContextMenuStrip = mnuServers; m_listViewServers.Dock = DockStyle.Fill; m_listViewServers.ResizeColumnString(0, 20); m_listViewServers.ResizeColumnString(1, 5); m_listViewServers.ResizeColumnString(2, 20); m_listViewServers.ResizeColumnString(3, 8); m_listViewServers.ResizeColumnString(4, 20); m_listViewServers.ResizeColumnString(5, 5); m_listViewServers.AllowColumnReorder = true; pnlServers.Controls.Add(m_listViewServers); m_listViewAreas = new ListViewAreas(); m_listViewAreas.ContextMenuStrip = mnuAreas; m_listViewAreas.Dock = DockStyle.Fill; m_listViewAreas.ResizeColumnString(0, 14); m_listViewAreas.ResizeColumnString(1, 8); m_listViewAreas.ResizeColumnString(2, 20); m_listViewAreas.ResizeColumnString(3, 6); m_listViewAreas.AllowColumnReorder = true; pnlAreas.Controls.Add(m_listViewAreas); m_listViewServers.MouseDoubleClick += new MouseEventHandler(m_listViewServers_MouseDoubleClick); m_listViewServers.SelectedIndexChanged += new EventHandler(m_listViewServers_SelectedIndexChanged); m_listViewAreas.SelectedIndexChanged += new EventHandler(m_listViewAreas_SelectedIndexChanged); lstStats.ImageIconResourcePrefix = "stats_"; lstStats.ResizeColumnMax(1); lstLogs.ImageIconResourcePrefix = "log_"; lstLogs.ResizeColumnString(0, 2); lstLogs.ResizeColumnString(1, LogEntry.GetDateForListSample()); lstLogs.ResizeColumnMax(2); chkShowAll.Checked = false; chkLockLast.Checked = Engine.Storage.GetBool("servers.locklast"); cboScoreType.Text = Engine.Storage.Get("servers.scoretype"); //ApplySkin(); bool forceMinimized = false; if (Engine.Storage.GetBool("gui.windows.start_minimized")) forceMinimized = true; if ((m_windowStateSetByShortcut) && (WindowState == FormWindowState.Minimized)) forceMinimized = true; bool forceMaximized = false; if ((m_windowStateSetByShortcut) && (WindowState == FormWindowState.Maximized)) forceMaximized = true; SetFormLayout(Engine.Storage.Get("gui.window.main"), forceMinimized, forceMaximized, MinimizeInTray(), new Size(m_windowDefaultWidth, m_windowDefaultHeight)); m_listViewServers.SetUserPrefs(Engine.Storage.Get("gui.list.servers")); m_listViewAreas.SetUserPrefs(Engine.Storage.Get("gui.list.areas")); lstLogs.SetUserPrefs(Engine.Storage.Get("gui.list.logs")); foreach (StatsEntry statsEntry in Engine.Stats.List) { ListViewItemStats statsEntryItem = new ListViewItemStats(); statsEntryItem.Entry = statsEntry; statsEntryItem.Text = statsEntry.Caption; statsEntryItem.ImageKey = statsEntry.Icon; lstStats.Items.Add(statsEntryItem); m_statsItems[statsEntry.Key] = statsEntryItem; StatsChange(statsEntry); // Without this, glitch in listview under Linux } lstStats.ResizeColumnAuto(0); cboSpeedResolution.Items.Clear(); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution1); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution2); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution3); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution4); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution5); cboSpeedResolution.SelectedIndex = 0; // Tooltips cmdConnect.Text = Messages.CommandConnect; lblConnectSubtitle.Text = Messages.CommandConnectSubtitle; cmdDisconnect.Text = Messages.CommandDisconnect; cmdCancel.Text = Messages.CommandCancel; if (m_toolTip != null) { m_toolTip.Connect(this.cboScoreType, Messages.TooltipServersScoreType); m_toolTip.Connect(this.chkLockLast, Messages.TooltipServersLockCurrent); m_toolTip.Connect(this.chkShowAll, Messages.TooltipServersShowAll); m_toolTip.Connect(this.cboScoreType, Messages.TooltipServersScoreType); m_toolTip.Connect(this.chkLockLast, Messages.TooltipServersLockCurrent); m_toolTip.Connect(this.chkShowAll, Messages.TooltipServersShowAll); m_toolTip.Connect(this.cmdServersConnect, Messages.TooltipServersConnect); m_toolTip.Connect(this.cmdServersUndefined, Messages.TooltipServersUndefined); m_toolTip.Connect(this.cmdServersBlackList, Messages.TooltipServersBlackList); m_toolTip.Connect(this.cmdServersWhiteList, Messages.TooltipServersWhiteList); m_toolTip.Connect(this.cmdAreasUndefined, Messages.TooltipAreasUndefined); m_toolTip.Connect(this.cmdAreasBlackList, Messages.TooltipAreasBlackList); m_toolTip.Connect(this.cmdAreasWhiteList, Messages.TooltipAreasWhiteList); m_toolTip.Connect(this.cmdLogsOpenVpnManagement, Messages.TooltipLogsOpenVpnManagement); m_toolTip.Connect(this.cmdLogsClean, Messages.TooltipLogsClean); m_toolTip.Connect(this.cmdLogsCopy, Messages.TooltipLogsCopy); m_toolTip.Connect(this.cmdLogsSave, Messages.TooltipLogsSave); m_toolTip.Connect(this.cmdLogsSupport, Messages.TooltipLogsSupport); Controls.SetChildIndex(m_toolTip, 0); } // Start if (Engine.Storage.GetBool("remember")) { chkRemember.Checked = true; txtLogin.Text = Engine.Storage.Get("login"); txtPassword.Text = Engine.Storage.Get("password"); } m_lockCoordUpdate = false; Resizing(); // base.OnLoad(e); // Removed in 2.11.9 m_formReady = true; Engine.OnRefreshUi(); /* TOCLEAN if (Platform.IsUnix()) { // Mono Bug, issue on start drawing in some systems like Mint timerMonoDelayedRedraw = new System.Timers.Timer(); timerMonoDelayedRedraw.Elapsed += new System.Timers.ElapsedEventHandler(OnMonoDelayedRedraw); timerMonoDelayedRedraw.Interval = 1000; timerMonoDelayedRedraw.Enabled = true; } */ }
protected override void OnLoad(EventArgs e) { m_lockCoordUpdate = true; SetStyle(ControlStyles.SupportsTransparentBackColor, true); MinimumSize = new Size(m_windowMinimumWidth, m_windowMinimumHeight); KeyPreview = true; // 2.10.1 m_formReady = false; Visible = false; base.OnLoad(e); CommonInit(""); if (Platform.Instance.IsTraySupported()) { m_notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); m_notifyIcon.Icon = this.Icon; m_notifyIcon.Text = "AirVPN"; m_notifyIcon.Visible = true; m_notifyIcon.BalloonTipTitle = Constants.Name; m_notifyIcon.MouseDoubleClick += new MouseEventHandler(notifyIcon_MouseDoubleClick); //m_notifyIcon.Click += new EventHandler(notifyIcon_Click); m_notifyIcon.ContextMenuStrip = mnuMain; } m_imgProgressInfinite = new ProgressInfinite(); this.pnlWaiting.Controls.Add(m_imgProgressInfinite); // Controls initialization mnuDevelopers.Visible = Engine.Instance.DevelopmentEnvironment; mnuTools.Visible = Engine.Instance.DevelopmentEnvironment; chkRemember.BackColor = Color.Transparent; m_pnlCharts = new ChartSpeed(); m_pnlCharts.Left = holSpeedChart.Left; m_pnlCharts.Top = holSpeedChart.Top; m_pnlCharts.Width = holSpeedChart.Width; m_pnlCharts.Height = holSpeedChart.Height; m_pnlCharts.Anchor = holSpeedChart.Anchor; holSpeedChart.Visible = false; tabSpeed.Controls.Add(m_pnlCharts); m_cmdMainMenu = new MenuButton(); m_cmdMainMenu.Left = 0; m_cmdMainMenu.Top = 0; m_cmdMainMenu.Width = 150; m_cmdMainMenu.Height = m_topHeaderHeight; m_cmdMainMenu.Click += cmdMenu_Click; Controls.Add(m_cmdMainMenu); m_listViewServers = new ListViewServers(); m_listViewServers.ContextMenuStrip = mnuServers; m_listViewServers.Dock = DockStyle.Fill; pnlServers.Controls.Add(m_listViewServers); m_listViewAreas = new ListViewAreas(); m_listViewAreas.ContextMenuStrip = mnuAreas; m_listViewAreas.Dock = DockStyle.Fill; pnlAreas.Controls.Add(m_listViewAreas); m_listViewServers.MouseDoubleClick += new MouseEventHandler(m_listViewServers_MouseDoubleClick); m_listViewServers.SelectedIndexChanged += new EventHandler(m_listViewServers_SelectedIndexChanged); m_listViewAreas.SelectedIndexChanged += new EventHandler(m_listViewAreas_SelectedIndexChanged); lstStats.ImageIconResourcePrefix = "stats_"; lstLogs.ImageIconResourcePrefix = "log_"; chkShowAll.Checked = false; chkLockLast.Checked = Engine.Storage.GetBool("servers.locklast"); cboScoreType.Text = Engine.Storage.Get("servers.scoretype"); Form.ChangeSkin(Engine.Storage.Get("gui.skin")); ApplySkin(); SetFormLayout(Engine.Storage.Get("forms.main"), true, true, new Size(m_windowDefaultWidth, m_windowDefaultHeight)); foreach (StatsEntry statsEntry in Engine.Stats.List) { ListViewItemStats statsEntryItem = new ListViewItemStats(); statsEntryItem.Entry = statsEntry; statsEntryItem.Text = statsEntry.Caption; statsEntryItem.ImageKey = statsEntry.Icon; lstStats.Items.Add(statsEntryItem); m_statsItems[statsEntry.Key] = statsEntryItem; StatsChange(statsEntry); // Without this, glitch in listview under Linux } cboSpeedResolution.Items.Clear(); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution1); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution2); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution3); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution4); cboSpeedResolution.Items.Add(Messages.WindowsMainSpeedResolution5); cboSpeedResolution.SelectedIndex = 0; // Tooltips cmdConnect.Text = Messages.CommandConnect; lblConnectSubtitle.Text = Messages.CommandConnectSubtitle; cmdDisconnect.Text = Messages.CommandDisconnect; cmdCancel.Text = Messages.CommandCancel; this.tip.SetToolTip(this.cboScoreType, Messages.TooltipServersScoreType); this.tip.SetToolTip(this.chkLockLast, Messages.TooltipServersLockCurrent); this.tip.SetToolTip(this.chkShowAll, Messages.TooltipServersShowAll); this.tip.SetToolTip(this.cmdServersConnect, Messages.TooltipServersConnect); this.tip.SetToolTip(this.cmdServersUndefined, Messages.TooltipServersUndefined); this.tip.SetToolTip(this.cmdServersBlackList, Messages.TooltipServersBlackList); this.tip.SetToolTip(this.cmdServersWhiteList, Messages.TooltipServersWhiteList); this.tip.SetToolTip(this.cmdAreasUndefined, Messages.TooltipAreasUndefined); this.tip.SetToolTip(this.cmdAreasBlackList, Messages.TooltipAreasBlackList); this.tip.SetToolTip(this.cmdAreasWhiteList, Messages.TooltipAreasWhiteList); this.tip.SetToolTip(this.cmdLogsOpenVpnManagement, Messages.TooltipLogsOpenVpnManagement); this.tip.SetToolTip(this.cmdLogsClean, Messages.TooltipLogsClean); this.tip.SetToolTip(this.cmdLogsCopy, Messages.TooltipLogsCopy); this.tip.SetToolTip(this.cmdLogsSave, Messages.TooltipLogsSave); this.tip.SetToolTip(this.cmdLogsSupport, Messages.TooltipLogsSupport); // Start if (Engine.Storage.GetBool("remember")) { chkRemember.Checked = true; txtLogin.Text = Engine.Storage.Get("login"); txtPassword.Text = Engine.Storage.Get("password"); } m_lockCoordUpdate = false; Resizing(); Show(); m_formReady = true; Engine.OnRefreshUi(); if (Platform.IsUnix()) { // Mono Bug, issue on start drawing in some systems like Mint timerMonoDelayedRedraw = new System.Timers.Timer(); timerMonoDelayedRedraw.Elapsed += new System.Timers.ElapsedEventHandler(OnMonoDelayedRedraw); timerMonoDelayedRedraw.Interval = 1000; timerMonoDelayedRedraw.Enabled = true; } }
protected override void OnViewAttached(object view, object context) { _view = view as ClosingPopupView; _selectedBtn = _view.btnYes; }
protected override void OnViewAttached(object view, object context) { _view = view as GameOverPopupView; _selectedBtn = _view.btnPlayAgain; }