Exemplo n.º 1
0
        public Navigator(TabControl tabs, Control buttonPanel)
        {
            this.buttonPanel = buttonPanel;
            this.tabs = tabs;

            //(Increase performance), Reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout.aspx

            ButtonList = new List<ButtonInfo>() //normal arrangement
            {
                new ButtonInfo() { Label = "Chat", TargetPath = "chat", Icon = Buttons.chat.GetResizedWithCache(32,32)},
                new ButtonInfo() { Label = "Quick browse", TargetPath = "battles", Icon = Buttons.qb.GetResized(32,32) },
                new ButtonInfo() { Label = "Extras", TargetPath = "extras", Icon= Buttons.extras.GetResized(32,32) },
                new ButtonInfo() { Label = "Downloads", TargetPath = "downloads", Icon = Buttons.downloads.GetResized(32,32) },
                new ButtonInfo() {Label = "Settings",TargetPath = "settings",Icon = Buttons.settings.GetResized(32,32)},
            };

            foreach (var b in ButtonList) buttonPanel.Controls.Add(b.GetButton());

            tabs.TabPages.Clear();

            chatTab = new ChatTab();

            lastTabPaths[chatTab] = string.Format("chat/channel/{0}",
                Program.Conf != null ? Program.Conf.AutoJoinChannels.OfType<string>().FirstOrDefault() : "zk");
            AddTabPage(chatTab, "Chat");

            var battles = new BattleListTab();
            AddTabPage(battles, "Battles");
            AddTabPage(new SettingsTab(), "Settings");
            AddTabPage(new ServerTab(), "Server");
            AddTabPage(new DownloaderTab(), "Rapid");
        }
        private void InitializeTabPageContent() {
            tabControl.TabPages.Clear();
            ChatTab = new ChatTab();
            lastTabPaths[ChatTab] = "chat/channel/zk";
            AddTabPage(ChatTab, "Chat");
            if (Environment.OSVersion.Platform != PlatformID.Unix && !Program.Conf.UseExternalBrowser)
            {
                if (!Program.Conf.SingleInstance) //run in multiple TAB?
                {
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Maps", false), "Maps");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Missions", true, GlobalConst.BaseSiteUrl + "/Missions?no_menu=1"), "sp");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Battles", false), "rp");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Planetwars", false), "pw");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Forum", false), "fm");
                }
                AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl, true), "hm");
            }
            var battles = new BattleListTab();
            AddTabPage(battles, "Battles");
            AddTabPage(new SettingsTab(), "Settings");
            AddTabPage(new ServerTab(), "Server");
            var home = AddTabPage(new WelcomeTab(), "Welcome");

            tabControl.SelectTab(home);
        }
        public NavigationControl() {
            SuspendLayout();//(Increase performance), Reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout.aspx
            InitializeComponent();

            isBusyTimer.Interval = 1020; //timer tick to update "isBusyIcon" every 1020 ms.
            isBusyTimer.Tick += isBusyTimer_Tick;
            isBusyTimer.Start();

            ButtonList = new List<ButtonInfo>() //normal arrangement
            {
                new ButtonInfo() { Label = "HOME", TargetPath = GlobalConst.BaseSiteUrl + "/", Icon= Buttons.home, Height = 32,Width = 80 },
                new ButtonInfo() { Label = "CHAT", TargetPath = "chat", Icon= ZklResources.chat, Height = 32, Width = 65 },
                new ButtonInfo()
                {
                    Label = "SINGLEPLAYER",
                    TargetPath = string.Format("{0}/Missions", GlobalConst.BaseSiteUrl),
                    Icon = Buttons.spherebot,
                    Width = 125,
                    Height = 32,
                },
                new ButtonInfo()
                {
                    Label = "MULTIPLAYER",
                    TargetPath = "battles", Icon =  ZklResources.battle,
                    Width = 115,
                    Height = 32,
                },
                
                new ButtonInfo() { Label = "PLANETWARS", TargetPath = string.Format("{0}/Planetwars/", GlobalConst.BaseSiteUrl), Height = 32,  },
                new ButtonInfo() { Label = "MAPS", TargetPath = string.Format("{0}/Maps/", GlobalConst.BaseSiteUrl), Icon = Buttons.map, Height = 32, Width = 75 },
                new ButtonInfo() { Label = "REPLAYS", TargetPath = string.Format("{0}/Battles/", GlobalConst.BaseSiteUrl), Icon = Buttons.video_icon, Height = 32, Width = 95 },
                new ButtonInfo() { Label = "FORUM", TargetPath = string.Format("{0}/Forum/", GlobalConst.BaseSiteUrl), Height = 32, Width = 65, },
                new ButtonInfo() { Label = "SETTINGS", TargetPath = "settings", Icon = Buttons.settings, Height = 32, Width = 100, Dock = DockStyle.Right},
               
            };

            Instance = this;

            tabControl.TabPages.Clear();

            chatTab = new ChatTab();
            
            lastTabPaths[chatTab] = string.Format("chat/channel/{0}", Program.Conf != null ? Program.Conf.AutoJoinChannels.OfType<string>().FirstOrDefault():"zk");
            AddTabPage(chatTab, "Chat");
            if (Environment.OSVersion.Platform != PlatformID.Unix && !Program.Conf.UseExternalBrowser) {
                if (!Program.Conf.SingleInstance) //run in multiple TAB?
                {
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Maps", false), "Maps");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Missions", false), "sp");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Battles", false), "rp");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Planetwars", false), "pw");
                    AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl + "/Forum", true), "fm");
                }
                var home = AddTabPage(new BrowserTab(GlobalConst.BaseSiteUrl, true), "hm");
                tabControl.SelectTab(home);
                if (Program.Conf.InterceptPopup) 
                {
                    AddTabPage(new BrowserTab("http", false), "other"); //a tab with generic match that match 100% of random URL (block new window)
                    ButtonList.Add(new ButtonInfo() { Label = "OTHER", TargetPath = "http", Height = 32, Width = 65,});
                }
                reloadButton1.Visible = true;
            }
            var battles = new BattleListTab();
            AddTabPage(battles, "Battles");
            AddTabPage(new SettingsTab(), "Settings");
            AddTabPage(new ServerTab(), "Server");
            AddTabPage(new DownloaderTab(), "Rapid");
            AddTabPage(new MicroLobby.ExtrasTab.ExtrasTab(), "Extra");
            
            foreach (var but in ButtonList) flowLayoutPanel1.Controls.Add(but.GetButton());
            flowLayoutPanel1.Controls.Add(logoutButton);
            flowLayoutPanel1.BringToFront();
            ResumeLayout();
        }