상속: System.Windows.Freezable
예제 #1
0
        private void ComboBoxOperation_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            FilterOption f = DataContext as FilterOption;

            if (f == null)
            {
                return;
            }

            var newValue = e.AddedItems.Cast <FilterOperation?>().SingleOrDefault();

            if (newValue == FilterOperation.IsIn)
            {
                if (!(f.Value is IList))
                {
                    valueContainer.Children.Clear();
                    var list = (IList)Activator.CreateInstance(typeof(MList <>).MakeGenericType(f.Token.Type.Nullify()));
                    list.Add(f.Value);
                    f.Value = list;
                    RecreateControls();
                }
            }
            else
            {
                if (f.Value is IList)
                {
                    valueContainer.Children.Clear();
                    f.Value = ((IList)f.Value)[0];
                    RecreateControls();
                }
            }
        }
예제 #2
0
        private void StackPanel_Loaded(object sender, RoutedEventArgs e)
        {
            FilterOption f = (FilterOption)valueContainer.DataContext;

            Common.SetIsReadOnly(valueContainer, f.Frozen);

            RecreateControls();
        }
예제 #3
0
        private void sp_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(FilterOption)))
            {
                FilterOption filter = (FilterOption)e.Data.GetData(typeof(FilterOption));

                Token = filter.Token;
            }
        }
예제 #4
0
        void CreateItem(object sender, RoutedEventArgs args)
        {
            FilterOption f    = (FilterOption)DataContext;
            var          list = (IList)f.Value;

            list.Add(null);

            RecreateControls();
        }
예제 #5
0
        private void RefreshSimpleFilters()
        {
            if (SimpleFilterBuilder != null)
            {
                FilterOptions.Clear();
                var newFilters = SimpleFilterBuilder.GenerateFilterOptions();

                FilterOption.SetFilterTokens(newFilters, Description);
                FilterOptions.AddRange(newFilters);
            }
        }
예제 #6
0
        private void filterHeader_Click(object sender, RoutedEventArgs e)
        {
            SortGridViewColumnHeader gvch = GetHeaderColumnHeader(sender);

            FilterOptions.Add(new FilterOption
            {
                Token     = gvch.RequestColumn.Token,
                Operation = FilterOperation.EqualTo,
                Value     = FilterOption.DefaultValue(gvch.RequestColumn.Type),
            });
        }
예제 #7
0
        public static QueryValueRequest ToRequest(this QueryCountOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            FilterOption.SetFilterTokens(options.FilterOptions, qd);

            var request = new QueryValueRequest
            {
                QueryName = options.QueryName,
                Filters   = options.FilterOptions.Select(f => f.ToFilter()).ToList()
            };

            return(request);
        }
예제 #8
0
        void RemoveItem(object sender, RoutedEventArgs args)
        {
            Button     b    = (Button)sender;
            DockPanel  line = (DockPanel)b.Parent;
            StackPanel sp   = (StackPanel)line.Parent;

            int index = sp.Children.IndexOf(line);

            FilterOption f    = (FilterOption)DataContext;
            var          list = (IList)f.Value;

            list.RemoveAt(index);

            RecreateControls();
        }
        public void AddFilter(QueryToken queryToken)
        {
            if (queryToken == null)
            {
                MessageBox.Show(SearchMessage.NoColumnSelected.NiceToString());
                return;
            }

            FilterOption f = new FilterOption
            {
                Token     = queryToken,
                Value     = queryToken.Type.IsValueType && !queryToken.Type.IsNullable() ? Activator.CreateInstance(queryToken.Type) : null,
                Operation = FilterOperation.EqualTo
            };

            Filters.Add(f);
        }
예제 #10
0
        public void AddFilter(QueryToken queryToken)
        {
            if (queryToken == null)
            {
                MessageBox.Show(SearchMessage.NoColumnSelected.NiceToString());
                return;
            }

            FilterOption f = new FilterOption
            {
                Token = queryToken,
                Value = queryToken.Type.IsValueType && !queryToken.Type.IsNullable() ? Activator.CreateInstance(queryToken.Type) : null,
                Operation = FilterOperation.EqualTo
            };

            Filters.Add(f);
        }
예제 #11
0
        public static UniqueEntityRequest ToRequest(this UniqueOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            FilterOption.SetFilterTokens(options.FilterOptions, qd);
            OrderOption.SetOrderTokens(options.OrderOptions, qd);

            var request = new UniqueEntityRequest
            {
                QueryName  = options.QueryName,
                Filters    = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders     = options.OrderOptions.Select(f => f.ToOrder()).ToList(),
                UniqueType = options.UniqueType,
            };

            return(request);
        }
예제 #12
0
        public static QueryGroupRequest ToRequest(this QueryGroupOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            ColumnOption.SetColumnTokens(options.ColumnOptions, qd, canAggregate: true);
            FilterOption.SetFilterTokens(options.FilterOptions, qd, canAggregate: true);
            OrderOption.SetOrderTokens(options.OrderOptions, qd, canAggregate: true);

            var request = new QueryGroupRequest
            {
                QueryName = options.QueryName,
                Filters   = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders    = options.OrderOptions.Select(f => f.ToOrder()).ToList(),
                Columns   = options.ColumnOptions.Select(f => f.ToColumn()).ToList(),
            };

            return(request);
        }
예제 #13
0
        public static QueryRequest ToRequest(this QueryOptions options)
        {
            QueryDescription qd = GetQueryDescription(options.QueryName);

            ColumnOption.SetColumnTokens(options.ColumnOptions, qd);
            FilterOption.SetFilterTokens(options.FilterOptions, qd);
            OrderOption.SetOrderTokens(options.OrderOptions, qd);

            var request = new QueryRequest
            {
                QueryName  = options.QueryName,
                Filters    = options.FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders     = options.OrderOptions.Select(f => f.ToOrder()).ToList(),
                Columns    = ColumnOption.MergeColumns(options.ColumnOptions, options.ColumnOptionsMode, qd),
                Pagination = options.Pagination ?? QueryOptions.DefaultPagination,
            };

            return(request);
        }
예제 #14
0
        public void Reinitialize(IEnumerable <FilterOption> filters, List <ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List <OrderOption> orders)
        {
            if (qd == null)
            {
                qd = DynamicQueryServer.GetQueryDescription(QueryName);
            }

            ColumnOptions.Clear();
            ColumnOptions.AddRange(columns);
            ColumnOptionsMode = columnOptionsMode;

            FilterOptions.Clear();
            FilterOptions.AddRange(filters);
            FilterOption.SetFilterTokens(FilterOptions, qd);

            OrderOptions.Clear();
            OrderOptions.AddRange(orders);
            OrderOption.SetOrderTokens(OrderOptions, qd);
        }
예제 #15
0
        private void RecreateControls()
        {
            FilterOption f = (FilterOption)DataContext;

            valueContainer.Children.Clear();

            if (f.Operation != FilterOperation.IsIn)
            {
                FillLite(f.RealValue as Lite <IEntity>);

                valueContainer.Children.Add(GetValueControl(f.Token, "RealValue"));
            }
            else
            {
                StackPanel sp = new StackPanel {
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var list = (IList)f.Value;
                for (int i = 0; i < list.Count; i++)
                {
                    FillLite(list[i] as Lite <IEntity>);

                    sp.Children.Add(new DockPanel
                    {
                        LastChildFill       = true,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        Children            =
                        {
                            (i == 0?
                             new Button {
                                Style = (Style)FindResource("RoundButton"), Focusable = false, Content = FindResource("Create")
                            }.Handle(Button.ClickEvent, CreateItem):
                             new Button {
                                Style = (Style)FindResource("RoundButton"), Focusable = false, Content = FindResource("Remove")
                            }.Handle(Button.ClickEvent, RemoveItem)
                            ).Set(DockPanel.DockProperty, Dock.Left),
                            GetValueControl(f.Token, "RealValue[" + i + "]"),
                        }
                    });
                }
                valueContainer.Children.Add(sp);
            }
        }
예제 #16
0
        void SearchControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= SearchControl_Loaded;

            if (DesignerProperties.GetIsInDesignMode(this) || QueryName == null)
            {
                return;
            }

            if (qd == null)
            {
                qd = DynamicQueryServer.GetQueryDescription(QueryName);
            }

            if (FilterColumn.HasText())
            {
                FilterOptions.Add(new FilterOption
                {
                    ColumnName = FilterColumn,
                    Operation  = FilterOperation.EqualTo,
                    Frozen     = true,
                }.Bind(FilterOption.ValueProperty, new Binding("DataContext" + (FilterRoute.HasText() ? "." + FilterRoute : null))
                {
                    Source = this
                }));
                ColumnOptions.Add(new ColumnOption(FilterColumn));
                ColumnOptionsMode = ColumnOptionsMode.Remove;
            }

            FilterOption.SetFilterTokens(FilterOptions, qd);

            AutomationProperties.SetName(this, QueryUtils.GetQueryUniqueKey(QueryName));

            Search();

            foreach (var item in FilterOptions)
            {
                item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged);
            }
        }
예제 #17
0
        public void Reinitialize(List <FilterOption> filters, List <ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List <OrderOption> orders, Pagination pagination)
        {
            try
            {
                avoidPaginationChange = true;

                ColumnOptions.Clear();
                ColumnOptions.AddRange(columns);
                ColumnOption.SetColumnTokens(ColumnOptions, Description);
                ColumnOptionsMode = columnOptionsMode;
                GenerateListViewColumns();

                if (!filters.SequenceEqual(FilterOptions))
                {
                    if (SimpleFilterBuilder != null)
                    {
                        SimpleFilterBuilder = null;
                    }

                    FilterOptions.Clear();
                    FilterOption.SetFilterTokens(filters, Description);
                    FilterOptions.AddRange(filters);
                }

                OrderOptions.Clear();
                OrderOptions.AddRange(orders);
                OrderOption.SetOrderTokens(OrderOptions, Description);
                SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

                UpdateMultiplyMessage(true);

                Pagination = pagination;
            }
            finally
            {
                avoidPaginationChange = false;
            }
        }
예제 #18
0
        public void OnLoaded()
        {
            if (loaded)
            {
                return;
            }

            loaded = true;

            if (FilterColumn.HasText())
            {
                FilterOptions.Add(new FilterOption
                {
                    ColumnName = FilterColumn,
                    Operation  = FilterOperation.EqualTo,
                    Frozen     = true,
                }.Bind(FilterOption.ValueProperty, new Binding("DataContext" + (FilterRoute.HasText() ? "." + FilterRoute : null))
                {
                    Source = this
                }));

                if (QueryUtils.IsColumnToken(FilterColumn))
                {
                    ColumnOptions.Add(new ColumnOption(FilterColumn));
                    ColumnOptionsMode = ColumnOptionsMode.Remove;
                }
                if (this.NotSet(SearchOnLoadProperty))
                {
                    SearchOnLoad = true;
                }
            }

            if (OrderOptions.IsNullOrEmpty() && !entityColumn.Implementations.Value.IsByAll)
            {
                var orderType = entityColumn.Implementations.Value.Types.All(t => EntityKindCache.GetEntityData(t) == EntityData.Master) ? OrderType.Ascending : OrderType.Descending;

                var column = Description.Columns.SingleOrDefaultEx(c => c.Name == "Id");

                if (column != null)
                {
                    OrderOptions.Add(new OrderOption(column.Name, orderType));
                }
            }

            btCreate.ToolTip = SearchMessage.CreateNew0_G.NiceToString()
                               .ForGenderAndNumber(entityColumn.Implementations.Value.Types.FirstOrDefault()?.GetGender() ?? 'm')
                               .FormatWith(entityColumn.Implementations.Value.Types.CommaOr(a => a.NiceName()));

            if (this.NotSet(SearchControl.NavigateProperty) && Navigate)
            {
                Navigate = Implementations.IsByAll ? true :
                           Implementations.Types.Any(t => Navigator.IsNavigable(t, isSearch: true));
            }

            if (this.NotSet(EntityBase.CreateProperty) && Create)
            {
                Create = Implementations.IsByAll ? false :
                         Implementations.Types.Any(t => Navigator.IsCreable(t, isSearch: true));
            }

            ColumnOption.SetColumnTokens(ColumnOptions, Description);

            if (this.CanAddFilters || this.AllowChangeColumns)
            {
                headerContextMenu = new ContextMenu();

                if (this.CanAddFilters)
                {
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = SearchMessage.AddFilter.NiceToString()
                    }.Handle(MenuItem.ClickEvent, filterHeader_Click));
                }

                if (this.CanAddFilters && this.AllowChangeColumns)
                {
                    headerContextMenu.Items.Add(new Separator());
                }

                if (this.AllowChangeColumns)
                {
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = SearchMessage.Rename.NiceToString()
                    }.Handle(MenuItem.ClickEvent, renameMenu_Click));
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = EntityControlMessage.Remove.NiceToString()
                    }.Handle(MenuItem.ClickEvent, removeMenu_Click));
                }
            }

            GenerateListViewColumns();

            FilterOption.SetFilterTokens(FilterOptions, Description);

            filterBuilder.Filters = FilterOptions;
            ((INotifyCollectionChanged)FilterOptions).CollectionChanged += FilterOptions_CollectionChanged;

            OrderOption.SetOrderTokens(OrderOptions, Description);

            SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

            if (IsVisible)
            {
                FillMenuItems();

                if (SearchOnLoad)
                {
                    Search();
                }
            }
            else
            {
                IsVisibleChanged += SearchControl_IsVisibleChanged;
            }

            UpdateVisibility();

            AutomationProperties.SetName(this, QueryUtils.GetKey(QueryName));

            foreach (var item in FilterOptions)
            {
                item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged);
            }
        }