/// <summary> /// Регистрирует новый косметический слой в системе /// </summary> /// <param name="cosLayer">Слой который нужно зарегистрировать в источнике</param> private void RegisterLayer(CosM.CosmeticTableBaseM cosLayer) { // Если таблица новая, создаем слой на карте if (cosLayer.IsNewTable) { cosLayer.Name = Guid.NewGuid().ToString(); cosLayer.NameMap = cosLayer.Name; _tables.Add(cosLayer); Groups.ElementAt(0).Tables.Add(cosLayer); mvStringArray ff = new mvStringArray(); ff.count = cosLayer.Fields.Count - 1; ff.setElem(0, cosLayer.PkFieldName); int i = 1; foreach (var f in cosLayer.Fields) { if (f.Name != cosLayer.GeomFieldName && f.Name != cosLayer.PkFieldName) { ff.setElem(i++, f.Name); } } var layer = _mv.CreateLayer(cosLayer.NameMap, ff); cosLayer.IsVisible = true; } CosM.CosmeticTableBaseM.UpdateIsNewTable(cosLayer, false); }
/// <summary> /// Удалить объекты слоя /// </summary> /// <param name="table">Таблица</param> /// <param name="ids">Список ID объектов</param> /// <returns>Результат операции</returns> public bool DeleteObjects(CosM.CosmeticTableBaseM table, mvIntArray ids) { if (table != null && ids != null) { try { var layer = MapViewer.getLayer(table.Name); if (layer != null) { bool result = true; for (int i = 0; i < ids.count; i++) { try { mvVectorObject obj = layer.getObject(ids.getElem(i)); int id = Convert.ToInt32((string)obj.fieldValue(table.PkFieldName)); result &= table.DeleteObject(id); } catch { result = false; } } result &= layer.DeleteArray(ids); return(result); } } catch { } } return(false); }
/// <summary> /// Сохранить измененные значения в BindingGroup /// </summary> public void SaveValidation(object parameter = null) { CosM.CosmeticTableBaseM cosLayer = null; if (parameter is Rekod.Behaviors.CommandEventParameter) { var commEventPar = parameter as Rekod.Behaviors.CommandEventParameter; var control = commEventPar.CommandParameter as FrameworkElement; if (control != null) { var bindings = FindBindingGroups(control); for (int i = 0; i < bindings.Count; i++) { if (bindings[i].CommitEdit() == false) { return; } } } var bindProxy = commEventPar.ExtraParameter as BindingProxy; cosLayer = bindProxy.Data as CosM.CosmeticTableBaseM; if (cosLayer.IsNewTable) { RegisterLayer(cosLayer); } ApplyStyleOnMap(cosLayer); var t = Tables.FirstOrDefault(p => (p as CosM.CosmeticTableBaseM).Name == cosLayer.Name); bindProxy.Data = t; } }
public CosmeticAttributesVM(AbsM.ITableBaseM table, int?obj, bool isReadOnly = false, string wkt = null, bool isDebug = false) { _table = table as CosM.CosmeticTableBaseM; if (_table == null) { throw new ArgumentNullException(Rekod.Properties.Resources.CosAttributes_TableIsNull); } else if (_table.PrimaryKeyField == null) { throw new ArgumentNullException(Rekod.Properties.Resources.CosAttributes_TableWithoutPK); } if (obj == null) { throw new ArgumentNullException(Rekod.Properties.Resources.CosAttributes_MvObjectIsNull); } _isDebug = isDebug; _source = _table.Source as CosVM.CosmeticDataRepositoryVM; _tableObject = GetOrCreateTableObject(obj); _attributesListVM = new CosmeticAttributesListVM(this); if (_table.Type == AbsM.ETableType.MapLayer || _table.Type == AbsM.ETableType.View) { string curWKT = string.Empty; if (string.IsNullOrWhiteSpace(wkt)) { var layerMV = Source.MapViewer.getLayer(_table.NameMap); if (layerMV != null) { var objMV = layerMV.getObject(_tableObject.Id); if (objMV != null) { curWKT = objMV.getWKT(); } } } else { curWKT = wkt; } _pgGeometryVM = new PgVM.PgAttributes.PgAttributesGeomVM(_attributesListVM, curWKT, (int?)_attributesListVM.PkAttribute.Value); } _styleVM = GetStyle(); Title = String.Format("{0}: [id: {3}]; {1}: \"{4}\"; {2}: \"{5}\"", Rekod.Properties.Resources.CosAttributes_Object, Rekod.Properties.Resources.CosAttributes_Table, Rekod.Properties.Resources.CosAttributes_Type, _tableObject != null ? _tableObject.Id.ToString() : "null", _table.Text, _table.Source.Type); }
/// <summary> /// Создает новый слой в системе с указанным именем /// </summary> /// <param name="layerName"></param> public void CreateLayer(String layerName) { var cosLayer = new CosM.CosmeticTableBaseM(this, Convert.ToInt32(_mv.SRID)) { Text = layerName, GeomType = AbsM.EGeomType.Any }; RegisterLayer(cosLayer); ApplyStyleOnMap(cosLayer); }
public CosmeticFieldM(AbsM.ITableBaseM table, string name, string text, AbsM.EFieldType type, bool isReadOnly = false) { var cosmTable = table as CosmeticTableBaseM; if (cosmTable == null) { throw new ArgumentNullException("Нет ссылки на таблицу"); } _id = CosmeticFieldM.cosmeticFieldId++; _table = cosmTable; _idTable = _table.Id; _name = name; _text = text; _type = type; _isReadOnly = isReadOnly; }
private void ApplyStyleOnMap(CosM.CosmeticTableBaseM cosLayer) { var mvLayer = Program.mainFrm1.axMapLIb1.getLayer(cosLayer.Name); bool isPrevVisible = mvLayer != null ? mvLayer.Visible : false; cosLayer.IsVisible = false; // Указываем стиль по умолчанию для слоя и стиль подписей mvLayer = Program.mainFrm1.axMapLIb1.getLayer(cosLayer.Name); if (mvLayer != null) { mvLayer.MaxScale = (uint)cosLayer.DefaultStyle.MaxScale; mvLayer.MinScale = (uint)cosLayer.DefaultStyle.MinScale; mvLayer.usebounds = cosLayer.DefaultStyle.UseBounds; var symbolStyle = new mvSymbolObject() { shape = (uint)cosLayer.DefaultStyle.Symbol }; var penStyle = new mvPenObject() { Color = (uint)cosLayer.DefaultStyle.PenColor, ctype = (ushort)cosLayer.DefaultStyle.PenType, width = (uint)cosLayer.DefaultStyle.PenWidth }; var brushStyle = new mvBrushObject() { bgcolor = (uint)cosLayer.DefaultStyle.BrushBgColor, fgcolor = (uint)cosLayer.DefaultStyle.BrushFgColor, hatch = (ushort)cosLayer.DefaultStyle.BrushHatch, style = (ushort)cosLayer.DefaultStyle.BrushStyle }; var fontStyle = new mvFontObject() { fontname = cosLayer.DefaultStyle.FontName, Color = (uint)cosLayer.DefaultStyle.FontColor, framecolor = (uint)cosLayer.DefaultStyle.FontFrameColor, graphicUnits = cosLayer.DefaultStyle.GraphicUnits, size = cosLayer.DefaultStyle.FontSize }; if (cosLayer.DefaultStyle.BrushStyle == 0 && cosLayer.DefaultStyle.BrushHatch == 0) { int grey = Convert.ToInt32(255 & (int)(cosLayer.DefaultStyle.Opacity * 255)); brushStyle.bgcolor = Convert.ToUInt32(grey + (grey << 8) + (grey << 16)); } else if (!cosLayer.DefaultStyle.HasBackground) { brushStyle.bgcolor = 0xffffffff; } cosLayer.SetDefaultStyle(symbolStyle, fontStyle, penStyle, brushStyle); mvFontObject labelFontObj = new mvFontObject(); labelFontObj.Color = cosLayer.LabelStyle.LabelFontColor; labelFontObj.fontname = cosLayer.LabelStyle.LabelFontName; if (cosLayer.LabelStyle.LabelShowFrame) { labelFontObj.framecolor = cosLayer.LabelStyle.LabelFrameColor; } else { labelFontObj.framecolor = 0xFFFFFFFF; } labelFontObj.graphicUnits = cosLayer.LabelStyle.LabelUseGraphicUnits; labelFontObj.italic = cosLayer.LabelStyle.LabelFontItalic; labelFontObj.size = cosLayer.LabelStyle.LabelFontSize; labelFontObj.strikeout = cosLayer.LabelStyle.LabelFontStrikeout; labelFontObj.underline = cosLayer.LabelStyle.LabelFontUnderline; if (cosLayer.LabelStyle.LabelFontBold) { labelFontObj.weight = 650; } mvLayer.showlabels = true; if (cosLayer.LabelStyle.LabelUseBounds) { mvLayer.labelBounds = true; mvLayer.labelMinScale = cosLayer.LabelStyle.LabelMinScale; mvLayer.labelMaxScale = cosLayer.LabelStyle.LabelMaxScale; } mvLayer.labelParallel = cosLayer.LabelStyle.LabelParallel; mvLayer.labelOverlap = cosLayer.LabelStyle.LabelOverlap; mvLayer.labelOffset = cosLayer.LabelStyle.LabelOffset; mvLayer.LabelField = 1; mvLayer.SetLabelstyle(labelFontObj); cosLayer.IsVisible = isPrevVisible; _mv.mapRepaint(); mvLayer.Update(); ReloadInfo(); } }
public static void SetIsNewTable(CosmeticTableBaseM layer, bool isNew) { layer._isNewTable = isNew; }