private void bindingNavigatorAddNewItem2_Click(object sender, EventArgs e) { // save current changes prior to adding new elements if (innerControl != null) { innerControl.CommitChanges(); } if (Element != null) { var bytes = new byte[0]; switch (Element.type) { case ElementValueType.SByte: case ElementValueType.Byte: case ElementValueType.String: case ElementValueType.LString: bytes = new byte[1]; break; case ElementValueType.Float: case ElementValueType.Str4: case ElementValueType.FormID: case ElementValueType.UInt: case ElementValueType.Int: case ElementValueType.IString: bytes = new byte[4]; break; case ElementValueType.Short: case ElementValueType.UShort: case ElementValueType.BString: bytes = new byte[2]; break; } elements.Add(new ArraySegment <byte>(bytes)); } else { elements.Add(default(ArraySegment <byte>)); } try { inUpdatePosition = true; bs.MoveLast(); } finally { inUpdatePosition = false; } }
private void listView1_DragDrop(object sender, DragEventArgs e) { int toswap = (int)e.Data.GetData(typeof(int)) - 1; if (toswap == -1) { return; } var rec = Selection.Record as Record; SubRecord sr = subrecords[toswap]; if (listSubrecord.SelectedIndices.Count == 0) { subrecords.RemoveAt(toswap); subrecords.Add(sr); } else if (listSubrecord.SelectedIndices.Count >= 1) { int moveto = listSubrecord.SelectedIndices[0]; if (toswap == moveto) { return; } subrecords.RemoveAt(toswap); subrecords.Insert(moveto, sr); } else { return; } RebuildSelection(); return; }
private void PopulateStrings() { if (Plugins == null) { return; } foreach (var plugin in Plugins) { foreach (var kvp in plugin.Strings) { strings.Add(new StringHolder { ID = kvp.Key, Plugin = plugin, Value = kvp.Value, Format = LocalizedStringFormat.Base } ); } foreach (var kvp in plugin.ILStrings) { strings.Add(new StringHolder { ID = kvp.Key, Plugin = plugin, Value = kvp.Value, Format = LocalizedStringFormat.IL } ); } foreach (var kvp in plugin.DLStrings) { strings.Add(new StringHolder { ID = kvp.Key, Plugin = plugin, Value = kvp.Value, Format = LocalizedStringFormat.DL } ); } } }
public override void AddRecord(BaseRecord br) { var sr = br as SubRecord; if (sr == null) { throw new TESParserException("Record to add was not of the correct type." + Environment.NewLine + "Records can only hold Subrecords."); } sr.Parent = this; SubRecords.Add(sr); }
internal Record(string name, uint Size, BinaryReader br, bool Oblivion) { bool compressedRecord = false; SubRecords = new AdvancedList <SubRecord>(1); SubRecords.AllowSorting = false; Name = name; Flags1 = br.ReadUInt32(); FormID = br.ReadUInt32(); Flags2 = br.ReadUInt32(); if (!Oblivion) { Flags3 = br.ReadUInt32(); } if ((Flags1 & 0x00040000) > 0) { //Flags1 ^= 0x00040000; uint newSize = br.ReadUInt32(); br = Decompressor.Decompress(br, (int)(Size - 4), (int)newSize); Size = newSize; compressedRecord = true; } uint AmountRead = 0; while (AmountRead < Size) { string s = ReadRecName(br); uint i = 0; if (s == "XXXX") { ushort xsize = br.ReadUInt16(); if (xsize != 4) { throw new TESParserException( String.Format("Unexpected Subrecord block XXXX size! Expected 4 but found {0:D}!", xsize)); } i = br.ReadUInt32(); s = ReadRecName(br); } var r = new SubRecord(this, s, br, i); AmountRead += (uint)(r.Size2); SubRecords.Add(r); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; if (AmountRead != Size) { System.Windows.Forms.Application.Exit(); // throw new TESParserException( // String.Format("Subrecord block did not match the size specified in the record header. Name={3} Header size={0:D} Subrecord Size={1:D} CompressedRecord={2:G}", Size, AmountRead, compressedRecord, name)); } }
private Record(Record r) { SubRecords = new AdvancedList <SubRecord>(r.SubRecords.Count); SubRecords.AllowSorting = false; foreach (var sr in r.SubRecords.OfType <SubRecord>()) { SubRecords.Add((SubRecord)sr.Clone()); } Flags1 = r.Flags1; Flags2 = r.Flags2; Flags3 = r.Flags3; FormID = r.FormID; Name = r.Name; descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); FixSubrecordOwner(); }
internal Record(string name, uint Size, BinaryReader br, bool Oblivion) { SubRecords = new AdvancedList <SubRecord>(1); SubRecords.AllowSorting = false; Name = name; Flags1 = br.ReadUInt32(); FormID = br.ReadUInt32(); Flags2 = br.ReadUInt32(); if (!Oblivion) { Flags3 = br.ReadUInt32(); } if ((Flags1 & 0x00040000) > 0) { //Flags1 ^= 0x00040000; uint newSize = br.ReadUInt32(); br = Decompressor.Decompress(br, (int)(Size - 4), (int)newSize); Size = newSize; } uint AmountRead = 0; while (AmountRead < Size) { string s = ReadRecName(br); uint i = 0; if (s == "XXXX") { br.ReadUInt16(); i = br.ReadUInt32(); s = ReadRecName(br); } var r = new SubRecord(this, s, br, i); AmountRead += (uint)(r.Size2); SubRecords.Add(r); } if (AmountRead > Size) { throw new TESParserException("Subrecord block did not match the size specified in the record header"); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; }
public AdvancedList<SheetDTO> GetSheetDTOByDate(DateTime date) { AdvancedList<SheetDTO> sheetsDTO = new AdvancedList<SheetDTO>(); foreach (var sheet in sheets.Where(s => s.start.Date.Equals(date.Date) && s.job != null)) { SheetDTO sheetDTO = new SheetDTO(); sheetDTO.JobName = sheet.job.name; sheetDTO.JobNum = sheet.job.number.ToString(); sheetDTO.TaskNum = sheet.job.task.number.ToString(); sheetDTO.TaskName = sheet.job.task.name; sheetDTO.ProjectNum = sheet.job.task.project.number.ToString(); sheetDTO.ProjectName = sheet.job.task.project.name; sheetDTO.Start = sheet.start.ToLongTimeString(); sheetDTO.End = sheet.end.ToLongTimeString(); sheetDTO.Duration = sheet.end.Subtract(sheet.start).ToString(); sheetDTO.Note = sheet.note; sheetsDTO.Add(sheetDTO); } if (actualSheet != null && actualSheet.start.Date.Equals(date.Date)) { SheetDTO sheetDTO = new SheetDTO(); sheetDTO.JobNum = actualSheet.job.number.ToString(); sheetDTO.JobName = actualSheet.job.name; sheetDTO.TaskNum = actualSheet.job.task.number.ToString(); sheetDTO.TaskName = actualSheet.job.task.name; sheetDTO.ProjectNum = actualSheet.job.task.project.number.ToString(); sheetDTO.ProjectName = actualSheet.job.task.project.name; sheetDTO.Start = actualSheet.start.ToLongTimeString(); sheetsDTO.Add(sheetDTO); } return sheetsDTO; }
internal Record(string name, uint dataSize, BinaryReader recordReader, FalloutSnip.Domain.Data.DomainDefinition define) { this.dataSize = dataSize; int estimatedCount = Math.Max( Math.Min(16, (int)dataSize/10), 0 ); SubRecords = new AdvancedList<SubRecord>(estimatedCount) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); if (define.RecSize >= 12) Flags2 = recordReader.ReadUInt32(); if (define.RecSize >= 16) Flags3 = recordReader.ReadUInt32(); bool compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; uint realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize),false)) using (var br = new BinaryReader(stream)) { var dataReader = compressed ? Decompressor.Decompress(br, (int)dataSize, (int)realSize, out compressLevel) : br; { while (true) { long left = dataReader.BaseStream.Length - dataReader.BaseStream.Position; if (left < 4) { break; } string type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = define.HEDRRecSize == 2 ? dataReader.ReadUInt16() : dataReader.ReadUInt32(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print( " * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException( string.Format( "Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); // br.BaseStream.Position+=Size; }
private Record(Record r) { SubRecords = new AdvancedList<SubRecord>(r.SubRecords.Count); SubRecords.AllowSorting = false; foreach (var sr in r.SubRecords.OfType<SubRecord>()) SubRecords.Add((SubRecord) sr.Clone()); Flags1 = r.Flags1; Flags2 = r.Flags2; Flags3 = r.Flags3; FormID = r.FormID; Name = r.Name; descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); FixSubrecordOwner(); }
internal Record(string name, uint dataSize, BinaryReader recordReader, bool oblivion) { this.dataSize = dataSize; SubRecords = new AdvancedList<SubRecord>(1) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); Flags2 = recordReader.ReadUInt32(); if (!oblivion) { Flags3 = recordReader.ReadUInt32(); } var compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; var realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize))) { using (var dataReader = compressed ? ZLib.Decompress(stream, (int)realSize) : new BinaryReader(stream)) { while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = dataReader.ReadUInt16(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print(" * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException(string.Format("Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; }
internal Record(string name, uint dataSize, BinaryReader recordReader, TESVSnip.Domain.Data.DomainDefinition define) { this.dataSize = dataSize; int estimatedCount = Math.Max( Math.Min(16, (int)dataSize/10), 0 ); SubRecords = new AdvancedList<SubRecord>(estimatedCount) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); if (define.RecSize >= 12) Flags2 = recordReader.ReadUInt32(); if (define.RecSize >= 16) Flags3 = recordReader.ReadUInt32(); bool compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; uint realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize),false)) using (var br = new BinaryReader(stream)) { var dataReader = compressed ? Decompressor.Decompress(br, (int)dataSize, (int)realSize, out compressLevel) : br; { while (true) { long left = dataReader.BaseStream.Length - dataReader.BaseStream.Position; if (left < 4) { break; } string type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = define.HEDRRecSize == 2 ? dataReader.ReadUInt16() : dataReader.ReadUInt32(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print( " * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException( string.Format( "Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); // br.BaseStream.Position+=Size; }
internal Record(string name, uint dataSize, BinaryReader recordReader, bool oblivion) { this.dataSize = dataSize; SubRecords = new AdvancedList <SubRecord>(1) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); Flags2 = recordReader.ReadUInt32(); if (!oblivion) { Flags3 = recordReader.ReadUInt32(); } var compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; var realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize))) { using (var dataReader = compressed ? ZLib.Decompress(stream, (int)realSize) : new BinaryReader(stream)) { while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = dataReader.ReadUInt16(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print(" * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException(string.Format("Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; }
internal Record(string name, uint Size, BinaryReader br, bool Oblivion) { bool compressedRecord = false; SubRecords = new AdvancedList<SubRecord>(1); SubRecords.AllowSorting = false; Name = name; Flags1 = br.ReadUInt32(); FormID = br.ReadUInt32(); Flags2 = br.ReadUInt32(); if (!Oblivion) Flags3 = br.ReadUInt32(); if ((Flags1 & 0x00040000) > 0) { //Flags1 ^= 0x00040000; uint newSize = br.ReadUInt32(); br = Decompressor.Decompress(br, (int) (Size - 4), (int) newSize); Size = newSize; compressedRecord = true; } uint AmountRead = 0; while (AmountRead < Size) { string s = ReadRecName(br); uint i = 0; if (s == "XXXX") { ushort xsize = br.ReadUInt16(); if (xsize != 4) { throw new TESParserException( String.Format("Unexpected Subrecord block XXXX size! Expected 4 but found {0:D}!", xsize)); } i = br.ReadUInt32(); s = ReadRecName(br); } var r = new SubRecord(this, s, br, i); AmountRead += (uint)(r.Size2); SubRecords.Add(r); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; if (AmountRead != Size) { System.Windows.Forms.Application.Exit(); // throw new TESParserException( // String.Format("Subrecord block did not match the size specified in the record header. Name={3} Header size={0:D} Subrecord Size={1:D} CompressedRecord={2:G}", Size, AmountRead, compressedRecord, name)); } }
internal Record(string name, uint Size, BinaryReader br, bool Oblivion) { SubRecords = new AdvancedList<SubRecord>(1); SubRecords.AllowSorting = false; Name = name; Flags1 = br.ReadUInt32(); FormID = br.ReadUInt32(); Flags2 = br.ReadUInt32(); if (!Oblivion) Flags3 = br.ReadUInt32(); if ((Flags1 & 0x00040000) > 0) { //Flags1 ^= 0x00040000; uint newSize = br.ReadUInt32(); br = Decompressor.Decompress(br, (int) (Size - 4), (int) newSize); Size = newSize; } uint AmountRead = 0; while (AmountRead < Size) { string s = ReadRecName(br); uint i = 0; if (s == "XXXX") { br.ReadUInt16(); i = br.ReadUInt32(); s = ReadRecName(br); } var r = new SubRecord(this, s, br, i); AmountRead += (uint) (r.Size2); SubRecords.Add(r); } if (AmountRead > Size) { throw new TESParserException("Subrecord block did not match the size specified in the record header"); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; }
private void LoadFormData() { List<CharacterSheet> emptyEveCharactersList = new List<CharacterSheet>(); List<CorpData> emptyCorporationDataList = new List<CorpData>(); List<SkillSheet> emptyEveSkillList = new List<SkillSheet>(); List<ImportedData> emptyCSVList = new List<ImportedData>(); List<ListItem> emptyCorpDropDownList = new List<ListItem>(); List<UserData> emptyUserInfoList = new List<UserData>(); AdvancedList<CharacterView> emptyCharacterDataGrid = new AdvancedList<CharacterView>(); EveCharactersList = emptyEveCharactersList; CorporationDataList = emptyCorporationDataList; EveSkillList = emptyEveSkillList; CSVList = emptyCSVList; CorpDropDownList = emptyCorpDropDownList; UserInfoList = emptyUserInfoList; CharacterDataGrid = emptyCharacterDataGrid; cbRemoveCorp.Items.Clear(); listCharacters.Items.Clear(); if (File.Exists(EveSkillsLocalXML)) { EveSkillList = EveSkillObject.GetSkills(EveSkillsLocalXML); listMainView.Items.Add("Loading Skill List."); } else { listMainView.Items.Add("Updating Skill List."); UpdateLocalEveSkillsXML(); } if (File.Exists(UserDataLocalXML)) { XElement xUserData; xUserData = XElement.Load(UserDataLocalXML); foreach (XElement usersettings in xUserData.Elements("settings")) { foreach (XElement xe in usersettings.Elements("user")) { UserInfoList.Add(new UserData( xe.Attribute("corp_keyID").Value, xe.Attribute("corp_vCode").Value, xe.Attribute("corpdataxml").Value)); } listMainView.Items.Add("Loading User Data."); } if (UserInfoList.Count > 0) { foreach (UserData user in UserInfoList) { LoadCorpData(user.corp_corpdata_xml); } int i = 0; foreach (CorpData corp in CorporationDataList) { CorpDropDownList.Add(new ListItem(corp.corporationName.ToString(), UserInfoList[i].corp_KeyID.ToString())); listMainView.Items.Add("Loading corporation data for: " + corp.corporationName); i++; } } foreach (ListItem item in CorpDropDownList) { cbRemoveCorp.Items.Add(item); cbRemoveCorp.SelectedIndex = 0; } if (cbRemoveCorp.Items.Count == 0) { cbRemoveCorp.Text = ""; } } else { listMainView.Items.Add("No user data loaded, please add your corp API information."); } if (File.Exists(CharacterDataXML)) { LoadLocalDataSheet(); listMainView.Items.Add("Loading all character data."); } else { XDocument CreateDatasheetXML = new XDocument(); XElement DatasheetRoot = new XElement("characters"); CreateDatasheetXML.Add(DatasheetRoot); CreateDatasheetXML.Save(CharacterDataXML); listMainView.Items.Add("No character data currently available."); } foreach (CharacterSheet pilot in EveCharactersList) { StringBuilder pilot_titles_build = new StringBuilder(); foreach (CharacterSheet.CharacterTitles title in pilot.titles) { pilot_titles_build.Append(title.titleName).Append(", "); } string str_pilot_titles = pilot_titles_build.ToString(); CorpData this_pilots_corp = CorporationDataList.Find(delegate(CorpData s) { return s.corporationID == pilot.corporationID; }); if (this_pilots_corp != null) { CorpData.Member this_pilots_corp_name = this_pilots_corp.memberList.Find(delegate(CorpData.Member s) { return s.characterID == pilot.characterID; }); CharacterDataGrid.Add(new CharacterView(pilot.name, pilot.corporationName, pilot.forumName, this_pilots_corp_name.startDateTime, this_pilots_corp_name.logoffDateTime, pilot.skills, str_pilot_titles, pilot.titles)); } else { CharacterDataGrid.Add(new CharacterView(pilot.name, pilot.corporationName, pilot.forumName, Convert.ToDateTime("1/1/1000"), Convert.ToDateTime("1/1/1000"), pilot.skills, str_pilot_titles, pilot.titles)); } } BindingSource charsource = new BindingSource(); charsource.DataSource = CharacterDataGrid; _dgMainView.DataSource = charsource; foreach (CharacterView item in CharacterDataGrid) { listCharacters.Items.Add(item.forumName + "\t\t" + item.name); } listMainView.Items.Add("Total characters loaded: " + CharacterDataGrid.Count); }