Skip to content

Commit

Permalink
implement link deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas O'Connor committed May 31, 2016
1 parent 3c97b7b commit 19f426b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Binary file modified Tilandis.VC.db
Binary file not shown.
29 changes: 28 additions & 1 deletion TilandisGUI/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics; // Process, ProcessStartInfo.
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
Expand All @@ -23,6 +24,8 @@ private void Form1_Load(object sender, EventArgs e) {
func_reloadjson();

lst_links.SelectedIndexChanged += clbk_linksel;

btn_dellink.Click += clbk_dellink;
}

private void clbk_linksel(object sender, EventArgs e) {
Expand All @@ -32,7 +35,7 @@ private void clbk_linksel(object sender, EventArgs e) {

ListViewItem lvi_curitem = lst_links.SelectedItems[0];

JObject prop_linksettings = (JObject) json_links.Value<JObject>(lvi_curitem.Text);
JObject prop_linksettings = json_links.Value<JObject>(lvi_curitem.Text);

edt_linkname.Text = lvi_curitem.Text;
edt_pathname.Text = prop_linksettings.Value<string>("path");
Expand All @@ -42,6 +45,8 @@ private void clbk_linksel(object sender, EventArgs e) {
}

private void func_reloadjson() {
lst_links.Items.Clear();

StreamReader r = new StreamReader("links.json");
string str_linksjson = r.ReadToEnd();
json_links = JObject.Parse(str_linksjson);
Expand All @@ -56,5 +61,27 @@ private void func_reloadjson() {
lst_links.Items.Add(lvi_curitem);
}
}

private void clbk_dellink(object sender, EventArgs e) {
if (lst_links.SelectedItems.Count <= 0) {
MessageBox.Show("Select a link first.");
return;
}

ListViewItem lvi_curitem = lst_links.SelectedItems[0];

ProcessStartInfo psi_tilandis = new ProcessStartInfo();
psi_tilandis.FileName = "tilandis.exe";
psi_tilandis.Arguments = "-d " + lvi_curitem.Text;
psi_tilandis.UseShellExecute = true; // carry workdir over

Process proc_tilandis = new Process();
proc_tilandis.StartInfo = psi_tilandis;

proc_tilandis.Start();
proc_tilandis.WaitForExit();

func_reloadjson();
}
}
}
5 changes: 3 additions & 2 deletions TilandisGUI/TilandisGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
Expand Down

0 comments on commit 19f426b

Please sign in to comment.