/// <summary> /// Opens the extension file. /// </summary> /// <param name="filename">The filename.</param> /// <remarks>Documented by Dev02, 2009-07-09</remarks> private void OpenExtensionFile(string filename) { ExtensionFile extFile = new ExtensionFile(filename); extFile.Open(LoginForm.OpenLoginForm); if (extFile.Extension.Version.Major < 1) { extFile.Extension.Version = new Version(1, 0, 0); } ExtensionFile = extFile; }
/// <summary> /// Load extension file /// </summary> public void LoadExtensionFile(ExtensionFile extensionFile) { try { extensionFile.CleanUpContent(); extensionFile.ContentBuffer = ReadExtensionFile(extensionFile.FileName); } catch (Exception ex) { extensionFile.ErrorInLoading = ex; } }
/// <summary> /// Clears this instance. /// </summary> /// <remarks>Documented by Dev02, 2009-07-10</remarks> private void Clear() { if (ExtensionFile != null) { ExtensionFile.Dispose(); ExtensionFile = null; } TextBoxName.Text = string.Empty; TextBoxVersion.Text = "1.0.0"; RefreshExtensionDataFiles(); }
public void OnPost(Guid id) { var service = new ExtensionService(); Extension = service.GetExtension(id); var firstFile = Extension.Files.FirstOrDefault(); if (firstFile == null) { firstFile = new ExtensionFile(); Extension.Files.Add(firstFile); } firstFile.Contents = FileContents; service.SaveExtensions(); }
/// <summary> /// Handles the Click event of the ButtonNewExtension control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2009-07-09</remarks> private void ButtonNewExtension_Click(object sender, RoutedEventArgs e) { Clear(); System.Windows.Forms.SaveFileDialog DialogSave = new System.Windows.Forms.SaveFileDialog(); DialogSave.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); DialogSave.Filter = MLifter.SettingsManager.Properties.Resources.EXTENSION_FILEFILTER; DialogSave.FilterIndex = 1; DialogSave.RestoreDirectory = true; if (DialogSave.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string file = DialogSave.FileName; ExtensionFile extensionFile = new ExtensionFile(file); extensionFile.Create(); OpenExtensionFile(file); } }
/// <summary> /// Handles the Click event of the buttonAddExtension control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev08, 2009-07-10</remarks> private void buttonAddExtension_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = MLifter.SettingsManager.Properties.Resources.EXTENSION_FILEFILTER; if (ofd.ShowDialog().Value) { ExtensionFile extFile = new ExtensionFile(ofd.FileName); extFile.Open(LoginForm.OpenLoginForm); Guid extensionId = extFile.Extension.Id; if (SettingsManagerLogic.LearningModule.Extensions.Any(ext => ext.Id == extensionId) && MessageBox.Show(String.Format(MLifter.SettingsManager.Properties.Resources.EXTENSION_REPLACE_TEXT, extFile.Extension.Name), MLifter.SettingsManager.Properties.Resources.EXTENSION_REPLACE_CAPTION, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } IExtension newExt = SettingsManagerLogic.LearningModule.ExtensionFactory(extFile.Extension.Id); extFile.Extension.CopyTo(newExt, null); LoadLMExtensions(); } }
/// <summary> /// Write the extension file. /// </summary> /// <param name="file">The extension file to be written</param> protected virtual void WriteExtensionFile(ExtensionFile file) { throw new NotImplementedException(); }