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 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); }
/// <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; } } }
/// <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); } } } }
///<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; }
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 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 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); } }
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); }
/// <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)); } }
/// <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 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; } } }
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>Loads the Song</summary> public void Load(string filename) { Init(filename); int i; this.strophe = 0; XmlDocument document = new XmlDocument(); try { //"Songs\\"+filename+".xml" //document.Load(DreamTools.DreamBeamPath() + @"\Songs\" + filename + ".xml"); document.Load(filename); } catch (XmlException xmle) { MessageBox.Show(xmle.Message); } XmlNodeList list = null; // Get This.Text[*] list = document.GetElementsByTagName("Text"); i = 0; foreach (XmlNode n in list) { this.Text[i] = n.InnerText; i++; } // Get This.FontFace[*] list = document.GetElementsByTagName("Font"); i = 0; foreach (XmlNode n in list) { this.FontFace[i] = n.InnerText; i++; } // Get This.TextStyle list = document.GetElementsByTagName("FontStyle"); i = 0; foreach (XmlNode n in list) { this.FontStyle[i] = (System.Drawing.FontStyle)Convert.ToInt32(n.InnerText); i++; } // Get This.FontSize[*] list = document.GetElementsByTagName("FontSize"); double x; i = 0; foreach (XmlNode n in list) { x = Convert.ToDouble(n.InnerText.Trim()); this.FontSize[i] = (float)x; i++; } // Get This.posX[*] list = document.GetElementsByTagName("posX"); i = 0; foreach (XmlNode n in list) { this.posX[i] = Convert.ToInt32(n.InnerText); i++; } // Get This.posX[*] list = document.GetElementsByTagName("posY"); i = 0; foreach (XmlNode n in list) { this.posY[i] = Convert.ToInt32(n.InnerText); i++; } // Get This.TextColor[*] list = document.GetElementsByTagName("TextColor"); i = 0; foreach (XmlNode n in list) { this.TextColor[i] = System.Drawing.Color.FromArgb(Convert.ToInt32(n.InnerText)); i++; } // Get This.OutlineColor[*] list = document.GetElementsByTagName("OutlineColor"); i = 0; foreach (XmlNode n in list) { this.OutlineColor[i] = System.Drawing.Color.FromArgb(Convert.ToInt32(n.InnerText)); i++; } // Get This.TextStyle list = document.GetElementsByTagName("TextStyle"); i = 0; foreach (XmlNode n in list) { this.TextStyle = Convert.ToInt32(n.InnerText); i++; } // Get This.TextAlign list = document.GetElementsByTagName("TextAlign"); TextAlign = "left"; foreach (XmlNode n in list) { TextAlign = n.InnerText; } // Get Multilang list = document.GetElementsByTagName("MultiLang"); MultiLang = false; foreach (XmlNode n in list) { MultiLang = Convert.ToBoolean(n.InnerText); } // Get This.TextEffect[*] list = document.GetElementsByTagName("TextEffect"); i = 0; foreach (XmlNode n in list) { this.TextEffect[i] = n.InnerText; i++; } // Get AutoPos list = document.GetElementsByTagName("AutoPos"); i = 0; AutoPos[0] = false; AutoPos[1] = false; AutoPos[2] = false; foreach (XmlNode n in list) { this.AutoPos[i] = Convert.ToBoolean(n.InnerText); i++; } // Get AutoPos list = document.GetElementsByTagName("windowHeight"); i = 0; foreach (XmlNode n in list) { windowHeight = Convert.ToInt32(n.InnerText); i++; } // Get AutoPos list = document.GetElementsByTagName("windowWidth"); i = 0; foreach (XmlNode n in list) { windowWidth = Convert.ToInt32(n.InnerText); i++; } // Get This.bg_image list = document.GetElementsByTagName("image"); foreach (XmlNode n in list) { if (System.IO.File.Exists(n.InnerText)) { this.bg_image = n.InnerText; } else { this.bg_image = null; // Define Directory and ImageTypes string strImageDir = DreamTools.GetDirectory(DirType.Backgrounds); string[] folders = Directory.GetDirectories(@strImageDir); string tmpfilename = Path.GetFileName(n.InnerText); if (File.Exists(DreamTools.GetDirectory(DirType.Backgrounds, tmpfilename))) { this.bg_image = DreamTools.GetDirectory(DirType.Backgrounds, tmpfilename); } else { foreach (string folder in folders) { if (File.Exists(Path.Combine(folder, tmpfilename))) { this.bg_image = Path.Combine(folder, tmpfilename); } } } } } this.SongName = filename; if (this.SizeForm != null) { CalculateSizes(); } this.strophe_count = CountStrophes(); }
public static void EmptyTempDir() { DreamTools.delTree(DreamTools.GetDirectory(DirType.DataRoot) + "\\temp"); }
private void Options_OkBtn_Click(object sender, System.EventArgs e) { Config config = new Config(); this._MainForm.Config = config; config.Alphablending = this.Alpha_CheckBox.Checked; config.PreRender = this.PreRendercheckBox.Checked; config.BlendSpeed = (int)Speed_Updown.Value; config.useDirect3D = this.Direct3D_CheckBox.Checked; config.BackgroundColor = this.showBeamBackground; if (config.BackgroundColor.IsEmpty) { config.BackgroundColor = Color.Black; } if (SizePosControl.SelectedIndex == 0) { config.BeamBoxAutoPosSize = true; } else { config.BeamBoxAutoPosSize = false; } if (config.BeamBoxAutoPosSize && ScreenList.SelectedIndex >= 0) { config.BeamBoxScreenNum = ScreenList.SelectedIndex; Rectangle r = System.Windows.Forms.Screen.AllScreens[ScreenList.SelectedIndex].Bounds; config.BeamBoxPosX = r.X; config.BeamBoxPosY = r.Y; config.BeamBoxSizeX = r.Width; config.BeamBoxSizeY = r.Height; } else { config.BeamBoxPosX = (int)this.BeamBox_posX.Value; config.BeamBoxPosY = (int)this.BeamBox_posY.Value; config.BeamBoxSizeX = (int)this.BeamBox_Width.Value; config.BeamBoxSizeY = (int)this.BeamBox_Height.Value; } // We need to update all displays with the new size. // They use this size to generate the bitmaps. this._MainForm.UpdateDisplaySizes(); config.SwordPath = this.Sword_PathBox.Text; if (!String.IsNullOrEmpty(this.Sword_LanguageBox.Text)) { config.BibleLang = this.Sword_LanguageBox.Text; SetBibleLocale(this._MainForm.bibles, config.SwordPath, config.BibleLang); } if (this.verseSep2L.Checked) { config.SongVerseSeparator = SongVerseSeparator.TwoBlankLines; } else { config.SongVerseSeparator = SongVerseSeparator.OneBlankLine; } config.HideMouse = this.BeamBox_HideMouse.Checked; config.AlwaysOnTop = this.BeamBox_AlwaysOnTop.Checked; switch (LanguageList.SelectedIndex) { case 0: config.Language = "en"; break; case 1: config.Language = "de"; break; } config.RememberPanelLocations = this.Options_PanelLocations_checkBox.Checked; //config.theme.Song = this.songThemeWidget.Theme as SongTheme; //config.theme.Bible = this.bibleFormatWidget.Theme as BibleTheme; //config.theme.Sermon = this.sermonThemeWidget.Theme as SermonTheme; IContentOperations content = _MainForm.DisplayPreview.content; if (content != null) { content.ShowRectangles = false; } config.ServerAddress = this.ServerAddress.Text; config.ListeningPort = (int)this.ListeningPort.Value; OperatingMode oldMode = config.AppOperatingMode; if (this.OperatingMode_StandAlone.Checked) { config.AppOperatingMode = OperatingMode.StandAlone; } else if (this.OperatingMode_Client.Checked) { config.AppOperatingMode = OperatingMode.Client; } else if (this.OperatingMode_Server.Checked) { config.AppOperatingMode = OperatingMode.Server; } if (oldMode != config.AppOperatingMode) { _MainForm.InitDisplays(); } string s = (String)DefaultSongFormatListBox.SelectedItem; config.DefaultThemes.SongThemePath = Path.Combine("Themes\\", s + ".SongTheme.xml"); s = (String)DefaultSermonFormatListBox.SelectedItem; config.DefaultThemes.SermonThemePath = Path.Combine("Themes\\", s + ".SermonTheme.xml"); s = (String)DefaultBibleFormatListBox.SelectedItem; config.DefaultThemes.BibleThemePath = Path.Combine("Themes\\", s + ".BibleTheme.xml"); config.Options_DataSet = this.Options_DataSet; this.Options_DataSet.WriteXml(DreamTools.GetDirectory(DirType.Config, _MainForm.ConfigSet + ".dataset.config.xml"), XmlWriteMode.WriteSchema); Config.SerializeTo(config, DreamTools.GetDirectory(DirType.Config, _MainForm.ConfigSet + ".config.xml")); this.Close(); }
/// <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; } } }
public static void CreateDreamMediaPackage() { 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.MediaLists); Crc32 crc = new Crc32(); ZipOutputStream s = new ZipOutputStream(File.Create(filepath)); s.SetLevel(9); //0 - store only to 9 - means best compression ImageList mediaList = new ImageList(); 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 file = strMediaListDir + List[j].ToString() + ".xml"; if (File.Exists(file)) { // Include BG Image mediaList.Load(List[j].ToString()); for (int k = 0; k < mediaList.Count; k++) { if (File.Exists(mediaList.iItem[k].Path)) { bool includeBG = true; for (int i = 0; i < bgList.Count; i++) { if (bgList[i].ToString() == mediaList.iItem[k].Path) { includeBG = false; } } if (includeBG) { bgList.Add(mediaList.iItem[k].Path); //DreamTools.DreamBeamPath()+"\\"+ string bgImage = 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, true); } if (singleFile) { progressBar.Value++; } } s.Finish(); s.Close(); if (singleFile) { Exporter.ExportForm.Enabled = true; } } }
public static void CreateDreamSongPackage(string filepath, ArrayList List, ProgressBar progressBar, bool include_Images, bool convert_Images, bool singleFile) { if (List.Count > 0) { string strSongDir = DreamTools.GetDirectory(DirType.Songs); Crc32 crc = new Crc32(); ZipOutputStream s = new ZipOutputStream(File.Create(filepath)); s.SetLevel(9); //0 - store only to 9 - means best compression Song song = new Song(); ArrayList bgList = new ArrayList(); if (singleFile) { progressBar.Maximum = List.Count; } if (singleFile) { progressBar.Value = 0; } for (int j = 0; j < List.Count; j++) { string file = strSongDir + List[j].ToString() + ".xml"; if (File.Exists(file)) { // Include BG Image /* if(include_Images){ * song.Load(List[j].ToString()); * if(File.Exists(song.bg_image)){ * bool includeBG = true; * for (int i = 0; i < bgList.Count;i++){ * if(bgList[i].ToString() == song.bg_image) includeBG = false; * } * if(includeBG){ * * bgList.Add(song.bg_image); * //DreamTools.DreamBeamPath()+"\\"+ * string bgImage = song.bg_image; * * if( ((Path.GetExtension(song.bg_image).ToLower() != ".jpg")&(Path.GetExtension(song.bg_image).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.DreamBeamPath()+"\\"+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, true); } if (singleFile) { progressBar.Value++; } } s.Finish(); s.Close(); } }
private void openDataDirectoryButton_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("explorer", DreamTools.GetDirectory(DirType.DataRoot)); }
public void DragDropThread() { DialogResult answer = MessageBox.Show(_MainForm.Lang.say("Message.ImportMedia"), _MainForm.Lang.say("Message.ImportMediaTitle"), MessageBoxButtons.YesNo); try { int i = 0; foreach (string dropFile in DragDropArray) { foreach (string ex in _MainForm.GuiTools.Presentation.filetypes) { if (Path.GetExtension(dropFile).ToLower() == ex) { string fileName; if (answer == DialogResult.Yes) { // Copy the file and change the file name to point to the copy string MediaFolder = DreamTools.GetDirectory(DirType.MediaFiles); if (Directory.Exists(MediaFolder) == false) { Directory.CreateDirectory(MediaFolder); } MediaFolder = Path.Combine(MediaFolder, this.MediaList.Name); if (Directory.Exists(MediaFolder) == false) { Directory.CreateDirectory(MediaFolder); } fileName = Path.Combine(MediaFolder, Path.GetFileName(dropFile)); if (File.Exists(fileName) == false) { File.Copy(dropFile, fileName, true); } } else { // Link file from the current location fileName = dropFile; } if (File.Exists(fileName)) { AddMedia(fileName); } break; } } _MainForm.UpdateStatusPanel(_MainForm.Lang.say("Status.LoadingMediaFiles", Convert.ToString(100 * i / DragDropArray.Length))); i++; } _MainForm.UpdateStatusPanel(_MainForm.Lang.say("Status.MediaFilesLoaded")); LoadingMediaList = ""; Refresh_MediaListBox(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
string GetLocation(Type type) { return(DreamTools.GetDirectory(DirType.Config, type.Name + ".xml")); }
public static void CreateTempDir() { Importer.tempDir = DreamTools.GetDirectory(DirType.DataRoot) + "\\temp\\importer_" + DreamTools.createTimeStamp() + "\\"; Directory.CreateDirectory(Importer.tempDir); }