Ejemplo n.º 1
0
        /// <summary>
        /// Add a shortcut to the shortcut bar.
        /// </summary>
        private void AddShortcut(string titleText, string tooltipString, EventHandler handler)
        {
            using (Graphics graphics = CreateGraphics())
            {
                int count = _shortcutBar.Controls.Count;
                int index = count - 1;
                int xPosition = _shortcutBar.Controls[count - 1].Right + 4;
                string name = titleText;

                if (index > 0)
                {
                    titleText = "•  " + titleText;
                }
                Font titleFont = UI.Menu.Font;
                int menuHeight = Math.Max(titleFont.Height + 4, 42);
                SizeF size = graphics.MeasureString(titleText, titleFont);

                CRLabel menuLabel = new CRLabel
                {
                    Anchor = AnchorStyles.Left | AnchorStyles.Top,
                    AutoSize = true,
                    Selected = true,
                    CanBeSelected = true,
                    Padding = new Padding(0, 0, 0, 0),
                    Font = titleFont,
                    BackColor = Color.Transparent,
                    ForeColor = UI.Menu.ForegroundColour,
                    InactiveColour = UI.Menu.InactiveColour,
                    CountColour = UI.System.CountColour,
                    CountTextColour = UI.System.CountTextColour,
                    MaxCount = Preferences.StandardPreferences.MaxCount,
                    Location = new Point(xPosition, (int)(menuHeight - size.Height) / 2),
                    Name = name,
                    TabIndex = index,
                    Parent = _shortcutBar,
                    Visible = true,
                    Text = titleText
                };

                menuLabel.Click += handler;

                ToolTip newToolTip = new ToolTip();
                newToolTip.SetToolTip(menuLabel, tooltipString);

                _labels.Add(menuLabel);
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }