Ejemplo n.º 1
0
        private void loadFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                fo = new FileOpener();
                if (!loaded)
                {
                    fo.OpeniniFile();
                    amountOfLines = File.ReadAllLines(fo.bestand).Length-1;
                    Debug.WriteLine(amountOfLines);

                    fs = new FileStream(fo.bestand, FileMode.Open);
                    reader = new StreamReader(fs);

                    versionString = reader.ReadLine();
                    versionTextBox.Text = versionString;

                    this.line = reader.ReadLine();
                    for(int i = 0; i < amountOfLines;i++)
                    {
                        //Debug.WriteLine(i + " " + line);
                        this.itemsArray = line.Split('|');
                        this.item = new Items(itemsArray[0], itemsArray[1], itemsArray[2], itemsArray[3], itemsArray[4], itemsArray[5],
                                              itemsArray[6], itemsArray[7], itemsArray[8], itemsArray[9], itemsArray[10], itemsArray[11],
                                              itemsArray[12], itemsArray[13], itemsArray[14], itemsArray[15], itemsArray[16], itemsArray[17],
                                              itemsArray[18], itemsArray[19], itemsArray[20], itemsArray[21], itemsArray[22], itemsArray[23],
                                              itemsArray[24], itemsArray[25], itemsArray[26], itemsArray[27], itemsArray[28], itemsArray[29],
                                              itemsArray[30], itemsArray[31], itemsArray[32], itemsArray[33], itemsArray[34], itemsArray[35],
                                              itemsArray[36], itemsArray[37], itemsArray[38], itemsArray[39], itemsArray[40], itemsArray[41],
                                              itemsArray[42], itemsArray[43], itemsArray[44], itemsArray[45], itemsArray[46], itemsArray[47],
                                              itemsArray[48], itemsArray[49], itemsArray[50], itemsArray[51], itemsArray[52], itemsArray[53],
                                              itemsArray[54], itemsArray[55], itemsArray[56], itemsArray[57]);
                        this.itemsList.Add(item);
                        this.itemListBox.Items.Add(itemsArray[0] + " - " + itemsArray[7]);
                        this.line = reader.ReadLine();
                    }
                    loaded = true;
                    #region fillInOnLoad
                    textBox01.Text = itemsList[0].ID;
                    textBox02.Text = itemsList[0].Ui_Itemicon;
                    textBox03.Text = itemsList[0].Item_Texture;
                    textBox04.Text = itemsList[0].Item_Model;
                    textBox05.Text = itemsList[0].Empty1;
                    textBox06.Text = itemsList[0].Empty2;
                    textBox07.Text = itemsList[0].Effect_Model;
                    textBox08.Text = itemsList[0].Name;
                    textBox09.Text = itemsList[0].Class;
                    textBox10.Text = itemsList[0].Equip_Type;
                    textBox11.Text = itemsList[0].Unk1;
                    textBox12.Text = itemsList[0].Item_Type;
                    textBox13.Text = itemsList[0].Gender;
                    textBox14.Text = itemsList[0].Level;
                    textBox15.Text = itemsList[0].Empty3;
                    textBox16.Text = itemsList[0].Emblem;
                    textBox17.Text = itemsList[0].Rank;
                    textBox18.Text = itemsList[0].Unk2;
                    textBox19.Text = itemsList[0].Unk3;
                    textBox20.Text = itemsList[0].Unk4;
                    textBox21.Text = itemsList[0].Unk5;
                    textBox22.Text = itemsList[0].Unk6;
                    textBox23.Text = itemsList[0].Unk7;
                    textBox24.Text = itemsList[0].Unk8;
                    textBox25.Text = itemsList[0].Unk9;
                    textBox26.Text = itemsList[0].Unk10;
                    textBox27.Text = itemsList[0].Unk11;
                    textBox28.Text = itemsList[0].Unk12;
                    textBox29.Text = itemsList[0].Unk13;
                    textBox30.Text = itemsList[0].Unk14;
                    textBox31.Text = itemsList[0].Description;
                    textBox32.Text = itemsList[0].Enchant1;
                    textBox33.Text = itemsList[0].Enchant2;
                    textBox34.Text = itemsList[0].Enchant3;
                    textBox35.Text = itemsList[0].Enchant4;
                    textBox36.Text = itemsList[0].Empty4;
                    textBox37.Text = itemsList[0].Unk15;
                    textBox38.Text = itemsList[0].ATK_SPD;
                    textBox39.Text = itemsList[0].DMG;
                    textBox40.Text = itemsList[0].Crit;
                    textBox41.Text = itemsList[0].SP;
                    textBox42.Text = itemsList[0].HP;
                    textBox43.Text = itemsList[0].Def;
                    textBox44.Text = itemsList[0].Eva;
                    textBox45.Text = itemsList[0].Empty5;
                    textBox46.Text = itemsList[0].Empty6;
                    textBox47.Text = itemsList[0].Empty7;
                    textBox48.Text = itemsList[0].Empty8;
                    textBox49.Text = itemsList[0].Empty9;
                    textBox50.Text = itemsList[0].Unk16;
                    textBox51.Text = itemsList[0].Unk17;
                    textBox52.Text = itemsList[0].Unk18;
                    textBox53.Text = itemsList[0].Unk19;
                    textBox54.Text = itemsList[0].Unk20;
                    textBox55.Text = itemsList[0].Unk21;
                    textBox56.Text = itemsList[0].Unk22;
                    textBox57.Text = itemsList[0].Unk23;
                    textBox58.Text = itemsList[0].Unk24;
                    #endregion
                }
                else
                {
                    MessageBox.Show("File is already read in.");
                }
            }
            catch(ArgumentNullException)
            {
                MessageBox.Show("Please select a file.");
            }
            catch(IOException ex)
            {
                DateTime date = DateTime.Now;
                string datum = (date.Day + "/" + date.Month + "/" + date.Year + "   " + date.Hour + ":" + date.Minute + ":" + date.Second).ToString();
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
                errorLog = new FileStream("LoadingError.log", FileMode.Append, FileAccess.Write);
                errorLogWriter = new StreamWriter(errorLog);
                errorLogWriter.WriteLine("-------" + datum + "--------");
                errorLogWriter.WriteLine("------- Start Error Message -------");
                errorLogWriter.WriteLine(ex.Message);
                errorLogWriter.WriteLine();
                errorLogWriter.WriteLine("------- End Error Message -------");
                errorLogWriter.WriteLine();
                errorLogWriter.WriteLine("-------- Start Stacktrace --------");
                errorLogWriter.WriteLine(ex.StackTrace);
                errorLogWriter.WriteLine();
                errorLogWriter.WriteLine("-------- End Stacktrace -----------");
                errorLogWriter.Close();
                MessageBox.Show("An error occured, please check the LoadingError.log in the folder where the ItemEditor program is located.", "Error", MessageBoxButton.OK);
            }
            finally
            {
                if(reader != null)
                {
                    reader.Close();
                }
                if(fs != null)
                {
                    fs.Close();
                }
            }
            
        }
Ejemplo n.º 2
0
 private void AddItem()
 {
     Items i = new Items("00000", "", "", "", "", "", "", "Insertname", "", "",
                                     "", "", "", "", "", "", "", "", "", "",
                                     "", "", "", "", "", "", "", "", "", "",
                                     "", "", "", "", "", "", "", "", "", "",
                                     "", "", "", "", "", "", "", "", "", "",
                                     "", "", "", "", "", "", "", "");
     itemsList.Add(i);
     this.itemListBox.Items.Add(i.ID + " - " + i.Name);
     itemListBox.Items.Refresh();
     itemListBox.SelectedIndex = itemsList.Count-1;
     itemListBox.ScrollIntoView(itemListBox.Items.GetItemAt(itemListBox.Items.Count-1));
 }