Ejemplo n.º 1
0
        /// <summary>
        /// Opens a dialog to edit a Locale's languageid.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_EditLocale(object sender, EventArgs e)
        {
            var parent = (GffData.Field)SelectedNode.Parent.Tag;

            if (parent.localeflags != LocaleDialog.Loc_ALL)
            {
                var field = (GffData.Field)SelectedNode.Tag;

                GffData.Locale locale;

                locale  = parent.Locales[(int)field.localeid];
                _langid = locale.langid;
                _langf  = locale.F;

                using (var f = new LocaleDialog(parent.localeflags, true))
                {
                    if (f.ShowDialog(this) == DialogResult.OK &&
                        (locale.langid != _langid || locale.F != _langf))
                    {
                        LocaleDialog.ClearLocaleFlag(ref parent.localeflags,
                                                     locale.langid,
                                                     locale.F);

                        field.label = GffData.Locale.GetLanguageString(locale.langid = _langid,
                                                                       locale.F = _langf);
                        ((Sortable)SelectedNode)._label = field.label;

                        LocaleDialog.SetLocaleFlag(ref parent.localeflags,
                                                   _langid,
                                                   _langf);

                        SelectedNode.Text = GeneralGFF.ConstructNodetext(field, locale);

                        _f.GffData.Changed = true;
                        _f.GffData         = _f.GffData;
                    }
                }
            }
            else
            {
                using (var f = new InfoDialog(Globals.Error, "All locales are taken."))
                    f.ShowDialog(this);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a Locale to a CExoLocString Field.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddLocale(object sender, EventArgs e)
        {
            var field = (GffData.Field)SelectedNode.Tag;

            if (field.localeflags != LocaleDialog.Loc_ALL)
            {
                using (var f = new LocaleDialog(field.localeflags))
                {
                    if (f.ShowDialog(this) == DialogResult.OK)
                    {
                        var locale = new GffData.Locale();
                        locale.local = String.Empty;

                        LocaleDialog.SetLocaleFlag(ref field.localeflags,
                                                   locale.langid = _langid,
                                                   locale.F      = _langf);

                        if (field.Locales == null)
                        {
                            field.Locales = new List <GffData.Locale>();
                        }

                        var fieldloc = new GffData.Field();
                        fieldloc.type     = FieldTypes.locale;
                        fieldloc.label    = GffData.Locale.GetLanguageString(_langid, _langf);
                        fieldloc.localeid = (uint)field.Locales.Count;

                        field.Locales.Add(locale);
                        AddField(fieldloc, locale);
                    }
                }
            }
            else
            {
                using (var f = new InfoDialog(Globals.Error, "All locales are taken."))
                    f.ShowDialog(this);
            }
        }