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); }
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); }
private D2DTextBlock GetShapeTextBlock(MapShapeModel model) { var text = this.GetShapeLabel(model); if (text == null) { return(null); } return(new D2DTextBlock() { Text = text }); }
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); }
/// <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()); }
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); }