Ejemplo n.º 1
0
        private void RefreshSelectedModels()
        {
            this.UnhookEvents();

            if (this.Files != null)
            {
                if (this.ComboBoxTypeValue == ComboBoxType.Books)
                {
                    this.SelectedFiles = this.Files.Where(f => this.WhereRootFiles(f)).Select(f => (FileModel) new BookFileModel(this.SelectWithOrder(f, 1))).ToList();

                    for (int index = 0; index < this.SelectedFiles.Count(); index++)
                    {
                        BookFileModel cModel = (BookFileModel)this.SelectedFiles.ElementAt(index);
                        cModel.Book = index + 1;
                    }

                    this.SelectedFiles = this.SelectedFiles.Select(f => this.HookBookFileModel((BookFileModel)f)).OrderBy(b => b.Book).ThenBy(b => b.ExpectedName).Select(b => (FileModel)b).ToList();
                    this.UnusedFiles   = this.Files.Where(f => !this.WhereRootFiles(f)).Select(f => this.SelectWithOrder(f, 0)).OrderBy(f => f.ExpectedName).ToList();
                }
                else
                {
                    this.SelectedFiles = this.Files.Where(f => this.WhereSubRootFiles(f, 1)).Select(f => this.CreateChapterFileModel(this.SelectWithOrder(f, 1))).OrderBy(c => c.Book).ThenBy(c => c.Chapter).ThenBy(c => c.ExpectedName).Select(c => (FileModel)c).ToList();
                    this.UnusedFiles   = this.Files.Where(f => !this.WhereSubRootFiles(f, 1)).Select(f => this.SelectWithOrder(f, 0)).OrderBy(f => f.ExpectedName).ToList();
                }

                this.PushSelectedModelsList();
            }
        }
Ejemplo n.º 2
0
 private void UnhookEvent(FileModel model)
 {
     if (model is BookFileModel)
     {
         BookFileModel cModel = (BookFileModel)model;
         cModel.BookChanged -= this.OnBookModelChanged;
     }
     else if (model is ChapterFileModel)
     {
         ChapterFileModel vModel = (ChapterFileModel)model;
         vModel.BookChanged -= this.OnChapterModelChanged;
         vModel.BookChanged -= this.OnChapterModelChanged;
     }
 }
Ejemplo n.º 3
0
 private BookFileModel HookBookFileModel(BookFileModel cModel)
 {
     cModel.BookChanged += this.OnBookModelChanged;
     return(cModel);
 }