/// <summary> /// Создает объект в списке /// Если объект существует на карте, то его значение обновляется, иначе объект создается /// </summary> /// <param name="label">Значение подписи</param> /// <param name="wkt">Геометрия</param> /// <param name="mapObj">Объект на карте</param> /// <returns>Созданный объект</returns> public CosmeticObjectM CreateObject(string label, string wkt, mvVectorObject mapObj = null) { var tableObj = new CosmeticObjectM(NextObjectId, wkt); tableObj.SetAttribute("label", label); Objects.Add(tableObj); var layerMV = (Source as SourceCosmetic.ViewModel.CosmeticDataRepositoryVM).MapViewer.getLayer(NameMap); if (layerMV != null && tableObj != null) { if (mapObj == null) { mapObj = layerMV.getObject(tableObj.Id); if (mapObj == null) { mapObj = layerMV.CreateObject(); } } if (mapObj != null) { mapObj.setWKT(wkt); mapObj.SetAttribute("label", label); mapObj.SetAttribute(PkFieldName, tableObj.Id.ToString()); } } return(tableObj); }
/// <summary> /// Копирование выделенных объектов /// </summary> public void CopySelectedObjects(object parameter = null) { _mvLayer.RemoveDeletedObjects(); try { foreach (DataRowView drv in SelectedItems) { DataRow dr = drv.Row; int id = Convert.ToInt32(dr["id"]); mvVectorObject mvObj = _mvLayer.getObject(id); mvVectorObject newObj = _mvLayer.CreateObject(); newObj.setWKT(mvObj.getWKT()); String labelValue = mvObj.fieldValue("label") == null ? null : mvObj.fieldValue("label").ToString(); newObj.SetAttribute("label", labelValue); newObj.SetAttribute("id", _cosTable.NextObjectId.ToString()); switch (mvObj.VectorType) { case mvVecTypes.mvVecLine: newObj.style = _cosTable.DefaultLineStyle.Value; break; case mvVecTypes.mvVecPoint: newObj.style = _cosTable.DefaultDotStyle.Value; break; case mvVecTypes.mvVecRegion: newObj.style = _cosTable.DefaultPolygonStyle.Value; break; } } } catch (NullReferenceException ex) { System.Windows.MessageBox.Show(Rekod.Properties.Resources.CosTableView_ObjectNotExists); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } Reload(); _mvLayer.ExternalFullReloadVisible(); _axMapLib.mapRepaint(); }