Example #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a font
		/// </summary>
		/// <param name="filename"></param>
		/// ------------------------------------------------------------------------------------
		public void AddFont(string filename)
		{
			int newLength = 1;
			if (m_Fonts != null)
				newLength = m_Fonts.Length + 1;

			FileName[] newFonts = new FileName[newLength];
			if (m_Fonts != null)
				m_Fonts.CopyTo(newFonts, 0);
			m_Fonts = newFonts;
			m_Fonts[newLength - 1] = new FileName(filename);
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Removes a font
		/// </summary>
		/// <param name="i"></param>
		/// ------------------------------------------------------------------------------------
		public void RemoveFont(int i)
		{
			if (i < 0 || m_Fonts == null || i >= m_Fonts.Length)
				throw new IndexOutOfRangeException();

			List<FileName> al = new List<FileName>(m_Fonts);
			al.RemoveAt(i);
			m_Fonts = al.ToArray();
		}
Example #3
0
        private void GetFileDetails(FileStream fs)
        {
            // Directory info

            int directoryCount = fs.Read<int>();

            if (directoryCount < 1 || directoryCount > 100) throw new Exception("Directory count invalid: " + directoryCount);

            directoryList = new DirectoryInfo[directoryCount];

            for (int i = 0; i < directoryCount; i++)
            {
                DirectoryInfo directoryInfo = fs.Read<DirectoryInfo>();
                directoryList[i] = directoryInfo;
            }

            // File info

            int fileCount = fs.Read<int>();

            if (fileCount < 1 || fileCount > 10000) throw new Exception("File count invalid: " + fileCount);

            fileList = new FileInfo[fileCount];

            for (int i = 0; i < fileCount; i++)
            {
                FileInfo file = fs.Read<FileInfo>();
                fileList[i] = file;
            }

            int directoryNameCount = fs.Read<int>();
            int fileNameCount = fs.Read<int>();

            // Directory names

            byte[] bytesDirectoryNames = new byte[directoryNameCount];
            fs.Read(bytesDirectoryNames, 0, directoryNameCount);
            string directoryNames = Encoding.UTF8.GetString(bytesDirectoryNames);

            directoryNameList = new DirectoryName[directoryCount];

            string[] splitDirectory = directoryNames.Split('\0');

            for (int i = 0; i < directoryCount; i++)
            {
                directoryNameList[i] = new DirectoryName { Directory = directoryList[i], Name = splitDirectory[i] };
            }

            // File names

            byte[] bytesFileNames = new byte[fileNameCount];
            fs.Read(bytesFileNames, 0, fileNameCount);
            string fileNames = Encoding.UTF8.GetString(bytesFileNames);

            fileNameList = new FileName[fileCount];

            string[] splitFile = fileNames.Split('\0');

            for (int i = 0; i < fileCount; i++)
            {
                fileNameList[i] = new FileName { File = fileList[i], Name = splitFile[i] };
            }
        }