Пример #1
0
        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>();
            }
        }
Пример #2
0
 private string GetMetadataValue(string key)
 {
     if (UIMetadata.ContainsKey(key))
     {
         return(UIMetadata[key]);
     }
     return(string.Empty);
 }
Пример #3
0
        public SendMailView()
        {
            InitializeComponent();

            UIMetadata = new UIMetadata {
                LabelProvider = () => "Send mail"
            };
        }
Пример #4
0
 void IEditableObject.CancelEdit()
 {
     Updates.Clear();
     UIMetadata.Clear();
     foreach (var metadata in Metadata)
     {
         UIMetadata.Add(metadata.Key, metadata.Value.Value);
     }
 }
Пример #5
0
        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);
        }
Пример #6
0
        protected ViewModelBase(bool createPropertiesAndCommandsImmediately)
        {
            _registeredProperties       = new List <IViewModelProperty>();
            _registeredCommands         = new List <ISimpleCommand>();
            _observableValidationEngine = new ObservableValidationEngine();

            UIMetadata = new UIMetadata {
                LabelProvider = () => "???"
            };

            if (createPropertiesAndCommandsImmediately)
            {
                InitializeAll();
            }
        }
Пример #7
0
        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);
        }
Пример #8
0
        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++;
            }
        }
Пример #9
0
 public ContactViewModel()
 {
     UIMetadata = new UIMetadata {
         LabelProvider = () => Texts.ModifyContactInformations
     };
 }
Пример #10
0
 public FakeViewModel()
 {
     UIMetadata = new UIMetadata {
         LabelProvider = () => "Label"
     };
 }
Пример #11
0
 public void SetMetadata(UIMetadata metadata)
 {
     this.metadata = metadata;
 }