Skip to content

Commit

Permalink
Merge pull request #41 from burninrubber0/vehiclelist-update
Browse files Browse the repository at this point in the history
Add VehicleList entry deletion
  • Loading branch information
burninrubber0 authored Jun 29, 2023
2 parents 29163f2 + ff35690 commit 968b013
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 218 deletions.
10 changes: 10 additions & 0 deletions VehicleList/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions VehicleList/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,7 @@
<data name="CopyHS" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CopyHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="remove_xform" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\remove_xform.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added VehicleList/Resources/remove_xform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions VehicleList/VehicleList.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
<ProjectReference Include="..\BundleUtilities\BundleUtilities.csproj" />
<ProjectReference Include="..\PluginAPI\PluginAPI.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)BundleManager\bin\$(ConfigurationName)\$(TargetFramework)\plugins\&quot; /s /e /y" />
</Target>
Expand Down
39 changes: 37 additions & 2 deletions VehicleList/VehicleListForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ private void UpdateDisplay()

lstVehicles.ListViewItemSorter = new VehicleSorter(0);
lstVehicles.Sort();

stlStatusLabel.Text = "";
copyItemToolStripMenuItem.Enabled = false;
deleteItemToolStripMenuItem.Enabled = false;
tsbCopyItem.Enabled = false;
tsbDeleteItem.Enabled = false;
}

private void EditSelectedEntry()
Expand Down Expand Up @@ -118,7 +124,7 @@ private void AddItem()

private void CopyItem()
{
if (List == null || lstVehicles.SelectedItems.Count > 1
if (List == null || lstVehicles.SelectedItems.Count != 1
|| lstVehicles.SelectedIndices.Count <= 0)
return;

Expand All @@ -133,6 +139,22 @@ private void CopyItem()
editor.ShowDialog(this);
}

private void DeleteItem()
{
if (List == null || lstVehicles.SelectedItems.Count != 1
|| lstVehicles.SelectedIndices.Count <= 0)
return;

if (!int.TryParse(lstVehicles.SelectedItems[0].Text, out int index))
return;
List.Entries.RemoveAt(index);
for (int i = index; i < List.Entries.Count; ++i)
List.Entries[i].Index--;

Edit?.Invoke();
UpdateDisplay();
}

private void Editor_OnDone1(Vehicle vehicle)
{
// Insert if not at end, else add
Expand Down Expand Up @@ -176,11 +198,14 @@ private void lstVehicles_MouseDoubleClick(object sender, MouseEventArgs e)
{
EditSelectedEntry();
}

private void lstVehicles_SelectedIndexChanged(object sender, EventArgs e)
{
stlStatusLabel.Text = lstVehicles.SelectedItems.Count + " Item(s) Selected";
copyItemToolStripMenuItem.Enabled = true;
deleteItemToolStripMenuItem.Enabled = true;
tsbCopyItem.Enabled = true;
tsbDeleteItem.Enabled = true;
}

private void lstVehicles_ColumnClick(object sender, ColumnClickEventArgs e)
Expand Down Expand Up @@ -277,5 +302,15 @@ private void tsbCopyItem_Click(object sender, EventArgs e)
{
CopyItem();
}

private void deleteItemToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteItem();
}

private void tsbDeleteItem_Click(object sender, EventArgs e)
{
DeleteItem();
}
}
}
Loading

0 comments on commit 968b013

Please sign in to comment.