Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            InitialState();
            t  = ReadFromJsonFile <Kbase>(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "knowledgebase.json"));
            sp = ReadFromJsonFile <StudentProfile>(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "profile.json"));
            nameLabel.Content  = "Hello, " + sp.Name;
            courseName.Content = "Chapters in course '" + t.CourseName + "':";

            //create business data
            var itemList = new List <SChapter>();
            int i        = 0;

            while (i < t.ChapterCount)
            {
                itemList.Add(new SChapter {
                    ChapterName = t.Chapters[i].ChapterName, locked = sp.StudentCourses[t.CourseId].ChaptersLocked.Contains(t.Chapters[i].ChapterId), id = t.Chapters[i].ChapterId
                });
                i++;
            }

            //link business data to CollectionViewSource
            CollectionViewSource itemCollectionViewSource;

            itemCollectionViewSource        = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
            itemCollectionViewSource.Source = itemList;
        }
Ejemplo n.º 2
0
        public int getChIdByChName(string ChName, Kbase t)
        {
            int i = 0;

            while (i < t.ChapterCount)
            {
                if (t.Chapters[i].ChapterName.Equals(ChName))
                {
                    return(t.Chapters[i].ChapterId);
                }
                i++;
            }
            return(-1);
        }
Ejemplo n.º 3
0
        private string getChapterSource(Kbase t, int id)
        {
            int i = 0;

            Console.WriteLine(id.ToString());
            while (i < t.ChapterCount)
            {
                if (t.Chapters[i].ChapterId == id)
                {
                    Console.WriteLine(System.IO.Path.Combine(Directory.GetCurrentDirectory(), t.Chapters[i].ChapterText));
                    return(System.IO.Path.Combine(Directory.GetCurrentDirectory(), t.Chapters[i].ChapterText));
                }
                i++;
            }
            return("");
        }