void SaveFleet(string path, ShipLoaderListView lv)
        {
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            Dictionary <string, int> shipListing = new Dictionary <string, int>();

            for (int pos = 0; pos < lv.Items.Count; ++pos)
            {
                string name = lv.Items[pos].Text;
                if (shipListing.ContainsKey(name))
                {
                    shipListing[name] += 1;
                }
                else
                {
                    shipListing[name] = 1;
                }
            }
            ShipCount[] array = new ShipCount[shipListing.Count];
            int         index = 0;

            foreach (KeyValuePair <string, int> pair in shipListing)
            {
                array[index++] = new ShipCount(pair.Key, pair.Value);
            }
            using (FileStream stream = File.Create(path))
            {
                shipCountArrayXmlSerializer.Serialize(stream, array);
            }
        }
 void LoadFleet(string path, ShipLoaderListView lv)
 {
     if (!File.Exists(path))
     {
         return;
     }
     ShipCount[] array = null;
     using (FileStream stream = File.OpenRead(path))
     {
         array = (ShipCount[])shipCountArrayXmlSerializer.Deserialize(stream);
     }
     lv.Items.Clear();
     foreach (ShipCount shipcount in array)
     {
         foreach (ListViewItem storeItem in this.lvGeneralShipLoaders.Items)
         {
             if (storeItem.Text == shipcount.ShipName)
             {
                 for (int pos = 0; pos < shipcount.Count; ++pos)
                 {
                     lv.Items.Add((ListViewItem)storeItem.Clone());
                 }
                 break;
             }
         }
     }
     RecalcPlayer2();
     RecalcPlayer1();
 }
 void SaveFleet(ShipLoaderListView lv)
 {
     if ((this.saveFileDialog1.ShowDialog(this) & DialogResult.OK) == DialogResult.OK)
     {
         SaveFleet(this.saveFileDialog1.FileName, lv);
         this.openFileDialog1.FileName = this.saveFileDialog1.FileName;
     }
 }
        private int GetTotalValue(ShipLoaderListView lv)
        {
            int total = 0;

            foreach (ListViewItem item in lv.Items)
            {
                ShipLoader loader = (ShipLoader)item.Tag;
                total += loader.Info.PointValue;
            }
            return(total);
        }
        private void lvPlayer1Ships_ItemDrag(object sender, ItemDragEventArgs e)
        {
            ShipLoaderListView lv = (ShipLoaderListView)sender;

            DragDropEffects effect = lv.DoDragDrop(lv.SelectedItems, DragDropEffects.Copy);

            foreach (ListViewItem item in lv.SelectedItems)
            {
                lv.Items.Remove(item);
            }
        }
        private void lvPlayer2Ships_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(SLWIC)))
            {
                ShipLoaderListView lv = (ShipLoaderListView)sender;
                SLWIC cool            = (SLWIC)e.Data.GetData(typeof(SLWIC));
                foreach (ListViewItem item in cool)
                {
                    lv.Items.Add((ListViewItem)item.Clone());
                }
                lv.Refresh();

                RecalcPlayer1();
                RecalcPlayer2();
            }
        }
 private void SetPointTotalValue(ShipLoaderListView lv, TextBox box)
 {
     box.Text = GetTotalValue(lv).ToString();
 }