コード例 #1
0
        /// <summary>
        /// Handles the Click event of the toolStripButtonCreate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void toolStripButtonCreate_Click(object sender, EventArgs e)
        {
            ResourceEditWindow editWindow = null;

            try
            {
                editWindow = new ResourceEditWindow();
                DialogResult result = editWindow.ShowDialog();

                if (result == DialogResult.OK)
                {
                    this.localization.Operations.CreateNewResource(editWindow.ClassName, editWindow.ResourceKey, editWindow.ResourceValue, editWindow.CultureInfo);
                    // this.LoadCultureData();


                    this.backgroundWorker.RunWorkerAsync();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error." + ex.Message);
            }
            finally
            {
                if (editWindow != null)
                {
                    editWindow.Dispose();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the Click event of the toolStripMenuItemNew control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void toolStripMenuItemNew_Click(object sender, EventArgs e)
        {
            ResourceEditWindow editWindow = null;

            try
            {
                editWindow = new ResourceEditWindow();
                editWindow.textBoxCultureInfo.Enabled = false;
                editWindow.textBoxCultureInfo.Text    = this.currentCulture;

                editWindow.textBoxResourceKey.Enabled   = false;
                editWindow.textBoxResourceValue.Enabled = false;

                DialogResult result = editWindow.ShowDialog();

                if (result == DialogResult.OK)
                {
                    this.localization.Operations.CreateNewResource(editWindow.ClassName, editWindow.ResourceKey,
                                                                   editWindow.ResourceValue, this.currentCulture);
                    this.listBox.Items.Add(editWindow.ClassName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error." + ex.Message);
            }
            finally
            {
                if (editWindow == null)
                {
                    editWindow.Dispose();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Handles the Click event of the toolStripMenuItemEdit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void toolStripMenuItemEdit_Click(object sender, EventArgs e)
        {
            ResourceEditWindow editWindow = null;

            try
            {
                if (this.listBox.SelectedItems.Count > 0)
                {
                    string oldClassName = this.listBox.SelectedItem.ToString();
                    int    index        = this.listBox.SelectedIndex;

                    editWindow = new ResourceEditWindow();
                    editWindow.textBoxResourceKey.Enabled   = false;
                    editWindow.textBoxResourceValue.Enabled = false;

                    editWindow.textBoxCultureInfo.Enabled = false;
                    editWindow.textBoxCultureInfo.Text    = this.currentCulture;

                    editWindow.textBoxClassName.SelectedText = this.currentClassName;

                    DialogResult result = editWindow.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        this.localization.Operations.UpdateClass(editWindow.textBoxClassName.Text, oldClassName, this.currentCulture);

                        this.LoadClasses();

                        //this.listBox.SelectedItems[index] = editWindow.textBoxClassName.Text;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error." + ex.Message, "Newt", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (editWindow != null)
                {
                    editWindow.Dispose();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles the Click event of the buttonNew control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void buttonNew_Click(object sender, EventArgs e)
        {
            ResourceEditWindow editWindow = null;

            try
            {
                //check if we have any classes
                if (this.listBox.Items.Count == 0 || this.currentClassName == string.Empty)
                {
                    MessageBox.Show("No classes found. Please enter a class first", "Newt");
                    return;
                }


                editWindow = new ResourceEditWindow();
                editWindow.textBoxClassName.Text      = this.currentClassName;
                editWindow.textBoxClassName.Enabled   = false;
                editWindow.textBoxCultureInfo.Text    = this.currentCulture;
                editWindow.textBoxCultureInfo.Enabled = false;

                if (editWindow.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    this.localization.Operations.CreateNewResource(this.currentClassName, editWindow.textBoxResourceKey.Text, editWindow.textBoxResourceValue.Text, this.currentCulture);
                    this.RefreshClass();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error." + ex.Message);
            }
            finally
            {
                if (editWindow != null)
                {
                    editWindow.Dispose();
                }
            }
        }
コード例 #5
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            ResourceEditWindow window = null;

            try
            {
                int selectedRowIndex = -1;

                if (this.dataGridView.SelectedCells.Count > 0)
                {
                    selectedRowIndex = this.dataGridView.SelectedCells[0].RowIndex;
                }

                if (this.dataGridView.SelectedRows.Count > 0)
                {
                    selectedRowIndex = this.dataGridView.SelectedRows[0].Index;
                }

                if (selectedRowIndex > -1)
                {
                    window = new ResourceEditWindow();

                    window.textBoxClassName.Text    = this.currentClassName;
                    window.textBoxClassName.Enabled = false;

                    window.textBoxCultureInfo.Enabled = false;
                    window.textBoxCultureInfo.Text    = this.currentCulture;

                    string oldResourceKey   = this.dataGridView.Rows[selectedRowIndex].Cells[0].Value.ToString();
                    string oldResourceValue = this.dataGridView.Rows[selectedRowIndex].Cells[1].Value.ToString();

                    window.textBoxResourceKey.SelectedText   = oldResourceKey;
                    window.textBoxResourceValue.SelectedText = oldResourceValue;


                    if (window.ShowDialog() == DialogResult.OK)
                    {
                        if (oldResourceKey != window.textBoxResourceKey.Text || oldResourceValue != window.textBoxResourceValue.Text)
                        {
                            this.localization.Operations.UpdateResource(this.currentCulture, this.currentClassName, window.textBoxResourceKey.Text, oldResourceKey, window.textBoxResourceValue.Text, oldResourceValue);

                            this.RefreshClass();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please select the resource to delete");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error." + ex.Message, "Newt");
            }
            finally
            {
                if (window != null)
                {
                    window.Dispose();
                }
            }
        }