Пример #1
0
        private void PerformSelection(D2DShape shape)
        {
            MapShapeModel model = shape.Model as MapShapeModel;

            if (model == null)
            {
                Debug.Assert(false, "Must have a model associated with each UI shape");
                return;
            }

            var context = new SelectionChangeContext()
            {
                Layer = this.map.Layers.FindLayerById(shape.LayerId),
                Shape = shape,
                Model = model
            };

            if (this.selectionModeCache == MapShapeSelectionMode.Single)
            {
                this.SingleSelect(context, true);
            }
            else if (this.selectionModeCache == MapShapeSelectionMode.MultiSimple)
            {
                this.SingleSelect(context, false);
            }
            else if (this.selectionModeCache == MapShapeSelectionMode.MultiExtended)
            {
                this.MultiExtendedSelect(context);
            }

            this.NotifySelectionChanged(context);
        }
Пример #2
0
        private void AddShape(D2DShape shape, MapShapeModel model)
        {
            // cross-references since we need to look-up a model from a shape and a shape from a model
            this.modelToVisualTable.Add(model, shape);
            shape.Model = model;

            // TODO: Extend label logic
            shape.Label = this.GetShapeTextBlock(model);
            this.ApplyShapeStyle(shape);

            this.shapes.Add(shape);
        }
Пример #3
0
        private D2DTextBlock GetShapeTextBlock(MapShapeModel model)
        {
            var text = this.GetShapeLabel(model);

            if (text == null)
            {
                return(null);
            }

            return(new D2DTextBlock()
            {
                Text = text
            });
        }
Пример #4
0
        private void SelectModel(MapShapeModel model)
        {
            var context = new SelectionChangeContext()
            {
                Model = model
            };

            this.ClearSelectedModels(context, false);

            this.selectedModels.Add(context.Model);

            context.AddedItems = new List <object>();
            context.AddedItems.Add(context.Model);

            this.NotifySelectionChanged(context);
        }
Пример #5
0
        /// <inheritdoc />
        protected override string GetNameCore()
        {
            MapShapeModel model = this.ShapeModel as MapShapeModel;

            if (model != null)
            {
                string layerLabelAttribute = this.LayerPeer.LayerOwner.ShapeLabelAttributeName;
                if (!string.IsNullOrEmpty(layerLabelAttribute))
                {
                    if (model.Attributes[layerLabelAttribute] != null)
                    {
                        return(model.Attributes[layerLabelAttribute].ToString());
                    }
                }
                return(model.UniqueId.ToString());
            }
            return(this.GetHashCode().ToString());
        }
Пример #6
0
        private string GetShapeLabel(MapShapeModel model)
        {
            if (string.IsNullOrEmpty(this.labelAttributeNameCache))
            {
                return(null);
            }

            object labelValue;

            if (!model.Attributes.TryGetValue(this.labelAttributeNameCache, out labelValue))
            {
                return(null);
            }

            if (labelValue == null)
            {
                return(null);
            }

            return(labelValue.ToString());
        }
 internal void DeselectShape(MapShapeModel shapeModel)
 {
     this.selectedModels.Remove(shapeModel);
 }