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.GetQueryUniqueKey(QueryName)); foreach (var item in FilterOptions) { item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged); } }
public override void OnLoad(object sender, RoutedEventArgs e) { base.OnLoad(sender, e); if (DesignerProperties.GetIsInDesignMode(this)) { return; } if (this.NotSet(EntityBase.EntityTemplateProperty) && this.NotSet(EntityBase.EntityTemplateSelectorProperty)) { var type = Type; if (this is EntityCombo && !type.IsLite()) //Allways going to be lite { type = Lite.Generate(type); } EntityTemplate = Navigator.FindDataTemplate(this, type); } if (this.NotSet(EntityBase.ImplementationsProperty) && CleanType.IsEntity() && !CleanType.IsAbstract) { Implementations = Signum.Entities.Implementations.By(CleanType); } if (this.NotSet(EntityBase.CreateProperty) && Create) { Create = CleanType.IsEmbeddedEntity() ? Navigator.IsCreable(CleanType) : Implementations.Value.IsByAll ? false: Implementations.Value.Types.Any(t => Navigator.IsCreable(t, isSearch: false)); } if (this.NotSet(EntityBase.ViewProperty) && View) { View = CleanType.IsEmbeddedEntity() ? Navigator.IsViewable(CleanType) : Implementations.Value.IsByAll ? true : Implementations.Value.Types.Any(t => Navigator.IsViewable(t)); } if (this.NotSet(EntityBase.NavigateProperty) && Navigate) { Navigate = CleanType.IsEmbeddedEntity() ? Navigator.IsNavigable(CleanType, isSearch: false) : Implementations.Value.IsByAll ? true : Implementations.Value.Types.Any(t => Navigator.IsNavigable(t, isSearch: false)); } if (this.NotSet(EntityBase.FindProperty) && Find) { Find = CleanType.IsEmbeddedEntity() ? false: Implementations.Value.IsByAll ? false : Implementations.Value.Types.Any(t => Finder.IsFindable(t)); } if (this.NotSet(EntityBase.ViewOnCreateProperty) && ViewOnCreate && !View) { ViewOnCreate = false; } UpdateVisibility(); }