Exemplo n.º 1
0
        public MainWindow()
        {
            /// TODO:
            /// Every annotation needs a timestam
            /// Also, we will add an edits table for handling diffs and revisions
            /// Edits are also timestamped
            /// By comparing timestamps we can preserve annotation indexing

               ///Show the number of annotations on the text selection page
               ///Highlight the

            db = DataUtil.GetDataContext();
            ///Todo:
            ///Add a library of fundamental texts
            ///Filter annotations based on where you are in the text
            ///Introduce inter-text linking and the notion of chapter, paragraph, etc.
            InitializeComponent();
            this.ShowAll = true;
            this.currentUser = db.Users.First();

            this.currentTextDetail = db.TextDetails.Where(i => i.Title == "Les Miserables").Single();
            this.currentText = db.Texts.Where(i => i.ID == 1).Single();

            if (!db.Texts.Select(i => i.TextDetail.Title).Contains(currentTextDetail.Title)) {
                db.Texts.AddObject(this.currentText);
                db.SaveChanges();
            }
            loadAnnotations();

            this.allTexts.ItemsSource = db.Texts.Select(i => i.TextDetail);
        }
 /// <summary>
 /// Create a new Text object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Text CreateText(global::System.Int32 id)
 {
     Text text = new Text();
     text.ID = id;
     return text;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Texts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTexts(Text text)
 {
     base.AddObject("Texts", text);
 }
Exemplo n.º 4
0
 private void Upload_Click(object sender, RoutedEventArgs e)
 {
     var title = this.fileTitle.Text;
     var author = this.fileAuthor.Text;
     var tags = this.tags.Text;
     var filepath = this.filepath.Text;
     if (title == "" || author == "" || filepath == "") {
         return;
     }
     var textDetail = new TextDetail() {
     Author = author,
     Title = title,
     TextSource = filepath,
     };
     db.TextDetails.AddObject(textDetail);
     db.SaveChanges();
     var newText = new Text() {
         Details = textDetail.ID,
         Content = string.Concat(System.IO.File.ReadAllText(filepath).Take(100000))
     };
     db.Texts.AddObject(newText);
     db.SaveChanges();
     this.allTexts.ItemsSource = null;
     this.allTexts.ItemsSource = db.Texts.Select(i => i.TextDetail);
 }