Beispiel #1
0
        contentProvider()
        {
            m_content      = new content();
            m_chapters     = new Dictionary <string, chapter>();
            m_lessons      = new Dictionary <string, lessons>();
            m_db           = new myDb();
            m_mainPgCfg    = myMainPgCfg.getInstance();
            m_chapterPgCfg = myChapterPgCfg.getInstance();
            m_lessonPgCfg  = myLessonPgCfg.getInstance();

            m_content.SaveCompleted += M_content_SaveCompleted;
            m_content.LoadCompleted += M_content_LoadCompleted;
        }
Beispiel #2
0
 public static myLessonPgCfg getInstance()
 {
     if (m_config == null)
     {
         var newObj = new myLessonPgCfg();
         var t      = Task.Run(async() => m_config = (myLessonPgCfg)await newObj.load <myLessonPgCfg>());
         t.Wait();
         if (m_config == null)
         {
             m_config = new myLessonPgCfg();
         }
     }
     return(m_config);
 }
Beispiel #3
0
        private void loadData()
        {
            m_config = myLessonPgCfg.getInstance();

            //load chapter data
            lessonsList.Items.Clear();
            int iCur = 0;

            lessonsList.ItemsSource = m_data;
            foreach (var i in s_cp.m_lessons)
            {
                var lesson = i.Value;
                var item   = new lessonItem()
                {
                    Name  = lesson.name,
                    Count = lesson.sentences.Count,
                    c     = lesson
                };
                //s_cp.m_db.getMarked(lesson);
                //if (lesson.words.Count < lesson.markedIndexs.Count)
                //{
                //    //db malform
                //    Debug.WriteLine("[error] {0} loadData chapter {1} marked data malform", this, lesson.path);
                //    lesson.markedIndexs.Clear();
                //}

                m_data.Add(item);

                //check selected chapter
                if (m_config.selectedLessons.Contains(lesson.path))
                {
                    m_config.selectedLessons.Remove(lesson.path);
                    lessonsList.SelectedItems.Add(item);
                    lesson.selected = false;
                }
                iCur++;
            }

            //load mydb file
            //s_cp.loadDb();
        }
Beispiel #4
0
        public MainPage()
        {
            this.InitializeComponent();

            m_content      = contentProvider.getInstance();
            m_config       = m_content.m_mainPgCfg;
            m_lessonPgCfg  = m_content.m_lessonPgCfg;
            m_chapterPgCfg = m_content.m_chapterPgCfg;

            //test();
            //testWriteData();
            //ApplicationView.PreferredLaunchViewSize = new Size(480, 800);
            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            //s_content.LoadChapterCompleted += C_LoadCompleted;
            //s_content.LoadMultiChapterCompleted += S_content_LoadMultiChapterCompleted;

            //this page events
            Loaded += MainPage_Loaded;
            //LayoutUpdated += MainPage_LayoutUpdated;
            Unloaded += MainPage_Unloaded;

            initCtrls();

            browserBtn.Tapped += browserBtn_ClickAsync;
            openBtn.Click     += browserBtn_ClickAsync;
            reloadBtn.Click   += reloadBtn_Click;
            addBtn.Click      += btnAdd_Click;
            nextBtn.Click     += btnNext_Click;
            prevBtn.Click     += PrevBtn_Click;
            clean.Click       += btnClean_Click;
            clearBtn.Click    += btnClean_Click;

            //background work
            m_bgwork            = new myWorker();
            m_bgwork.BgProcess += bg_process;
            m_bgwork.FgProcess += fg_process;
        }