private void PerformFileActionEdit() { if (lstVwFileActions.SelectedItems.Count == 1) { ListViewItem itemExtension = lstVwFileActions.SelectedItems[0] as ListViewItem; var form = new WindowFileActionByExtension(itemExtension.Extension, itemExtension.FileAction); if (form.ShowDialog().GetValueOrDefault()) { string extension = form.SelectedExtension.ToLower(); var fileAction = form.GetFileAction(); this.Dispatcher.Invoke(() => { if (!string.IsNullOrEmpty(extension)) { _sourceFileActions.Remove(itemExtension); _config.FileActionsByExtensions.TryRemove(itemExtension.Extension, out _); _config.FileActionsByExtensions.TryAdd(extension, fileAction); _sourceFileActions.Add(new ListViewItem() { Extension = extension, FileAction = fileAction, }); } }); } UpdateButtonsFileActions(); } }
private void tSBFileActionCreate_Click(object sender, RoutedEventArgs e) { var form = new WindowFileActionByExtension(string.Empty, _config.DefaultFileAction); if (form.ShowDialog().GetValueOrDefault()) { string extension = form.SelectedExtension; var fileAction = form.GetFileAction(); this.Dispatcher.Invoke(() => { if (!string.IsNullOrEmpty(extension) && !_config.FileActionsByExtensions.ContainsKey(extension)) { _config.FileActionsByExtensions.TryAdd(extension, fileAction); _sourceFileActions.Add(new ListViewItem() { Extension = extension, FileAction = fileAction, }); } }); } UpdateButtonsFileActions(); }