Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys;
I want to create a method. In the form of layername1 and layername2. The colors may be the same.
When I call this method from another routine; layername1 and layername2 should be available.
how can I do that ?
I solved the problem with this code now. But it didn't seem like the right format to me... though I used it in code. How can I create a method?
string layerName = "deneme";
string layerName2 = "deneme2";
string rgbTxt = "160,253,129";
//layer oluşturmak başlangıç
var layersTable = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);
// create layer if not exist
if (layersTable.Has(layerName) == false)
{
var newLayer = new LayerTableRecord();
var newLayer2 = new LayerTableRecord();
newLayer.Name = layerName;
newLayer2.Name = layerName2;
layersTable.Add(newLayer);
layersTable.Add(newLayer2);
tr.AddNewlyCreatedDBObject(newLayer, true);
tr.AddNewlyCreatedDBObject(newLayer2, true);
}
// set color
var layer = (LayerTableRecord)layersTable[layerName].GetObject(OpenMode.ForWrite);
var layer2 = (LayerTableRecord)layersTable[layerName2].GetObject(OpenMode.ForWrite);
var rgbArr = rgbTxt.Split(',').Select(byte.Parse).ToArray(); // unhandled exception in byte.Parse()
layer.Color = Color.FromRgb(rgbArr[0], rgbArr[1], rgbArr[2]);
// set current layer
//db.Clayer = layer.Id;
///// bitiş ///
Solved! Go to Solution.