Skip to content

Commit 7e6fb60

Browse files
During upgrade OR from 1.5.1 to 1.6 automatic routes are imported. Name clashes can occur with local routes. This update renames the manual added route appending (1), (2) etc. This update does the same when automatic routes are added.
1 parent 6380c71 commit 7e6fb60

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Source/Menu/ContentForm.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
9595
route.Installed ? route.DateInstalled.ToString(CultureInfo.CurrentCulture.DateTimeFormat) : "",
9696
route.Url });
9797
dataGridViewAutoInstall.Rows[indexAdded].Cells[2].ToolTipText = route.Url;
98+
if (!route.Installed)
99+
{
100+
changeManualInstallRoute(routeName);
101+
}
98102
}
99103

100104
dataGridViewAutoInstall.Sort(dataGridViewAutoInstall.Columns[0], ListSortDirection.Ascending);
@@ -139,6 +143,42 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
139143
buttonCancel.Enabled = false;
140144
}
141145

146+
void changeManualInstallRoute(string Route)
147+
{
148+
bool found = false;
149+
150+
foreach (var folder in Settings.Folders.Folders)
151+
{
152+
if (folder.Key == Route)
153+
{
154+
// Route found in folder settings
155+
found = true;
156+
}
157+
}
158+
159+
if (found)
160+
{
161+
// search for the next route (1), (2) etc. not found in folder settings
162+
int seqNr = 1;
163+
string route = Route + " (" + seqNr + ")";
164+
while (found)
165+
{
166+
found = false;
167+
foreach (var folder in Settings.Folders.Folders)
168+
{
169+
if (folder.Key == route)
170+
{
171+
found = true;
172+
seqNr++;
173+
route = Route + " (" + seqNr + ")";
174+
}
175+
}
176+
}
177+
Settings.Folders.Folders[route] = Settings.Folders.Folders[Route];
178+
Settings.Folders.Folders.Remove(Route);
179+
}
180+
}
181+
142182
private void tabControlContent_Selecting(object sender, TabControlCancelEventArgs e)
143183
{
144184
switch ((sender as TabControl).SelectedTab.Name)

0 commit comments

Comments
 (0)