public override void GetRenderings(RenderingSelectorFilterParameters parameters, GetItemsCompleted <ItemHeader> completed) { Assert.ArgumentNotNull(parameters, nameof(parameters)); Assert.ArgumentNotNull(completed, nameof(completed)); if (Renderings == null) { completed(Enumerable.Empty <ItemHeader>()); return; } var filtered = Renderings; if (!string.IsNullOrEmpty(FilterText)) { filtered = filtered.Where(r => r.Name.IsFilterMatch(FilterText)).ToList(); } if (!string.IsNullOrEmpty(RootPath)) { filtered = filtered.Where(r => r.Path.StartsWith(RootPath, StringComparison.InvariantCultureIgnoreCase)).ToList(); } completed(filtered); }
public override void GetRenderings(RenderingSelectorFilterParameters parameters, GetItemsCompleted <ItemHeader> completed) { Assert.ArgumentNotNull(parameters, nameof(parameters)); Assert.ArgumentNotNull(completed, nameof(completed)); var renderings = Renderings; if (renderings == null) { completed(Enumerable.Empty <ItemHeader>()); return; } var list = AppHost.Settings.Get(ControlsRenderingSelectorRecent, GetStorageKey(parameters.DatabaseUri), string.Empty) as string; if (string.IsNullOrEmpty(list)) { completed(Enumerable.Empty <ItemHeader>()); return; } var result = new List <ItemHeader>(); var items = list.Split('|'); foreach (var item in items) { var parts = item.Split('^'); if (parts.Length != 4) { continue; } var name = parts[0]; var itemId = new ItemId(new Guid(parts[1])); var templateName = parts[2]; var path = parts[3]; var itemUri = new ItemUri(parameters.DatabaseUri, itemId); if (renderings.All(t => t.ItemUri != itemUri)) { continue; } var itemHeader = new ItemHeader { Name = name, ItemUri = itemUri, ParentName = Resources.Recent, Path = path, TemplateName = templateName }; result.Add(itemHeader); } completed(result); }
public override void GetRenderings(RenderingSelectorFilterParameters parameters, GetItemsCompleted <ItemHeader> completed) { Assert.ArgumentNotNull(parameters, nameof(parameters)); Assert.ArgumentNotNull(completed, nameof(completed)); if (Renderings == null) { completed(Enumerable.Empty <ItemHeader>()); return; } completed(Renderings); }
private void ChangeFilter([NotNull] object sender, [NotNull] SelectionChangedEventArgs selectionChangedEventArgs) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(selectionChangedEventArgs, nameof(selectionChangedEventArgs)); selectionChangedEventArgs.Handled = true; RemoveFilterButton.IsEnabled = false; if (renderings.Count == 0) { return; } var listBoxItem = FilterListbox.SelectedItem as ListBoxItem; if (listBoxItem == null) { return; } var filter = listBoxItem.Tag as IRenderingSelectorFilter; if (filter == null) { return; } RemoveFilterButton.IsEnabled = filter is CustomRenderingSelectorFilter; Loading.Visibility = Visibility.Visible; Stack.Visibility = Visibility.Collapsed; var parameters = new RenderingSelectorFilterParameters(DatabaseUri); filter.GetRenderings(parameters, LoadRenderings); AppHost.Settings.SetString("RenderingSelector", "SelectedTab", filter.Name); }
public abstract void GetRenderings(RenderingSelectorFilterParameters parameters, GetItemsCompleted <ItemHeader> completed);