2

当我运行下面的代码时,我想在我的形状中填充 (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(); 
        }

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

4

1 回答 1

4

此处颜色 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();
       }
 }
于 2014-10-08T09:12:18.037 回答