Exemplo n.º 1
0
        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) / (buttonBarHeight + 1);
                if (index >= 0 && index < listButtons.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(Handle);

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

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

                    // highlight new hovering button
                    OutlookBarButton b2 = listButtons[index];
                    b2.PaintButton(g, 1, index * (buttonBarHeight + 1) + 1, b2.Equals(selectedButtonBar), 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(Handle);
                        OutlookBarButton b1 = listButtons[hoveringButtonIndex];

                        // un-highlight current hovering button
                        b1.PaintButton(g, 1, hoveringButtonIndex * (buttonBarHeight + 1) + 1, b1.Equals(selectedButtonBar), false);
                        hoveringButtonIndex = -1;
                        g.Dispose();
                    }
                }
            }
        }
Exemplo n.º 2
0
        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(Handle);
                OutlookBarButton b1 = listButtons[hoveringButtonIndex];

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