internal static byte[] OpenInclude(GetIncludeEventArgs ea, ExcelFile Workbook) { string iPath = Workbook.ActiveFileName; try { if (iPath.Length > 0) { iPath = Path.GetDirectoryName(iPath) + Path.DirectorySeparatorChar; } } catch (ArgumentException) { iPath = String.Empty; } if (Path.IsPathRooted(ea.FileName)) { iPath = String.Empty; } ea.FileName = iPath + ea.FileName; using (FileStream f = new FileStream(ea.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //FileShare.ReadWrite is the way we have to open a file even if it is being used by excel. { byte[] Result = new byte[f.Length]; Sh.Read(f, Result, 0, Result.Length); return(Result); } }
private static byte[] OpenFile(string Path) { using (FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //FileShare.ReadWrite is the way we have to open a file even if it is being used by excel.)) { byte[] b = new byte[fs.Length]; Sh.Read(fs, b, 0, (int)fs.Length); return(b); } }
private void LoadFont(string path) { byte[] b = null; using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //FileShare.ReadWrite is the way we have to open a file even if it is being used by excel.)) { b = new byte[fs.Length]; Sh.Read(fs, b, 0, (int)fs.Length); } LoadFont(path, b); }
protected void s_Calc_Shields() { int t_Shield_V = 0; int t_Shield_R = 0; foreach (_Shield Sh in s_Shields) { if (Sh != null) { t_Shield_V += Sh.sh_Get_Shield(); //get shield value shield t_Shield_R += Sh.sh_Get_Recharge(); //get the recharge rate of the shield } } s_Shield = t_Shield_V; //set shield value s_Shield_Rate = t_Shield_R; //set recharge rate }
private static byte[] DecodeImage(byte[] Img, int w, int h, int ScanLine) { using (TCompressor Cmp = new TCompressor()) { if (w <= 0) { return(new byte[2]); } byte[] Result = new byte[h * ScanLine]; using (MemoryStream InflatedStream = new MemoryStream()) { unchecked { Cmp.Inflate(Img, 0, InflatedStream); InflatedStream.Position = 0; Sh.Read(InflatedStream, Result, 0, h * ScanLine); return(UnFilter(Result, ScanLine, h)); } } } }
private void ShRead(Stream aDataStream, byte[] Data, int IniOfs, int Count) { Sh.Read(aDataStream, Data, IniOfs, Count); DataStreamPosition += Count; }
/// <summary> /// Arrange to .OUT Form /// </summary> /// <param name="Data"></param> /// <param name="savePath"></param> /// <param name="OutSaveName"></param> /// <returns></returns> public static ArrayList OUT_sub(ArrayList Data, string savePath, ref string OutSaveName, int caseNum) { //OutSaveName = Convert.ToString(Data[0]); //if (caseNum == 0) //{ //} //else //{ // OutSaveName = OutSaveName.Trim(); // OutSaveName = OutSaveName.Substring(2, OutSaveName.Length - 2).Trim(); // OutSaveName = OutSaveName.Replace(".dat", ".out"); // OutSaveName = OutSaveName.Replace(".DAT", ".out"); //} OutSaveName = Convert.ToString(Data[0]); OutSaveName = OutSaveName.Substring(21, 15).Trim(); OutSaveName = OutSaveName.Replace(".dat", ".out"); OutSaveName = OutSaveName.Replace(".DAT", ".out"); //// Sort Data ArrayList RbRfData = new ArrayList(); ArrayList allData = new ArrayList(); string Sh, Db, End; int i = 0; foreach (string ff in Data) { if (ff.Contains("Start-Line")) { Start1 = Convert.ToString(Data[i]).Replace("BFFB", " BF"); Start2 = Convert.ToString(Data[i + 1]); RbRfData.Clear(); } else if (ff.Contains("|Rb") || ff.Contains("|Rf")) { RbRfData.Add(ff); } else if (ff.Contains("|Sh")) { Sh = Convert.ToString(Data[i]); Db = Convert.ToString(Data[i + 1]); End = Convert.ToString(Data[i + 2]); string GoName = Start2.Substring(22, 9); string BackName = Db.Substring(22, 9); //// Go //// Save Start-Line allData.Add(Start1); allData.Add(Start2); //// Save Rb Rf data for (int ii = 0; ii < RbRfData.Count / 4; ii++) { allData.Add(RbRfData[ii * 4]); allData.Add(RbRfData[ii * 4 + 1]); } //// Save Sh,Db,End-Line allData.Add(Sh); allData.Add(Db); allData.Add(End); //// Back //// Save Start-Line allData.Add(Start1.Replace(GoName, BackName)); allData.Add(Start2.Replace(GoName, BackName)); //// Save Rb, Rf Data for (int ii = 0; ii < RbRfData.Count / 4; ii++) { String index1 = Convert.ToString(RbRfData[RbRfData.Count - ii * 4 - 1 - 1]); String index2 = Convert.ToString(RbRfData[RbRfData.Count - ii * 4 - 1]); index1 = index1.Replace("Rf", "Rb"); index2 = index2.Replace("Rb", "Rf"); allData.Add(index1); allData.Add(index2); } //// Save Sh,Db,End-line allData.Add(Sh.Replace(BackName, GoName)); allData.Add(Db.Replace(BackName, GoName)); allData.Add(End); } i++; } StreamWriter sw = new StreamWriter(Path.Combine(savePath, OutSaveName)); foreach (string ff in allData) { sw.WriteLine(ff); } sw.WriteLine("-9999"); sw.Close(); return(allData); }
internal static void ReadtRNS(UInt32 Len, Stream PngImageData, TPdfPngData OutData) { OutData.tRNS = new byte[Len]; Sh.Read(PngImageData, OutData.tRNS, 0, (int)Len); }