Ejemplo n.º 1
0
        private void OnClickFindFree(object sender, EventArgs e)
        {
            int id = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());

            ++id;
            for (int i = listBox.SelectedIndex + 1; i < listBox.Items.Count; ++i, ++id)
            {
                if (id < int.Parse(listBox.Items[i].ToString()))
                {
                    listBox.SelectedIndex = i;
                    break;
                }

                if (!_showFreeSlots)
                {
                    continue;
                }

                if (!Gumps.IsValidIndex(int.Parse(listBox.Items[i].ToString())))
                {
                    listBox.SelectedIndex = i;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Options.LoadedUltimaClass["Gumps"] = true;
            ShowFreeSlots = false;
            showFreeSlotsToolStripMenuItem.Checked = false;

            listBox.BeginUpdate();
            listBox.Items.Clear();
            List <object> cache = new List <object>();

            for (int i = 0; i < Gumps.GetCount(); ++i)
            {
                if (Gumps.IsValidIndex(i))
                {
                    cache.Add((object)i);
                }
            }
            listBox.Items.AddRange(cache.ToArray());
            listBox.EndUpdate();
            if (listBox.Items.Count > 0)
            {
                listBox.SelectedIndex = 0;
            }
            if (!Loaded)
            {
                FiddlerControls.Events.FilePathChangeEvent += new FiddlerControls.Events.FilePathChangeHandler(OnFilePathChangeEvent);
                FiddlerControls.Events.GumpChangeEvent     += new FiddlerControls.Events.GumpChangeHandler(OnGumpChangeEvent);
            }
            Loaded         = true;
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 3
0
        private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());

            if (Gumps.IsValidIndex(i))
            {
                Bitmap bmp = Gumps.GetGump(i);
                if (bmp != null)
                {
                    pictureBox.BackgroundImage = bmp;
                    IDLabel.Text   = $"ID: 0x{i:X} ({i})";
                    SizeLabel.Text = $"Size: {bmp.Width},{bmp.Height}";
                }
                else
                {
                    pictureBox.BackgroundImage = null;
                }
            }
            else
            {
                pictureBox.BackgroundImage = null;
            }

            listBox.Invalidate();
            JumpToMaleFemaleInvalidate();
        }
Ejemplo n.º 4
0
        private void listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());

            if (Gumps.IsValidIndex(i))
            {
                Bitmap bmp = Gumps.GetGump(i);
                if (bmp != null)
                {
                    pictureBox.BackgroundImage = bmp;
                    IDLabel.Text   = String.Format("ID: 0x{0:X} ({1})", i, i);
                    SizeLabel.Text = String.Format("Size: {0},{1}", bmp.Width, bmp.Height);
                }
                else
                {
                    pictureBox.BackgroundImage = null;
                }
            }
            else
            {
                pictureBox.BackgroundImage = null;
            }
            listBox.Invalidate();
            jumpToMaleFemaleInvalidate();
        }
Ejemplo n.º 5
0
        private void PopulateListBox(bool showOnlyValid)
        {
            listBox.BeginUpdate();
            listBox.Items.Clear();

            List <object> cache = new List <object>();

            for (int i = 0; i < Gumps.GetCount(); ++i)
            {
                if (showOnlyValid)
                {
                    if (Gumps.IsValidIndex(i))
                    {
                        cache.Add(i);
                    }
                }
                else
                {
                    cache.Add(i);
                }
            }

            listBox.Items.AddRange(cache.ToArray());
            listBox.EndUpdate();

            if (listBox.Items.Count > 0)
            {
                listBox.SelectedIndex = 0;
            }
        }
Ejemplo n.º 6
0
        private void OnGumpChangeEvent(object sender, int index)
        {
            if (!_loaded)
            {
                return;
            }

            if (sender.Equals(this))
            {
                return;
            }

            if (Gumps.IsValidIndex(index))
            {
                bool done = false;
                for (int i = 0; i < listBox.Items.Count; ++i)
                {
                    int j = int.Parse(listBox.Items[i].ToString());
                    if (j > index)
                    {
                        listBox.Items.Insert(i, index);
                        listBox.SelectedIndex = i;
                        done = true;
                        break;
                    }

                    if (j == index)
                    {
                        done = true;
                        break;
                    }
                }

                if (!done)
                {
                    listBox.Items.Add(index);
                }
            }
            else
            {
                for (int i = 0; i < listBox.Items.Count; ++i)
                {
                    int j = int.Parse(listBox.Items[i].ToString());
                    if (j == index)
                    {
                        listBox.Items.RemoveAt(i);
                        break;
                    }
                }

                listBox.Invalidate();
            }
        }
Ejemplo n.º 7
0
        private void Listbox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox listBox = (ListBox)sender;

            if (e.Index < 0)
            {
                return;
            }

            Brush fontBrush = Brushes.Gray;

            int i = (int)listBox.Items[e.Index];

            if (listBox.SelectedIndex == e.Index)
            {
                e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
            }

            bool valid = (int)listBox.Tag == 1 ? Gumps.IsValidIndex(i) : SecondGump.IsValidIndex(i);

            if (valid)
            {
                Bitmap bmp = (int)listBox.Tag == 1 ? Gumps.GetGump(i) : SecondGump.GetGump(i);

                if (bmp != null)
                {
                    if (listBox2.Items.Count > 0)
                    {
                        if (!Compare(i))
                        {
                            fontBrush = Brushes.Blue;
                        }
                    }
                    int width  = bmp.Width > 80 ? 80 : bmp.Width;
                    int height = bmp.Height > 54 ? 54 : bmp.Height;

                    e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 3, e.Bounds.Y + 3, width, height));
                }
                else
                {
                    fontBrush = Brushes.Red;
                }
            }
            else
            {
                fontBrush = Brushes.Red;
            }

            e.Graphics.DrawString($"0x{i:X}", Font, fontBrush,
                                  new PointF(85,
                                             e.Bounds.Y + ((e.Bounds.Height / 2) -
                                                           (e.Graphics.MeasureString($"0x{i:X}", Font).Height / 2))));
        }
Ejemplo n.º 8
0
        private void ListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            Brush fontBrush = _brushGray;

            int i = int.Parse(listBox.Items[e.Index].ToString());

            if (Gumps.IsValidIndex(i))
            {
                Bitmap bmp = Gumps.GetGump(i, out bool patched);

                if (bmp != null)
                {
                    int width  = bmp.Width > 100 ? 100 : bmp.Width;
                    int height = bmp.Height > 54 ? 54 : bmp.Height;

                    if (listBox.SelectedIndex == e.Index)
                    {
                        e.Graphics.FillRectangle(_brushLightSteelBlue, e.Bounds.X, e.Bounds.Y, 105, 60);
                    }
                    else if (patched)
                    {
                        e.Graphics.FillRectangle(_brushLightCoral, e.Bounds.X, e.Bounds.Y, 105, 60);
                    }

                    e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 3, e.Bounds.Y + 3, width, height));
                }
                else
                {
                    fontBrush = _brushRed;
                }
            }
            else
            {
                if (listBox.SelectedIndex == e.Index)
                {
                    e.Graphics.FillRectangle(_brushLightSteelBlue, e.Bounds.X, e.Bounds.Y, 105, 60);
                }

                fontBrush = _brushRed;
            }

            e.Graphics.DrawString($"0x{i:X} ({i})", Font, fontBrush,
                                  new PointF(105,
                                             e.Bounds.Y + ((e.Bounds.Height / 2) -
                                                           (e.Graphics.MeasureString($"0x{i:X} ({i})", Font).Height / 2))));
        }
Ejemplo n.º 9
0
 private void onKeyDownGump(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         int index;
         if (Utils.ConvertStringToInt(TextBoxGump.Text, out index, 0, 0xFFFE))
         {
             if (!Gumps.IsValidIndex(index))
             {
                 return;
             }
             contextMenuStrip1.Close();
             preview = Gumps.GetGump(index);
             RefreshPreview();
         }
     }
 }
Ejemplo n.º 10
0
        protected override void OnLoad(EventArgs e)
        {
            if (FormsDesignerHelper.IsInDesignMode())
            {
                return;
            }

            if (_loaded)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            Options.LoadedUltimaClass["Gumps"] = true;
            _showFreeSlots = false;
            showFreeSlotsToolStripMenuItem.Checked = false;

            listBox.BeginUpdate();
            listBox.Items.Clear();
            List <object> cache = new List <object>();

            for (int i = 0; i < Gumps.GetCount(); ++i)
            {
                if (Gumps.IsValidIndex(i))
                {
                    cache.Add(i);
                }
            }

            listBox.Items.AddRange(cache.ToArray());
            listBox.EndUpdate();
            if (listBox.Items.Count > 0)
            {
                listBox.SelectedIndex = 0;
            }

            if (!_loaded)
            {
                ControlEvents.FilePathChangeEvent += OnFilePathChangeEvent;
                ControlEvents.GumpChangeEvent     += OnGumpChangeEvent;
            }

            _loaded        = true;
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 11
0
        private void onTextChanged_InsertAt(object sender, EventArgs e)
        {
            int index;

            if (Utils.ConvertStringToInt(InsertText.Text, out index, 0, Gumps.GetCount()))
            {
                if (Gumps.IsValidIndex(index))
                {
                    InsertText.ForeColor = Color.Red;
                }
                else
                {
                    InsertText.ForeColor = Color.Black;
                }
            }
            else
            {
                InsertText.ForeColor = Color.Red;
            }
        }
Ejemplo n.º 12
0
        private void onTextChangedGump(object sender, EventArgs e)
        {
            int index;

            if (Utils.ConvertStringToInt(TextBoxGump.Text, out index, 0, 0xFFFE))
            {
                if (Gumps.IsValidIndex(index))
                {
                    TextBoxGump.ForeColor = Color.Black;
                }
                else
                {
                    TextBoxGump.ForeColor = Color.Red;
                }
            }
            else
            {
                TextBoxGump.ForeColor = Color.Red;
            }
        }
Ejemplo n.º 13
0
        private void onKeydown_InsertText(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            int index;

            if (Utils.ConvertStringToInt(InsertText.Text, out index, 0, Gumps.GetCount()))
            {
                if (Gumps.IsValidIndex(index))
                {
                    return;
                }
                contextMenuStrip1.Close();
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    dialog.Multiselect     = false;
                    dialog.Title           = String.Format("Choose image file to insert at 0x{0:X}", index);
                    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);
                        }
                        Gumps.ReplaceGump(index, bmp);
                        FiddlerControls.Events.FireGumpChangeEvent(this, index);
                        bool done = false;
                        for (int i = 0; i < listBox.Items.Count; ++i)
                        {
                            int j = int.Parse(listBox.Items[i].ToString());
                            if (j > index)
                            {
                                listBox.Items.Insert(i, index);
                                listBox.SelectedIndex = i;
                                done = true;
                                break;
                            }
                            else if (ShowFreeSlots)
                            {
                                if (j == i)
                                {
                                    listBox.SelectedIndex = i;
                                    done = true;
                                    break;
                                }
                            }
                        }
                        if (!done)
                        {
                            listBox.Items.Add(index);
                            listBox.SelectedIndex = listBox.Items.Count - 1;
                        }
                        Options.ChangedUltimaClass["Gumps"] = true;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void listbox_SelectedChange(object sender, EventArgs e)
        {
            ListBox listBox = (ListBox)sender;

            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            int  i = (int)listBox.Items[listBox.SelectedIndex];
            bool valid;

            if ((int)listBox.Tag == 1)
            {
                valid = Gumps.IsValidIndex(i);
                if (listBox2.Items.Count > 0)
                {
                    listBox2.SelectedIndex = listBox2.Items.IndexOf(i);
                }
            }
            else
            {
                valid = SecondGump.IsValidIndex(i);
                listBox1.SelectedIndex = listBox1.Items.IndexOf(i);
            }
            if (valid)
            {
                Bitmap bmp;
                if ((int)listBox.Tag == 1)
                {
                    bmp = Gumps.GetGump(i);
                }
                else
                {
                    bmp = SecondGump.GetGump(i);
                }

                if (bmp != null)
                {
                    if ((int)listBox.Tag == 1)
                    {
                        pictureBox1.BackgroundImage = bmp;
                    }
                    else
                    {
                        pictureBox2.BackgroundImage = bmp;
                    }
                }
                else
                {
                    if ((int)listBox.Tag == 1)
                    {
                        pictureBox1.BackgroundImage = null;
                    }
                    else
                    {
                        pictureBox2.BackgroundImage = null;
                    }
                }
            }
            else
            {
                if ((int)listBox.Tag == 1)
                {
                    pictureBox1.BackgroundImage = null;
                }
                else
                {
                    pictureBox2.BackgroundImage = null;
                }
            }
            listBox.Invalidate();
        }