Skip to content

Commit 3501eee

Browse files
committed
add folder to group converter (resolves #5)
1 parent 3161e49 commit 3501eee

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

ProgramManagerVC/FormCreateItem.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ private void ButtonOK_Click(object sender, EventArgs e)
5454

5555
private void CheckTextBoxes()
5656
{
57-
/* https://tjournal.ru/flood/66038-artemiy-lebedev-puknul */
57+
/* TJournal закрылся, поэтому оставлю ссылку на оригинал :D
58+
* https://t.me/temablog/337
59+
*/
5860
if (!string.IsNullOrEmpty(textBoxName.Text) && !string.IsNullOrEmpty(textBoxPath.Text))
5961
{
6062
buttonOK.Enabled = true;

ProgramManagerVC/FormMain.Designer.cs

Lines changed: 35 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ProgramManagerVC/FormMain.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,30 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
226226
if(formSettings.DialogResult == DialogResult.OK)
227227
InitializeTitle();
228228
}
229+
230+
private void convertFolderToGroupToolStripMenuItem_Click(object sender, EventArgs e)
231+
{
232+
DialogResult result = folderBrowserDialogCovnerter.ShowDialog();
233+
if (result == DialogResult.OK)
234+
{
235+
string path = folderBrowserDialogCovnerter.SelectedPath;
236+
string[] list = Directory.GetFiles(path, "*.lnk");
237+
string name = path.Replace(Path.GetDirectoryName(path) + Path.DirectorySeparatorChar, "");
238+
239+
data.SendQueryWithoutReturn("INSERT INTO groups (id,name,status) VALUES (NULL,\"" + name + "\",1)");
240+
241+
DataTable group = new DataTable();
242+
group = data.SendQueryWithReturn("SELECT * FROM groups WHERE name = \"" + name + "\";");
243+
244+
foreach (string Link in list)
245+
{
246+
string itemName = Path.GetFileNameWithoutExtension(Link);
247+
data.SendQueryWithoutReturn("INSERT INTO \"items\"(id,name,path,icon,groups) VALUES (NULL,'" + itemName + "','" + Link + "','" + Link + "','" + group.Rows[0][0].ToString() + "');");
248+
}
249+
250+
CloseAllMDIWindows();
251+
InitializeMDI();
252+
}
253+
}
229254
}
230255
}

ProgramManagerVC/FormMain.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123+
<metadata name="folderBrowserDialogCovnerter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124+
<value>132, 17</value>
125+
</metadata>
123126
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
124127
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125128
<value>

0 commit comments

Comments
 (0)