Example #1
0
        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);
            }
        }
Example #2
0
 /// <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);
     }
 }
Example #3
0
        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);
        }
Example #4
0
        ///<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();
        }
Example #5
0
        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);
                }
            }
        }