예제 #1
0
 private void nudrcMain(int offset, int bits)
 {         //Sorts main list based on data.
     if ((Control.ModifierKeys & Keys.Control) != Keys.Control)
     {
         return;
     }
     if (sl == null)             //Some error-proofing if you don't have a main list.
     {
         return;
     }
     //int k = nuds.IndexOf((DataNud)sender); //What we should sort by.
     //var dnud = ((DataNud)sender);
     for (int i = 0; i < sl.sItems.Count; i++)
     {
         int x     = sl.sItems[i];
         int value = Bits.getBits(buf, baseAddr + x * entryLen + offset, bits);
         int j     = i;
         while ((j > 0) && (Bits.getBits(buf, (baseAddr + sl.sItems[j - 1] * entryLen) + offset, bits) > value))
         {
             sl.sItems[j] = sl.sItems[j - 1];
             j            = j - 1;
         }
         sl.sItems[j] = x;
     }
     sl.lv.Invalidate();
 }
예제 #2
0
        private void okClick(object sender, EventArgs e)
        {
            lpnl.Hide();
            curList.Focus();
            //int i = ctrls.IndexOf((ButtonL)curList);
            //int value = (int)((ListView)sl2.lv)..SelectedIndex;
            if (sl2.lv.SelectedIndices.Count != 1)
            {
                return;
            }
            int value = sl2.sItems[sl2.lv.SelectedIndices[0]];

            for (int j = 0; j < bits; j += 8)
            {
                buf[addr + (j >> 3)] = (byte)value;
                value >>= 8;
            }
            value = Bits.getBits(buf, addr, bits);
            Text  = Bits.getTextShort(txt, items[value]);           //itemsL[value].ToString();
        }
예제 #3
0
        //private void comboChanged(object sender, EventArgs e)
        //{
        //	int i = ctrls.IndexOf((ComboBox)sender);
        //	int value = (int)((ComboBox)sender).SelectedIndex;
        //	for (int j = 0; j < bits[i]; j += 8)
        //	{
        //		buf[entryAddr + offsets[i] + (j >> 3)] = (byte)value;
        //		value >>= 8;
        //	}
        //}

        private void comboKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            //base.comboKeyDown(e);
            //base.OnKeyDown(e);
            //e..Handled = true;
            int value = Bits.getBits(buf, addr, bits);

            switch (e.KeyCode)
            {
            //case Keys.Left:
            //case Keys.Right:
            case Keys.Up:
                if (value <= 0)
                {
                    break;
                }
                Bits.setBits(buf, addr, bits, --value);
                Text = Bits.getTextShort(txt, sl2.mItems[sl2.sItems[value]]);                         //itemsL[value].ToString();
                break;

            case Keys.Down:
                if (value >= items.Count() - 1)
                {
                    break;
                }
                Bits.setBits(buf, addr, bits, ++value);
                Text = Bits.getTextShort(txt, sl2.mItems[sl2.sItems[value]]);                         //itemsL[value].ToString();
                break;
            }
            //int value = (int)((ComboBox)sender).SelectedIndex;
            //for (int j = 0; j < bits[i]; j += 8)
            //{
            //	buf[entryAddr + offsets[i] + (j >> 3)] = (byte)value;
            //	value >>= 8;
            //}
        }
예제 #4
0
        public void loadEntry(object sender, EventArgs e)
        {
            int srcEntry   = 0;
            int entryAddr2 = entryAddr;

            if (sender != null)
            {
                ListView lv = ((ListView)sender);
                if (lv.SelectedIndices.Count != 1)
                {
                    return;
                }
                srcEntry   = sl.sItems[lv.SelectedIndices[0]];              //sortList[lv.SelectedIndices[0]];
                entryAddr2 = baseAddr + srcEntry * entryLen;

                //I want copy/paste entire entries functionality! Yay!
                if (entryAddr != 0)                 //Ensuring that there is an item to copy. Also prevents CtrL+Shift form load bug because an item is selected on form load.
                {
                    if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                    {
                        if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                        {
                            for (int i = 0; i < entryLen; i++)
                            {
                                buf[entryAddr2 + i] = buf[entryAddr + i];
                            }
                        }
                    }
                }
                if (entryLen != 0)                 // Entry length is "0" for text editor at present.
                {
                    cntAddr.Text = (0x8000000 | entryAddr2).ToString("X8");
                }
            }
            else
            {
                entryAddr = baseAddr;
            }
            //int ind = ((ListBox)pnl.Controls[0]).SelectedIndex;
            //int addr = 0xEDACC + ind * 0x1C;
            //pnl.Controls[1].Text = (0x8000000 | addr).ToString("X8");
            for (int i = 0; i < nuds.Count; i++)
            {
                nuds[i].addr  = nuds[i].addr - entryAddr + entryAddr2;
                nuds[i].Value = Bits.getBits(nuds[i].buf, nuds[i].addr, nuds[i].bits);                 //nuds[i].getData();
            }
            for (int i = 0; i < butls.Count; i++)
            {
                butls[i].addr = butls[i].addr - entryAddr + entryAddr2;
                butls[i].Text = Bits.getTextShort(butls[i].txt, butls[i].items[Bits.getBits(butls[i].buf, butls[i].addr, butls[i].bits)]);
                //butls[i].itemsL[Bits.getBits(butls[i].buf, butls[i].addr, butls[i].bits)].ToString();
                //butls[i].Text = Bits.getTextLong(txt, Bits.getBits(butls[i].buf, butls[i].addr, butls[i].bits));
            }
            for (int i = 0; i < dtbs.Count; i++)
            {
                dtbs[i].theIndex = dtbs[i].baseIndex + srcEntry;
                dtbs[i].tbx.Text = Bits.getTextLong(dtbs[i].txt, dtbs[i].theIndex);
            }
            entryAddr = entryAddr2;
            //for (int i = 0; i < ctrls.Count; i++)
            //{
            //	if (ctrls[i].GetType() == typeof(ComboBox))
            //	{
            //		((ComboBox)ctrls[i]).SelectedIndex = Bits.getBits(buf, entryAddr + offsets[i], bits[i]);
            //	}
            //	if (ctrls[i].GetType() == typeof(ButtonL))
            //	{
            //		((ButtonL)ctrls[i]).Text = itemsL[i][Bits.getBits(buf, entryAddr + offsets[i], bits[i])].ToString();
            //	}
            //	if (ctrls[i].GetType() == typeof(TextBox))
            //	{
            //		((TextBox)ctrls[i]).Text = Bits.getTextLong(txt, theIndex + srcEntry);
            //	}
            //}
        }