Skip to content

Commit a4dd0dc

Browse files
committed
Reupdate project at its full potential
1 parent 08b91da commit a4dd0dc

File tree

45 files changed

+104
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+104
-92
lines changed

.vs/LFAR/v16/.suo

-50 KB
Binary file not shown.

.vs/TrinityConfigsManager/v16/.suo

48 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
-6.84 KB
Binary file not shown.

LFAR/obj/Debug/LFAR.pdb

-43.5 KB
Binary file not shown.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# LinesFindAndReplace
1+
# TrinityConfigsManager
22
Windows app, finds and replaces multiple lines from a text compatible file
33

4-
## ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/CyberMist2/LinesFindAndReplace?color=lime&label=LFAR)
4+
## ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/CyberMist2/TrinityConfigsManager?color=lime&label=LFAR)
55
| Current Status | Issues Open | Current Version | Latest Release | Guest Downloads |
66
| ------------- |:-------------:|:-------------:|:-------------:|:-------------:|
7-
| ![Travis (.org) branch](https://img.shields.io/travis/CyberMist2/LinesFindAndReplace/master?color=lime) | ![GitHub issues](https://img.shields.io/github/issues-raw/CyberMist2/LinesFindAndReplace) | ![GitHub release (latest by date)](https://img.shields.io/github/v/release/CyberMist2/LinesFindAndReplace?label=Version) | ![GitHub Release Date](https://img.shields.io/github/release-date/CyberMist2/LinesFindAndReplace?label=Latest%20Release&logo=travis) | ![GitHub All Releases](https://img.shields.io/github/downloads/CyberMist2/LinesFindAndReplace/total?label=Total%20Downloads) |
7+
| ![Travis (.org) branch](https://img.shields.io/travis/CyberMist2/TrinityConfigsManager/master?color=lime) | ![GitHub issues](https://img.shields.io/github/issues-raw/CyberMist2/TrinityConfigsManager) | ![GitHub release (latest by date)](https://img.shields.io/github/v/release/CyberMist2/TrinityConfigsManager?label=Version) | ![GitHub Release Date](https://img.shields.io/github/release-date/CyberMist2/TrinityConfigsManager?label=Latest%20Release&logo=travis) | ![GitHub All Releases](https://img.shields.io/github/downloads/CyberMist2/TrinityConfigsManager/total?label=Total%20Downloads) |
88

9-
9+
1010

1111
![LFAR APP](screenshot.jpg)

LFAR.sln renamed to TrinityConfigsManager.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29806.167
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFAR", "LFAR\LFAR.csproj", "{C678AB4A-90B8-4AF3-89A9-D6B46431F7C9}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrinityConfigsManager", "TrinityConfigsManager\TrinityConfigsManager.csproj", "{C678AB4A-90B8-4AF3-89A9-D6B46431F7C9}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Lines changed: 39 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LFAR/Form1.cs renamed to TrinityConfigsManager/Form1.cs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using System.Xml;
1414
using System.Xml.Linq;
1515

16-
namespace LFAR
16+
namespace TrinityConfigsManager
1717
{
1818
public partial class Form1 : Form
1919
{
@@ -45,17 +45,17 @@ private void saveCollectionButton_Click(object sender, EventArgs e)
4545
string pathFile = comboBox1.Text + ".xml";
4646

4747
DataTable dt = new DataTable();
48-
dt.TableName = "LineJobs";
48+
dt.TableName = "ConfigJobs";
4949

5050
for (int i = 0; i < dataGridView1.Columns.Count; i++)
5151
{
5252
if (dataGridView1.Columns[i].Visible) // Add's only Visible columns (if you need it)
5353
{
54-
string headerText = dataGridView1.Columns[i].HeaderText;
55-
headerText = Regex.Replace(headerText, "[-/, ]", "_");
54+
string headerText = dataGridView1.Columns[i].HeaderText;
55+
headerText = Regex.Replace(headerText, "[-/, ]", "_");
5656

57-
DataColumn column = new DataColumn(headerText);
58-
dt.Columns.Add(column);
57+
DataColumn column = new DataColumn(headerText);
58+
dt.Columns.Add(column);
5959
}
6060
}
6161

@@ -66,7 +66,6 @@ private void saveCollectionButton_Click(object sender, EventArgs e)
6666
dataRow[0] = DataGVRow.Cells[0].Value;
6767
dataRow[1] = DataGVRow.Cells[1].Value;
6868
dataRow[2] = DataGVRow.Cells[2].Value;
69-
dataRow[3] = DataGVRow.Cells[3].Value;
7069

7170
dt.Rows.Add(dataRow); //dt.Columns.Add();
7271
}
@@ -106,7 +105,7 @@ private void Form1_Load(object sender, EventArgs e)
106105
// focus on last row
107106
try { dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0]; } catch { }
108107

109-
label1.Text = "Total: " + dataGridView1.RowCount.ToString() + " lines to replace";
108+
label1.Text = "Total: " + dataGridView1.RowCount.ToString() + " configs prepared.";
110109
}
111110

112111
private void deleteCollectionButton_Click(object sender, EventArgs e)
@@ -132,12 +131,11 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
132131

133132
XDocument xmlDoc = XDocument.Load(fileName);
134133

135-
foreach (var coordinate in xmlDoc.Descendants("LineJobs"))
134+
foreach (var coordinate in xmlDoc.Descendants("ConfigJobs"))
136135
{
137136
dataGridView1.Rows.Add(coordinate.Element("Check").Value,
138-
coordinate.Element("Line_to_Search").Value,
139-
coordinate.Element("Replace_with").Value,
140-
coordinate.Element("Comment").Value);
137+
coordinate.Element("Config_Name").Value,
138+
coordinate.Element("Set_Value").Value);
141139
};
142140
}
143141

@@ -171,7 +169,7 @@ private void button3_Click(object sender, EventArgs e)
171169

172170
private void button7_Click(object sender, EventArgs e)
173171
{
174-
dataGridView1.Rows.Add(false, "......", "......", "......");
172+
dataGridView1.Rows.Add(false, "......", "......");
175173

176174
// focus on last row
177175
try { dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0]; } catch { }
@@ -191,14 +189,14 @@ private async void buttonDoReplaceJob_Click(object sender, EventArgs e)
191189
{
192190
int replacesCount = 0;
193191

194-
DialogResult result = MessageBox.Show("This action will replace all lines with the values specified.", "Confirmation", MessageBoxButtons.YesNo);
192+
DialogResult result = MessageBox.Show("This action will replace specified config values with yours.", "Confirmation", MessageBoxButtons.YesNo);
195193
if (result == DialogResult.Yes)
196194
{
197195
if (File.Exists(pathOfFile))
198196
{
199197
label1.Text = "Running task, please wait...";
200198
replacesCount = await Task.Run(() => DoReplaceJob(1000));
201-
label1.Text = "Jobs finished: " + replacesCount + " replaces.";
199+
label1.Text = "Jobs finished: " + replacesCount + " configs affected.";
202200
}
203201
else
204202
MessageBox.Show("Please select a valid file!");
@@ -219,10 +217,24 @@ private int DoReplaceJob(int sleepTime)
219217

220218
foreach (DataGridViewRow row in dataGridView1.Rows)
221219
{
222-
if (line.Contains(row.Cells[1].Value.ToString()))
220+
if (!line.StartsWith("#")) // ignore hashtag lines
223221
{
224-
line = line.Replace(line, row.Cells[2].Value.ToString());
225-
replacesCount++;
222+
if (line.Contains('=')) // if contains our separator
223+
{
224+
string configName = line.Split('=').First();
225+
226+
if (configName.Contains(row.Cells[1].Value.ToString())) // if found the config we are looking for
227+
{
228+
string configValue = line.Split('=').Last();
229+
230+
if (!string.IsNullOrEmpty(configValue)) // if string after separator is not null or empty
231+
{
232+
string newline = configName + "= " + row.Cells[2].Value.ToString(); // prepare new line
233+
line = line.Replace(line, newline);
234+
replacesCount++;
235+
}
236+
}
237+
}
226238
}
227239
}
228240
text = text + line + Environment.NewLine;

0 commit comments

Comments
 (0)