Exemplo n.º 1
0
        private void StartCoursePreview()
        {
            if ((Course.State & CourseStates.Opened) == 0)
            {
                ErrorDialog.ShowError("No course for preview. Please open an existing course or create new one.");
            }
            if (_PreviewProcess != null)
            {
                throw new FireFlyException("Course preview already started!");
            }

            Course.Save();

            if (_Provider == null)
            {
                _Provider = new HttpCourseProvider {
                    PlayerLocation = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "player")
                };
            }
            if (!Directory.Exists(_Provider.PlayerLocation))
            {
                ErrorDialog.ShowError("Could not start course preview because player not found.");
                return;
            }
            _Provider.Start();
            _PreviewProcess = Process.Start("IExplore.exe", "http://localhost:" + HttpCourseProvider.Port + "/index.html");

            if (_PreviewProcess == null)
            {
                _Provider.Stop();
                ErrorDialog.ShowError("Cant start process for browser.");
                return;
            }
            _PreviewProcess.Exited += ((sender, e) =>
            {
                if (_PreviewProcess != null)
                {
                    Invoke(_StopPreviewInvoker);
                }
            });
            _PreviewProcess.EnableRaisingEvents = true;

            startPreviewToolStripButton.Enabled = false;
            stopPreviewToolStripButton.Enabled  = true;
            Course.CourseClosed += StopCoursePreview;
        }
Exemplo n.º 2
0
        private void StartCoursePreview()
        {
            if ((Course.State & CourseStates.Opened) == 0)
            {
                ErrorDialog.ShowError("No course for preview. Please open an existing course or create new one.");
            }
            if (_PreviewProcess != null)
            {
                throw new FireFlyException("Course preview already started!");
            }

            Course.Save();

            if (_Provider == null)
            {
                _Provider = new HttpCourseProvider { PlayerLocation = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "player") };
            }
            if (!Directory.Exists(_Provider.PlayerLocation))
            {
                ErrorDialog.ShowError("Could not start course preview because player not found.");
                return;
            }
            _Provider.Start();
            _PreviewProcess = Process.Start("IExplore.exe", "http://localhost:" + HttpCourseProvider.Port + "/index.html");

            if (_PreviewProcess == null)
            {
                _Provider.Stop();
                ErrorDialog.ShowError("Cant start process for browser.");
                return;
            }
            _PreviewProcess.Exited += ((sender, e) =>
            {
                if (_PreviewProcess != null)
                {
                    Invoke(_StopPreviewInvoker);
                }
            });
            _PreviewProcess.EnableRaisingEvents = true;

            startPreviewToolStripButton.Enabled = false;
            stopPreviewToolStripButton.Enabled = true;
            Course.CourseClosed += StopCoursePreview;
        }