void IEditableObject.EndEdit() { if (Updates.Count > 0) { //removes any operations that act on the same metadata key, only the last update is added to the chain CompactUpdates(); var chain = new TransactionChain(); foreach (var detail in Updates) { switch (detail.Type) { case UpdateMetadataType.AddOrUpdateValue: Metadata.Add(detail.NewKey, detail.NewValue, ref chain); if (UIMetadata.ContainsKey(detail.NewKey)) { UIMetadata[detail.NewKey] = detail.NewValue; } else { UIMetadata.Add(detail.NewKey, detail.NewValue); } OnNotifyPropertyChanged(detail.NewKey); break; case UpdateMetadataType.Delete: if (Metadata.ContainsKey(detail.NewKey)) { Metadata[detail.NewKey].MetadataSet.Delete(ref chain); Metadata.Remove(detail.NewKey); } if (UIMetadata.ContainsKey(detail.NewKey)) { UIMetadata.Remove(detail.NewKey); } break; case UpdateMetadataType.UpdateKey: if (Metadata.ContainsKey(detail.Key)) { var metadataSet = Metadata[detail.Key]; metadataSet.SetName(detail.NewKey, ref chain); if (!metadataSet.Value.Equals(detail.NewValue)) { metadataSet.SetValue(detail.NewValue, ref chain); } Metadata.Remove(detail.Key); Metadata.Add(detail.NewKey, metadataSet); UIMetadata.Remove(detail.Key); UIMetadata.Add(detail.NewKey, detail.NewValue); } break; } } MapManager.ExecuteTransaction(chain); Updates = new List <UpdateMetadataDetail>(); } }
void IEditableObject.CancelEdit() { Updates.Clear(); UIMetadata.Clear(); foreach (var metadata in Metadata) { UIMetadata.Add(metadata.Key, metadata.Value.Value); } }
public MultipleNodesProperties(List <NodeProperties> nodes) { NodeProperties = nodes; var count = 0; foreach (var node in nodes) { foreach (var uiMetadata in node.UIMetadata) { if (!UIMetadata.ContainsKey(uiMetadata.Key)) { if (count == 0) { UIMetadata.Add(uiMetadata.Key, uiMetadata.Value); } else { UIMetadata.Add(uiMetadata.Key, string.Empty); } } else if (UIMetadata[uiMetadata.Key] != uiMetadata.Value) { UIMetadata[uiMetadata.Key] = string.Empty; } } if (count > 0) { var copy = UIMetadata.ToList(); foreach (var keyValuePair in copy) { if (!node.UIMetadata.ContainsKey(keyValuePair.Key)) { UIMetadata[keyValuePair.Key] = string.Empty; } } } count++; } }