Beispiel #1
0
        /// <summary>
        /// Handles the double click.
        /// </summary>
        /// <param name="lv">The lv.</param>
        /// <param name="dictionary">The dictionary.</param>
        private void HandleDoubleClick(Selector lv, IDictionary<string, string> dictionary)
        {
            if (lv.SelectedItem == null)
            {
                return;
            }

            var item = (KeyValuePair<string, string>)lv.SelectedItem;
            var modal = new EditItem(item.Key, item.Value) { Owner = this };

            if ((bool)(!modal.ShowDialog()))
            {
                return;
            }

            this.SetValueFromModal(modal, dictionary);

            if (item.Key != modal.Key && dictionary.ContainsKey(item.Key))
            {
                dictionary.Remove(item.Key);
            }

            lv.ItemsSource = null;
            lv.ItemsSource = dictionary;
        }
Beispiel #2
0
 /// <summary>
 /// Sets the value from modal.
 /// </summary>
 /// <param name="modal">The modal.</param>
 /// <param name="items">The items.</param>
 private void SetValueFromModal(EditItem modal, IDictionary<string, string> items)
 {
     this.IsDirty = true;
     if (items.ContainsKey(modal.Key))
     {
         items[modal.Key] = modal.Value;
     }
     else
     {
         items.Add(modal.Key, modal.Value);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Handles the add.
        /// </summary>
        /// <param name="lv">The lv.</param>
        /// <param name="dictionary">The dictionary.</param>
        private void HandleAdd(ItemsControl lv, IDictionary<string, string> dictionary)
        {
            var modal = new EditItem { Owner = this };

            if ((bool)(!modal.ShowDialog()))
            {
                return;
            }

            this.SetValueFromModal(modal, dictionary);

            lv.ItemsSource = null;
            lv.ItemsSource = dictionary;
        }