public static bool IsImage(Model_Property model) { if (model.NameSize == 0) { return(false); } for (int i = 0; i < model.Name.Length; i++) { if (i < model.NameSize / 2 - 1) { if (model.Name[i] < 0x30 || model.Name[i] > 0x39) { return(false); } } else { if (model.Name[i] != 0) { return(false); } } } return(true); }
public static bool IsImageFixed(Model_Property model) { if (model.Name.Length < 7) return false; int FixedNo = model.Name.Length - 6; for (int i = 0; i < FixedNo; i++) { if (model.Name[i] < 0x30 || model.Name[i] > 0x39) return false; } if (model.Name[FixedNo] == 0x46 && model.Name[FixedNo + 1] == 0x69 && model.Name[FixedNo + 2] == 0x78 && model.Name[FixedNo + 3] == 0x65 && model.Name[FixedNo + 4] == 0x64 && model.Name[FixedNo + 5] == 0) return true; return false; }
public static bool IsImage(Model_Property model) { if (model.NameSize == 0) return false; for (int i = 0; i < model.Name.Length; i++) { if (i<model.NameSize/2-1) { if (model.Name[i] < 0x30 || model.Name[i] > 0x39) return false; } else { if (model.Name[i] != 0) return false; } } return true; }
public static bool IsImageFixed(Model_Property model) { if (model.Name.Length < 7) { return(false); } int FixedNo = model.Name.Length - 6; for (int i = 0; i < FixedNo; i++) { if (model.Name[i] < 0x30 || model.Name[i] > 0x39) { return(false); } } if (model.Name[FixedNo] == 0x46 && model.Name[FixedNo + 1] == 0x69 && model.Name[FixedNo + 2] == 0x78 && model.Name[FixedNo + 3] == 0x65 && model.Name[FixedNo + 4] == 0x64 && model.Name[FixedNo + 5] == 0) { return(true); } return(false); }
public PropertyReader(byte[] AllPropertyData) { Propertys = AllPropertyData; byte[] PropertyBytes; List<byte[]> PropertyList = new List<byte[]>(); for (int i = 0; i < AllPropertyData.Length; i += Struct_POIFSConstants.PROPERTY_SIZE) { PropertyBytes = new byte[Struct_POIFSConstants.PROPERTY_SIZE]; for (int j = 0; j < Struct_POIFSConstants.PROPERTY_SIZE; j++) { PropertyBytes[j] = AllPropertyData[i + j]; } PropertyList.Add(PropertyBytes); } //get property foreach (byte[] TempByte in PropertyList) { Model_Property M_Property = new Model_Property(); M_Property.NameSize = BitConverter.ToUInt16(TempByte, Struct_Property_Offset.NAME_SIZE); ushort[] ShortTemp = new ushort[M_Property.NameSize/2]; int ShortTempIndex = 0; for (int i = 0; i < M_Property.NameSize; i += 2) { ShortTemp[ShortTempIndex] = BitConverter.ToUInt16(TempByte, i); ShortTempIndex++; } M_Property.Name = ShortTemp; M_Property.PropertyType = TempByte[ Struct_Property_Offset.PROPERTY_TYPE]; M_Property.NodeColor = TempByte[ Struct_Property_Offset.NODE_COLOR]; M_Property.PreviousProp = BitConverter.ToInt32(TempByte, Struct_Property_Offset.PREVIOUS_PROP); M_Property.NextProp = BitConverter.ToInt32(TempByte, Struct_Property_Offset.NEXT_PROP); M_Property.ChildProp = BitConverter.ToInt32(TempByte, Struct_Property_Offset.CHILD_PROP); M_Property.Seconds1 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.SECONDS_1); M_Property.Days1 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.DAYS_1); M_Property.Seconds2 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.SECONDS_2); M_Property.Days2 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.DAYS_2); M_Property.StartBlock = BitConverter.ToInt32(TempByte, Struct_Property_Offset.START_BLOCK); M_Property.Size = BitConverter.ToInt32(TempByte, Struct_Property_Offset.SIZE); if (Contrast.ShortArray(M_Property.Name, s_FaceXML)) p_FaceXML = M_Property; else if (Contrast.ShortArray(M_Property.Name, s_RootEntry)) p_RootEntry = M_Property; else if (Contrast.ShortArray(M_Property.Name, s_config)) p_Config = M_Property; else if (Contrast.IsImage(M_Property)) p_Image.Add(M_Property); else if (Contrast.IsImageFixed(M_Property)) p_ImageFixed.Add(M_Property); } List<Model_Property> p_Image_temp = new List<Model_Property>(); int imageCount = p_Image.Count; for (int i = 0; i < imageCount; i++) { for (int j = 0; j < p_Image.Count; j++) { if(NameConvertToInt(p_Image[j].Name) == i) { p_Image_temp.Add(p_Image[j]); p_Image.RemoveAt(j); break; } } } p_Image = p_Image_temp; }
public PropertyReader(byte[] AllPropertyData) { Propertys = AllPropertyData; byte[] PropertyBytes; List <byte[]> PropertyList = new List <byte[]>(); for (int i = 0; i < AllPropertyData.Length; i += Struct_POIFSConstants.PROPERTY_SIZE) { PropertyBytes = new byte[Struct_POIFSConstants.PROPERTY_SIZE]; for (int j = 0; j < Struct_POIFSConstants.PROPERTY_SIZE; j++) { PropertyBytes[j] = AllPropertyData[i + j]; } PropertyList.Add(PropertyBytes); } //get property foreach (byte[] TempByte in PropertyList) { Model_Property M_Property = new Model_Property(); M_Property.NameSize = BitConverter.ToUInt16(TempByte, Struct_Property_Offset.NAME_SIZE); ushort[] ShortTemp = new ushort[M_Property.NameSize / 2]; int ShortTempIndex = 0; for (int i = 0; i < M_Property.NameSize; i += 2) { ShortTemp[ShortTempIndex] = BitConverter.ToUInt16(TempByte, i); ShortTempIndex++; } M_Property.Name = ShortTemp; M_Property.PropertyType = TempByte[Struct_Property_Offset.PROPERTY_TYPE]; M_Property.NodeColor = TempByte[Struct_Property_Offset.NODE_COLOR]; M_Property.PreviousProp = BitConverter.ToInt32(TempByte, Struct_Property_Offset.PREVIOUS_PROP); M_Property.NextProp = BitConverter.ToInt32(TempByte, Struct_Property_Offset.NEXT_PROP); M_Property.ChildProp = BitConverter.ToInt32(TempByte, Struct_Property_Offset.CHILD_PROP); M_Property.Seconds1 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.SECONDS_1); M_Property.Days1 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.DAYS_1); M_Property.Seconds2 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.SECONDS_2); M_Property.Days2 = BitConverter.ToInt32(TempByte, Struct_Property_Offset.DAYS_2); M_Property.StartBlock = BitConverter.ToInt32(TempByte, Struct_Property_Offset.START_BLOCK); M_Property.Size = BitConverter.ToInt32(TempByte, Struct_Property_Offset.SIZE); if (Contrast.ShortArray(M_Property.Name, s_FaceXML)) { p_FaceXML = M_Property; } else if (Contrast.ShortArray(M_Property.Name, s_RootEntry)) { p_RootEntry = M_Property; } else if (Contrast.ShortArray(M_Property.Name, s_config)) { p_Config = M_Property; } else if (Contrast.IsImage(M_Property)) { p_Image.Add(M_Property); } else if (Contrast.IsImageFixed(M_Property)) { p_ImageFixed.Add(M_Property); } } List <Model_Property> p_Image_temp = new List <Model_Property>(); int imageCount = p_Image.Count; for (int i = 0; i < imageCount; i++) { for (int j = 0; j < p_Image.Count; j++) { if (NameConvertToInt(p_Image[j].Name) == i) { p_Image_temp.Add(p_Image[j]); p_Image.RemoveAt(j); break; } } } p_Image = p_Image_temp; }