// *********************************
// Message from Original Author:
//
// 2008 Jose Menendez Poo
// Please give me credit if you use this code. It's all I ask.
// Contact me for more info: menendezpoo@gmail.com
// *********************************
//
// Original project from http://ribbon.codeplex.com/
// Continue to support and maintain by http://officeribbon.codeplex.com/
using System.Drawing;
using System.Drawing.Imaging;
namespace System.Windows.Forms
{
///
/// Provides render functionallity for the Ribbon control
///
///
public class RibbonRenderer
{
#region Static
private static ColorMatrix _disabledImageColorMatrix;
///
/// Gets the disabled image color matrix
///
private static ColorMatrix DisabledImageColorMatrix
{
get
{
if (_disabledImageColorMatrix == null)
{
float[][] numArray = new float[5][];
numArray[0] = new[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f };
numArray[1] = new[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f };
numArray[2] = new[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f };
float[] numArray3 = new float[5];
numArray3[3] = 1f;
numArray[3] = numArray3;
numArray[4] = new[] { 0.38f, 0.38f, 0.38f, 0f, 1f };
float[][] numArray2 = new float[5][];
float[] numArray4 = new float[5];
numArray4[0] = 1f;
numArray2[0] = numArray4;
float[] numArray5 = new float[5];
numArray5[1] = 1f;
numArray2[1] = numArray5;
float[] numArray6 = new float[5];
numArray6[2] = 1f;
numArray2[2] = numArray6;
float[] numArray7 = new float[5];
numArray7[3] = 0.7f;
numArray2[3] = numArray7;
numArray2[4] = new float[5];
_disabledImageColorMatrix = MultiplyColorMatrix(numArray2, numArray);
}
return _disabledImageColorMatrix;
}
}
///
/// Multiplies the color matrix (Extracted from .NET Framework
///
///
///
///
internal static ColorMatrix MultiplyColorMatrix(float[][] matrix1, float[][] matrix2)
{
int num = 5;
float[][] newColorMatrix = new float[num][];
for (int i = 0; i < num; i++)
{
newColorMatrix[i] = new float[num];
}
float[] numArray2 = new float[num];
for (int j = 0; j < num; j++)
{
for (int k = 0; k < num; k++)
{
numArray2[k] = matrix1[k][j];
}
for (int m = 0; m < num; m++)
{
float[] numArray3 = matrix2[m];
float num6 = 0f;
for (int n = 0; n < num; n++)
{
num6 += numArray3[n] * numArray2[n];
}
newColorMatrix[m][j] = num6;
}
}
return new ColorMatrix(newColorMatrix);
}
///
/// Creates the disabled image for the specified Image
///
///
///
public static Image CreateDisabledImage(Image normalImage)
{
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.ClearColorKey();
imageAttr.SetColorMatrix(DisabledImageColorMatrix);
Size size = normalImage.Size;
Bitmap image = new Bitmap(size.Width, size.Height);
Graphics graphics = Graphics.FromImage(image);
graphics.DrawImage(normalImage, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, imageAttr);
graphics.Dispose();
return image;
}
#endregion
///
/// Renders the Ribbon Orb's DropDown background
///
///
public virtual void OnRenderOrbDropDownBackground(RibbonOrbDropDownEventArgs e)
{
}
///
/// Renders the Ribbon's caption bar
///
///
public virtual void OnRenderRibbonCaptionBar(RibbonRenderEventArgs e)
{
}
///
/// Renders the orb of the ribbon
///
///
public virtual void OnRenderRibbonOrb(RibbonRenderEventArgs e)
{
}
///
/// Renders the background of the QuickAccess toolbar
///
///
public virtual void OnRenderRibbonQuickAccessToolbarBackground(RibbonRenderEventArgs e)
{
}
///
/// Renders the Ribbon's background
///
public virtual void OnRenderRibbonBackground(RibbonRenderEventArgs e)
{
}
///
/// Renders a RibbonTab
///
/// Event data and paint tools
public virtual void OnRenderRibbonTab(RibbonTabRenderEventArgs e)
{
}
///
/// Renders a RibbonContext
///
/// Event data and paint tools
public virtual void OnRenderRibbonContext(RibbonContextRenderEventArgs e)
{
}
///
/// Renders a RibbonItem
///
public virtual void OnRenderRibbonItem(RibbonItemRenderEventArgs e)
{
}
///
/// Renders the background of the content of the specified tab
///
/// Event data and paint tools
public virtual void OnRenderRibbonTabContentBackground(RibbonTabRenderEventArgs e)
{
}
///
/// Renders the background of the specified ribbon panel
///
/// Event data and paint tools
public virtual void OnRenderRibbonPanelBackground(RibbonPanelRenderEventArgs e)
{
}
///
/// Renders the text of the tab specified on the event
///
/// Event data and paint tools
public virtual void OnRenderRibbonTabText(RibbonTabRenderEventArgs e)
{
}
///
/// Renders the text of the context specified on the event
///
/// Event data and paint tools
public virtual void OnRenderRibbonContextText(RibbonContextRenderEventArgs e)
{
}
///
/// Renders the text of the item specified on the event
///
/// Event data and paint tools
public virtual void OnRenderRibbonItemText(RibbonTextEventArgs e)
{
}
///
/// Renders the border of the item, after the text and image of the item
///
///
public virtual void OnRenderRibbonItemBorder(RibbonItemRenderEventArgs e)
{
}
///
/// Renders the image of the item specified on the event
///
public virtual void OnRenderRibbonItemImage(RibbonItemBoundsEventArgs e)
{
}
///
/// Renders the text of the specified panel
///
/// Event data and paint tools
public virtual void OnRenderRibbonPanelText(RibbonPanelRenderEventArgs e)
{
}
///
/// Renders the background of a dropdown
///
///
public virtual void OnRenderDropDownBackground(RibbonCanvasEventArgs e)
{
}
///
/// Renders the image separator of a dropdown
///
///
///
public virtual void OnRenderDropDownDropDownImageSeparator(RibbonItem item, RibbonCanvasEventArgs e)
{
}
///
/// Renders the background of a panel background
///
///
public virtual void OnRenderPanelPopupBackground(RibbonCanvasEventArgs e)
{
}
///
/// Call to draw the scroll buttons on the tab
///
///
public virtual void OnRenderTabScrollButtons(RibbonTabRenderEventArgs e)
{
}
///
/// Call to draw the scrollbar on the Control
///
///
///
///
public virtual void OnRenderScrollbar(Graphics g, Control item, Ribbon ribbon)
{
}
///
/// Call to draw the Tooltip
///
///
public virtual void OnRenderToolTipBackground(RibbonToolTipRenderEventArgs e)
{
}
///
/// Renders the text of the Tooltip specified on the event
///
/// Event data and paint tools
public virtual void OnRenderToolTipText(RibbonToolTipRenderEventArgs e)
{
}
public virtual void OnRenderToolTipImage(RibbonToolTipRenderEventArgs e)
{
}
}
}