예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateLanguageCombos()
        {
            var wsSaveVern = (IWritingSystem)m_cbVernWrtSys.SelectedItem;
            var wsSaveAnal = (IWritingSystem)m_cbAnalWrtSys.SelectedItem;

            m_cbAnalWrtSys.BeginUpdate();
            m_cbVernWrtSys.BeginUpdate();
            m_cbAnalWrtSys.Items.Clear();
            m_cbVernWrtSys.Items.Clear();

            // Make sure our manager knows about any writing systems in the template folder.
            // In pathological cases where no projects have been installed these might not be in the global store.
            foreach (var templateLangFile in Directory.GetFiles(FwDirectoryFinder.TemplateDirectory, @"*.ldml"))
            {
                var            id = Path.GetFileNameWithoutExtension(templateLangFile);
                IWritingSystem dummy;
                m_wsManager.GetOrSet(id, out dummy);
            }

            foreach (IWritingSystem ws in m_wsManager.LocalWritingSystems)
            {
                m_cbAnalWrtSys.Items.Add(ws);
                m_cbVernWrtSys.Items.Add(ws);
            }

            if (m_cbVernWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveVern == null ? -1 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
                if (i != -1)
#endif
                m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbVernWrtSys.EndUpdate();

            if (m_cbAnalWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveAnal == null ? -1 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
                if (i != -1)
#endif
                m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbAnalWrtSys.EndUpdate();
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateLanguageCombos()
        {
            ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
            string userLocale           = wsf.GetStrFromWs(wsf.UserWs);

            // Get the set of writing systems.
            Set <NamedWritingSystem> writingSystems =
                LangProject.GetAllNamedWritingSystemsFromLDFs(wsf, userLocale);

            NamedWritingSystem wsSaveVern = (NamedWritingSystem)m_cbVernWrtSys.SelectedItem;
            NamedWritingSystem wsSaveAnal = (NamedWritingSystem)m_cbAnalWrtSys.SelectedItem;

            m_cbAnalWrtSys.Items.Clear();
            m_cbVernWrtSys.Items.Clear();
            m_cbAnalWrtSys.BeginUpdate();
            m_cbVernWrtSys.BeginUpdate();

            foreach (NamedWritingSystem nws in writingSystems)
            {
                m_cbAnalWrtSys.Items.Add(nws);
                m_cbVernWrtSys.Items.Add(nws);
            }

            int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.Name));

            m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            m_cbVernWrtSys.EndUpdate();

            i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.Name));
            m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            m_cbAnalWrtSys.EndUpdate();
        }
예제 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateLanguageCombos()
        {
            var wsSaveVern = (IWritingSystem)m_cbVernWrtSys.SelectedItem;
            var wsSaveAnal = (IWritingSystem)m_cbAnalWrtSys.SelectedItem;

            m_cbAnalWrtSys.BeginUpdate();
            m_cbVernWrtSys.BeginUpdate();
            m_cbAnalWrtSys.Items.Clear();
            m_cbVernWrtSys.Items.Clear();

            foreach (IWritingSystem ws in m_wsManager.LocalWritingSystems)
            {
                m_cbAnalWrtSys.Items.Add(ws);
                m_cbVernWrtSys.Items.Add(ws);
            }

            if (m_cbVernWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveVern == null ? -1 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
                if (i != -1)
#endif
                m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbVernWrtSys.EndUpdate();

            if (m_cbAnalWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveAnal == null ? -1 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
                if (i != -1)
#endif
                m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbAnalWrtSys.EndUpdate();
        }
예제 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptureProperties"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="styleSheet">The style sheet.</param>
        /// <param name="rootSite">The active view (or the draft view if the footnote view is
        /// active).</param>
        /// <param name="showFootnoteTab">True to show the footnote tab. Otherwise the
        /// footnote tab will be hidden.</param>
        /// <param name="helpTopicProvider">The help topic provider.</param>
        /// ------------------------------------------------------------------------------------
        public ScriptureProperties(FdoCache cache, IVwStylesheet styleSheet, IRootSite rootSite,
                                   bool showFootnoteTab, IHelpTopicProvider helpTopicProvider)
        {
            m_cache             = cache;
            m_helpTopicProvider = helpTopicProvider;
            m_styleSheet        = styleSheet;
            m_scr      = cache.LangProject.TranslatedScriptureOA;
            m_rootSite = rootSite;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            if (!showFootnoteTab)
            {
                tabControl1.TabPages.Remove(tpgFootnotes);
            }

            fpsCrossRefOptions.SiblingPropertiesSelector = fpsFootnoteOptions;
            fpsFootnoteOptions.SiblingPropertiesSelector = fpsCrossRefOptions;
            m_fCombineFootnotes = m_scr.CrossRefsCombinedWithFootnotes;
            opnCombined.Checked = m_fCombineFootnotes;
            opnSeparate.Checked = !m_fCombineFootnotes;
            UpdateCombinedFootnotes();

            FillScriptLanguages();
            FillVersificationSchemes();
            UpdateFootnoteTabs();

            if (m_scr.UseScriptDigits)
            {
                m_btnScriptNumbers.Checked = true;
                string language = m_baseDigitMap[(char)m_scr.ScriptDigitZero];
                m_cboScriptLanguages.SelectedIndex =
                    m_cboScriptLanguages.FindString(language);
            }
            else
            {
                m_btnLatinNumbers.Checked = true;
            }

            // Fill in the reference separator fields to edit
            m_txtRefSep.Text          = m_scr.RefSepr;
            m_txtChapterVerseSep.Text = m_scr.ChapterVerseSepr;
            m_txtVerseSep.Text        = m_scr.VerseSepr;
            m_txtVerseBridge.Text     = m_scr.Bridge;

            // Make the option button for footnotes and cross references invisible.
            fpsFootnoteOptions.ShowSequenceButton = false;
            fpsCrossRefOptions.ShowSequenceButton = false;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialize this dialog
        /// </summary>
        /// <param name="fParatextMapping"><c>true</c> if a Paratext mapping is being modified;
        /// <c>false</c> otherwise</param>
        /// <param name="mapping">Mapping object being modified</param>
        /// <param name="styleSheet">Stylesheet containing styles that will appear in the list
        /// </param>
        /// <param name="cache">The cache representing the DB connection</param>
        /// <param name="fBackTransDomainLocked">If <c>true</c>, won't allow the user to
        /// check or clear the BT checkbox. If the incoming mapping is for the back translation
        /// and has a domain of either Scripture or Footnote, these two domains remain
        /// enabled so the user can switch between them, but the Notes domain will be
        /// disabled. If the incoming mapping is not for the back translation, then
        /// this only affects the BT checkbox, not the domain options.
        /// </param>
        /// <param name="isAnnotationMapping">If <c>true</c>, forces this mapping to be in the
        /// Annotation domain.</param>
        /// <remarks>We separated this from the constructor so that we can create a mock object
        /// for testing purposes.</remarks>
        /// ------------------------------------------------------------------------------------
        public virtual void Initialize(bool fParatextMapping, ImportMappingInfo mapping,
                                       FwStyleSheet styleSheet, FdoCache cache, bool isAnnotationMapping,
                                       bool fBackTransDomainLocked)
        {
            CheckDisposed();

            m_fParatextMapping = fParatextMapping;
            m_cache            = cache;
            m_scr                        = cache.LangProject.TranslatedScriptureOA;
            m_mapping                    = mapping;
            m_StyleSheet                 = styleSheet;
            m_isAnnotationMapping        = isAnnotationMapping;
            m_fBackTransDomainLocked     = fBackTransDomainLocked;
            m_styleListHelper.StyleSheet = styleSheet as FwStyleSheet;

            //			// if there are items in the styles list and there is not one selected then
            //			// set the first item to be the selected item.
            //			if (lbStyles.SelectedIndex == -1 && lbStyles.Items.Count > 0)
            //				lbStyles.SelectedIndex = 0;

            // Fill in the list selector combo box with the filters for the style list
            // Also set the maximum style level for the style list helper before the
            // style list gets filled in.
            cboList.Items.Clear();
            cboList.Items.Add(TeResourceHelper.GetResourceString("kstidStyleFilterBasic"));
            cboList.Items.Add(TeResourceHelper.GetResourceString("kstidStyleFilterAllStyles"));
            cboList.Items.Add(TeResourceHelper.GetResourceString("kstidStyleFilterCustomList"));

            cboList.SelectedIndex = 1;
            // This code was not completely removed for the highly likely case that
            // it gets put back :)
//			switch (Options.ShowTheseStylesSetting)
//			{
//				case Options.ShowTheseStyles.Basic:
//					cboList.SelectedIndex = 0;
//					m_styleListHelper.MaxStyleLevel = 0;
//					break;
//				case Options.ShowTheseStyles.All:
//					cboList.SelectedIndex = 1;
//					m_styleListHelper.MaxStyleLevel = int.MaxValue;
//					break;
//				case Options.ShowTheseStyles.Custom:
//					cboList.SelectedIndex = 2;
//					m_styleListHelper.MaxStyleLevel = ToolsOptionsDialog.MaxStyleLevel;
//					break;
//			}

            chkBackTranslation.Checked = (mapping.Domain & MarkerDomain.BackTrans) != 0;

            // Check the appropriate button for the domain.  This will cause the
            // style list to be loaded correctly for the domain.
            switch (mapping.Domain & ~MarkerDomain.BackTrans)
            {
            case MarkerDomain.Footnote:
                rbtnFootnotes.Checked = true;
                break;

            case MarkerDomain.Note:
                rbtnNotes.Checked = true;
                break;

            default:
                rbtnScripture.Checked = true;
                break;
            }

            // select the style name and add the handler for style changes.  This needs
            // to be done after setting the domain since that causes the style list to
            // be loaded the first time.
            m_styleListHelper.SelectedStyleName = MappingToUiStylename(mapping);
            m_styleListHelper.StyleChosen      += new StyleChosenHandler(StyleChosen);

            // if the selected mapping is excluded, then check the box
            if (chkExclude.Checked != mapping.IsExcluded)
            {
                chkExclude.Checked = mapping.IsExcluded;
            }
            else
            {
                SetControlStatesBasedOnExcludeCheckBox(null, null);
            }

            cboWritingSys.Items.Clear();
            // Create a fake WS for the "Based on Context" item
            cboWritingSys.Items.Add(TeResourceHelper.GetResourceString("kstidBasedOnContext"));
            string initialWritingSystem = string.Empty;

            // Iterate through the available writing systems and add them to the writing systems
            // combo box.
            foreach (IWritingSystem wsObj in cache.ServiceLocator.WritingSystems.AllWritingSystems)
            {
                cboWritingSys.Items.Add(wsObj);

                // If the mapping's ICULocale matches the current writing system's ICULocale,
                // save the string just added to the combo box so we can initialize the
                // combo box's value with it.
                if (mapping.WsId == wsObj.Id)
                {
                    initialWritingSystem = wsObj.ToString();
                }
            }

            // Initialize the combo's value.
            cboWritingSys.SelectedIndex = (initialWritingSystem == string.Empty ?
                                           0 : cboWritingSys.FindString(initialWritingSystem));
        }