Inheritance: OkCancelDialog
示例#1
0
        private void buttonChangeText_Click(object sender, EventArgs e)
        {
            EnterSymbolText dialog = new EnterSymbolText(symbolDB);

            char kind = symbolDB[selectedId].Kind;

            SymbolLanguage language = CurrentLanguage();
            dialog.SetLanguage(language);

            List<SymbolText> symTexts;
            if (TextIsCustomized(selectedId))  // UNDONE: this isn't right!
                symTexts = customSymbolText[selectedId];
            else
                symTexts = symbolDB[selectedId].SymbolTexts;

            // Only consider the current language.
            symTexts = symTexts.FindAll(symtext => (symtext.Lang == language.LangId));

            bool hasPlural = false, hasGender = false, hasCase = false;
            foreach (SymbolText symtext in symTexts) {
                if (symtext.Plural)
                    hasPlural = true;
                if (!string.IsNullOrEmpty(symtext.Gender))
                    hasGender = true;
                if (!string.IsNullOrEmpty(symtext.Case))
                    hasCase = true;
            }

            bool isModifier = (kind == 'E' || kind=='C' || kind == 'G' || kind == 'F') && selectedId != "11.15" && !selectedId.StartsWith("10.", StringComparison.InvariantCulture);   // column C, E, F, G, but not between/crossing/junction
            bool isNoun = (kind == 'D' || selectedId == "11.15" || selectedId.StartsWith("10.", StringComparison.InvariantCulture));  // column D or between/junction/crossing

            // Note that between/junction/crossing can both modify case of somthing inside, and have it's own case.
            bool canHaveCase = isNoun;
            bool canModifyCase = (kind=='F' || kind == 'E' || kind=='C' || kind == 'G');

            dialog.SetAllowableForms((isNoun && language.PluralNouns) || (kind=='E' && language.PluralModifiers), hasPlural,
                                                       isModifier && language.GenderModifiers, hasGender,
                                                       canHaveCase && language.CaseModifiers, hasCase,
                                                       isNoun && language.GenderModifiers,
                                                       canModifyCase && language.CaseModifiers,
                                                       !useAsLocalizeTool && isModifier);

            dialog.SymbolTexts = symTexts;

            if (dialog.ShowDialog(this) == DialogResult.OK) {
                symTexts = dialog.SymbolTexts;

                // retain custom texts from other languages, if any
                if (customSymbolText.ContainsKey(selectedId))
                    symTexts.AddRange(customSymbolText[selectedId].FindAll(symtext => (symtext.Lang != language.LangId)));

                customSymbolText[selectedId] = symTexts;
                customSymbolKey[selectedId] = checkBoxShowKey.Checked;
                UpdateControlsFromId(selectedId);
            }

            dialog.Dispose();
        }
示例#2
0
        private void buttonChangeText_Click(object sender, EventArgs e)
        {
            if (selectedId != null)
            {
                UpdateDataFromControls(selectedId);
            }

            EnterSymbolText dialog = new EnterSymbolText(symbolDB);

            char kind = symbolDB[selectedId].Kind;

            SymbolLanguage language = CurrentLanguage();

            dialog.SetLanguage(language);

            List <SymbolText> symTexts;

            if (TextIsCustomized(selectedId))  // UNDONE: this isn't right!
            {
                symTexts = customSymbolText[selectedId];
            }
            else
            {
                symTexts = symbolDB[selectedId].SymbolTexts;
            }

            // Only consider the current language.
            symTexts = symTexts.FindAll(symtext => (symtext.Lang == language.LangId));

            bool hasPlural = false, hasGender = false, hasCase = false;

            foreach (SymbolText symtext in symTexts)
            {
                if (symtext.Plural)
                {
                    hasPlural = true;
                }
                if (!string.IsNullOrEmpty(symtext.Gender))
                {
                    hasGender = true;
                }
                if (!string.IsNullOrEmpty(symtext.Case))
                {
                    hasCase = true;
                }
            }

            bool isModifier = (kind == 'E' || kind == 'C' || kind == 'G' || kind == 'F') && selectedId != "11.15" && !selectedId.StartsWith("10.", StringComparison.InvariantCulture); // column C, E, F, G, but not between/crossing/junction
            bool isNoun     = (kind == 'D' || selectedId == "11.15" || selectedId.StartsWith("10.", StringComparison.InvariantCulture));                                               // column D or between/junction/crossing

            // Note that between/junction/crossing can both modify case of somthing inside, and have it's own case.
            bool canHaveCase   = isNoun;
            bool canModifyCase = (kind == 'F' || kind == 'E' || kind == 'C' || kind == 'G');


            dialog.SetAllowableForms((isNoun && language.PluralNouns) || (kind == 'E' && language.PluralModifiers), hasPlural,
                                     isModifier && language.GenderModifiers, hasGender,
                                     canHaveCase && language.CaseModifiers, hasCase,
                                     isNoun && language.GenderModifiers,
                                     canModifyCase && language.CaseModifiers,
                                     !useAsLocalizeTool && isModifier);

            dialog.SymbolTexts = symTexts;

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                symTexts = dialog.SymbolTexts;

                // retain custom texts from other languages, if any
                if (customSymbolText.ContainsKey(selectedId))
                {
                    symTexts.AddRange(customSymbolText[selectedId].FindAll(symtext => (symtext.Lang != language.LangId)));
                }

                customSymbolText[selectedId] = symTexts;
                customSymbolKey[selectedId]  = checkBoxShowKey.Checked;
                UpdateControlsFromId(selectedId);
            }

            dialog.Dispose();
        }