private void GetFileResources() { HtmlPageBase page = GetParentPage(); page.Scripts.IncludeAllWithRoot(HIGHLIGHT_DIRECTORY, HIGHLIGHT_JS_FILENAME); page.Styles.IncludeAllWithRoot(HIGHLIGHT_DIRECTORY, SAMPLE_CSS_FILENAME); Course.EnsureCourseContainsResources(Course.LANGUAGES_NAMESPACE, HIGHLIGHT_DIRECTORY, HIGHLIGHT_JS_FILENAME, SAMPLE_CSS_FILENAME, Language.ToString().ToLower() + ".js"); }
private void ReleaseFileResources() { Course.ReleaseCourseResource(HIGHLIGHT_DIRECTORY, HIGHLIGHT_JS_FILENAME, SAMPLE_CSS_FILENAME, Language.ToString().ToLower() + ".js"); HtmlPageBase page = GetParentPage(); page.Scripts.RemoveAllWithRoot(HIGHLIGHT_DIRECTORY, HIGHLIGHT_JS_FILENAME); page.Styles.RemoveAllWithRoot(HIGHLIGHT_DIRECTORY, SAMPLE_CSS_FILENAME); }
/// <summary> /// Updates editors /// </summary> /// <param name="node">Current node that should be shown in editors</param> private void UpdateEditors([CanBeNull] ItemType node) { if (tcEditor.Visible = node != null) { if (node.PageType == PageType.Question || node.PageType == PageType.Summary) { var page = HtmlPageBase.GetPage(node); if (page != null) { page.Store(); } } string fileName = node.PageHref; #if CHECKERS if (!File.Exists(fileName) && tcEditor.SelectedTab != tpPageDesigner) { throw new FireFlyException("File '{0}' not found", fileName); } #endif if (tcEditor.SelectedTab == tpPlainText) { if (node.PageType == PageType.Summary) { tcEditor.SelectedTab = tpBrowser; UpdateEditors(node); } else { tbText.Text = FileUtils.ReadAllText(fileName); } } else if (tcEditor.SelectedTab == tpPageDesigner) { if (node.PageType == PageType.Theory) { tcEditor.SelectedTab = tpBrowser; UpdateEditors(node); } else { _pageEditor.SetPageItem(node); } } else if (tcEditor.SelectedTab == tpBrowser) { webBrowser.NavigateItem(fileName, node.parameters); } } }
/// <summary> /// Save all changes of current course to folder that represents is /// </summary> public static bool Save() { FFDebug.EnterMethod(Cattegory.Course, State.ToString()); State |= CourseStates.Saving; #if CHECKERS if (__Manifest == null) { throw new FireFlyException("Course is not assigned"); } if (__Manifest.organizations.Organizations.Count == 0) { throw new FireFlyException("No organization assigned"); } #endif if (CourseSaving != null) { CourseSaving(); } HtmlPageBase.StorePages(); State &= ~CourseStates.Saving; var cv = new CourseValidator(); if (!cv.Validate()) { ErrorDialog.ShowError("THIS COURSE IS INVALID!!! It cannot be played. Errors:" + Environment.NewLine + cv.GetErrorMessages()); State &= ~CourseStates.Modified; return(false); } using (var f = new FileStream(MapPath(MANIFEST_FILE_NAME), FileMode.Create)) { ManifestType.Serializer.Serialize(f, __Manifest, ManifestNamespaces.SerializerNamespaces); } Answers.SaveToFile(MapPath(ANSWERS_FILE_NAME)); State &= ~CourseStates.Modified; if (CourseSaved != null) { CourseSaved(); } FFDebug.LeaveMethod(Cattegory.Course, MethodBase.GetCurrentMethod()); return(true); }
/// <summary> /// Close opened course /// </summary> /// <returns>If course was closed return false</returns> public static bool Close() { var failed = (State & (CourseStates.UpgradeFailed | CourseStates.OpenFailed)) > 0; if ((State & CourseStates.Opened) == 0 && !failed) { return(true); } if (CanClose()) { __Manifest = null; __Organization = null; Answers = null; var tempFullPath = __FullPath; __FullPath = null; if (!failed) { HtmlPageBase.ReleasePages(); if (CourseClosed != null) { CourseClosed(); } } try { Directory.Delete(tempFullPath, true); } catch (Exception e) { ErrorDialog.ShowError("Error on deleting temporary files: " + e.Message); } __ContainedFileResource.Clear(); State &= ~CourseStates.Opened; return(true); } return(false); }