Exemplo n.º 1
1
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            linkIO = LinkIOImp.Instance;

            if (!Directory.Exists(Data.NineFolder))
            {
                Directory.CreateDirectory(Data.NineFolder);
            }

            currentWindow = new MainWindow();
#if START_ON_MAINPAGE
            // Connect user as a Teacher
            new UserConnection().Connection.Execute(0);

            // If a Lesson exists, go to MainPage
            var nineFiles = Directory.GetFiles(Data.NineFolder.ToString(), "*.nine", SearchOption.AllDirectories);
            if (nineFiles.Length > 0)
            {
                FileStream serializedLesson = new FileStream(nineFiles[0], FileMode.Open);
                Data.Instance.Lesson = (Lessons.Lesson)(new BinaryFormatter()).Deserialize(serializedLesson);
                serializedLesson.Close();
                Catalog.Instance.NavigateTo("MainPage");
            }
            // Else go to HomePage (to create a Lesson)
            else
            {
                Catalog.Instance.NavigateTo("HomePage");
            }
#else
            Catalog.Instance.NavigateTo("UserConnectionPage");
#endif
            currentWindow.Show();

        }
Exemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            linkIO = LinkIOImp.Instance;

            if (!Directory.Exists(Data.NineFolder))
            {
                Directory.CreateDirectory(Data.NineFolder);
            }

            currentWindow = new MainWindow();
#if START_ON_MAINPAGE
            // Connect user as a Teacher
            new UserConnection().Connection.Execute(0);

            // If a Lesson exists, go to MainPage
            var nineFiles = Directory.GetFiles(Data.NineFolder.ToString(), "*.nine", SearchOption.AllDirectories);
            if (nineFiles.Length > 0)
            {
                FileStream serializedLesson = new FileStream(nineFiles[0], FileMode.Open);
                Data.Instance.Lesson = (Lessons.Lesson)(new BinaryFormatter()).Deserialize(serializedLesson);
                serializedLesson.Close();
                Catalog.Instance.NavigateTo("MainPage");
            }
            // Else go to HomePage (to create a Lesson)
            else
            {
                Catalog.Instance.NavigateTo("HomePage");
            }
#else
            Catalog.Instance.NavigateTo("UserConnectionPage");
#endif
            currentWindow.Show();
        }