// Codehimbelonga kwb@theSwamp 20070211
// For AC2007: VS2005
//
#region usingdeclarations
using System;
using System.Windows.Forms;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Colors;
#endregion
#region usingAliases
// Shortcuts to the managed classes .. using the ObjectARX class prefixes
using AcAp = Autodesk.AutoCAD.ApplicationServices;
using AcColors = Autodesk.AutoCAD.Colors;
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using AcEd = Autodesk.AutoCAD.EditorInput;
using AcGe = Autodesk.AutoCAD.Geometry;
using AcGi = Autodesk.AutoCAD.GraphicsInterface;
using AcLy = Autodesk.AutoCAD.LayerManager;
using AcPl = Autodesk.AutoCAD.PlottingServices;
using AcRx = Autodesk.AutoCAD.Runtime;
using AcWindows = Autodesk.AutoCAD.Windows;
//
//
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
#endregion
[assembly
: AcRx
.CommandClass(typeof(kdubTestStuff
.kdubColorLab))]
namespace kdubTestStuff
{
/// <summary>
/// Summary for kdubTestStuff
/// </summary>
public class kdubColorLab : AcRx.IExtensionApplication
{
/// <summary>
/// ---------------------------------------------------------------------------------------------
/// </summary>
public void Initialize()
{
//Let the user know what's happening while loading your stuff
AcEd.Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("\nConcept Code For AC2007, MSVS2005 :: kwb@theSwamp 20070211 ->> ...");
ed.WriteMessage("\nType CMD1 : Run Color Lab test\n");
}
/// ---------
public void Terminate()
{
//Nothing to see here yet, move along !
}
/// <summary>
/// ---------------------------------------------------------------------------------------------
/// </summary>
public kdubColorLab()
{
//
// TODO: Add constructor logic here
//
}
[AcRx.CommandMethod("Cmd1")]
static public void testColor()
{
AcWindows
.ColorDialog clr
= new AcWindows
.ColorDialog(); if (clr.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
MessageBox.Show("Color was Not Selected", "Oooooops");
return;
}
if (clr.Color.IsByAci)
{
// get the RGB values of the Color.ColorIndex
int colorIndex = clr.Color.ColorIndex;
System.Byte colorByte = System.Convert.ToByte(colorIndex);
int rgb = AcColors.EntityColor.LookUpRgb(colorByte);
long b = (rgb & 0xffL);
long g = (rgb & 0xff00L) >> 8;
long r = rgb >> 16; ;
// not really required for this sample ..
int ri = System.Convert.ToInt32(r);
int gi = System.Convert.ToInt32(g);
int bi = System.Convert.ToInt32(b);
// Tell us about it !
MessageBox.Show(
"Color is : " + clr.Color.ToString()
+ "\nColor Index ToByte : " + colorByte.ToString()
+ "\nTranslated RGB int : " + rgb.ToString()
+ "\nTranslated R,G,B : " + ri.ToString() + "," + gi.ToString() + "," + bi.ToString()
, "Color is by ACI");
}
else if (clr.Color.IsByLayer)
{
MessageBox.Show(
"Color Code is : " + clr.Color.ToString()
, "Color is By LAyer");
}
else if (clr.Color.IsByBlock)
{
MessageBox.Show(
"Color Code is : " + clr.Color.ToString()
, "Color is By Block");
}
else if (clr.Color.HasBookName)
{
MessageBox.Show(
"Color Code is : " + clr.Color.ToString()
+ "\n To RGB : "
+ clr.Color.Red.ToString()
+ "," + clr.Color.Green.ToString()
+ "," + clr.Color.Blue.ToString()
, "Color Has Book Name"
);
}
else
{
MessageBox.Show(
"Color Code is : " + clr.Color.ToString()
+ "\n To RGB : "
+ clr.Color.Red.ToString()
+ "," + clr.Color.Green.ToString()
+ "," + clr.Color.Blue.ToString()
, "Color is True Color"
);
}
}
}
}