在功率点互操作中用颜色填充形状

时间:2014-10-07 16:28:03

标签: c# visual-studio-2013 add-in visual-studio-addins powerpoint-2013

当我在下面的代码中运行时,我想填充(255,168,0)我的形状颜色它有点给我一点浅蓝色。

   private void Shape_fill_Click(object sender, RibbonControlEventArgs e)
    {
        Color_palette.Visible = true;
         type = "Fill";           
    }

    private void btn_Orange_Click(object sender, RibbonControlEventArgs e)
    {
        if(type=="Fill")
        { 
        PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
        PowerPoint.ShapeRange ppshr = ppApp.ActiveWindow.Selection.ShapeRange;
        ppshr.Fill.ForeColor.RGB = System.Drawing.Color.FromArgb(255,168,0).ToArgb(); 
        }

问题:除了浅蓝色外,我怎样才能获得不同或不同的颜色?

1 个答案:

答案 0 :(得分:3)

这里颜色RGB以BGR的格式给出,因为互操作将其读取为BGR而不是RGB

private void btn_Orange_Click(object sender, RibbonControlEventArgs e)
{
    if(type=="Fill")
    {  
       PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
            PowerPoint.ShapeRange ppshr = ppApp.ActiveWindow.Selection.ShapeRange;
            // here the color RGB is given in format of BGR because interop reads it as BGR and not RGB

            ppshr.Fill.ForeColor.RGB =System.Drawing.Color.FromArgb(0,168,255).ToArgb();
       }
 }