コード例 #1
0
 public void SetRootGroup(a7FilterGroupEditor fge)
 {
     if (_rootGroup != null)
     {
         var flt = _rootGroup.Filter; //setvalue, clear binding
         BindingOperations.ClearBinding(_rootGroup, a7FilterGroupEditor.FilterProperty);
         _rootGroup.Filter             = flt;
         _rootGroup.AddedFirstElement -= fgeOnAddedFirstElement;
         _rootGroup.Parent             = fge;
         mainGrid.Children.Remove(_rootGroup);
     }
     _rootGroup = fge;
     this.SetBinding(a7FilterEditor.FilterExprProperty, new Binding("Filter")
     {
         Source = fge, Mode = BindingMode.TwoWay
     });
     //      fge.Background = Brushes.White;
     fge.AddedFirstElement += fgeOnAddedFirstElement;
     fge.Parent             = null;
     mainGrid.Children.Add(fge);
     if (fge.AtomFilter != null)
     {
         fge.SetAsRoot();
     }
 }
コード例 #2
0
        public void RemoveSubGroup(a7FilterGroupEditor fe)
        {
            var ix = this.spSubGroups.Children.IndexOf(fe);

            if (ix == 0 && this.SubGroups.Count > 1) //remove the join label from second element if first is removed
            {
                this.spSubGroups.Children.Remove(this.SubGroups[1].JoinLabelOnParent);
                this.SubGroups[1].JoinLabelOnParent = null;
            }
            this.spSubGroups.Children.Remove(fe);
            this.spSubGroups.Children.Remove(fe.JoinLabelOnParent);
            this.SubGroups.Remove(fe);
            var fgeExpr = this.Filter as FltGroupExprData;

            if (fgeExpr != null)
            {
                fgeExpr.FilterExpressions.Remove(fe.Filter);
            }
            if (this.SubGroups.Count == 1)
            {
                if (Parent != null)
                {
                    var or = Parent.Orientation;
                    this.SubGroups[0].Orientation = (or == Orientation.Horizontal)
                                                        ? Orientation.Vertical
                                                        : Orientation.Horizontal;
                    this.SubGroups[0]._vertical = !Parent._vertical;
                    this.spSubGroups.Children.Remove(this.SubGroups[0]);
                    Parent.addGroupSubFilter(this.SubGroups[0], true);
                    Parent.RemoveSubGroup(this);
                }
                else
                {
                    if (this.SubGroups[0].SubGroups.Count < 2)
                    {
                        var or = this.SubGroups[0].Orientation;
                        this.SubGroups[0].Orientation = Orientation.Horizontal;
                        this.SubGroups[0]._vertical   = false;
                        this.spSubGroups.Children.Remove(this.SubGroups[0]);
                        EditorContext.SetRootGroup(this.SubGroups[0]);
                    }
                    bAdd.Visibility = Visibility.Collapsed;
                    bAnd.Visibility = Visibility.Visible;
                    bOr.Visibility  = Visibility.Visible;
                }
            }
            else if (this.SubGroups.Count == 0)
            {
                if (Parent != null)
                {
                    Parent.RemoveSubGroup(this);
                }
                else
                {
                    EditorContext.Reset();
                }
            }
        }
コード例 #3
0
 public void SetFilter(FilterExpressionData filter)
 {
     Reset();
     this.Filter = filter;
     if (filter != null)
     {
         if (filter is FltAtomExprData)
         {
             if (filter.HasActiveFilter)
             {
                 this.Filter = filter;
                 if (_entity != null && _entity.AvailableColumns.Any(column => column.Name == (filter as FltAtomExprData)?.Field))
                 {
                     this.SetAtomFilter(new a7SqlTools.Controls.Filter.a7FilterElementEditor(_entity, filter as FltAtomExprData)
                     {
                         IsReadOnly    = this.IsReadOnly,
                         EditorContext = this.EditorContext
                     });
                 }
             }
         }
         else if (filter is FltGroupExprData)
         {
             var fge = filter as FltGroupExprData;
             this.Filter   = new FltGroupExprData(fge.AndOr);
             this.JoinType = fge.AndOr;
             foreach (var f in fge.FilterExpressions)
             {
                 if (f.HasActiveFilter)
                 {
                     var subGroup = new a7FilterGroupEditor(_entity, !_vertical, this.IsReadOnly, EditorContext, f);
                     this.AddGroupSubFilter(subGroup);
                 }
             }
         }
         else if (filter is FltFlatGroupExprData)
         {
             var fge = filter as FltFlatGroupExprData;
             this.Filter   = new FltFlatGroupExprData(fge.AndOr);
             this.JoinType = fge.AndOr;
             foreach (var f in fge.FieldFilters.Values)
             {
                 if (f.HasActiveFilter)
                 {
                     var subGroup = new a7FilterGroupEditor(_entity, !_vertical, this.IsReadOnly, EditorContext, f);
                     this.AddGroupSubFilter(subGroup);
                 }
             }
         }
         this.Negate(filter.Negate);
     }
     if (this.AtomFilter == null && this.SubGroups.Count == 0)
     {
         Reset();
     }
 }
コード例 #4
0
 private void fgeOnAddedFirstElement(object sender, EventArgs eventArgs)
 {
     if (!this.IsReadOnly)
     {
         _backgroundIndex += BackgroundIndexStep;
         var newFge = new a7FilterGroupEditor(_entity, true, this.IsReadOnly, this);
         mainGrid.Children.Remove(_rootGroup);
         newFge.AddGroupSubFilter(_rootGroup);
         newFge.SetBackground(_rootGroup.MyBackgroundIndex + BackgroundIndexStep);
         SetRootGroup(newFge);
     }
 }
コード例 #5
0
        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;
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        public void SetFilter(a7SingleTableExplorer entity, FilterExpressionData filter)
        {
            if (entity == null)
            {
                Reset();
                return;
            }
            Elements = a7FilterEditorUtils.GetFilterEditorElements(entity);
            var fge = new a7FilterGroupEditor(entity, false, this.IsReadOnly, this);

            fge.SetFilter(filter);
            this.FilterExpr = filter;
            SetRootGroup(fge);
            if (filter != null)
            {
                gStartPanel.Visibility = Visibility.Collapsed;
                MyBorder.Visibility    = System.Windows.Visibility.Visible;
                if (!IsReadOnly)
                {
                    spButtons.Visibility = System.Windows.Visibility.Visible;
                }
            }
        }
コード例 #8
0
        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();
        }
コード例 #9
0
 public void AddGroupSubFilter(a7FilterGroupEditor fge)
 {
     addGroupSubFilter(fge, false);
 }