private string GetStyleFilename()
        {
            CorrectStyleFilenameForNewDirectoryLocation();

            // Get the style filename that is in the text box
            string style_filename = ConfigurationManager.Instance.ConfigurationRecord.InCite_LastStyleFile;

            if (!File.Exists(style_filename))
            {
                MessageBoxes.Warn("The CSL style file you were using seems to have been moved or deleted.\nPlease select a new CSL style file.\n\nThe current missing CSL style file is:\n  {0}", style_filename);
                return(null);
            }


            string root_style_filename = DependentStyleDetector.GetRootStyleFilename(style_filename);

            if (null == root_style_filename)
            {
                MessageBoxes.Info("This style is dependent on another style that is not available on your computer.  Please download it before proceeding.");
                return(null);
            }

            if (root_style_filename != style_filename)
            {
                Logging.Info("We are using the root style {0} instead of the selected style {1}", root_style_filename, style_filename);
            }

            return(style_filename);
        }
        private void ChooseCSLFile(CSLFileSource csl_file_source)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter          = "CSL style files|*.csl" + "|" + "All files|*.*";
            dialog.CheckFileExists = true;
            dialog.Multiselect     = false;

            string filename  = null;
            string directory = null;

            // Decide what we want to use as the CSL file location
            if (CSLFileSource.TEXTBOX == csl_file_source)
            {
                try
                {
                    CorrectStyleFilenameForNewDirectoryLocation();
                    directory = Path.GetDirectoryName(ConfigurationManager.Instance.ConfigurationRecord.InCite_LastStyleFile);
                    filename  = Path.GetFileName(ConfigurationManager.Instance.ConfigurationRecord.InCite_LastStyleFile);

                    // If the directory no longer exists, kill our memory of it.  We will pick the default directory again.
                    if (!Directory.Exists(directory))
                    {
                        directory = null;
                    }
                }
                catch { }
            }
            if (null == directory)
            {
                directory = PDFDocumentCitingTools.BASE_STYLE_DIRECTORY;
            }

            // Set the dialog defaults
            dialog.FileName         = filename;
            dialog.InitialDirectory = directory;

            // Get the user response
            if (true == dialog.ShowDialog())
            {
                ConfigurationManager.Instance.ConfigurationRecord.InCite_LastStyleFile = dialog.FileName;
                ConfigurationManager.Instance.ConfigurationRecord_Bindable.NotifyPropertyChanged(() => ConfigurationManager.Instance.ConfigurationRecord.InCite_LastStyleFile);

                // Check if it is a dependent style
                string style_xml_filename  = ConfigurationManager.Instance.ConfigurationRecord.InCite_LastStyleFile;
                string root_style_filename = DependentStyleDetector.GetRootStyleFilename(style_xml_filename);
                if (root_style_filename != style_xml_filename)
                {
                    if (null != root_style_filename)
                    {
                        MessageBoxes.Info("This style is dependent on another style, so InCite will be using this file instead:\n" + root_style_filename);
                    }
                    else
                    {
                        MessageBoxes.Info("This style is dependent on another style that is not available on your computer.  Please download it before proceeding.");
                    }
                }
            }
        }