private async void Edit_Click(object sender, RoutedEventArgs e)
        {
            if (FilterListBox.SelectedItem == null)
            {
                return;                                     // No selection.
            }
            try
            {
                Filter filter = FilterManager.Load(FilterListBox.SelectedItem as string);

                var window = new ItemFilterEditWindow(filter)
                {
                    Owner = this
                };
                if (window.ShowDialog() == true)
                {
                    try
                    {
                        FilterManager.Save(filter);
                        FilterManager.Enable(filter);
                    } catch (Exception ex)
                    {
                        await this.ShowErrorAsync("An error occurred while attempting to save item filter.", ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                await this.ShowErrorAsync("An error occurred while attempting to load item filter.", ex.Message);
            }
        }
        private async void New_Click(object sender, RoutedEventArgs e)
        {
            string name = NameTextBox.Text;

            if (!FilterManager.IsValidFilterName(name))
            {
                await this.ShowErrorAsync(string.Format("'{0}' is incorrect item filter name.", name));

                return;
            }

            if (FilterNames.Contains(name))
            {
                await this.ShowErrorAsync(string.Format("Item filter '{0}' already exists.", name));

                return;
            }

            // Ask whether existing game filter should be overwritten.
            if (FilterManager.GameFilterExists(name))
            {
                string msg = string.Format("Item filter '{0}.filter' already exists in game folder.\nAre you sure you want to overwrite it?", name);
                if (await this.ShowQuestionAsync(msg) == MessageBoxResult.No)
                {
                    return;
                }
            }

            Filter filter = FilterManager.Create(name);

            var window = new ItemFilterEditWindow(filter)
            {
                Owner = this
            };

            if (window.ShowDialog() == true)
            {
                bool saved = false;
                try
                {
                    FilterManager.Save(filter);

                    saved            = true;
                    NameTextBox.Text = string.Empty;
                    FilterNames.Add(name);

                    FilterManager.Enable(filter);
                }
                catch (Exception ex)
                {
                    string msg = saved ? "An error occurred while attempting to create game filter." : "An error occurred while attempting to save item filter.";
                    await this.ShowErrorAsync(msg, ex.Message);
                }
            }
        }