Exemplo n.º 1
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="parent">the used language for the components</param>
 internal ToolLanguageApplication(ToolLanguage parent)
 {
     Parent     = parent;
     Components = new LocalizableCompoments();
     Components.Add(new LocalizableCompoment(Parent, "Error Dialog", typeof(NetOffice.DeveloperToolbox.Controls.Error.ErrorControl)));
     Components.Add(new LocalizableCompoment(Parent, "Language Selector", typeof(TranslationControl)));
 }
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="parent">the used language for the components</param>
 internal ToolLanguageApplication(ToolLanguage parent)
 {
     Parent = parent;
     Components = new LocalizableCompoments();
     Components.Add(new LocalizableCompoment(Parent, "Error Dialog", typeof(NetOffice.DeveloperToolbox.Controls.Error.ErrorControl)));
     Components.Add(new LocalizableCompoment(Parent, "Language Selector", typeof(TranslationControl)));
 }
        /// <summary>
        /// Creates an instance of the class as new language
        /// </summary>
        /// <param name="parent">parent collection</param>
        /// <param name="template">role model</param>
        internal ToolLanguage(ToolLanguages parent, ToolLanguage template)
        {
            _parent     = parent;
            _name       = "New Language";
            _nameGlobal = "New Language";
            _lcid       = 0;
            Initialize();

            foreach (var item in template.Application.Components[0].ControlResources)
            {
                Application.Components[0].ControlResources[item.Value].Value2 = item.Value2;
            }

            foreach (var item in template.Application.Components[1].ControlResources)
            {
                Application.Components[1].ControlResources[item.Value].Value2 = item.Value2;
            }

            for (int i = 0; i < template.Components.Count; i++)
            {
                LocalizableCompoment templateComponent = template.Components[i];
                LocalizableCompoment ownComponent      = Components[i];
                foreach (var item in templateComponent.ControlResources)
                {
                    ownComponent.ControlResources[item.Value].Value2 = item.Value2;
                }
            }

            IsNew = true;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates an instance of ToolLanguageForm and show
        /// </summary>
        /// <param name="owner">modal owner</param>
        /// <param name="language">edit language</param>
        /// <returns>contains unsaved changes</returns>
        internal static bool ShowForm(IWin32Window owner, ToolLanguage language)
        {
            ToolLanguageForm dlg = new ToolLanguageForm(language);

            dlg.ShowDialog(owner);
            dlg.Dispose(true);
            return(dlg.Changed);
        }
 private DataGridViewRow GetRow(ToolLanguage language)
 {
     foreach (DataGridViewRow item in dataGridView1.Rows)
     {
         ToolLanguage lang = item.Tag as ToolLanguage;
         if (lang == language)
         {
             return(item);
         }
     }
     return(null);
 }
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            ToolLanguage language = Selected;

            if (null != language)
            {
                toolStripRemoveLanguage.Enabled = !(language is ToolDefaultLanguage);
            }
            else
            {
                toolStripRemoveLanguage.Enabled = false;
            }
        }
        /// <summary>
        /// Change current used language
        /// </summary>
        /// <param name="lcid">language id</param>
        internal void SetLanguage(int lcid)
        {
            ToolLanguage language = Forms.MainForm.Singleton.Languages[lcid, false];

            if (null != language)
            {
                var component = language.Application.Components["Language Selector"];
                Translator.TranslateControls(this, component.ControlRessources);
            }
            else
            {
                Translation.Translator.TranslateControls(this, "Ressources.TranslationControlStrings.txt", lcid);
            }
        }
        private void Languages_ListChanged(object sender, ListChangedEventArgs e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
            {
                ToolLanguage language = Forms.MainForm.Singleton.Languages[e.NewIndex];
                var          row      = new DataGridViewRow();
                row.CreateCells(dataGridView1, new object[] { language.NameGlobal });
                row.Tag = language;
                dataGridView1.Rows.Add(row);
                break;
            }

            case ListChangedType.ItemChanged:
            {
                var language = Forms.MainForm.Singleton.Languages[e.NewIndex];
                var row      = GetRow(language);
                if (null != row)
                {
                    row.Cells[0].Value = String.IsNullOrWhiteSpace(language.NameGlobal) == true ? "<Empty>" : language.NameGlobal;
                }
                break;
            }

            case ListChangedType.ItemDeleted:
            {
                List <DataGridViewRow> listRows = new List <DataGridViewRow>();
                foreach (DataGridViewRow item in dataGridView1.Rows)
                {
                    ToolLanguage lang = item.Tag as ToolLanguage;
                    if (!Forms.MainForm.Singleton.Languages.Contains(lang))
                    {
                        listRows.Add(item);
                    }
                }
                foreach (var item in listRows)
                {
                    dataGridView1.Rows.Remove(item);
                }

                break;
            }

            case ListChangedType.Reset:
                ShowLanguages();
                break;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates an instance of the class
        /// </summary>
        /// <param name="language">edit language</param>
        internal ToolLanguageForm(ToolLanguage language)
        {
            InitializeComponent();
            _language = language;
            if (language is ToolDefaultLanguage)
            {
                label1DefaultHint.Text = String.Format("{0} is a readonly default language.", language.NameGlobal);
                panelDefaultHint.Visible = true;
            }
            else
                panelDefaultHint.Visible = false;

            toolLanguageControl1.SelectedLanguage = language;
            _highlightPen = new Pen(Color.Red, 2);
            overlayPainter1.Owner = this;
        }
Exemplo n.º 10
0
        private void toolStripAddLanguage_Click(object sender, EventArgs e)
        {
            ToolLanguage template = Forms.SelectLanguageForm.ShowForm(this, "Select a language template");

            if (null != template)
            {
                this.Refresh();
                ToolLanguage newLanguage = new ToolLanguage(Forms.MainForm.Singleton.Languages, template);
                Forms.MainForm.Singleton.Languages.Add(newLanguage);
                if (dataGridView1.SelectedCells.Count > 0)
                {
                    dataGridView1.SelectedCells[0].Selected = false;
                }
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
                dataGridView1_DoubleClick(dataGridView1, EventArgs.Empty);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates an instance of the class
        /// </summary>
        /// <param name="language">edit language</param>
        internal ToolLanguageForm(ToolLanguage language)
        {
            InitializeComponent();
            _language = language;
            if (language is ToolDefaultLanguage)
            {
                label1DefaultHint.Text   = String.Format("{0} is a readonly default language.", language.NameGlobal);
                panelDefaultHint.Visible = true;
            }
            else
            {
                panelDefaultHint.Visible = false;
            }

            toolLanguageControl1.SelectedLanguage = language;
            _highlightPen         = new Pen(Color.Red, 2);
            overlayPainter1.Owner = this;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Creates an instance as sub component
        /// </summary>
        /// <param name="parent">parent language</param>
        /// <param name="parentComponentName">name of the parent component</param>
        /// <param name="name">name of the component</param>
        /// <param name="controlType">component type to create an instance from</param>
        internal LocalizableCompoment(ToolLanguage parent, string parentComponentName, string name, Type controlType)
        {
            Parent            = parent;
            _value            = name;
            _value2           = parentComponentName;
            _controlType      = controlType;
            ControlRessources = new ItemCollection();

            string[] names = RessourceTableAttribute.GetRessourceNames(controlType);
            Dictionary <string, string> values = RessourceTableAttribute.GetRessourceValues(Design, parent.LCID);

            foreach (var resName in names)
            {
                string resValue = "";
                values.TryGetValue(resName, out resValue);

                Control ctrl = Translator.TryGetControl(Design, resName);
                Controls.Text.AdvRichTextBox advrichText = ctrl as Controls.Text.AdvRichTextBox;
                if (null != advrichText)
                {
                    ControlRessources.Add(new LocalizableWideString(resName, resValue));
                }
                else
                {
                    RichTextBox richBox = ctrl as RichTextBox;
                    if (null != richBox)
                    {
                        ControlRessources.Add(new LocalizableRTFString(resName, resValue));
                    }
                    else
                    {
                        TextBox textBox = ctrl as TextBox;
                        if (null != textBox && textBox.Multiline)
                        {
                            ControlRessources.Add(new LocalizableWideString(resName, resValue));
                        }
                        else
                        {
                            ControlRessources.Add(new LocalizableString(resName, resValue));
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates an instance as sub component
        /// </summary>
        /// <param name="parent">parent language</param>
        /// <param name="parentComponentName">name of the parent component</param>
        /// <param name="name">name of the component</param>
        /// <param name="controlType">component type to create an instance from</param>
        internal LocalizableCompoment(ToolLanguage parent, string parentComponentName, string name, Type controlType)
        {
            Parent = parent;
            _value = name;
            _value2 = parentComponentName;
            _controlType = controlType;
            ControlRessources = new ItemCollection();

            string[] names = RessourceTableAttribute.GetRessourceNames(controlType);
            Dictionary<string, string> values = RessourceTableAttribute.GetRessourceValues(Design, parent.LCID);
            foreach (var resName in names)
            {
                string resValue = "";
                values.TryGetValue(resName, out resValue);

                Control ctrl = Translator.TryGetControl(Design, resName);
                Controls.Text.AdvRichTextBox advrichText = ctrl as Controls.Text.AdvRichTextBox;
                if (null != advrichText)
                {
                    ControlRessources.Add(new LocalizableWideString(resName, resValue));
                }
                else
                {
                    RichTextBox richBox = ctrl as RichTextBox;
                    if (null != richBox)
                    {
                        ControlRessources.Add(new LocalizableRTFString(resName, resValue));
                    }
                    else
                    {
                        TextBox textBox = ctrl as TextBox;
                        if (null != textBox && textBox.Multiline)
                            ControlRessources.Add(new LocalizableWideString(resName, resValue));
                        else
                            ControlRessources.Add(new LocalizableString(resName, resValue));
                    }

                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates an instance of the class as new language
        /// </summary>
        /// <param name="parent">parent collection</param>
        /// <param name="template">role model</param>
        internal ToolLanguage(ToolLanguages parent, ToolLanguage template)
        {
            _parent = parent;
            _name = "New Language";
            _nameGlobal = "New Language";
            _lcid = 0;
            Initialize();

            foreach (var item in template.Application.Components[0].ControlRessources)
                Application.Components[0].ControlRessources[item.Value].Value2 = item.Value2;

            foreach (var item in template.Application.Components[1].ControlRessources)
                Application.Components[1].ControlRessources[item.Value].Value2 = item.Value2;

            for (int i = 0; i < template.Components.Count; i++)
            {
                LocalizableCompoment templateComponent = template.Components[i];
                LocalizableCompoment ownComponent = Components[i];
                foreach (var item in templateComponent.ControlRessources)
                    ownComponent.ControlRessources[item.Value].Value2 = item.Value2;
            }

            IsNew = true;
        }
Exemplo n.º 15
0
 private void toolStripAddLanguage_Click(object sender, EventArgs e)
 {
     ToolLanguage template = Forms.SelectLanguageForm.ShowForm(this, "Select a language template");
     if (null != template)
     {
         this.Refresh();
         ToolLanguage newLanguage = new ToolLanguage(Forms.MainForm.Singleton.Languages, template);
         Forms.MainForm.Singleton.Languages.Add(newLanguage);
         if (dataGridView1.SelectedCells.Count > 0)
             dataGridView1.SelectedCells[0].Selected = false;
         dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
         dataGridView1_DoubleClick(dataGridView1, EventArgs.Empty);
     }
 }
Exemplo n.º 16
0
 private DataGridViewRow GetRow(ToolLanguage language)
 {
     foreach (DataGridViewRow item in dataGridView1.Rows)
     {
         ToolLanguage lang = item.Tag as ToolLanguage;
         if (lang == language)
             return item;
     }
     return null;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Creates an instance of ToolLanguageForm and show
 /// </summary>
 /// <param name="owner">modal owner</param>
 /// <param name="language">edit language</param>
 /// <returns>contains unsaved changes</returns>
 internal static bool ShowForm(IWin32Window owner, ToolLanguage language)
 {
     ToolLanguageForm dlg = new ToolLanguageForm(language);
     dlg.ShowDialog(owner);
     dlg.Dispose(true);
     return dlg.Changed;
 }