Skip to content

Commit

Permalink
Copy functionality for VehicleList
Browse files Browse the repository at this point in the history
  • Loading branch information
burninrubber0 committed Apr 4, 2022
1 parent b468ea4 commit a8f8628
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 12 deletions.
12 changes: 11 additions & 1 deletion 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 @@ -124,4 +124,7 @@
<data name="EditTableHS" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\EditTableHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<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>
</root>
Binary file added VehicleList/Resources/CopyHS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions VehicleList/VehicleList.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
<ItemGroup>
<None Include="Resources\EditTableHS.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\CopyHS.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)BundleManager\bin\$(ConfigurationName)\plugins\" /s /e /y</PostBuildEvent>
Expand Down
29 changes: 29 additions & 0 deletions VehicleList/VehicleListForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ private void AddItem()
editor.ShowDialog(this);
}

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

int index;
if (!int.TryParse(lstVehicles.SelectedItems[0].Text, out index))
return;
Vehicle vehicle = new Vehicle(List.Entries[index]);
vehicle.Index = List.Entries.Count;

VehicleEditor editor = new VehicleEditor();
editor.Vehicle = vehicle;
editor.OnDone += Editor_OnDone1;
editor.ShowDialog(this);
}

private void Editor_OnDone1(Vehicle vehicle)
{
List.Entries.Add(vehicle);
Expand All @@ -149,6 +167,7 @@ private void lstVehicles_MouseDoubleClick(object sender, MouseEventArgs e)
private void lstVehicles_SelectedIndexChanged(object sender, EventArgs e)
{
stlStatusLabel.Text = lstVehicles.SelectedItems.Count + " Item(s) Selected";
tsbCopyItem.Enabled = true;
}

private void lstVehicles_ColumnClick(object sender, ColumnClickEventArgs e)
Expand Down Expand Up @@ -237,5 +256,15 @@ private void tsbAddItem_Click(object sender, EventArgs e)
{
AddItem();
}

private void copyItemToolStripMenuItem_Click(object sender, EventArgs e)
{
CopyItem();
}

private void tsbCopyItem_Click(object sender, EventArgs e)
{
CopyItem();
}
}
}
47 changes: 36 additions & 11 deletions VehicleList/VehicleListForm.designer.cs

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

0 comments on commit a8f8628

Please sign in to comment.