Пример #1
0
        private void OutlookBar_MouseLeave(object sender, EventArgs e)
        {
            // mouse is leaving control, so unhighlight anything that is highlighted
            if (hoveringButtonIndex >= 0)
            {
                // so we need to change the hoveringButtonIndex to the new index
                Graphics         g  = Graphics.FromHwnd(this.Handle);
                OutlookBarButton b1 = buttons[hoveringButtonIndex];

                // un-highlight current hovering button
                b1.PaintButton(g, 1, hoveringButtonIndex * (buttonHeight + 1) + 1, b1.Equals(selectedButton), false);
                hoveringButtonIndex = -1;
                g.Dispose();
            }
        }
Пример #2
0
        private void OutlookBar_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                // determine over which button the mouse is moving
                int index = (e.Location.Y - 1) / (buttonHeight + 1);
                if (index >= 0 && index < buttons.Count)
                {
                    if (hoveringButtonIndex == index)
                    {
                        return; // nothing changed so we're done, current button stays highlighted
                    }
                    // so we need to change the hoveringButtonIndex to the new index
                    Graphics g = Graphics.FromHwnd(this.Handle);

                    if (hoveringButtonIndex >= 0)
                    {
                        OutlookBarButton b1 = buttons[hoveringButtonIndex];

                        // un-highlight current hovering button
                        b1.PaintButton(g, 1, hoveringButtonIndex * (buttonHeight + 1) + 1, b1.Equals(selectedButton), false);
                    }

                    // highlight new hovering button
                    OutlookBarButton b2 = buttons[index];
                    b2.PaintButton(g, 1, index * (buttonHeight + 1) + 1, b2.Equals(selectedButton), true);
                    hoveringButtonIndex = index; // set to new index
                    g.Dispose();
                }
                else
                {
                    // no hovering button, so un-highlight all.
                    if (hoveringButtonIndex >= 0)
                    {
                        // so we need to change the hoveringButtonIndex to the new index
                        Graphics         g  = Graphics.FromHwnd(this.Handle);
                        OutlookBarButton b1 = buttons[hoveringButtonIndex];

                        // un-highlight current hovering button
                        b1.PaintButton(g, 1, hoveringButtonIndex * (buttonHeight + 1) + 1, b1.Equals(selectedButton), false);
                        hoveringButtonIndex = -1;
                        g.Dispose();
                    }
                }
            }
        }