Example #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lvEnh.SelectedIndices.Count <= 0)
            {
                return;
            }
            //Console.WriteLine(lvEnh.SelectedItems[0].SubItems[6].Text);
            var selectedIndex = DatabaseAPI.GetEnhancementByUIDName(lvEnh.SelectedItems[0].SubItems[5].Text);

            //var selectedIndex = DatabaseAPI.GetEnhancementByName(lvEnh.SelectedItems[0].SubItems[6].Text);
            using var frmEnhData = new frmEnhData(ref DatabaseAPI.Database.Enhancements[selectedIndex], 0);
            frmEnhData.ShowDialog();
            if (frmEnhData.DialogResult != DialogResult.OK)
            {
                return;
            }
            var newEnhancement = new Enhancement(frmEnhData.myEnh)
            {
                IsModified = true
            };

            DatabaseAPI.Database.Enhancements[lvEnh.SelectedIndices[0]] = newEnhancement;
            ImageUpdate();
            UpdateListItem(selectedIndex);
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IEnhancement iEnh = new Enhancement();

            using var frmEnhData = new frmEnhData(ref iEnh,
                                                  DatabaseAPI.Database.Enhancements[DatabaseAPI.Database.Enhancements.Length - 1].StaticIndex + 1);
            var num = (int)frmEnhData.ShowDialog();

            if (frmEnhData.DialogResult != DialogResult.OK)
            {
                return;
            }
            var database         = DatabaseAPI.Database;
            var enhancementArray = (IEnhancement[])Utils.CopyArray(database.Enhancements,
                                                                   new IEnhancement[DatabaseAPI.Database.Enhancements.Length + 1]);

            database.Enhancements = enhancementArray;
            var newEnhancement = new Enhancement(frmEnhData.myEnh)
            {
                IsNew = true
            };

            DatabaseAPI.Database.Enhancements[DatabaseAPI.Database.Enhancements.Length - 1] = newEnhancement;
            if (newEnhancement.nIDSet > 0)
            {
                var es = DatabaseAPI.Database.EnhancementSets[newEnhancement.nIDSet];
                Array.Resize(ref es.Enhancements, es.Enhancements.Length + 1);
                es.Enhancements[es.Enhancements.Length - 1] = newEnhancement.StaticIndex;
            }

            ImageUpdate();
            AddListItem(DatabaseAPI.Database.Enhancements.Length - 1);
        }
Example #3
0
        private void btnClone_Click(object sender, EventArgs e)
        {
            if (lvEnh.SelectedIndices.Count <= 0)
            {
                return;
            }
            var oldEnhancement =
                DatabaseAPI.Database.Enhancements[
                    DatabaseAPI.GetEnhancementByUIDName(lvEnh.SelectedItems[0].SubItems[5].Text)];

            using var frmEnhData = new frmEnhData(ref oldEnhancement,
                                                  DatabaseAPI.Database.Enhancements[DatabaseAPI.Database.Enhancements.Length - 1].StaticIndex + 1);
            var num = (int)frmEnhData.ShowDialog();

            if (frmEnhData.DialogResult != DialogResult.OK)
            {
                return;
            }
            var database         = DatabaseAPI.Database;
            var enhancementArray = (IEnhancement[])Utils.CopyArray(database.Enhancements,
                                                                   new IEnhancement[DatabaseAPI.Database.Enhancements.Length + 1]);

            database.Enhancements = enhancementArray;
            DatabaseAPI.Database.Enhancements[DatabaseAPI.Database.Enhancements.Length - 1] =
                new Enhancement(frmEnhData.myEnh)
            {
                IsNew = true, StaticIndex = -1
            };
            ImageUpdate();
            AddListItem(DatabaseAPI.Database.Enhancements.Length - 1);
        }