3

I want to fill (255,168,0) color in my shape when I run this below code it kinda gives me a little lighter color in blue.

   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(); 
        }

Question: How can I get a different or a varying color other than lighter blue?

user2583182
  • 185
  • 5
  • 22
  • Whats your question? If you need to find out about the color codes, Try this link:http://www.rapidtables.com/web/color/RGB_Color.htm – Juniar Oct 07 '14 at 16:35
  • Above is the code i have used to fill in shape. I am aware of the color code, I tried using this RGB(255,168,0) in above code which is suppose to be orange shade but, it doesn't work in the case above with power point. It gives me lighter shade of blue. – user2583182 Oct 08 '14 at 07:55
  • I understand its suppose to be backwards with interop. So its; BGR(0, 168, 255). – Juniar Oct 08 '14 at 15:40
  • "interop reads it as BGR and not RGB" << good finding. I have been struggling with color. It's better to use FromArgb(0,0,255).ToArgb() rather than 0x0000FF – Bac Hoang May 21 '17 at 07:10

1 Answers1

5

Here the color RGB is given in format of BGR because interop reads it as BGR and not 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();
       }
 }
user2583182
  • 185
  • 5
  • 22