public NavigationViewModel(SynchronizationContext synchronizationContext, IScarletCommandBuilder commandBuilder, LocalizationsViewModel localizationsViewModel)
            : base(commandBuilder, localizationsViewModel)
        {
            var dataGridViewModel = new DataGridViewModel(commandBuilder, synchronizationContext);

            Add("Lazy Loading / Data-Virtualization", new DataEntriesViewModel(CommandBuilder));
            Add("Image Loading + Drag and Drop", new ProcessingImagesViewModel(commandBuilder, new ImageFactory(CommandBuilder)));
            Add("ConcurrentCommands and state changes", new AsyncStateListViewModel(commandBuilder));
            Add("MVVM Live Sorting and Grouping in bound collections", dataGridViewModel);
            Add("Progress, -notification and dispatcher throtteling", new ProgressViewModel(commandBuilder));
            Add("FileSystemBrowser", new FileSystemViewModel(commandBuilder, new FileSystemViewModelFactory(commandBuilder), FileSystemOptionsViewModel.Default));
            Add("State changes in a tree structure", new BusyViewModel(commandBuilder));
            Add("Geometry rendering", new GeometryRenderViewModel(commandBuilder));
            Add("Binding Passwordbox", new PasswordViewModel());
            Add("MVVM Grouping", GroupingViewModel.Create(commandBuilder, dataGridViewModel.Items));
            Add("Dialog-ViewModel", new DialogViewModel(commandBuilder));
            Add("MVVM Terminal/Console", new ProcessViewModel(commandBuilder));

            var contextMenu = new ContextMenuViewModels();
            var menuitem    = new ContextMenuViewModel();

            menuitem.Items.Add(new ContextMenuViewModel());
            menuitem.Items.Add(new ContextMenuViewModel());

            contextMenu.Items[0].Items.Add(menuitem);

            Add("MVVM ContextMenus", contextMenu);
            Add("Binding Enum values", new EnumViewModel());
            Add("MVVM Toast-Notification", new ToastsViewModel(commandBuilder));
        }
 public GroupingJournalViewModel(Factories factories, BackgroundWorkerFactory workerFactory,
     SugarEditingViewModel sugarEditing)
     : base(factories, workerFactory, sugarEditing)
 {
     Grouping = new GroupingViewModel<JournalItemViewModel, DateViewModel>(this, () => Items,
         keySelector: item => item.Date,
         predicate: item => item.FilterIn(search),
         choose: Choose);
 }
 public static GroupingViewComponent ToViewModel(GroupingViewModel model)
 {
     return(new GroupingViewComponent()
     {
         Name = model.Name,
         Title = model.Title,
         Grid = model.Grid
     });
 }
        public DataGridViewModel(IScarletCommandBuilder commandBuilder, SynchronizationContext synchronizationContext)
            : base(commandBuilder, synchronizationContext, vm => vm.Name, new DataGridDataProvider(commandBuilder, 2000, 50))
        {
            Groups = GroupingViewModel.Create(Items);
            Filter = IsMatch;

            PageSize       = 50;
            TotalPageCount = 2000;
            CurrentPage    = 1;
        }
Beispiel #5
0
        public async Task <IHtmlContent> Card(IDisplayHelper displayAsync, GroupingViewModel shape)
        {
            var tagBuilder = shape.GetTagBuilder("div");

            tagBuilder.AddCssClass("card-body");
            shape.Metadata.Alternates.Clear();
            shape.Metadata.Type = "ColumnGrouping";

            tagBuilder.InnerHtml.AppendHtml(await displayAsync.ShapeExecuteAsync(shape));
            var cardIdPrefix = $"card-{shape.Identifier}-{shape.Grouping.Key}".HtmlClassify();

            var cardTag = new TagBuilder("div");

            cardTag.AddCssClass("card mb-2");

            var headerArrowTag = new TagBuilder("div");

            headerArrowTag.AddCssClass("card-header");
            headerArrowTag.Attributes["id"] = $"heading-{cardIdPrefix}";

            var headerTitleTag = new TagBuilder("h5");

            headerTitleTag.AddCssClass("float-start mb-0 mt-1");
            headerTitleTag.InnerHtml.Append(shape.Grouping.Key);

            var buttonTag = new TagBuilder("button");

            buttonTag.AddCssClass("btn btn-link btn-block text-start float-end");
            buttonTag.Attributes["type"]           = "button";
            buttonTag.Attributes["data-bs-toggle"] = "collapse";
            buttonTag.Attributes["data-bs-target"] = $"#collapse-{cardIdPrefix}";
            buttonTag.Attributes["aria-expanded"]  = "true";
            buttonTag.Attributes["aria-controls"]  = $"collapse-{cardIdPrefix}";

            var buttonIconTag = new TagBuilder("i");

            buttonIconTag.AddCssClass("fa-solid fa-angle-down");

            buttonTag.InnerHtml.AppendHtml(buttonIconTag);

            headerArrowTag.InnerHtml.AppendHtml(headerTitleTag);
            headerArrowTag.InnerHtml.AppendHtml(buttonTag);

            var bodyTag = new TagBuilder("div");

            bodyTag.AddCssClass("collapse show");
            bodyTag.Attributes["id"] = $"collapse-{cardIdPrefix}";

            bodyTag.InnerHtml.AppendHtml(tagBuilder);
            cardTag.InnerHtml.AppendHtml(headerArrowTag);
            cardTag.InnerHtml.AppendHtml(bodyTag);

            return(cardTag);
        }
 public void CanSort()
 {
     var unsorted = new GroupingViewModel<string, int>(viewModel, () => viewModel.Items,
         item => item.Length, item => filterResult, choose);
     viewModel.Load();
     Assert.AreEqual(4, unsorted.Groups[0].Key);
     Assert.AreEqual("foo", unsorted.Groups[1].First());
     var sorted = new SortedGroupingViewModel<string, int, string, int>(viewModel, () => viewModel.Items,
         item => item.Length, item => filterResult, choose, itemSort: item => item,
         groupSort: group => -group.Key);
     viewModel.Refresh();
     Assert.AreEqual(4, sorted.Groups[0].Key);
     Assert.AreEqual("bar", sorted.Groups[1].First());
 }
Beispiel #7
0
        public async Task <IHtmlContent> Tab(IDisplayHelper displayAsync, GroupingViewModel shape)
        {
            var tagBuilder = shape.GetTagBuilder("div");

            tagBuilder.Attributes["id"] = $"tab-{shape.Grouping.Key}-{shape.Identifier}".HtmlClassify();
            tagBuilder.AddCssClass("tab-pane fade");

            // Morphing this shape to a grouping shape to keep Model untouched.
            shape.Metadata.Alternates.Clear();
            shape.Metadata.Type = "CardGrouping";

            tagBuilder.InnerHtml.AppendHtml(await displayAsync.ShapeExecuteAsync(shape));

            return(tagBuilder);
        }
Beispiel #8
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            diaries = SqliteDatabase.LoadFromDatabase(DBName, DiaryTableName);
            reminds = SqliteDatabase.LoadFromDatabase2(DBName, RemindTableName);
            //Canvas.SetZIndex(FlyoutFrame, -1);
            groupingViewModel = new GroupingViewModel(diaries);
            CSV.Source        = groupingViewModel.Groups;
            string AppClientID = "cb8d4295-9fd0-4604-b220-ccfbc7aad516";

            string[] scopes = { MicrosoftGraphScope.FilesReadWriteAppFolder };
            OneDriveService.Instance
            .Initialize(
                AppClientID,
                scopes, null, null
                );
        }
Beispiel #9
0
        public async Task <IHtmlContent> ColumnGrouping(IDisplayHelper DisplayAsync, GroupingViewModel Shape, IShapeFactory ShapeFactory)
        {
            var htmlContentBuilder = new HtmlContentBuilder();

            var groupings = Shape.Grouping.ToLookup(x =>
            {
                if (x is IShape s)
                {
                    var key = s.Metadata.Column;
                    if (String.IsNullOrEmpty(key))
                    {
                        return(ContentKey);
                    }

                    // Remove column modifier.
                    var modifierIndex = key.IndexOf('_');
                    if (modifierIndex != -1)
                    {
                        key = key.Substring(0, modifierIndex);
                    }

                    // Remove positional modifier.
                    modifierIndex = key.IndexOf(';');
                    if (modifierIndex != -1)
                    {
                        key = key.Substring(0, modifierIndex);
                    }

                    return(key);
                }

                return(ContentKey);
            });

            if (groupings.Count > 1)
            {
                var positionModifiers = GetColumnPositions(groupings);

                var orderedGroupings = groupings.OrderBy(grouping =>
                {
                    if (positionModifiers.TryGetValue(grouping.Key, out var position))
                    {
                        return(new PositionalGrouping {
                            Position = position
                        });
                    }
                    else
                    {
                        return(new PositionalGrouping());
                    }
                }, FlatPositionComparer.Instance);

                var columnModifiers = GetColumnModifiers(orderedGroupings);

                var container = (GroupViewModel)await ShapeFactory.CreateAsync <GroupViewModel>("ColumnContainer", m =>
                {
                    m.Identifier = Shape.Identifier;
                });

                foreach (var orderedGrouping in orderedGroupings)
                {
                    var groupingShape = (GroupingViewModel)await ShapeFactory.CreateAsync <GroupingViewModel>("Column", m =>
                    {
                        m.Identifier = Shape.Identifier;
                        m.Grouping   = orderedGrouping;
                    });

                    groupingShape.Classes.Add("ta-col-grouping");
                    groupingShape.Classes.Add("column-" + orderedGrouping.Key.HtmlClassify());

                    // To adjust this breakpoint apply a modifier of lg-3 to every column.
                    var columnClasses = "col-12 col-md";
                    if (columnModifiers.TryGetValue(orderedGrouping.Key, out var columnModifier))
                    {
                        // When the modifier also has a - assume it is providing a breakpointed class.
                        if (columnModifier.IndexOf('-') != -1)
                        {
                            columnClasses = "col-12 col-" + columnModifier;
                        }
                        else // Otherwise assume a default md breakpoint.
                        {
                            columnClasses = "col-12 col-md-" + columnModifier;
                        }
                    }

                    groupingShape.Classes.Add(columnClasses);

                    foreach (var item in orderedGrouping)
                    {
                        await groupingShape.AddAsync(item);
                    }
                    await container.AddAsync(groupingShape);
                }

                htmlContentBuilder.AppendHtml(await DisplayAsync.ShapeExecuteAsync(container));
            }
            else
            {
                // When nothing is grouped in a column, the grouping is rendered directly.
                foreach (var item in Shape.Grouping)
                {
                    htmlContentBuilder.AppendHtml(await DisplayAsync.ShapeExecuteAsync((IShape)item));
                }
            }

            return(htmlContentBuilder);
        }
Beispiel #10
0
        public async Task <IHtmlContent> CardGrouping(IDisplayHelper DisplayAsync, GroupingViewModel Shape, IShapeFactory ShapeFactory)
        {
            var htmlContentBuilder = new HtmlContentBuilder();

            var groupings = Shape.Grouping.ToLookup(x =>
            {
                if (x is IShape s)
                {
                    var key = s.Metadata.Card;
                    if (String.IsNullOrEmpty(key))
                    {
                        return(ContentKey);
                    }

                    // Remove positional modifier.
                    var modifierIndex = key.IndexOf(';');
                    if (modifierIndex != -1)
                    {
                        key = key.Substring(0, modifierIndex);
                    }

                    return(key);
                }

                return(ContentKey);
            });

            if (groupings.Count > 1)
            {
                var orderedGroupings = groupings.OrderBy(grouping =>
                {
                    var firstGroupWithModifier = grouping.FirstOrDefault(group =>
                    {
                        if (group is IShape s && !String.IsNullOrEmpty(s.Metadata.Card) && s.Metadata.Card.IndexOf(';') != -1)
                        {
                            return(true);
                        }

                        return(false);
                    });

                    if (firstGroupWithModifier is IShape shape)
                    {
                        var key           = shape.Metadata.Card;
                        var modifierIndex = key.IndexOf(';');
                        return(new PositionalGrouping(key.Substring(modifierIndex)));
                    }

                    return(new PositionalGrouping());
                }, FlatPositionComparer.Instance);

                var container = (GroupViewModel)await ShapeFactory.CreateAsync <GroupViewModel>("CardContainer", m =>
                {
                    m.Identifier = Shape.Identifier;
                });

                container.Classes.Add("accordion");

                foreach (var orderedGrouping in orderedGroupings)
                {
                    var groupingShape = (GroupingViewModel)await ShapeFactory.CreateAsync <GroupingViewModel>("Card", m =>
                    {
                        m.Identifier = Shape.Identifier;
                        m.Grouping   = orderedGrouping;
                    });

                    foreach (var item in orderedGrouping)
                    {
                        await groupingShape.AddAsync(item);
                    }

                    await container.AddAsync(groupingShape);
                }

                htmlContentBuilder.AppendHtml(await DisplayAsync.ShapeExecuteAsync(container));
            }
            else
            {
                // Evaluate for columns.
                var groupingShape = (GroupingViewModel)await ShapeFactory.CreateAsync <GroupingViewModel>("ColumnGrouping", m =>
                {
                    m.Identifier = Shape.Identifier;
                    m.Grouping   = Shape.Grouping;
                });

                htmlContentBuilder.AppendHtml(await DisplayAsync.ShapeExecuteAsync(groupingShape));
            }

            return(htmlContentBuilder);
        }
 public RemoveGroupingFromShooterDialogMessage(int shooterId, GroupingViewModel grouping)
 {
     ShooterId = shooterId;
     Grouping  = grouping;
 }
 public RemoveGroupingFromShooterDialogMessage(int shooterId, GroupingViewModel grouping)
 {
     ShooterId = shooterId;
     Grouping = grouping;
 }
 public void TestInitialize()
 {
     viewModel = new SearchSubViewModelStub();
     choose = Substitute.For<Action<string>>();
     sut = new GroupingViewModel<string, int>(viewModel, () => viewModel.Items, item => item.Length,
         item => filterResult, choose);
 }