Ejemplo n.º 1
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.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            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.º 3
0
 private void OnClickShowFreeSlots(object sender, EventArgs e)
 {
     ShowFreeSlots = !ShowFreeSlots;
     if (ShowFreeSlots)
     {
         listBox.BeginUpdate();
         listBox.Items.Clear();
         List <object> cache = new List <object>();
         for (int i = 0; i < Gumps.GetCount(); ++i)
         {
             cache.Add((object)i);
         }
         listBox.Items.AddRange(cache.ToArray());
         listBox.EndUpdate();
         if (listBox.Items.Count > 0)
         {
             listBox.SelectedIndex = 0;
         }
     }
     else
     {
         OnLoad(null);
     }
 }
Ejemplo n.º 4
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;
                    }
                }
            }
        }