Ejemplo n.º 1
0
        private void dataGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var dataRow = editingRow;

            TranslationChange change = new TranslationChange();

            change.Source = dataRow[0].ToString();
            string originalValue = originalValues[change.Source];

            if (originalValue != dataRow[1].ToString())
            {
                change.ChangeType  = TranslationChange.ChangeTypeEnum.UPDATE;
                change.Translation = originalValue;
                change.NewValue    = dataRow[1].ToString();
                addChange(change);
            }
            // Edited back to default value
            else if (changeList.Contains(change))
            {
                changeList.Remove(change);
                if (changeList.Count == 0)
                {
                    updateButton.Enabled = false;
                }
            }

            editingRow = null;
        }
Ejemplo n.º 2
0
        private void OnDeleteClick(object sender, EventArgs e)
        {
            int rows = dataGrid.SelectedRows.Count;

            if (rows == 0)
            {
                MessageBox.Show("No rows selected (you must select entire row)");
                return;
            }
            ShowWaitForm("Deleting...");
            foreach (DataGridViewRow item in dataGrid.SelectedRows)
            {
                TranslationChange change = new TranslationChange();
                change.ChangeType = TranslationChange.ChangeTypeEnum.DELETE;
                change.Source     = item.Cells[0].Value.ToString();

                if (originalValues.Keys.Contains(item.Cells[0].ToString()))
                {
                    change.Translation = originalValues[item.Cells[0].ToString()];
                }
                else
                {
                    change.Translation = item.Cells[1].ToString();
                }
                addChange(change);

                dataGrid.Rows.RemoveAt(item.Index);
            }
            MessageBox.Show("Deleted " + rows.ToString() + " Rows");
        }
        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(obj, this))
            {
                return(true);
            }

            TranslationChange other = obj as TranslationChange;

            if (Object.ReferenceEquals(null, other))
            {
                return(false);
            }

            if (Object.ReferenceEquals(Source, other.Source))
            {
                return(true);
            }
            else if (Object.ReferenceEquals(Source, null) || Object.ReferenceEquals(other.Source, null))
            {
                return(false);
            }

            return(String.Equals(Source, Source, StringComparison.Ordinal));
        }
Ejemplo n.º 4
0
 private void addChange(TranslationChange change)
 {
     if (changeList.Contains(change))
     {
         changeList.Remove(change);
     }
     changeList.Add(change);
     updateButton.Enabled = true;
 }
Ejemplo n.º 5
0
        private void dataGrid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            ShowWaitForm("Deleting...");
            string            key    = e.Row.Cells[0].Value.ToString();
            string            value  = e.Row.Cells[1].Value.ToString();
            TranslationChange change = new TranslationChange();

            change.ChangeType = TranslationChange.ChangeTypeEnum.DELETE;
            change.Source     = key;
            if (originalValues.Keys.Contains(key))
            {
                change.Translation = originalValues[key];
            }
            else
            {
                change.Translation = value;
            }
            addChange(change);

            if (deletingRowsTotal == -1)
            {
                deletingRowsTotal = dataGrid.SelectedRows.Count;
            }
        }
Ejemplo n.º 6
0
        private void replace()
        {
            bool requireSplitting = wholeWordCheckbox.Checked || !caseSensitiveCheckbox.Checked;
            int  totalReplaced    = 0;

            foreach (DataRowView rowView in dataTable.DefaultView)
            {
                DataRow row            = rowView.Row;
                string  rowKey         = row[0].ToString();
                String  rowText        = row[1].ToString();
                String  replacementRow = "";
                if (requireSplitting)
                {
                    var            split  = rowText.Split(null);
                    IList <string> output = new List <string>();
                    foreach (string word in split)
                    {
                        if (wholeWordCheckbox.Checked)
                        {
                            string input = word;
                            string check = findTextBox.Text;
                            if (!caseSensitiveCheckbox.Checked)
                            {
                                input = input.ToLower();
                                check = check.ToLower();
                            }
                            if (input == check)
                            {
                                output.Add(replaceTextBox.Text);
                            }
                            else
                            {
                                output.Add(word);
                            }
                        }
                        else
                        {
                            output.Add(Regex.Replace(word, findTextBox.Text, replaceTextBox.Text, RegexOptions.IgnoreCase));
                        }
                    }
                    String final = String.Join(" ", output.ToArray <string>());
                    replacementRow = final;
                }
                else
                {
                    replacementRow = rowText.Replace(findTextBox.Text, replaceTextBox.Text);
                }

                if (replacementRow != rowText)
                {
                    addToOriginalValueCache(rowKey, rowText);
                    ++totalReplaced;

                    TranslationChange change = new TranslationChange();
                    change.ChangeType  = TranslationChange.ChangeTypeEnum.UPDATE;
                    change.Source      = rowKey.ToString();
                    change.Translation = originalValues[rowKey];
                    change.NewValue    = replacementRow;
                    addChange(change);

                    row[1] = replacementRow;
                }
            }

            MessageBox.Show("Replaced " + totalReplaced.ToString() + " instances of " + findTextBox.Text);
        }