Example #1
0
 bool CanClearValueInField(object param = null)
 {
     CosM.CosmeticAttributes.CosmeticAttributeM attr = null;
     if (param is CommandEventParameter)
     {
         CommandEventParameter commEvtParam = param as CommandEventParameter;
         attr = commEvtParam.CommandParameter as CosM.CosmeticAttributes.CosmeticAttributeM;
     }
     else if (param is CosM.CosmeticAttributes.CosmeticAttributeM)
     {
         attr = param as CosM.CosmeticAttributes.CosmeticAttributeM;
     }
     return(attr != null && attr.Value != null);
 }
Example #2
0
 void ClearValueInField(object param = null)
 {
     if (CanClearValueInField(param))
     {
         CosM.CosmeticAttributes.CosmeticAttributeM attr = null;
         if (param is CommandEventParameter)
         {
             CommandEventParameter commEvtParam = param as CommandEventParameter;
             attr = commEvtParam.CommandParameter as CosM.CosmeticAttributes.CosmeticAttributeM;
         }
         else if (param is CosM.CosmeticAttributes.CosmeticAttributeM)
         {
             attr = param as CosM.CosmeticAttributes.CosmeticAttributeM;
         }
         attr.Value = null;
     }
 }
Example #3
0
        /// <summary>
        /// Загружает или обновляет список атрибутов
        /// </summary>
        public void Reload(object param = null)
        {
            var addAttributes = new List <CosM.CosmeticAttributes.CosmeticAttributeM>();

            foreach (CosM.CosmeticFieldM item in _table.Fields)
            {
                if (item.Type != AbsM.EFieldType.Geometry &&
                    PkAttribute.Field != item)
                {
                    var attribute = FindAttribute(item);
                    if (attribute == null)
                    {
                        attribute = new CosM.CosmeticAttributes.CosmeticAttributeM(item);
                    }
                    addAttributes.Add(attribute);
                }
            }
            ExtraFunctions.Sorts.SortList(Attributes, addAttributes);
            var layer = _attributeVM.Source.MapViewer.getLayer(Table.Name);

            if (layer != null)
            {
                for (int t = 0; t < layer.FieldsCount; t++)
                {
                    String fieldName  = layer.FieldName(t).ToString();
                    var    vmObj      = layer.getObject(_attributeVM.TableObject.Id);
                    Object fieldValue = vmObj.fieldValue(fieldName);

                    if (PkAttribute.Field.Name == fieldName)
                    {
                        PkAttribute.Value = fieldValue;
                    }
                    else
                    {
                        var attr = Attributes.FirstOrDefault(a => a.Field.Name == fieldName);
                        if (attr != null)
                        {
                            attr.Value = fieldValue;
                        }
                    }
                }
            }
            CancelValidation(param);
        }
Example #4
0
        /// <summary>
        /// Работы с атрибутами объекта
        /// </summary>
        /// <param name="table">Ссылка на таблицу</param>
        /// <param name="mapObj">Объекта слоя с атрибутами.</param>
        /// <exception cref="ArgumentNullException"/>
        public CosmeticAttributesListVM(CosmeticAttributesVM attributeVM)
        {
            _attributeVM = attributeVM;

            _isDebug = attributeVM.IsDebug;
            _table   = attributeVM.Table;

            _geomAttribute = new CosM.CosmeticAttributes.CosmeticAttributeM((CosM.CosmeticFieldM)_table.Fields.First(p => p.Name == _table.GeomFieldName));
            _pkAttribute   = new CosM.CosmeticAttributes.CosmeticAttributeM((CosM.CosmeticFieldM)_table.PrimaryKeyField);

            if (_attributeVM.TableObject != null)
            {
                int id = _attributeVM.TableObject.Id;
                if (id >= 0)
                {
                    _pkAttribute.Value = id;
                }
            }

            _isNew = (_pkAttribute.Value == null);

            _attributes = new ObservableCollection <CosM.CosmeticAttributes.CosmeticAttributeM>();
        }