/// <summary> /// Show or hide the search bar using the specified search bar visibility option. /// </summary> /// <param name="v">The SearchBarVisibility setting</param> private void ShowSearchBar(SearchBarVisibility v) { _searchBarHeight = 32; if (_searchBar == null) { _searchBar = new CRPanel { Anchor = (AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right, BackColor = UI.System.InfoBarColour, BottomBorderWidth = 1, ForeColor = UI.System.EdgeColour, Name = "sbPanel", Parent = this, Location = new Point(0, 0), Size = new Size(575, 0) }; Controls.Add(_searchBar); } if (v == SearchBarVisibility.Show && !_searchBarVisible) { _searchBarIncrement = 4; _searchBarIteration = 0; _searchBarTimer.Enabled = true; _searchBarVisible = true; } if (v == SearchBarVisibility.FastHide && _searchBarVisible) { _searchBar.Size = new Size(frmSplitContainer.Width, _searchBar.Height - _searchBarHeight); frmSplitContainer.Location = new Point(0, frmSplitContainer.Top - _searchBarHeight); frmSplitContainer.Size = new Size(frmSplitContainer.Width, frmSplitContainer.Height + _searchBarHeight); _searchBarVisible = false; } UpdateSearchBarButtons(); }
/// <summary> /// Initialises a new instance of the <see cref="MainForm"/> class. /// </summary> internal MainForm() { InitializeComponent(); _scriptManager = new ScriptManager(this); Initialise(); _mainPanel = new Panel { Parent = this, Location = new Point(0, 0), Size = new Size(ClientRectangle.Width, ClientRectangle.Height), Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom, }; Controls.Add(_mainPanel); Image cixLogoImage = Resources.CIXLogo2; _isBacktracking = true; Font titleFont = UI.Menu.Font; int menuHeight = Math.Max(titleFont.Height + 4, 42); // Top level menu panel _shortcutBar = new CRPanel { Parent = _mainPanel, Location = new Point(0, 0), Gradient = true, Size = new Size(_mainPanel.Width, menuHeight), Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right, BackColor = UI.Menu.BackgroundColour }; _mainPanel.Controls.Add(_shortcutBar); // Add the CIX logo to the left edge of the shortcut bar PictureBox cixLogo = new PictureBox { Image = cixLogoImage, Location = new Point(4, (menuHeight - cixLogoImage.Height) / 2), Name = "cixlogo", Parent = _shortcutBar, BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, Visible = true, Size = cixLogoImage.Size }; cixLogo.Click += delegate { Address = "welcome"; }; _shortcutBar.Controls.Add(cixLogo); _labels = new List<CRLabel>(); AddShortcut(Resources.Forums, Resources.ForumsTooltip, delegate { Address = "cix:_lastview"; }); AddShortcut(Resources.PMessages, Resources.PMessagesTooltip, delegate { Address = "cixmailbox:inbox"; }); AddShortcut(Resources.Directory, Resources.DirectoryTooltip, delegate { Address = "cixdirectory:all"; }); AddShortcut(Resources.Support, Resources.SupportTooltip, delegate { Address = "cix:" + Constants.SupportForum; }); if (Preferences.StandardPreferences.UseBeta) { AddShortcut(Resources.Beta, Resources.BetaTooltip, delegate { Address = "cix:" + Constants.BetaForum; }); } // Add the control menu to the extreme right edge of the shortcut bar Image controlImage = Resources.Control; _controlMenu = new PictureBox { Anchor = AnchorStyles.Right | AnchorStyles.Top, Image = controlImage, Location = new Point(_mainPanel.Width - (controlImage.Width + 2), (menuHeight - controlImage.Height) / 2), Name = "controlMenu", Parent = _shortcutBar, BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, Visible = true, Size = controlImage.Size }; _controlMenu.Click += ControlMenuOnClick; _controlMenu.MouseEnter += ControlMenuMouseEnter; _controlMenu.MouseLeave += ControlMenuMouseLeave; // Add the user's mugshot image. We don't have it yet. We'll // get it once the database is ready. Size imageSize = new Size(menuHeight - 4, menuHeight - 4); _logonImage = new PictureBox { Anchor = AnchorStyles.Right | AnchorStyles.Top, Location = new Point(_mainPanel.Width - (imageSize.Width + controlImage.Width + 2), 2), Name = "logonImage", Parent = _shortcutBar, SizeMode = PictureBoxSizeMode.StretchImage, Visible = true, Size = imageSize }; // Add the user's name to the left of the image. Font logonNameFont = UI.GetFont(UI.Menu.Font, UIConfigMenu.FontSize - 10); string logonText = CIX.Username; SizeF nameSize = CreateGraphics().MeasureString(logonText, logonNameFont); int xPosition = _labels[_labels.Count - 1].Right; _logonName = new CRLabel { Anchor = AnchorStyles.Right | AnchorStyles.Top, AutoSize = true, Padding = new Padding(0, 1, 0, 0), Font = logonNameFont, ForeColor = UI.Menu.ForegroundColour, InactiveColour = UI.Menu.ForegroundColour, BackColor = Color.Transparent, Location = new Point(xPosition, (int)(menuHeight - nameSize.Height) / 2), Size = new Size(_logonImage.Left - xPosition, (int)nameSize.Height), Parent = _shortcutBar, Visible = true, Text = logonText }; _shortcutBar.Controls.Add(_logonName); // Top level menu panel int dpi = GetDPI(); _toolbar = new CRToolbar { Parent = _mainPanel, Location = new Point(0, menuHeight), Size = new Size(_mainPanel.Width, Math.Max(dpi / 3, 36)), Visible = false }; // Add the panel for the view _viewPanel = new Panel { Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right, Location = new Point(0, menuHeight), Size = new Size(ClientRectangle.Width, ClientRectangle.Height - menuHeight), Margin = new Padding(0), Name = "viewPanel", Tag = this, Parent = _mainPanel, TabIndex = _labels.Count }; // Add the folders tree portion _foldersTree = new FoldersTree(this) { TopLevel = false, Location = new Point(0, 0), Parent = _viewPanel, Size = _viewPanel.Size }; _mainPanel.Controls.Add(_viewPanel); _mainPanel.Controls.Add(_toolbar); // Good time to show the status bar if needed. mainStatusBar.ForeColor = UI.System.EdgeColour; mainStatusBar.BackColor = UI.System.InfoBarColour; mainMenubar.BackColor = UI.Menu.BackgroundColour; mainMenubar.ForeColor = UI.Menu.ForegroundColour; mainMenubar.Renderer = new MainMenuBarRenderer(); ShowStatusBar(Preferences.StandardPreferences.ViewStatusBar); ShowMenuBar(Preferences.StandardPreferences.ViewMenuBar); ShowToolbar(Preferences.StandardPreferences.ShowToolBar); // Set the service online state now ChangeOnlineState(NetworkInterface.GetIsNetworkAvailable() && Program.StartupOnline); }