From a8f862869f903d44cd9e5c3db8b910357159a017 Mon Sep 17 00:00:00 2001 From: burninrubber0 Date: Mon, 4 Apr 2022 12:39:16 -0400 Subject: [PATCH] Copy functionality for VehicleList --- VehicleList/Properties/Resources.Designer.cs | 12 ++++- VehicleList/Properties/Resources.resx | 3 ++ VehicleList/Resources/CopyHS.png | Bin 0 -> 643 bytes VehicleList/VehicleList.csproj | 3 ++ VehicleList/VehicleListForm.cs | 29 ++++++++++++ VehicleList/VehicleListForm.designer.cs | 47 ++++++++++++++----- 6 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 VehicleList/Resources/CopyHS.png diff --git a/VehicleList/Properties/Resources.Designer.cs b/VehicleList/Properties/Resources.Designer.cs index e39c8fc..3da6073 100644 --- a/VehicleList/Properties/Resources.Designer.cs +++ b/VehicleList/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace VehicleList.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -70,6 +70,16 @@ internal static System.Drawing.Bitmap AddTableHS { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap CopyHS { + get { + object obj = ResourceManager.GetObject("CopyHS", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/VehicleList/Properties/Resources.resx b/VehicleList/Properties/Resources.resx index d9c1284..00f4371 100644 --- a/VehicleList/Properties/Resources.resx +++ b/VehicleList/Properties/Resources.resx @@ -124,4 +124,7 @@ ..\Resources\EditTableHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\CopyHS.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/VehicleList/Resources/CopyHS.png b/VehicleList/Resources/CopyHS.png new file mode 100644 index 0000000000000000000000000000000000000000..cb3d8717a1f2b4efbbfda4dda7c7b2b666c0249a GIT binary patch literal 643 zcmV-}0(||6P)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ-`AI}URCwB?lRaotQ5c4w+r}yux;P1r6#`Xkk?K-^ zK#FZes31X*fvP`c`_A!1ghrBhmi;0C#u@;$iizWx9}BsGGwFj9|0RsS`7D3u?$a4L zap}J77)W=D2&x3W-IJ|Ego0A>0I}cU^#a^i&%{_Q5NtL#u&7=Tz#IyFDbM(#9EWw&ZO{AL1euw}Vc^I%<2v`bBgp~>a{T&XhUIFx` zPS*ME?mq>=MI6ectd;UmYNG<*fi5zwxzp^Y83W z3gXO4gMXzML{wtO-u3_yhd76bt-e6#5T{oM_@QF^(MJF{6XA@)8I3rFSdF;qcDzP^ dV-pSL*8r9tU~{m$x5NMd002ovPDHLkV1oE^7W@DJ literal 0 HcmV?d00001 diff --git a/VehicleList/VehicleList.csproj b/VehicleList/VehicleList.csproj index 1ff4026..a2d6538 100644 --- a/VehicleList/VehicleList.csproj +++ b/VehicleList/VehicleList.csproj @@ -99,6 +99,9 @@ + + + xcopy "$(TargetPath)" "$(SolutionDir)BundleManager\bin\$(ConfigurationName)\plugins\" /s /e /y diff --git a/VehicleList/VehicleListForm.cs b/VehicleList/VehicleListForm.cs index c27af20..648053f 100644 --- a/VehicleList/VehicleListForm.cs +++ b/VehicleList/VehicleListForm.cs @@ -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); @@ -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) @@ -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(); + } } } diff --git a/VehicleList/VehicleListForm.designer.cs b/VehicleList/VehicleListForm.designer.cs index b9d97ed..01dd42f 100644 --- a/VehicleList/VehicleListForm.designer.cs +++ b/VehicleList/VehicleListForm.designer.cs @@ -30,7 +30,6 @@ private void InitializeComponent() { this.mnuMain = new System.Windows.Forms.MenuStrip(); this.itemsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.lstVehicles = new System.Windows.Forms.ListView(); this.colIndex = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.colVehicleID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -70,6 +69,9 @@ private void InitializeComponent() this.stlStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.tsbAddItem = new System.Windows.Forms.ToolStripButton(); + this.tsbCopyItem = new System.Windows.Forms.ToolStripButton(); + this.addItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mnuMain.SuspendLayout(); this.stsMain.SuspendLayout(); this.toolStrip1.SuspendLayout(); @@ -88,19 +90,12 @@ private void InitializeComponent() // itemsToolStripMenuItem // this.itemsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addItemToolStripMenuItem}); + this.addItemToolStripMenuItem, + this.copyItemToolStripMenuItem}); this.itemsToolStripMenuItem.Name = "itemsToolStripMenuItem"; this.itemsToolStripMenuItem.Size = new System.Drawing.Size(48, 20); this.itemsToolStripMenuItem.Text = "Items"; // - // addItemToolStripMenuItem - // - this.addItemToolStripMenuItem.Image = global::VehicleList.Properties.Resources.AddTableHS; - this.addItemToolStripMenuItem.Name = "addItemToolStripMenuItem"; - this.addItemToolStripMenuItem.Size = new System.Drawing.Size(123, 22); - this.addItemToolStripMenuItem.Text = "Add Item"; - this.addItemToolStripMenuItem.Click += new System.EventHandler(this.addItemToolStripMenuItem_Click); - // // lstVehicles // this.lstVehicles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -317,7 +312,8 @@ private void InitializeComponent() // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tsbAddItem}); + this.tsbAddItem, + this.tsbCopyItem}); this.toolStrip1.Location = new System.Drawing.Point(0, 24); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(1079, 25); @@ -334,6 +330,33 @@ private void InitializeComponent() this.tsbAddItem.Text = "Add Item"; this.tsbAddItem.Click += new System.EventHandler(this.tsbAddItem_Click); // + // tsbCopyItem + // + this.tsbCopyItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbCopyItem.Enabled = false; + this.tsbCopyItem.Image = global::VehicleList.Properties.Resources.CopyHS; + this.tsbCopyItem.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tsbCopyItem.Name = "tsbCopyItem"; + this.tsbCopyItem.Size = new System.Drawing.Size(23, 22); + this.tsbCopyItem.Text = "Copy Item"; + this.tsbCopyItem.Click += new System.EventHandler(this.tsbCopyItem_Click); + // + // addItemToolStripMenuItem + // + this.addItemToolStripMenuItem.Image = global::VehicleList.Properties.Resources.AddTableHS; + this.addItemToolStripMenuItem.Name = "addItemToolStripMenuItem"; + this.addItemToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + this.addItemToolStripMenuItem.Text = "Add Item"; + this.addItemToolStripMenuItem.Click += new System.EventHandler(this.addItemToolStripMenuItem_Click); + // + // copyItemToolStripMenuItem + // + this.copyItemToolStripMenuItem.Image = global::VehicleList.Properties.Resources.CopyHS; + this.copyItemToolStripMenuItem.Name = "copyItemToolStripMenuItem"; + this.copyItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.copyItemToolStripMenuItem.Text = "Copy Item"; + this.copyItemToolStripMenuItem.Click += new System.EventHandler(this.copyItemToolStripMenuItem_Click); + // // VehicleListForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -401,6 +424,8 @@ private void InitializeComponent() private System.Windows.Forms.ColumnHeader colTopSpeedBoost; private System.Windows.Forms.ColumnHeader colDamageLimit; private System.Windows.Forms.ColumnHeader colColorPalette; + private System.Windows.Forms.ToolStripButton tsbCopyItem; + private System.Windows.Forms.ToolStripMenuItem copyItemToolStripMenuItem; } }