예제 #1
0
        private void toolStripButtonTranslationInsert_Click(object sender, EventArgs e)
        {
            using (FormSelectLocale form = new FormSelectLocale())
            {
                DialogResult res = form.ShowDialog(this);
                if (res == DialogResult.OK && form.SelectedLocale != null)
                {
                    DocLocalization docLocal = new DocLocalization();
                    docLocal.Locale = form.SelectedLocale.Name;
                    this.m_target.Localization.Add(docLocal);

                    ListViewItem lvi = new ListViewItem();
                    lvi.Tag = docLocal;
                    lvi.Text = docLocal.Locale;
                    lvi.SubItems.Add("");
                    lvi.SubItems.Add("");
                    this.listViewLocale.Items.Add(lvi);

                    this.listViewLocale.SelectedItems.Clear();
                    lvi.Selected = true;
                }
            }
        }
예제 #2
0
        private void toolStripMenuItemFileExport_Click(object sender, EventArgs e)
        {
            DialogResult res = this.saveFileDialogExport.ShowDialog(this);
            if (res == DialogResult.OK)
            {
                DocModelView[] views = null;
                string[] locales = null;
                DocDefinitionScopeEnum scope = DocDefinitionScopeEnum.None;

                string ext = System.IO.Path.GetExtension(this.saveFileDialogExport.FileName).ToLower();
                switch (ext)
                {
                    case ".txt":
                        // prompt for locale
                        using (FormSelectLocale form = new FormSelectLocale())
                        {
                            if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                            {
                                locales = new string[] { form.SelectedLocale.TwoLetterISOLanguageName };
                            }
                            else
                            {
                                return;
                            }
                        }
                        // prompt for definitions
                        using (FormFilterDefinitions formFilter = new FormFilterDefinitions())
                        {
                            if (formFilter.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                            {
                                scope = formFilter.DefinitionScope;
                            }
                            else
                            {
                                return;
                            }
                        }
                        break;

                    default:
                        // prompt for model view
                        using (FormSelectView form = new FormSelectView(this.m_project, "Select an optional model view for filtering the export, or no model view to export all definitions."))
                        {
                            if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                            {
                                if (form.Selection != null)
                                {
                                    views = form.Selection;
                                }
                            }
                        }
                        break;
                }

                // swap out instances temporarily
                Dictionary<long, SEntity> old = this.m_instances;
                long lid = this.m_lastid;

                this.m_instances = new Dictionary<long, SEntity>();
                this.m_lastid = 0;

                try
                {
                    DocumentationISO.DoExport(this.m_project, this.saveFileDialogExport.FileName, views, locales, scope, this.m_instances);
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.Message, "Error");
                }
                finally
                {
                    this.m_instances = old;
                    this.m_lastid = lid;
                }

            }
        }