Skip to content

Commit

Permalink
10.2 - Improved Mass Insert - now it will not create duplicates with …
Browse files Browse the repository at this point in the history
…same IDs, but will update str values of the existing strings.
  • Loading branch information
ArtUrlWWW committed Jun 25, 2017
1 parent d61ef57 commit 6dbf172
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Source/AboutEditorForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<value>1</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>Version 10.1 by ArtUrlWWW</value>
<value>Version 10.2 by ArtUrlWWW</value>
</data>
<data name="label1.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
Expand Down
2 changes: 1 addition & 1 deletion Source/AddString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void copyStrFldsValues_Click(object sender, EventArgs e)
sh.textIDFld = textIDFld.Text;
sh.displayTextFld = displayTextFld.Text;

MainUI.strHolders.Add(sh);
MainUI.copiedValuesStrHolders.Add(sh);
}

private void pasteStrFldsValues_Click(object sender, EventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions Source/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventA
sh.textIDFld = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
sh.displayTextFld = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();

MainUI.strHolders.Add(sh);
MainUI.copiedValuesStrHolders.Add(sh);
}
}

private void Paste_ALL_copied_values_Click(object sender, EventArgs e)
{
for (int x = 0; x < MainUI.strHolders.Count; x++)
for (int x = 0; x < MainUI.copiedValuesStrHolders.Count; x++)
{
StringHolder sh = MainUI.strHolders[x];
StringHolder sh = MainUI.copiedValuesStrHolders[x];

DataTable dt = (DataTable)dataGridView1.DataSource;
DataRow dr;
Expand Down Expand Up @@ -311,7 +311,7 @@ private void CopySelectedRows()
sh.textIDFld = dataGridView1.SelectedRows[x].Cells[0].Value.ToString();
sh.displayTextFld = dataGridView1.SelectedRows[x].Cells[1].Value.ToString();

MainUI.strHolders.Add(sh);
MainUI.copiedValuesStrHolders.Add(sh);
}

MessageBox.Show(dataGridView1.SelectedRows.Count + " rows copied!");
Expand Down Expand Up @@ -354,7 +354,7 @@ private void copyThisRowToolStripMenuItem_Click(object sender, EventArgs e)
sh.textIDFld = row.Cells[0].Value.ToString();
sh.displayTextFld = row.Cells[1].Value.ToString();

MainUI.strHolders.Add(sh);
MainUI.copiedValuesStrHolders.Add(sh);
}


Expand Down
39 changes: 28 additions & 11 deletions Source/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class MainUI : Form
private DataGridViewSettings settings0 = new DataGridViewSettings();
private DataGridViewSettings settings1 = new DataGridViewSettings();

public static List<StringHolder> strHolders = new List<StringHolder>();
public static List<StringHolder> copiedValuesStrHolders = new List<StringHolder>();

public MainUI()
{
Expand Down Expand Up @@ -375,6 +375,8 @@ private void closeAndSavePackage(bool save = true)
SaveSTBLFile(true);
}

fileNameLbl.Text = "";
LanguageLbl.Text = "";

dataGridView1.DataSource = null;
dataGridView1.Columns.Add("Column1", "");
Expand Down Expand Up @@ -421,7 +423,7 @@ private void showLangCodesToolStripMenuItem_Click(object sender, EventArgs e)

private void multyInsertIntoFilesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MainUI.strHolders.Count > 0)
if (MainUI.copiedValuesStrHolders.Count > 0)
{

isTextChanged = false;
Expand Down Expand Up @@ -462,17 +464,31 @@ private void multyInsertIntoFilesToolStripMenuItem_Click(object sender, EventArg

isTextChanged = true;

for (int x = 0; x < MainUI.strHolders.Count; x++)
for (int x = 0; x < MainUI.copiedValuesStrHolders.Count; x++)
{
StringHolder sh = MainUI.strHolders[x];
StringHolder copiedStrElement = MainUI.copiedValuesStrHolders[x];

DataTable dt = (DataTable)dataGridView1.DataSource;
DataRow dr;
dr = dt.NewRow();
dr[0] = sh.textIDFld;
dr[1] = sh.displayTextFld;
dt.Rows.Add(dr);
dataGridView1.Rows[dataGridView1.Rows.Count - 1].HeaderCell.Value = (dataGridView1.Rows.Count).ToString();

var drArr = (from rowEl in dt.AsEnumerable()
where rowEl.Field<string>(0) == copiedStrElement.textIDFld
select rowEl);

if (drArr.Count() == 0)
{
DataRow dr = dt.NewRow();
dr[0] = copiedStrElement.textIDFld;
dr[1] = copiedStrElement.displayTextFld;
dt.Rows.Add(dr);
dataGridView1.Rows[dataGridView1.Rows.Count - 1].HeaderCell.Value = (dataGridView1.Rows.Count).ToString();

}
else
{
DataRow dr = drArr.First();
dr[1] = copiedStrElement.displayTextFld;
}


}

Expand All @@ -484,7 +500,8 @@ private void multyInsertIntoFilesToolStripMenuItem_Click(object sender, EventArg
isTextChanged = false;

}
} else
}
else
{
MessageBox.Show("You have not copied any string. \r\nCopy strings and use this option for mass insert of copied strings into STBL files!");
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("10.1.0.0")]
[assembly: AssemblyFileVersion("10.1.0.0")]
[assembly: AssemblyVersion("10.2.0.0")]
[assembly: AssemblyFileVersion("10.2.0.0")]
10 changes: 5 additions & 5 deletions Source/StringPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ private void reloadListView()
{
listView1.Items.Clear();
listView1.View = View.List;
for (int x = 0; x < MainUI.strHolders.Count; x++)
for (int x = 0; x < MainUI.copiedValuesStrHolders.Count; x++)
{
StringHolder sh = MainUI.strHolders[x];
StringHolder sh = MainUI.copiedValuesStrHolders[x];
listView1.Items.Add(sh.textIDFld + " - " + sh.displayTextFld);

}
Expand All @@ -45,12 +45,12 @@ private void listView1_MouseClick(object sender, MouseEventArgs e)
{
if (addstr != null)
{
addstr.setFldsValues(MainUI.strHolders[listView1.SelectedIndices[0]]);
addstr.setFldsValues(MainUI.copiedValuesStrHolders[listView1.SelectedIndices[0]]);
}
}
else
{
MainUI.strHolders.RemoveAt(listView1.SelectedIndices[0]);
MainUI.copiedValuesStrHolders.RemoveAt(listView1.SelectedIndices[0]);
reloadListView();
}
}
Expand All @@ -60,7 +60,7 @@ private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (addstr != null)
{
addstr.setFldsValues(MainUI.strHolders[listView1.SelectedIndices[0]]);
addstr.setFldsValues(MainUI.copiedValuesStrHolders[listView1.SelectedIndices[0]]);
}

this.Close();
Expand Down

0 comments on commit 6dbf172

Please sign in to comment.