I am working on Arc Objects using C# and I have to make a button add in, such that if I click button one time then layout background color changes to red and then if I click again then button add in change the background color from red to blue in Arc Map. I have successfully changed layout background color to red and blue but I want that color keep changing on each click from red to blue and then from blue to green.
Here is my code:
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Desktop.AddIns;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.ArcMapUI;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace lecture5test
{
public class Button1 : ESRI.ArcGIS.Desktop.AddIns.Button
{
public Button1()
{
}
protected override void OnClick()
{
//
// TODO: Sample code showing how to access button host
//
ArcMap.Application.CurrentTool = null;
RgbColor r = new RgbColor();
IRgbColor iRgb = (IRgbColor)r;
iRgb.Red = 255;
iRgb.Green = 0;
iRgb.Blue = 0;
IColor ic = (IColor)r;
// Page iPl = ArcMap.Document.PageLayout;
IPageLayout iPl = ArcMap.Document.PageLayout;
IPage pPage = (IPage)iPl.Page;
RgbColor b = new RgbColor();
IRgbColor bRgb = (IRgbColor)b;
bRgb.Red = 0;
bRgb.Green = 0;
bRgb.Blue = 255;
IColor ib = (IColor)b;
RgbColor g = new RgbColor();
IRgbColor gRgb = (IRgbColor)g;
gRgb.Red = 0;
gRgb.Green = 255;
gRgb.Blue = 0;
IColor ig = (IColor)g;
pPage.BackgroundColor = ic;
pPage.BackgroundColor = ib;
pPage.BackgroundColor = ig;
}
private void EnableDynamicDisplay()
{
throw new NotImplementedException();
}
protected override void OnUpdate()
{
Enabled = ArcMap.Application != null;
}
}
}