///<summary>Loads the MediaList. The "filename" must be relative to ///the MediaLists directory.</summary> public void Load(string filename) { Count = 0; XmlDocument document = new XmlDocument(); try { document.Load(DreamTools.GetDirectory(DirType.MediaLists, filename + ".xml")); } catch (XmlException xmle) { MessageBox.Show(xmle.Message); } XmlNodeList list = null; string fullPath; // Get the Path list = document.GetElementsByTagName("Path"); foreach (XmlNode n in list) { fullPath = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), n.InnerText); if (fullPath != null && File.Exists(fullPath)) { this.iItem[Count].Path = fullPath; this.iItem[Count].Name = Path.GetFileName(this.iItem[Count].Path); Count++; } } this.Name = filename; }
/// <summary> /// Renders the background image for the content (unless HideBG is true). /// </summary> /// <param name="ConfigBGImagePath">This background is used unless the user selected a custom one.</param> /// <param name="graphics">The Graphics object to render the background on</param> /// <param name="Width"></param> /// <param name="Height"></param> public void RenderBGImage(string ConfigBGImagePath, Graphics graphics, int Width, int Height) { if (this.HideBG == false) { string fullPath = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), this.BGImagePath); if (DreamTools.FileExists(fullPath)) { if (this.bgImage == null) { try { this.bgImage = Image.FromFile(fullPath); } catch { } } } else if (DreamTools.FileExists(DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), ConfigBGImagePath))) { if (this.bgImage == null) { try { this.bgImage = Image.FromFile(DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), ConfigBGImagePath)); } catch { } } } if (this.bgImage != null) { graphics.DrawImage(this.bgImage, 0, 0, Width, Height); } } else { // Draw blank rectangle if no image is defined graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, Width, Height)); } }
public void Media_Remove_Click(object sender, System.EventArgs e) { if (_MainForm.RightDocks_BottomPanel_MediaList.SelectedIndex >= 0) { string MediaFolder = DreamTools.GetDirectory(DirType.MediaFiles); string localFile = MediaFolder + "\\" + this.MediaList.Name + "\\" + _MainForm.RightDocks_BottomPanel_MediaList.Items[_MainForm.RightDocks_BottomPanel_MediaList.SelectedIndex].Text; int tmp = _MainForm.RightDocks_BottomPanel_MediaList.SelectedIndex; MediaList.Remove(tmp); this.Refresh_MediaListBox(); if (_MainForm.RightDocks_BottomPanel_MediaList.Items.Count <= tmp) { tmp--; } if (File.Exists(localFile)) { try { File.Delete(localFile); } catch { } } if (tmp >= 0) { _MainForm.RightDocks_BottomPanel_MediaList.SelectedIndex = tmp; } } }
public static void addToZip(ZipOutputStream s, Crc32 crc, string file, bool putInFolder) { FileStream fs = File.OpenRead(file); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); string filename = Path.GetFileName(file); if (putInFolder) { filename = DreamTools.ReplaceSpecialChars(DreamTools.Reverse(DreamTools.Reverse(Path.GetDirectoryName(file)).Substring(0, DreamTools.Reverse(Path.GetDirectoryName(file)).IndexOf("\\"))) + "\\" + filename); } // MessageBox.Show(filename); ZipEntry entry = new ZipEntry(filename); entry.DateTime = DateTime.Now; entry.Size = fs.Length; fs.Close(); crc.Reset(); crc.Update(buffer); entry.Crc = crc.Value; s.PutNextEntry(entry); s.Write(buffer, 0, buffer.Length); }
/// <summary> /// Handles serialization of the Song class, or of any types derived from it. /// </summary> /// <param name="instance">The instance to serialize</param> /// <param name="file">The XML file to serialize to</param> public static void SerializeTo(Song instance, string file) { // We need to save these and restore them after serializing, or else whoever is holding // a reference to this "instance" will end up with a broken object because we set these // to "null" below so that we don't serialize them. string savedBGImagePath = instance.BGImagePath; Type type = instance.GetType(); XmlSerializer xs = new XmlSerializer(type); Directory.CreateDirectory(Path.GetDirectoryName(file)); FileStream fs = null; // When files are de-serialized, they retain the version they were // originally serialized under. We need to update it here. instance.Version = DreamTools.GetAppVersion(); if (instance.UseDesign) { Console.WriteLine("Saving Design.."); instance.Theme.SaveFile(DreamTools.GetDirectory(DirType.SongDesigns) + "\\" + Path.GetFileNameWithoutExtension(file) + ".SongTheme.xml"); instance.ThemePath = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.SongDesigns), Path.GetFileNameWithoutExtension(file) + ".SongTheme.xml"); } try { fs = File.Open(file, FileMode.Create, FileAccess.Write, FileShare.Read); xs.Serialize(fs, instance); } finally { if (fs != null) { fs.Close(); } instance.BGImagePath = savedBGImagePath; } }
///<summary>If BGImage chosen, update the current component </summary> public void SelectedIndexChanged(object sender, System.EventArgs e) { string path = DreamTools.GetDirectory(DirType.Backgrounds); string relativePath = ""; if (_MainForm.RightDocks_FolderDropdown.SelectedIndex > 0) { path = Path.Combine(path, _MainForm.RightDocks_FolderDropdown.Items[_MainForm.RightDocks_FolderDropdown.SelectedIndex].ToString()); relativePath = _MainForm.RightDocks_FolderDropdown.Items[_MainForm.RightDocks_FolderDropdown.SelectedIndex].ToString(); } if (_MainForm.RightDocks_ImageListBox.SelectedIndex >= 0) { path = Path.Combine(path, _MainForm.RightDocks_ImageListBox.Items[_MainForm.RightDocks_ImageListBox.SelectedIndex].Text); relativePath = Path.Combine(relativePath, _MainForm.RightDocks_ImageListBox.Items[_MainForm.RightDocks_ImageListBox.SelectedIndex].Text); if (_MainForm.selectedTab == MainTab.Presentation) { _MainForm.PreviewPresentationMedia(path); } else { if (_MainForm.DisplayPreview.content != null) { _MainForm.DisplayPreview.content.BGImagePath = path; _MainForm.songThemeWidget.BGImagePath = relativePath; _MainForm.DisplayPreview.UpdateDisplay(true); } } } }
public Options(MainForm mainForm) { _MainForm = mainForm; Lang = mainForm.Lang; InitializeComponent(); InitializeBackgroundWorker(); this.DataDirectory.Text = DreamTools.GetAppDocPath(); PopulateBibleCacheTab(); string DataSetFile = DreamTools.GetDirectory(DirType.Config, _MainForm.ConfigSet + ".dataset.config.xml"); if (DreamTools.FileExists(DataSetFile)) { this.Options_DataSet.ReadXml(DataSetFile, XmlReadMode.ReadSchema); } if (Options_RegEx_Table.Rows.Count > 0) { BibleConversions_Custom.Checked = true; BibleConversions_dataGrid_enable(true); } else { BibleConversions_Default.Checked = true; BibleConversions_dataGrid_enable(false); } SizeColumns(this.BibleConversions_dataGrid); }
public static Config DeserializeCleanup(Config config) { if (config.BackgroundColor.IsEmpty) { config.BackgroundColor = Color.Black; } // Versions prior to 0.72 had fewer TextFormats config.theme.Bible.CreateTextFormats(Enum.GetValues(typeof(BibleTextType)).Length); config.theme.Song.CreateTextFormats(Enum.GetValues(typeof(SongTextType)).Length); config.theme.Sermon.CreateTextFormats(Enum.GetValues(typeof(TextToolType)).Length); if (config.DefaultThemes.SongThemePath != "" && File.Exists(Path.Combine(DreamTools.GetDirectory(DirType.DataRoot), config.DefaultThemes.SongThemePath))) { config.theme.Song.ThemeFile = Path.Combine(DreamTools.GetDirectory(DirType.DataRoot), config.DefaultThemes.SongThemePath); } else if (File.Exists(Path.Combine(DreamTools.GetDirectory(DirType.DataRoot), "Themes\\Default.SongTheme.xml"))) { config.DefaultThemes.SongThemePath = "Themes\\Default.SongTheme.xml"; config.theme.Song.ThemeFile = Path.Combine(DreamTools.GetDirectory(DirType.DataRoot), config.DefaultThemes.SongThemePath); } return(config); }
public Song() { this.enumType = typeof(SongTextType); this.SongLyrics = new ArrayList(); this.Sequence = new ArrayList(); this.CurrentLyric = 0; this.Version = DreamTools.GetAppVersion(); wrapper = new WordWrapAtSpace(); }
private string GetCurrentPath() { string path = DreamTools.GetDirectory(DirType.Backgrounds); if (_MainForm.RightDocks_FolderDropdown.SelectedIndex > 0) { path = Path.Combine(path, _MainForm.RightDocks_FolderDropdown.Items[_MainForm.RightDocks_FolderDropdown.SelectedIndex].ToString()); } return(path); }
private void UpdateMarginBoxes() { changingRect = true; // If we assign values that are out-of-range to the controls, we'll get an exception. this.Bounds1.Value = DreamTools.ForceToRange(Bounds1.Minimum, Bounds1.Maximum, (decimal)imagePanel.RectPosition.Left); this.Bounds2.Value = DreamTools.ForceToRange(Bounds2.Minimum, Bounds2.Maximum, (decimal)imagePanel.RectPosition.Top); this.Bounds3.Value = DreamTools.ForceToRange(Bounds3.Minimum, Bounds3.Maximum, (decimal)(100F - imagePanel.RectPosition.Right)); this.Bounds4.Value = DreamTools.ForceToRange(Bounds4.Minimum, Bounds4.Maximum, (decimal)(100F - imagePanel.RectPosition.Bottom)); changingRect = true; }
public void Log(string Text) { if (doLog) { StreamWriter SW; SW = File.AppendText(DreamTools.GetDirectory(DirType.Logs, logPrefix + ".LogFile.txt")); SW.WriteLine(DateTime.Now.ToString() + ": " + Text); SW.Close(); } }
private void bgImageBrowse_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = ImageFileFilter; ofd.InitialDirectory = DreamTools.GetDirectory(DirType.Backgrounds); if (ofd.ShowDialog() != DialogResult.Cancel) { this.BGImagePathLabel.Text = DreamTools.GetRelativePath(DirType.DataRoot, ofd.FileName); } }
/// <summary> /// Saves Theme into a Directory /// </summary> /// <param name="fileName">Path to File</param> public void SaveFile(string fileName) { try { SerializeTo(this, fileName); this.ThemeFile = DreamTools.GetRelativePath(DirType.DataRoot, fileName); //this.StatusPanel.Text = Lang.say("Status.SongSavedAs", this.SaveFileDialog.FileName); } catch (Exception ex) { MessageBox.Show("Theme not saved: " + ex.Message); } }
public Bitmap GetBitmap(int Width, int Height) { if (this.RenderedFramesContains(this.VisibleHashCode())) { Console.WriteLine("ImageContent pre-render cache hit."); return(this.RenderedFramesGet(this.VisibleHashCode()) as Bitmap); } Bitmap bmp = new Bitmap(Width, Height); Graphics graphics = Graphics.FromImage(bmp); #region Render background image // Draw background image if (this.HideBG == false) { string fullPath = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), this.BGImagePath); if (DreamTools.FileExists(fullPath)) { if (this.bgImage == null) { try { this.bgImage = Image.FromFile(fullPath); } catch { } } } if (this.bgImage != null) { if (this._proportional) { graphics.DrawImage(ShowBeam.DrawProportionalBitmap(new System.Drawing.Size(Width, Height), this.bgImage).Bitmap, 0, 0, Width, Height); } else { graphics.DrawImage(this.bgImage, 0, 0, Width, Height); } } } else { // Draw blank rectangle if no image is defined graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, Width, Height)); } #endregion graphics.Dispose(); this.RenderedFramesSet(this.VisibleHashCode(), bmp); return(bmp); }
public static object DeserializeFrom(Type type, string file) { XmlSerializer xs = null; file = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), file); if (file == null) { return(null); } try { xs = new XmlSerializer(type); } catch (InvalidOperationException ex) { // Invalid class. Does the class have a public constructor? Console.WriteLine("DeserializeFrom exception: " + ex.Message); } if (xs != null) { try { using (FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read)) { Theme t = (Theme)xs.Deserialize(fs); if (t != null) { t.ThemeFile = DreamTools.GetRelativePath(DirType.DataRoot, file); if (type == typeof(SongTheme)) { t.CreateTextFormats(Enum.GetValues(typeof(SongTextType)).Length); } else if (type == typeof(BibleTheme)) { t.CreateTextFormats(Enum.GetValues(typeof(BibleTextType)).Length); } else if (type == typeof(SermonTheme)) { t.CreateTextFormats(Enum.GetValues(typeof(TextToolType)).Length); } } return(t); } } catch (FileNotFoundException) { return(null); } catch (InvalidOperationException) { // Invalid XML code return(null); } } return(null); }
public ColoredTextBoxPanel() { InitializeComponent(); this.rte.MouseWheel += new MouseEventHandler(this.MouseWheelHandler); renew = true; oldLines = DreamTools.SplitString(rte.Text, separator); for (int i = 0; i < oldLines.Length; i++) { Typelist.Add(LyricsType.Verse); } this.Update(); }
/// <summary> /// If this display is a remote server it will receive a description of the content, /// and will have to create a content object based on that. We don't want to send /// actual objects to remote servers. /// </summary> /// <param name="identity">A "description" of the content</param> public bool SetContent(ContentIdentity identity) { IContentOperations newContent = null; bool success = true; try { switch ((ContentType)identity.Type) { case ContentType.BibleVerseIdx: newContent = new ABibleVerse(bibleLib[identity.BibleTransl], identity.VerseIdx, Display.config); break; case ContentType.BibleVerseRef: BibleVersion bible = bibleLib[identity.BibleTransl]; int idx = bible.GetVerseIndex(identity.VerseRef); newContent = new ABibleVerse(bible, idx, Display.config); break; case ContentType.PlainText: newContent = new TextToolContents(identity.Text, Display.config); break; case ContentType.Song: string songFile = DreamTools.GetDirectory(DirType.Songs, identity.SongName); newContent = (Song)Song.DeserializeFrom(songFile, identity.SongStrophe, Display.config); break; } } catch { } // Covers a multitude of sins (non-existent translation, or song, or verse, etc...) if (newContent != null) { if (NextDisplay != null) { success = NextDisplay.SetContent(newContent); } if (success) { this.content = newContent; success = this.UpdateDisplay(false); } } else { success = false; } return(success); }
/// <summary></summary> public void ListDirectories() { string strImageDir = DreamTools.GetDirectory(DirType.Backgrounds); _MainForm.RightDocks_imageList.Images.Clear(); _MainForm.RightDocks_ImageListBox.Items.Clear(); // Define Directory and ImageTypes string[] folders = Directory.GetDirectories(@strImageDir); _MainForm.RightDocks_FolderDropdown.Items.Clear(); _MainForm.RightDocks_FolderDropdown.Items.Add("- Top -"); foreach (string folder in folders) { _MainForm.RightDocks_FolderDropdown.Items.Add(Path.GetFileName(folder)); } }
public static void delTree(string path) { try { string[] dirs = Directory.GetDirectories(@path); foreach (string dir in dirs) { DreamTools.delTree(dir); // Directory.Delete (dir); } dirs = Directory.GetFiles(@path); foreach (string dir in dirs) { // File.Delete(dir); } } catch (Exception e) { } }
public void setText(Song song) { if (verseSeparator == SongVerseSeparator.OneBlankLine) { separator = "\n\n"; } if (verseSeparator == SongVerseSeparator.TwoBlankLines) { separator = "\n\n\n"; } Typelist = new ArrayList(); //song.SongLyrics.Sort(); StringBuilder s = new StringBuilder(); int i = 0; foreach (LyricsItem item in song.SongLyrics) { if (item.Lyrics.Length > 0) { if (s.Length > 0) { s.Append(separator); } s.Append(item.Lyrics); Typelist.Add(item.Type); i++; } } if (Typelist.Count == 0) { Typelist.Add(LyricsType.Verse); } Updating = true; rte.Text = song.SanitizeLyrics(s.ToString()); oldLines = DreamTools.SplitString(rte.Text, separator); rte.Font = new Font("Microsoft Sans Serif", 9); Updating = false; renew = true; Update(); Resizer(false); }
/// <summary> /// Handles deserialization of the Config class, or of any types derived from it. /// </summary> /// <param name="instance">An instance of the class to deserialize</param> /// <param name="file">The XML file to deserialize</param> /// <returns></returns> public static object DeserializeFrom(Config instance, string file) { Type type = instance.GetType(); XmlSerializer xs = null; string fullPath = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.Config), file); try { xs = new XmlSerializer(type); } catch (InvalidOperationException ex) { // Invalid class. Does the class have a public constructor? Console.WriteLine("DeserializeFrom exception: " + ex.Message); } if (!DreamTools.FileExists(fullPath)) { // fullPath could be NULL here, so use "file" Config.SerializeTo(instance, file); } else if (xs != null) { try { using (FileStream fs = File.Open(fullPath, FileMode.Open, FileAccess.Read)) { Config config = xs.Deserialize(fs) as Config; if (config != null) { return(DeserializeCleanup(config)); } else { Config.SerializeTo(instance, fullPath); } } } catch (FileNotFoundException) { Config.SerializeTo(instance, fullPath); } catch (InvalidOperationException) { // Invalid XML code Config.SerializeTo(instance, fullPath); } } return(DeserializeCleanup(instance)); }
///<summary>Saves the ImageList</summary> public void Save() { XmlTextWriter tw = new XmlTextWriter(DreamTools.GetDirectory(DirType.MediaLists, Name + ".xml"), null); tw.Formatting = Formatting.Indented; tw.WriteStartDocument(); tw.WriteStartElement("MediaList"); tw.WriteElementString("Version", DreamTools.GetAppVersion()); for (int i = 0; i < Count; i++) { tw.WriteStartElement("MediaItem"); tw.WriteElementString("Path", DreamTools.GetRelativePath(DirType.DataRoot, this.iItem[i].Path)); tw.WriteEndElement(); } tw.WriteEndElement(); tw.WriteEndDocument(); tw.Flush(); tw.Close(); }
public void GetText(Song song) { string[] newLines = DreamTools.SplitString(rte.Text, separator); int verseCount = 1; int chorusCount = 1; int otherCount = 1; int j = 0; song.ClearLyrics(); StringBuilder verse = new StringBuilder(); StringBuilder chorus = new StringBuilder(); StringBuilder other = new StringBuilder(); foreach (string line in newLines) { switch ((LyricsType)Typelist[j]) { case LyricsType.Verse: verseCount = song.AddLyrics(LyricsType.Verse, line, verseCount, verseSeparator); //if (verse.Length > 0) verse.Append(separator); //verse.Append(line); break; case LyricsType.Chorus: //if (chorus.Length > 0) chorus.Append(separator); //chorus.Append(line); chorusCount = song.AddLyrics(LyricsType.Chorus, line, chorusCount, verseSeparator); break; case LyricsType.Other: //if (other.Length > 0) other.Append(separator); //other.Append(line); otherCount = song.AddLyrics(LyricsType.Other, line, otherCount, verseSeparator); break; } j++; } //song.SetLyrics(LyricsType.Verse, verse.ToString(), verseSeparator); //song.SetLyrics(LyricsType.Chorus, chorus.ToString(), verseSeparator); //song.SetLyrics(LyricsType.Other, other.ToString(), verseSeparator); }
public static Theme OpenFile(string FileDialogFilter, Type type) { OpenFileDialog dialog = new OpenFileDialog(); dialog.DefaultExt = "xml"; dialog.Filter = FileDialogFilter; dialog.FilterIndex = 1; dialog.InitialDirectory = DreamTools.GetDirectory(DirType.Themes); dialog.Title = "Open Theme"; dialog.Multiselect = false; if (dialog.ShowDialog() == DialogResult.OK) { Theme t = DeserializeFrom(type, dialog.FileName) as Theme; return(t); } else { return(null); } }
private void ListThemes(Config config) { this.DefaultSongFormatListBox.Items.Clear(); this.DefaultBibleFormatListBox.Items.Clear(); this.DefaultSermonFormatListBox.Items.Clear(); DirectoryInfo di = new DirectoryInfo(DreamTools.GetDirectory(DirType.Themes)); FileInfo[] rgFiles = di.GetFiles("*.SongTheme.xml"); foreach (FileInfo fi in rgFiles) { this.DefaultSongFormatListBox.Items.Add(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(fi.Name))); if (Path.GetFileName(config.DefaultThemes.SongThemePath).ToLower() == Path.GetFileName(fi.Name).ToLower()) { this.DefaultSongFormatListBox.SelectedIndex = this.DefaultSongFormatListBox.Items.Count - 1; } } rgFiles = di.GetFiles("*.BibleTheme.xml"); foreach (FileInfo fi in rgFiles) { this.DefaultBibleFormatListBox.Items.Add(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(fi.Name))); if (Path.GetFileName(config.DefaultThemes.BibleThemePath).ToLower() == Path.GetFileName(fi.Name).ToLower()) { this.DefaultBibleFormatListBox.SelectedIndex = this.DefaultBibleFormatListBox.Items.Count - 1; } } rgFiles = di.GetFiles("*.SermonTheme.xml"); foreach (FileInfo fi in rgFiles) { this.DefaultSermonFormatListBox.Items.Add(Path.GetFileNameWithoutExtension((Path.GetFileNameWithoutExtension(fi.Name)))); if (Path.GetFileName(config.DefaultThemes.SermonThemePath).ToLower() == Path.GetFileName(fi.Name).ToLower()) { this.DefaultSermonFormatListBox.SelectedIndex = this.DefaultSermonFormatListBox.Items.Count - 1; } } }
/// <summary> /// Handles serialization of the Config class, or of any types derived from it. /// </summary> /// <param name="instance">The instance to serialize</param> /// <param name="file">The XML file to serialize to</param> public static void SerializeTo(Config instance, string file) { Type type = instance.GetType(); XmlSerializer xs = new XmlSerializer(type); file = Path.GetFullPath(file); Directory.CreateDirectory(Path.GetDirectoryName(file)); FileStream fs = null; instance.Version = DreamTools.GetAppVersion(); try { fs = File.Open(file, FileMode.Create, FileAccess.Write, FileShare.Read); xs.Serialize(fs, instance); } catch (Exception e) { Console.WriteLine(e.Message); } finally { if (fs != null) { fs.Close(); } } }
public void SaveAs(string FileDialogFilter) { SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = "xml"; dialog.Filter = FileDialogFilter; dialog.FilterIndex = 1; dialog.InitialDirectory = DreamTools.GetDirectory(DirType.Themes); dialog.Title = "Save Theme As"; Directory.CreateDirectory(dialog.InitialDirectory); if (dialog.ShowDialog() == DialogResult.OK) { string fileName = dialog.FileName; try { SerializeTo(this, fileName); this.ThemeFile = DreamTools.GetRelativePath(DirType.DataRoot, fileName); //this.StatusPanel.Text = Lang.say("Status.SongSavedAs", this.SaveFileDialog.FileName); } catch (Exception ex) { MessageBox.Show("Theme not saved: " + ex.Message); } } }
/// <summary> /// The SandDoc layout for each tab is stored in a separate file. This function tells us the name of that file. /// </summary> /// <param name="tab"></param> /// <returns></returns> private string GetTabLayoutFile(MainTab tab) { return(DreamTools.GetDirectory(DirType.Config, _MainForm.ConfigSet + ".Tab_" + Enum.GetName(typeof(MainTab), tab) + ".xml")); }
public static void CreateDreamBGPackage() { string filepath = Exporter.filepath; ArrayList List = Exporter.List; ProgressBar progressBar = Exporter.progressBar; bool convert_Images = Exporter.convert_Images; bool singleFile = Exporter.singleFile; if (List.Count > 0) { string strMediaListDir = DreamTools.GetDirectory(DirType.Backgrounds); Crc32 crc = new Crc32(); ZipOutputStream s = new ZipOutputStream(File.Create(filepath)); s.SetLevel(9); //0 - store only to 9 - means best compression ArrayList bgList = new ArrayList(); if (singleFile) { progressBar.Maximum = List.Count; } if (singleFile) { progressBar.Value = 0; } if (singleFile) { Exporter.ExportForm.Enabled = false; } for (int j = 0; j < List.Count; j++) { string [] filetypes = { ".bmp", ".jpg", ".png", ".gif", ".jpeg" }; string strImageDir = strMediaListDir + List[j].ToString(); if (Directory.Exists(strImageDir)) { //find all files from defined FileTypes foreach (string filetype in filetypes) { string[] dirs = Directory.GetFiles(@strImageDir, "*" + filetype); foreach (string dir in dirs) { string bgImage = dir; //mediaList.iItem[k].Path; if (((Path.GetExtension(bgImage).ToLower() != ".jpg") & (Path.GetExtension(bgImage).ToLower() != ".jpeg")) && convert_Images) { Bitmap bmp = new Bitmap(bgImage); System.Drawing.Imaging.ImageCodecInfo ici = BitmapManipulator.GetEncoderInfo("image/jpeg"); EncoderParameters eps = new EncoderParameters(1); eps.Param[0] = new EncoderParameter(Encoder.Quality, 100L); bgImage = DreamTools.GetDirectory(DirType.DataRoot) + "\\" + Path.GetFileNameWithoutExtension(bgImage) + ".jpg"; bmp.Save(bgImage, ici, eps); addToZip(s, crc, bgImage, true); bmp.Dispose(); File.Delete(bgImage); } else if (File.Exists(bgImage)) { addToZip(s, crc, bgImage, true); } } } // addToZip(s,crc,file); } if (singleFile) { progressBar.Value++; } } s.Finish(); s.Close(); if (singleFile) { Exporter.ExportForm.Enabled = true; } } }