Exemplo n.º 1
0
        /// <summary>
        /// Setup the embedded template fields related to a specific project.
        /// </summary>
        /// <param name="li">language information about the 'projectNum' project</param>
        /// <param name="projectNum"></param>
        /// <param name="projectCount"></param>
        /// <returns></returns>
        private Dictionary <string, string> setupProjectVars(ProjectSettings.LanguageInfo li, int projectNum, int projectCount)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict["ScrTextName"] = li.LangName;
            dict["ProjectN"]    = "project" + projectNum.ToString();
            dict["FontFace"]    = li.FontToUse.Name;
            dict["FontSize"]    = li.FontToUse.Size.ToString();

            if (li.DoRtl)
            {
                dict["Direction"] = "rtl";
                dict["Alignment"] = "right";
            }
            else
            {
                dict["Direction"] = "ltr";
                dict["Alignment"] = "left";
            }

            int colWidthPercent = 100 / projectCount;

            dict["ColWidthPercent"] = colWidthPercent.ToString();
            dict["ColCount"]        = projectCount.ToString();

            return(dict);
        }
        protected void InitTextBox(VerseControl ctrlVerse, string strTbName,
                                   StringTransfer strTbText, ProjectSettings.LanguageInfo li, int nLayoutColumn)
        {
            CtrlTextBox tb = new CtrlTextBox(strTbName + CstrSuffixTextBox, ctrlVerse, this,
                                             strTbText, li, CstrTestQuestionsLabelFormat);

            tableLayoutPanel.Controls.Add(tb, nLayoutColumn, 1);
        }
Exemplo n.º 3
0
        protected void InitTextBox(VerseControl ctrlVerse, string strTbName, StringTransfer strTbText,
                                   ProjectSettings.LanguageInfo li, bool bDisableTabStop, int nLayoutColumn)
        {
            System.Diagnostics.Debug.Assert(!tableLayoutPanel.Controls.ContainsKey(strTbName + CstrSuffixTextBox), "otherwise, fix wrong assumption");
            CtrlTextBox tb = new CtrlTextBox(strTbName + CstrSuffixTextBox, ctrlVerse, this,
                                             strTbText, li, li.LangCode);

            tb.TabStop = !bDisableTabStop;
            tableLayoutPanel.Controls.Add(tb, nLayoutColumn, 1);
        }
Exemplo n.º 4
0
        private void InitLanguageControls(Control tabPage, ProjectSettings.LanguageInfo languageInfo)
        {
            System.Diagnostics.Debug.Assert(tabPage.Controls[0] is TableLayoutPanel);
            TableLayoutPanel tlp = tabPage.Controls[0] as TableLayoutPanel;

            System.Diagnostics.Debug.Assert(tlp.GetControlFromPosition(1, 2) is ComboBox);
            ComboBox comboBoxKeyboard = tlp.GetControlFromPosition(1, 2) as ComboBox;

            // initialize the keyboard combo list
            foreach (KeyboardController.KeyboardDescriptor keyboard in
                     KeyboardController.GetAvailableKeyboards(KeyboardController.Engines.All))
            {
                comboBoxKeyboard.Items.Add(keyboard.Name);
            }

            System.Diagnostics.Debug.Assert(tlp.GetControlFromPosition(1, 4) is TextBox);
            TextBox tbSentFullStop = tlp.GetControlFromPosition(1, 4) as TextBox;

            tbSentFullStop.Font      = languageInfo.FontToUse;
            tbSentFullStop.ForeColor = languageInfo.FontColor;
            tbSentFullStop.Text      = languageInfo.FullStop;

            System.Diagnostics.Debug.Assert(tlp.GetControlFromPosition(1, 3) is Button);
            Button btnFont = tlp.GetControlFromPosition(1, 3) as Button;

            toolTip.SetToolTip(btnFont, String.Format(CstrDefaultFontTooltip,
                                                      Environment.NewLine,
                                                      languageInfo.DefaultFontName,
                                                      languageInfo.DefaultFontSize,
                                                      languageInfo.FontColor));

            if (languageInfo.HasData)
            {
                System.Diagnostics.Debug.Assert(tlp.GetControlFromPosition(1, 0) is TextBox);
                TextBox textBoxLanguageName = tlp.GetControlFromPosition(1, 0) as TextBox;
                textBoxLanguageName.Text = languageInfo.LangName;

                System.Diagnostics.Debug.Assert(tlp.GetControlFromPosition(1, 1) is TextBox);
                TextBox textBoxEthCode = tlp.GetControlFromPosition(1, 1) as TextBox;
                textBoxEthCode.Text = languageInfo.LangCode;

                comboBoxKeyboard.SelectedItem = languageInfo.DefaultKeyboard;

                System.Diagnostics.Debug.Assert(tlp.GetControlFromPosition(2, 3) is CheckBox);
                CheckBox checkBoxIsRTL = tlp.GetControlFromPosition(2, 3) as CheckBox;
                checkBoxIsRTL.Checked = languageInfo.DefaultRtl;
            }
        }
Exemplo n.º 5
0
        public GlossingControl(GlossingForm parent,
                               ProjectSettings.LanguageInfo liSource, string strSourceWord,
                               ProjectSettings.LanguageInfo liTarget, string strTargetWord,
                               string strInBetween)
        {
            _parent = parent;
            InitializeComponent();

            _strTargetKeyboard = liTarget.Keyboard;

            if (liSource.IsRTL)
            {
                this.tableLayoutPanel.RightToLeft = RightToLeft.Yes;
            }

            string strFollowingSource = strInBetween.Trim();

            if (!String.IsNullOrEmpty(strFollowingSource))
            {
                buttonJoin.Visible = false;
            }

            textBoxSourceWord.Font      = liSource.LangFont;
            textBoxSourceWord.ForeColor = liSource.FontColor;
            if (liSource.IsRTL)
            {
                textBoxSourceWord.RightToLeft = RightToLeft.Yes;
            }
            textBoxSourceWord.Text = strSourceWord + strFollowingSource;

            textBoxTargetWord.Font      = liTarget.LangFont;
            textBoxTargetWord.ForeColor = liTarget.FontColor;
            if (liTarget.IsRTL)
            {
                textBoxTargetWord.RightToLeft = RightToLeft.Yes;
            }

            MatchCollection mc = FindMultipleAmbiguities.Matches(strTargetWord);

            if (mc.Count > 0)
            {
                string strAmbiguityList = mc[0].Groups[1].ToString();
                strTargetWord = strAmbiguityList.Replace("%", strAmbiguitySeparator);
            }

            textBoxTargetWord.Text = strTargetWord + strFollowingSource.Replace(liSource.FullStop, liTarget.FullStop);
        }
        readonly BiblicalTermsList _biblicalTerms;           // All Biblical terms

        public BiblicalKeyTermsForm(StoryEditor theSE, ProjectSettings projSettings, ProjectSettings.LanguageInfo liMainLang)
        {
            _theSE        = theSE;
            MainLang      = liMainLang;
            _projSettings = projSettings;
            InitializeComponent();
            _biblicalTerms = BiblicalTermsList.GetBiblicalTerms();
            htmlBuilder    = new BiblicalTermsHTMLBuilder(projSettings);

            // TODO: temporary hack. If we are using the Hindi 'MyKeyTerms' db, then
            // change the 'English Gloss' column header to Hindi and change the font
            if (_biblicalTerms.IsMyBiblicalTerms)
            {
                ColumnGlossEnglish.HeaderText            = "Gloss";
                ColumnGlossEnglish.DefaultCellStyle.Font = new Font("Arial Unicode MS", 12);
            }
        }
Exemplo n.º 7
0
        protected static void WriteAdaptItProjectFiles(ProjectSettings.LanguageInfo liSource,
                                                       ProjectSettings.LanguageInfo liTarget, ProjectSettings.LanguageInfo liNavigation)
        {
            // create folders...
            if (!Directory.Exists(AdaptItProjectAdaptationsFolder(liSource.LangName, liTarget.LangName)))
            {
                Directory.CreateDirectory(AdaptItProjectAdaptationsFolder(liSource.LangName, liTarget.LangName));
            }

            // create Project file
            if (!File.Exists(AdaptItProjectFileSpec(liSource.LangName, liTarget.LangName)))
            {
                string strFormat = Properties.Settings.Default.DefaultAIProjectFile;
                string strProjectFileContents = String.Format(strFormat,
                                                              liSource.LangFont.Name,
                                                              liTarget.LangFont.Name,
                                                              liNavigation.LangFont.Name,
                                                              liSource.LangName,
                                                              liTarget.LangName,
                                                              Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                                              AIPunctuation(liSource.FullStop),
                                                              AIPunctuation(liTarget.FullStop),
                                                              (liSource.IsRTL) ? "1" : "0",
                                                              (liTarget.IsRTL) ? "1" : "0");
                File.WriteAllText(AdaptItProjectFileSpec(liSource.LangName, liTarget.LangName), strProjectFileContents);
            }

            // create main KB
            if (!File.Exists(AdaptItLookupFileSpec(liSource.LangName, liTarget.LangName)))
            {
                string strFormat     = Properties.Settings.Default.DefaultAIKBFile;
                string strKBContents = String.Format(strFormat, liSource.LangName, liTarget.LangName);
                File.WriteAllText(AdaptItLookupFileSpec(liSource.LangName, liTarget.LangName), strKBContents);
            }

            if (!File.Exists(AdaptItGlossingLookupFileSpec(liSource.LangName, liTarget.LangName)))
            {
                string strFormat     = Properties.Settings.Default.DefaultAIKBFile;
                string strKBContents = String.Format(strFormat, liSource.LangName, liTarget.LangName);
                File.WriteAllText(AdaptItGlossingLookupFileSpec(liSource.LangName, liTarget.LangName), strKBContents);
            }
        }
Exemplo n.º 8
0
        /* was used by the ConNotes, which are now done differently
         * public CtrlTextBox(string strName, VerseControl ctrlVerseParent, ResizableControl ctrlParent, StringTransfer stData,
         *      ThrowIfNotCorrectEditor delegateRequiredEditorCheck, TeamMemberData.UserTypes eRequiredEditor)
         * {
         *      InitComponent();
         *      Font = new Font("Arial Unicode MS", 12);
         *      Name = strName;
         *      stData.SetAssociation(this);
         *      TextChanged += new EventHandler(ctrlParent.textBox_TextChanged);
         *      System.Diagnostics.Debug.Assert(ctrlParent.StageLogic != null);
         *      _stageLogic = ctrlParent.StageLogic;
         *      _ctrlVerseParent = ctrlVerseParent;
         *      _delegateRequiredEditorCheck = delegateRequiredEditorCheck; // call to check if the proper member is logged in!
         *      _eRequiredEditor = eRequiredEditor;
         * }
         */

        public CtrlTextBox(string strName, VerseControl ctrlVerseParent,
                           ResizableControl ctrlParent, StringTransfer stData,
                           ProjectSettings.LanguageInfo li, string strLabel)
        {
            InitComponent();
            Name      = strName;
            _strLabel = strLabel;
            Font      = li.FontToUse;
            ForeColor = li.FontColor;
            if (li.DoRtl)
            {
                RightToLeft = RightToLeft.Yes;
            }
            stData.SetAssociation(this);
            TextChanged += ctrlParent.textBox_TextChanged;
            System.Diagnostics.Debug.Assert(ctrlParent.StageLogic != null);
            _stageLogic      = ctrlParent.StageLogic;
            _ctrlVerseParent = ctrlVerseParent;
            _strKeyboardName = li.Keyboard;
        }
Exemplo n.º 9
0
        private void editKeyTermsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // the only function of the button here is to add a slot to type a con note
            StoryEditor theSE;

            if (!CheckForProperEditToken(out theSE))
            {
                return;
            }

            try
            {
                // if the language code changed (such that we'll need to build a new key terms db)
                ProjectSettings.LanguageInfo liMainLang = WhichLangInfoToUseForKeyTerms;
                if ((m_dlgKeyTerms != null) &&
                    ((m_dlgKeyTerms.MainLang.LangCode != liMainLang.LangCode) ||
                     (m_dlgKeyTerms._projSettings.ProjectFolder != theSE.StoryProject.ProjSettings.ProjectFolder)))
                {
                    m_dlgKeyTerms = null;
                }

                if (m_dlgKeyTerms == null)
                {
                    System.Diagnostics.Debug.Assert(theSE.StoryProject.ProjSettings.Vernacular.HasData ||
                                                    theSE.StoryProject.ProjSettings.NationalBT.HasData ||
                                                    theSE.StoryProject.ProjSettings.InternationalBT.HasData);

                    m_dlgKeyTerms = new BiblicalKeyTermsForm(theSE, theSE.StoryProject.ProjSettings, liMainLang);
                }
                m_dlgKeyTerms.Show(_myAnchorsData, theSE.StoryProject);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Properties.Resources.IDS_KeyTermsProblem,
                                              Environment.NewLine, ex.Message), Properties.Resources.IDS_Caption);
                return;
            }
        }
Exemplo n.º 10
0
        protected void DoFontDialog(ProjectSettings.LanguageInfo li, TextBox tb,
                                    out string strOverrideFont, out float fOverrideFontSize)
        {
            strOverrideFont   = null;
            fOverrideFontSize = 0;
            try
            {
                fontDialog.Font  = li.FontToUse;
                fontDialog.Color = li.FontColor;
                if (fontDialog.ShowDialog() == DialogResult.OK)
                {
                    li.FontToUse = fontDialog.Font;
                    if (LoggedInMember != null)
                    {
                        if (!String.IsNullOrEmpty(li.DefaultFontName) &&
                            (fontDialog.Font.Name != li.DefaultFontName))
                        {
                            DialogResult res = MessageBox.Show(String.Format(Properties.Resources.IDS_ConfirmOverride,
                                                                             li.DefaultFontName, "font", LoggedInMember.Name), Properties.Resources.IDS_Caption,
                                                               MessageBoxButtons.YesNoCancel);

                            if (res == DialogResult.Yes)
                            {
                                strOverrideFont   = fontDialog.Font.Name;
                                fOverrideFontSize = fontDialog.Font.Size;
                            }
                            else if (res == DialogResult.No)
                            {
                                li.DefaultKeyboard = fontDialog.Font.Name;
                                // strOverrideFont = null;   // if there was an override, it should go away
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            li.DefaultFontName = fontDialog.Font.Name;
                            // strOverrideFont = null;   // if there was an override, it should go away
                        }
                    }
                    else
                    {
                        li.DefaultFontName = fontDialog.Font.Name;
                    }

                    li.FontColor = fontDialog.Color;
                    tb.Font      = fontDialog.Font;
                    tb.ForeColor = fontDialog.Color;
                    Modified     = true;
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "Only TrueType fonts are supported. This is not a TrueType font.")
                {
                    MessageBox.Show("Since you just added this font, you have to restart the program for it to work", Properties.Resources.IDS_Caption);
                }
            }
        }
Exemplo n.º 11
0
        protected void ProcessLanguageTab(ComboBox cb, ProjectSettings.LanguageInfo li,
                                          CheckBox cbRtl, TextBox textBoxLanguageName, TextBox textBoxEthCode,
                                          TextBox textBoxSentFullStop, ref string strKeyboardOverride, ref bool bRtfOverride)
        {
            // if there is a default keyboard (from before) and the user has chosen another
            //  one, then see if they mean to change it for everyone or just themselves
            //  (then we can make sure that they are who we think we are)
            string strKeyboard = (string)cb.SelectedItem;

            if (LoggedInMember != null)
            {
                if (!String.IsNullOrEmpty(li.DefaultKeyboard) &&
                    (strKeyboard != li.DefaultKeyboard))
                {
                    DialogResult res = MessageBox.Show(String.Format(Properties.Resources.IDS_ConfirmOverride,
                                                                     li.LangName, "keyboard", LoggedInMember.Name), Properties.Resources.IDS_Caption,
                                                       MessageBoxButtons.YesNoCancel);

                    if (res == DialogResult.Yes)
                    {
                        strKeyboardOverride = strKeyboard;
                    }
                    else if (res == DialogResult.No)
                    {
                        li.DefaultKeyboard  = strKeyboard;
                        strKeyboardOverride = null;                           // if there was an override, it should go away
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    li.DefaultKeyboard  = strKeyboard;
                    strKeyboardOverride = null;                       // if there was an override, it should go away
                }

                if (li.DefaultRtl != cbRtl.Checked)
                {
                    DialogResult res = MessageBox.Show(String.Format(Properties.Resources.IDS_ConfirmOverride,
                                                                     "Right-to-left", "value", LoggedInMember.Name), Properties.Resources.IDS_Caption,
                                                       MessageBoxButtons.YesNoCancel);

                    if (res == DialogResult.Yes)
                    {
                        bRtfOverride = true;
                    }
                    else if (res == DialogResult.No)
                    {
                        li.DefaultRtl = cbRtl.Checked;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    li.DefaultRtl = cbRtl.Checked;
                }
            }
            else
            {
                li.DefaultRtl = cbRtl.Checked;
            }

            li.LangName = ThrowIfTextNullOrEmpty(textBoxLanguageName, "Language Name");
            li.LangCode = ThrowIfTextNullOrEmpty(textBoxEthCode, "Ethnologue Code");
            li.FullStop = ThrowIfTextNullOrEmpty(textBoxSentFullStop, "Sentence Final Punctuation");

            tabControl.SelectedIndex++;
        }