Exemple #1
0
        private void OnClickReplace(object sender, EventArgs e)
        {
            if (listBox.SelectedItems.Count == 1)
            {
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    dialog.Multiselect     = false;
                    dialog.Title           = "Choose image file to replace";
                    dialog.CheckFileExists = true;
                    dialog.Filter          = "Image files (*.tif;*.tiff;*.bmp)|*.tif;*.tiff;*.bmp";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        Bitmap bmp = new Bitmap(dialog.FileName);
                        if (dialog.FileName.Contains(".bmp"))
                        {
                            bmp = Utils.ConvertBmp(bmp);
                        }

                        int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());
                        Gumps.ReplaceGump(i, bmp);
                        ControlEvents.FireGumpChangeEvent(this, i);
                        listBox.Invalidate();
                        ListBox_SelectedIndexChanged(this, EventArgs.Empty);
                        Options.ChangedUltimaClass["Gumps"] = true;
                    }
                }
            }
        }
        private void OnClickCopy(object sender, EventArgs e)
        {
            if (listBox2.SelectedIndex == -1)
            {
                return;
            }

            int i = (int)listBox2.Items[listBox2.SelectedIndex];

            if (!SecondGump.IsValidIndex(i))
            {
                return;
            }

            Bitmap copy = new Bitmap(SecondGump.GetGump(i));

            Gumps.ReplaceGump(i, copy);
            Options.ChangedUltimaClass["Gumps"] = true;
            ControlEvents.FireGumpChangeEvent(this, i);
            _mCompare[i] = true;
            listBox1.BeginUpdate();
            bool done = false;

            for (int id = 0; id < 0x10000; id++)
            {
                if (id > i)
                {
                    listBox1.Items.Insert(id, i);
                    done = true;
                    break;
                }
                if (id == i)
                {
                    done = true;
                    break;
                }
            }
            if (!done)
            {
                listBox1.Items.Add(i);
            }

            listBox1.EndUpdate();
            listBox1.Invalidate();
            listBox2.Invalidate();
            Listbox_SelectedChange(listBox1, null);
        }
Exemple #3
0
        private void OnClickRemove(object sender, EventArgs e)
        {
            int          i      = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());
            DialogResult result =
                MessageBox.Show($"Are you sure to remove {i}", "Remove",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                Gumps.RemoveGump(i);
                ControlEvents.FireGumpChangeEvent(this, i);
                if (!_showFreeSlots)
                {
                    listBox.Items.RemoveAt(listBox.SelectedIndex);
                }

                pictureBox.BackgroundImage = null;
                listBox.Invalidate();
                Options.ChangedUltimaClass["Gumps"] = true;
            }
        }
        public override void Import(bool direct, ref Dictionary <string, bool> changedClasses)
        {
            if (!Remove)
            {
                Bitmap import = new Bitmap(File);
                if (File.Contains(".bmp"))
                {
                    import = Utils.ConvertBmp(import);
                }
                Ultima.Gumps.ReplaceGump(Index, import);
            }
            else
            {
                Ultima.Gumps.RemoveGump(Index);
            }

            if (!direct)
            {
                ControlEvents.FireGumpChangeEvent(this, Index);
                Options.ChangedUltimaClass["Gumps"] = true;
            }

            changedClasses["Gumps"] = true;
        }