using System;
using System.Windows.Forms;
using Autodesk.AutoCAD.DatabaseServices;
using cadApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace TestDialog0615
{
public partial class ModalDialog : Form
{
public ModalDialog()
{
InitializeComponent();
}
private void ModalDialog_Load(object sender, EventArgs e)
{
}
private void CbRed_CheckedChanged(object sender, EventArgs e)
{
{
TurnLayerOnOff("RedStuff", true);
textBox.Text = "Red Checked";
Active.Editor.UpdateScreen();
}
else
{
TurnLayerOnOff("RedStuff", false);
textBox.Text = "Red Unchecked";
Active.Editor.UpdateScreen();
}
}
private void CbGreen_CheckedChanged(object sender, EventArgs e)
{
{
TurnLayerOnOff("GreenStuff", true);
textBox.Text = "Green Checked";
Active.Editor.UpdateScreen();
}
else
{
TurnLayerOnOff("GreenStuff", false);
textBox.Text = "Green Unchecked";
Active.Editor.UpdateScreen();
}
}
private void CbBlue_CheckedChanged(object sender, EventArgs e)
{
{
TurnLayerOnOff("BlueStuff", true);
textBox.Text = "Blue Checked";
Active.Editor.UpdateScreen();
}
else
{
TurnLayerOnOff("BlueStuff", false);
textBox.Text = "Blue Unchecked";
Active.Editor.UpdateScreen();
}
}
private void ButtonZoom_Click(object sender, EventArgs e)
{
//Call the COM library
dynamic acadApp = cadApp.AcadApplication;
acadApp.ZoomExtents();
acadApp.ZoomScaled(0.75, 1);
}
// should not be in the Dialog Stuff; move to control file :kdub
// and change to use delegates
private void TurnLayerOnOff(
string layerName, bool isOffp)
{
using (var tr = Active.Database.TransactionManager.StartTransaction())
{
var layerTable = tr.GetObject(
Active.Database.LayerTableId, OpenMode.ForRead) as LayerTable;
if (layerTable != null)
{
if (layerTable.Has(layerName))
{
var layerTableRecord = tr.GetObject(
layerTable[layerName], OpenMode.ForWrite) as LayerTableRecord;
if (layerTableRecord != null)
{
layerTableRecord.IsOff = isOffp;
}
}
}
tr.Commit();
}
}
}
}