private void UpdateForm()
        {
            var enable = ListBoxUserExpressions.SelectedItem is UserExpressionVisualItem;

            ButtonCopyCurrent.IsEnabled = enable;
            ButtonDelete.IsEnabled      = enable;
            ButtonMoveUp.IsEnabled      = enable;
            ButtonMoveDown.IsEnabled    = enable;

            if (!enable)
            {
                return;
            }

            _selectedPredefinedCondition = (UserExpressionVisualItem)ListBoxUserExpressions.SelectedItem;

            TextBoxCaption.Text          = _selectedPredefinedCondition.Caption;
            TextBoxExpression.Text       = _selectedPredefinedCondition.Condition;
            CheckBoxIsNeedEdit.IsChecked = _selectedPredefinedCondition.IsNeedEdit;

            foreach (var item in _selectedPredefinedCondition.ShowOnlyForDbTypes.Select(type => ComboboxDbTypes.Items.First(x =>
                                                                                                                            string.Equals(x.Content.ToString(), type.ToString(), StringComparison.InvariantCultureIgnoreCase))))
            {
                item.IsChecked = true;
            }

            ButtonSave.IsEnabled = false;
        }
        private void ResetForm()
        {
            _selectedPredefinedCondition = null;
            TextBoxCaption.Text          = string.Empty;
            TextBoxExpression.Text       = string.Empty;
            CheckBoxIsNeedEdit.IsChecked = false;

            foreach (var selectableItem in ComboboxDbTypes.Items)
            {
                selectableItem.IsChecked = false;
            }
        }
        public void Load(IQueryView queryView)
        {
            _source.Clear();
            _selectedPredefinedCondition = null;

            if (_queryView == null)
            {
                _queryView = queryView;
                TextBoxExpression.Query = queryView.Query;
            }

            if (_queryView == null)
            {
                return;
            }

            foreach (var expression in _queryView.UserPredefinedConditions)
            {
                _source.Add(new UserExpressionVisualItem(expression));
            }
        }
        private void ButtonCopyCurrent_OnClick(object sender, RoutedEventArgs e)
        {
            _selectedPredefinedCondition = ListBoxUserExpressions.SelectedItem as UserExpressionVisualItem;

            if (_selectedPredefinedCondition == null)
            {
                return;
            }

            var name = _selectedPredefinedCondition.Caption;

            var newName = "";

            if (_source.All(x => string.Compare(x.Caption, $"{name} Copy", StringComparison.InvariantCultureIgnoreCase) != 0))
            {
                newName = $"{name} Copy";
            }
            else
            {
                for (var i = 1; i < 1000; i++)
                {
                    if (_source.Any(x => string.Compare(x.Caption, $"{name} Copy ({i})", StringComparison.InvariantCultureIgnoreCase) == 0))
                    {
                        continue;
                    }

                    newName = $"{name} Copy ({i})";
                    break;
                }
            }

            var newCopy = _selectedPredefinedCondition.Copy(newName);
            var index   = _source.IndexOf(_selectedPredefinedCondition);

            _queryView.UserPredefinedConditions.Insert(index + 1, newCopy.PredefinedCondition);

            Load(null);
            ListBoxUserExpressions.SelectedIndex = index + 1;
        }