public InsertScriptureForm()
        {
            log.Info("Loading InsertScriptureForm");
            InitializeComponent();

            var registryKey  = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\WorshipHelper");
            var lastTemplate = registryKey.GetValue("LastScriptureTemplate") as string;
            var lastBible    = registryKey.GetValue("LastBibleTranslation") as string;

            // Get a list of available templates, populate list and set initial selection
            log.Debug("Loading scripture templates");
            var installedTemplateFiles = Directory.GetFiles($@"{ThisAddIn.appDataPath}\Templates", "*.pptx");

            Directory.CreateDirectory($@"{ThisAddIn.userDataPath}\UserTemplates\Scripture");
            var userTemplateFiles = Directory.GetFiles($@"{ThisAddIn.userDataPath}\UserTemplates\Scripture", "*.pptx");

            foreach (var file in installedTemplateFiles.Concat(userTemplateFiles))
            {
                var template = new ScriptureTemplate(file);
                cmbTemplate.Items.Add(template);
                if (template.name == lastTemplate)
                {
                    cmbTemplate.SelectedItem = template;
                }
            }
            if (cmbTemplate.SelectedItem == null)
            {
                cmbTemplate.SelectedIndex = 0;
            }

            // Get a list of installed bibles, populate list and set initial selection
            log.Debug("Loading bibles");
            var installedBibleFiles = Directory.GetFiles($@"{ThisAddIn.appDataPath}\Bibles", "*.xmm");

            foreach (var file in installedBibleFiles)
            {
                var bibleName = file.Split(new char[] { '\\' }).Last().Replace(".xmm", "");
                cmbTranslation.Items.Add(bibleName);
                if (bibleName == lastBible)
                {
                    cmbTranslation.SelectedItem = bibleName;
                }
            }
            if (cmbTranslation.SelectedItem == null)
            {
                cmbTranslation.SelectedIndex = 0;
            }

            // Initialise so that we can populate the books
            log.Debug($"Loading default bible ({cmbTranslation.SelectedItem})");
            bible = OpenSongBibleReader.LoadTranslation(cmbTranslation.SelectedItem as string);

            var source = new AutoCompleteStringCollection();

            log.Debug("Adding books");
            source.AddRange(bible.books.Select(book => book.name).ToArray());
            txtBook.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            txtBook.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            txtBook.AutoCompleteCustomSource = source;
        }
示例#2
0
        public static Bible LoadTranslation(String translationName)
        {
            var bible = new OpenSongBibleReader().load($@"{ThisAddIn.appDataPath}\Bibles\{translationName}.xmm");

            bible.name = translationName;
            return(bible);
        }
        private void cmbTranslation_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var box             = (sender as ComboBox);
            var translationName = box.SelectedItem as string;

            log.Info($"Selecting translation: {translationName}");

            bible = OpenSongBibleReader.LoadTranslation(translationName);

            var registryKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\WorshipHelper");

            registryKey.SetValue("LastBibleTranslation", translationName);
        }