Ejemplo n.º 1
0
        private void QueryNameChanged(DependencyPropertyChangedEventArgs s)
        {
            if (DesignerProperties.GetIsInDesignMode(this) || s.NewValue == null)
            {
                return;
            }

            if (!Finder.IsFindable(s.NewValue))
            {
                Common.VoteCollapsed(this);
                return;
            }

            Common.VoteVisible(this);


            Settings = Finder.GetQuerySettings(s.NewValue);

            Description = DynamicQueryServer.GetQueryDescription(s.NewValue);

            if (Settings.SimpleFilterBuilder != null)
            {
                SimpleFilterBuilder = Settings.SimpleFilterBuilder(Description);
            }

            tokenBuilder.Token           = null;
            tokenBuilder.SubTokensEvent += tokenBuilder_SubTokensEvent;

            entityColumn = Description.Columns.SingleOrDefaultEx(a => a.IsEntity);
            if (entityColumn == null)
            {
                throw new InvalidOperationException("Entity Column not found on {0}".FormatWith(QueryUtils.GetKey(QueryName)));
            }
        }
Ejemplo n.º 2
0
        public virtual void Explore(ExploreOptions options)
        {
            AssertFindable(options.QueryName);

            if (options.NavigateIfOne)
            {
                Lite <Entity> lite = DynamicQueryServer.QueryUnique(new UniqueOptions(options.QueryName)
                {
                    FilterOptions = options.FilterOptions,
                    UniqueType    = UniqueType.Only
                });

                if (lite != null)
                {
                    Navigator.Navigate(lite, new NavigateOptions {
                        Closed = options.Closed
                    });
                    return;
                }
            }

            Navigator.OpenIndependentWindow(() => CreateSearchWindow(options),
                                            afterShown: null,
                                            closed: options.Closed);
        }
Ejemplo n.º 3
0
        public virtual Lite <Entity> Find(FindOptions options)
        {
            AssertFindable(options.QueryName);

            if (options.ReturnIfOne)
            {
                Lite <Entity> lite = DynamicQueryServer.QueryUnique(new UniqueOptions(options.QueryName)
                {
                    FilterOptions = options.FilterOptions,
                    UniqueType    = UniqueType.SingleOrMany
                });

                if (lite != null)
                {
                    return(lite);
                }
            }

            SearchWindow sw = CreateSearchWindow(options);

            sw.MultiSelection = false;

            if (sw.ShowDialog() == true)
            {
                return(sw.SelectedItem);
            }
            return(null);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public QuickLinkExplore(ExploreOptions options)
        {
            Options = options;
            Label   = QueryUtils.GetNiceName(Options.QueryName);
            //Icon = Navigator.Manager.GetFindIcon(Options.QueryName, false);
            IsVisible = Finder.IsFindable(Options.QueryName);

            if (ShowResultCount && IsVisible)
            {
                EvaluateFunValues();

                DynamicQueryServer.QueryCountBatch(new QueryCountOptions(Options.QueryName)
                {
                    FilterOptions = options.FilterOptions,
                }, count =>
                {
                    Label = "{0} ({1})".FormatWith(Label, count);
                }, () => { });
            }
        }
Ejemplo n.º 6
0
        public override void Execute()
        {
            EvaluateFunValues();

            Lite <T> lite = DynamicQueryServer.QueryUnique <T>(FindUniqueOptions);

            if (lite == null)
            {
                MessageBox.Show(QuickLinkMessage.No0Found.NiceToString().ForGenderAndNumber(typeof(T).GetGender()).FormatWith(typeof(T).NiceName()));
                return;
            }

            if (NavigateOptions != null)
            {
                Navigator.Navigate(lite, NavigateOptions);
            }
            else
            {
                Navigator.Navigate(lite);
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        public void Search()
        {
            if (IsSearching)
            {
                searchQueued = true;
                return;
            }

            FormattedText = (TextWaiting ?? QueryUtils.GetNiceName(QueryName) + "...");
            tb.FontWeight = FontWeights.Regular;

            var options = new QueryCountOptions
            {
                QueryName     = QueryName,
                FilterOptions = FilterOptions.ToList()
            };

            DynamicQueryServer.QueryCountBatch(options, count =>
            {
                ItemsCount = count;
                if (ItemsCount == 0)
                {
                    FormattedText = (TextZeroItems ?? SearchMessage.ThereIsNo0.NiceToString()).FormatWith(QueryUtils.GetNiceName(QueryName));
                    tb.FontWeight = FontWeights.Regular;
                }
                else
                {
                    FormattedText = (Text ?? (QueryUtils.GetNiceName(QueryName) + ": {0}")).FormatWith(ItemsCount);
                    tb.FontWeight = FontWeights.Bold;
                }

                if (searchQueued)
                {
                    searchQueued = false;
                    Search();
                }
            },
                                               () => { });
        }