예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (hexText.Text == "" && decText.Text != "")
            {
                int hexValue = int.Parse(decText.Text);
                hexText.Text = IDToHex.idToHex(hexValue);
            }

            if (decText.Text == "" && hexText.Text != "")
            {
                char[] decValue = hexText.Text.ToCharArray();
                HexToID.hexToID(decValue);
                string resultHex = new string(decValue);

                if (resultHex == "FFFF")
                {
                    //isEmpty = true;
                }
                else if (resultHex.EndsWith("0"))
                {
                    resultHex = resultHex.Substring(0, resultHex.Length - 1);
                }

                int resultHex2 = Convert.ToInt32(resultHex, 16);
                decText.Text = resultHex2.ToString();
            }
        }
예제 #2
0
        // Reads offsets for items
        void readOffset(int start, int end, string offset, TextBox textbox = null, TreeNode treeView = null, NumericUpDown itemAmount = null, BinaryReader br = null)
        {
            char[] characters = null;
            for (int i = start; i <= end; i++)
            {
                br.BaseStream.Position = i;
                offset += br.ReadByte().ToString("X2");
            }

            characters = offset.ToCharArray();
            HexToID.hexToID(characters);
            string hexID = new string(characters);

            bool isEmpty = false;

            if (hexID == "FFFF")
            {
                isEmpty = true;
            }
            else if (hexID.EndsWith("0"))
            {
                hexID = hexID.Substring(0, hexID.Length - 1);
            }

            int itemID = Convert.ToInt32(hexID, 16);

            english englishItems = JsonConvert.DeserializeObject <english>(englishJson);

            foreach (var item in englishItems.treasures)
            {
                englishIDs.Add(item.id);
                englishNames.Add(item.name);
                //itemNames.Add(item.name);
            }

            if (textbox != null && isEmpty)
            {
                textbox.Text = null;
            }

            treeView1.BeginUpdate();
            if (treeView != null && isEmpty)
            {
                treeView.Nodes.Add("[Empty]");
            }

            for (int i = 0; i < englishItems.treasures.Count; i++)
            {
                englishIDs.Add(englishItems.treasures[i].id);
                englishNames.Add(englishItems.treasures[i].name);

                if ((textbox != null))
                {
                    int eID = Convert.ToInt32(englishIDs[i]);
                    if (itemID == eID)
                    {
                        textbox.Text = englishNames[i].ToString();
                    }
                }

                if ((treeView != null))
                {
                    int eID = Convert.ToInt32(englishIDs[i]);
                    if (itemID == eID)
                    {
                        treeView.Nodes.Add(englishNames[i].ToString());
                    }
                }
                treeView1.EndUpdate();
            }
            if (itemAmount != null)
            {
                //itemAmount.Tag = itemID;
                tags.Add(itemID);
            }
        }