public static List <Zone> GetZones(BlockReference blref) { List <Zone> zones = new List <Zone>(); Database db = HostApplicationServices.WorkingDatabase; using (var t = db.TransactionManager.StartTransaction()) { foreach (ObjectId id in blref.AttributeCollection) { var attRef = t.GetObject(id, OpenMode.ForRead) as AttributeReference; // Если тег атрибута начинается с з, то это номер зоны, значение атрибута это тип цвета if (attRef.Tag.StartsWith("з")) { Zone zone = new Zone(); zone.Name = attRef.Tag.Substring(1); zone.TypeColor = attRef.TextString; TileColor.AddTypeColor(zone.TypeColor); zones.Add(zone); } } t.Commit(); } return(zones); }
private void listBoxColor_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); int index = e.Index; if (index >= 0 && index < listBoxColor.Items.Count) { TileColor tileColor = listBoxColor.Items[index] as TileColor; if (tileColor == null) { return; } Graphics g = e.Graphics; //background: if (tileColor.Color != null) { SolidBrush brush = new SolidBrush(tileColor.Color.ColorValue); g.FillRectangle(brush, e.Bounds); } //text: g.DrawString(tileColor.TypeColor, e.Font, Brushes.Black, listBoxColor.GetItemRectangle(index).Location); } e.DrawFocusRectangle(); }
internal static void AddTypeColor(string typeColor) { if (!Contains(typeColor)) { TileColor tileColor = new TileColor(); tileColor.TypeColor = typeColor; TileColors.Add(tileColor); } }
internal static void AddTypeColor(string typeColor) { if (!Contains(typeColor)) { TileColor tileColor = new TileColor(); tileColor.TypeColor = typeColor; TileColors.Add(tileColor); } }
private void PaintTile(BlockReference blRefTile) { string zoneTileAtr = GetTileZone(blRefTile); // Получение цвета по типу зоны string zoneType = GetTypeColor(zoneTileAtr); // Получение цвета по типу цвета Color color = TileColor.GetColor(zoneType); if (color == null) { return; } blRefTile.Color = color; }
private void buttonColor_Click(object sender, EventArgs e) { // Выбор цвета для выбранного типа цвета TileColor tileColor = listBoxColor.SelectedItem as TileColor; if (tileColor == null) { return; } Autodesk.AutoCAD.Windows.ColorDialog colorDlg = new Autodesk.AutoCAD.Windows.ColorDialog(); var res = colorDlg.ShowDialog(); if (res == DialogResult.OK) { tileColor.Color = colorDlg.Color; } }