コード例 #1
0
ファイル: Controller.cs プロジェクト: zxsean/YuriAVGEngine
        /// <summary>
        /// 添加一本书籍
        /// </summary>
        /// <param name="bookName">书籍的名字</param>
        /// <returns>所添加的书籍的唯一标识符</returns>
        public string AddBook(string bookName)
        {
            // 记录时间戳
            var createTime = DateTime.Now;
            // 构造主页文章
            FlowDocument flowDoc  = new FlowDocument();
            TextRange    st       = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd);
            MemoryStream metadata = new MemoryStream();

            st.Save(metadata, System.Windows.DataFormats.XamlPackage);
            HArticle homePage = new HArticle()
            {
                Id                = "HArticle#" + Guid.NewGuid(),
                ParentId          = "HArticle#ROOT",
                Name              = bookName,
                CreateTimeStamp   = createTime,
                LastEditTimeStamp = createTime,
                DocumentMetadata  = metadata
            };

            this.ArticleDict[homePage.Id] = homePage;
            // 构造书籍对象
            var   bookId = "HBook#" + Guid.NewGuid();
            HBook hb     = new HBook()
            {
                Id                = bookId,
                Name              = bookName,
                HomePage          = homePage,
                CreateTimeStamp   = createTime,
                LastEditTimeStamp = createTime,
                FileName          = $"{bookId}.{App.AppBookDataExtension}"
            };

            this.BookVector.Add(new BookCacheDescriptor(hb, true));
            homePage.BookId = bookId;
            // 提交到稳定储存器
            this.FullCommit();
            return(bookId);
        }
コード例 #2
0
 /// <summary>
 /// 构造世界设定窗体
 /// </summary>
 /// <param name="bookId">书籍的唯一标识符</param>
 public WorldWindow(string bookId)
 {
     InitializeComponent();
     this.BookRef = WorldWindow.core.BookVector.Find(t => t.BookRef.Id == bookId).BookRef;
     this.Title   = $"World - [{this.BookRef.Name}]";
     this.ComboBox_Chapters.Items.Clear();
     WorldWindow.core.RetrieveOffspringArticle(this.BookRef.HomePage.Id, true, out var chapterVec);
     foreach (var ci in chapterVec)
     {
         this.ComboBox_Chapters.Items.Add(ci.Name);
     }
     WorldWindow.core.RetrieveMilestone(this.BookRef.Id, t => true, out this.MsList);
     this.milestoneIdList = new List <string>();
     foreach (var msi in this.MsList)
     {
         var lbi      = new ListBoxItem();
         var lbiGrid  = new Grid();
         var lbiLabel = new Label()
         {
             Content = msi.Detail
         };
         var flagEllipse = new Ellipse()
         {
             HorizontalAlignment = HorizontalAlignment.Right,
             Fill       = new SolidColorBrush(Colors.Green),
             Margin     = new Thickness(0, 0, 10, 0),
             MaxHeight  = 12,
             MaxWidth   = 12,
             Width      = 25,
             Visibility = msi.IsFinished ? Visibility.Visible : Visibility.Hidden
         };
         lbiGrid.Children.Add(lbiLabel);
         lbiGrid.Children.Add(flagEllipse);
         lbi.Content = lbiGrid;
         this.Listbox_Milestone.Items.Add(lbi);
         this.milestoneIdList.Add(msi.Id);
     }
     this.Listbox_Milestone.SelectedIndex = 0;
 }
コード例 #3
0
ファイル: Controller.cs プロジェクト: zxsean/YuriAVGEngine
 /// <summary>
 /// 构造一个内存书籍描述脏块
 /// </summary>
 /// <param name="bref">书籍对象的引用</param>
 /// <param name="dirty">初始脏位</param>
 public BookCacheDescriptor(HBook bref, bool dirty)
 {
     this.BookRef  = bref;
     this.DirtyBit = dirty;
 }