Exemplo n.º 1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listViewPages.SelectedItems.Count <= 0 || listViewPages.SelectedItems[0] == null)
            {
                return;
            }
            if (listViewEntries.SelectedItems.Count <= 0 || listViewEntries.SelectedItems[0] == null)
            {
                return;
            }

            try
            {
                var categoryLViewItem = listViewPages.SelectedItems[0];
                var page = (RTextPageBase)categoryLViewItem.Tag;

                var           lViewItem = listViewEntries.SelectedItems[0];
                RTextPairUnit rowData   = (RTextPairUnit)lViewItem.Tag;

                var rowEditor = new RowEditor(rowData.ID, rowData.Label, rowData.Value, _isUiFolderProject);
                if (rowEditor.ShowDialog() == DialogResult.OK)
                {
                    if (_isUiFolderProject && rowEditor.ApplyToAllLocales)
                    {
                        foreach (var rt in _rTexts)
                        {
                            var rtPage = rt.RText.GetPages()[page.Name];
                            rtPage.DeleteRow(rowData.Label);
                            rtPage.AddRow(rowEditor.Id, rowEditor.Label, rowEditor.Data);
                        }

                        toolStripStatusLabel.Text = $"{rowEditor.Label} - edited to {_rTexts.Count} locales";
                    }
                    else
                    {
                        if (rowEditor.Label != rowEditor.Label && page.PairExists(rowEditor.Label))
                        {
                            MessageBox.Show("This label already exists in this category.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        // Remove, Add - Incase label was changed else we can't track it in our page
                        page.DeleteRow(rowData.Label);
                        page.AddRow(rowEditor.Id, rowEditor.Label, rowEditor.Data);

                        toolStripStatusLabel.Text = $"{rowEditor.Label} - edited";
                    }

                    DisplayEntries(page);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                toolStripStatusLabel.Text = ex.Message;
            }
        }
Exemplo n.º 2
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listViewPages.SelectedItems.Count <= 0 || listViewPages.SelectedItems[0] == null)
            {
                return;
            }

            try
            {
                var pageLViewItem = listViewPages.SelectedItems[0];
                var page          = (RTextPageBase)pageLViewItem.Tag;

                var rowEditor = new RowEditor(CurrentRText.RText is RT03, _isUiFolderProject);
                rowEditor.Id = page.GetLastId() + 1;

                if (rowEditor.ShowDialog() == DialogResult.OK)
                {
                    if (page.PairExists(rowEditor.Label))
                    {
                        MessageBox.Show("This label already exists in this category.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (_isUiFolderProject && rowEditor.ApplyToAllLocales)
                    {
                        foreach (var rt in _rTexts)
                        {
                            var rPage = rt.RText.GetPages()[page.Name];
                            rPage.AddRow(rowEditor.Id, rowEditor.Label, rowEditor.Data);
                        }

                        toolStripStatusLabel.Text = $"{rowEditor.Label} - added to {_rTexts.Count} locales";
                    }
                    else
                    {
                        var rowId = page.AddRow(rowEditor.Id, rowEditor.Label, rowEditor.Data);
                        toolStripStatusLabel.Text = $"{rowEditor.Label} - added";
                    }

                    DisplayEntries(page);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                toolStripStatusLabel.Text = ex.Message;
            }
        }