private void lbFields_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var selectedField = lbFields.SelectedItem as a7FilterElementDefinition;

            if (selectedField != null)
            {
                var fae = new a7SqlTools.Controls.Filter.a7FilterElementEditor(selectedField)
                {
                    Margin = new Thickness(0, 0, 0, 0), IsReadOnly = this.IsReadOnly
                };
                fae.EditorContext = this.EditorContext;
                var fge = new a7FilterGroupEditor(_entity, !_vertical, IsReadOnly, EditorContext)
                {
                    Background = Brushes.White
                };
                fge.SetAtomFilter(fae);
                AddGroupSubFilter(fge);
                popupFieldSelect.IsOpen = false;
            }
        }
Example #2
0
        private void lbFields_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var selectedField = lbFields.SelectedItem as a7FilterElementDefinition;

            if (selectedField != null)
            {
                gStartPanel.Visibility = Visibility.Collapsed;
                MyBorder.Visibility    = System.Windows.Visibility.Visible;
                spButtons.Visibility   = System.Windows.Visibility.Visible;
                var fge = new a7FilterGroupEditor(_entity, false, this.IsReadOnly, this);
                var fae = new a7FilterElementEditor(selectedField)
                {
                    Margin = new Thickness(0, 0, 0, 0), IsReadOnly = this.IsReadOnly
                };
                fae.EditorContext = this;
                fge.SetAtomFilter(fae);
                this.FilterExpr = fge.Filter;
                SetRootGroup(fge);
            }
        }
        private void addGroupSubFilter(a7FilterGroupEditor fge, bool fromRemove)
        {
            fge.Parent = this;
            FltGroupExprData fgeExpr = null;

            if (this.Filter is FltGroupExprData)
            {
                fgeExpr = this.Filter as FltGroupExprData;
            }
            else
            {
                if (JoinType.HasValue)
                {
                    fgeExpr = new FltGroupExprData(JoinType.Value);
                }
                else
                {
                    fgeExpr = new FltGroupExprData();
                }
                if (Parent != null && Parent.Filter != null)
                {
                    var parentGroup = Parent.Filter as FltGroupExprData;
                    parentGroup.FilterExpressions.Remove(this.Filter);
                    parentGroup.FilterExpressions.Add(fgeExpr);
                }
                this.Filter = fgeExpr;
            }
            fgeExpr.FilterExpressions.Add(fge.Filter);



            if (this.SubGroups.Count > 0 || this.AtomFilter != null)
            {
                bAdd.Visibility = Visibility.Visible;
                bAnd.Visibility = Visibility.Collapsed;
                bOr.Visibility  = Visibility.Collapsed;
            }
            else
            {
                SetBackground(fge.MyBackgroundIndex + a7SqlTools.Controls.Filter.a7FilterEditor.BackgroundIndexStep);
                bAdd.Visibility = Visibility.Collapsed;
                bAnd.Visibility = Visibility.Visible;
                bOr.Visibility  = Visibility.Visible;
            }

            if (JoinType.HasValue)
            {
                if (JoinType.Value == eAndOrJoin.And)
                {
                    miChangeToOr.Visibility  = System.Windows.Visibility.Visible;
                    miChangeToAnd.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    miChangeToOr.Visibility  = System.Windows.Visibility.Collapsed;
                    miChangeToAnd.Visibility = System.Windows.Visibility.Visible;
                }
            }
            else
            {
                miChangeToOr.Visibility  = System.Windows.Visibility.Collapsed;
                miChangeToAnd.Visibility = System.Windows.Visibility.Collapsed;
            }

            if (!fromRemove && (AddedFirstElement != null && this.Parent == null))
            {
                this.AddedFirstElement(this, null);
            }

            if (AtomFilter != null) //replacing existing atomfilter with groupfilter containing the atomfilter
            {
                var newFge = new a7FilterGroupEditor(_entity, !_vertical, this.IsReadOnly, EditorContext, AtomFilter.Filter);
                fgeExpr.FilterExpressions.Add(AtomFilter.Filter);
                newFge.Parent  = this;
                ccAtom.Content = null;
                newFge.SetAtomFilter(AtomFilter);
                AtomFilter = null;
                this.Negate(false);
                spSubGroups.Children.Add(newFge);
                SubGroups.Add(newFge);
            }

            if (SubGroups.Count > 0 && JoinType.HasValue)
            {
                var andOrLabel = new Label()
                {
                    Content             = (JoinType.Value == eAndOrJoin.And) ? "And": "Or",
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                spSubGroups.Children.Add(andOrLabel);
                fge.JoinLabelOnParent = andOrLabel;
                fgeExpr.AndOr         = JoinType.Value;
            }
            SubGroups.Add(fge);
            spSubGroups.Children.Add(fge);
            fge.AtomFilter?.FocusControl();
        }