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>(); } }
private string GetMetadataValue(string key) { if (UIMetadata.ContainsKey(key)) { return(UIMetadata[key]); } return(string.Empty); }
public SendMailView() { InitializeComponent(); UIMetadata = new UIMetadata { LabelProvider = () => "Send mail" }; }
void IEditableObject.CancelEdit() { Updates.Clear(); UIMetadata.Clear(); foreach (var metadata in Metadata) { UIMetadata.Add(metadata.Key, metadata.Value.Value); } }
private int?GetIntMetadataValue(string key) { if (UIMetadata.ContainsKey(key)) { var stringValue = UIMetadata[key]; int result; if (int.TryParse(stringValue, out result)) { return(result); } } return(null); }
protected ViewModelBase(bool createPropertiesAndCommandsImmediately) { _registeredProperties = new List <IViewModelProperty>(); _registeredCommands = new List <ISimpleCommand>(); _observableValidationEngine = new ObservableValidationEngine(); UIMetadata = new UIMetadata { LabelProvider = () => "???" }; if (createPropertiesAndCommandsImmediately) { InitializeAll(); } }
public static UIMetadata GetUIMetadata(Rank rank) { var result = new UIMetadata(); switch (rank) { case Rank.Boss: result.LabelProvider = () => Labels.Boss; break; case Rank.Trainee: result.LabelProvider = () => Labels.Trainee; break; } return(result); }
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++; } }
public ContactViewModel() { UIMetadata = new UIMetadata { LabelProvider = () => Texts.ModifyContactInformations }; }
public FakeViewModel() { UIMetadata = new UIMetadata { LabelProvider = () => "Label" }; }
public void SetMetadata(UIMetadata metadata) { this.metadata = metadata; }