private void SaveAll_Click(object sender, RoutedEventArgs e) { if (pressureInfo == null) { return; } SaveFrames saveFrames = new SaveFrames(); saveFrames.toFrame = pressureInfo.allFrames.Count - 1; if (saveFrames.ShowDialog() == true) { string savePath = saveFrames.savePath + "\\ " + pressureInfo.GetFileName(); string topSavePath = savePath + "_top"; string bottomSavePath = savePath + "_bottom"; int backindex; int[,] subPressureTop, subPressureBottom; for (int index = saveFrames.fromFrame; index <= saveFrames.toFrame; index = index + saveFrames.interval) { backindex = pressureInfo.allFrames[index].backIndex; //背景索引 FrameInfo backFrame = pressureInfo.backFrames[backindex]; //默认帧数小于1000帧 //int tmpIndex = frameInfo.frameIndex - saveFrames.fromFrame; //保存的文件名从0开始 int tmpIndex = index; //保存的文件名以真实的帧数 int baiwei = tmpIndex / 100; int shiwei = (tmpIndex - baiwei * 100) / 10; int gewei = tmpIndex % 10; int t_Top = backFrame.t_Top; int t_Bottom = backFrame.t_Bottom; int t_Left = backFrame.t_Left; int t_Right = backFrame.t_Right; int b_Top = backFrame.b_Top; int b_Bottom = backFrame.b_Bottom; int b_Left = backFrame.b_Left; int b_Right = backFrame.b_Right; if (backFrame.twoFeet) { if (!Directory.Exists(topSavePath)) { Directory.CreateDirectory(topSavePath); } if (!Directory.Exists(bottomSavePath)) { Directory.CreateDirectory(bottomSavePath); } subPressureTop = new int[t_Bottom - t_Top + 1, t_Right - t_Left + 1]; for (int i = 0; i < t_Bottom - t_Top + 1; i++) { for (int j = 0; j < t_Right - t_Left + 1; j++) { subPressureTop[i, j] = pressureInfo.allFrames[index].pressureValue[t_Top + i, t_Left + j]; } } subPressureBottom = new int[b_Bottom - b_Top + 1, b_Right - b_Left + 1]; for (int i = 0; i < b_Bottom - b_Top + 1; i++) { for (int j = 0; j < b_Right - b_Left + 1; j++) { subPressureBottom[i, j] = pressureInfo.allFrames[index].pressureValue[b_Top + i, b_Left + j]; } } string topSP = topSavePath + "\\" + string.Format("{0}{1}{2}", baiwei, shiwei, gewei) + ".txt"; string bottomSP = bottomSavePath + "\\" + string.Format("{0}{1}{2}", baiwei, shiwei, gewei) + ".txt"; using (StreamWriter writer = File.CreateText(topSP)) { for (int i = 0; i < subPressureTop.GetLength(0); i++) { string tmp = string.Empty; for (int j = 0; j < subPressureTop.GetLength(1); j++) { tmp = tmp + subPressureTop[i, j].ToString() + " "; } writer.WriteLine(tmp.Substring(0, tmp.Length - 1)); } } using (StreamWriter writer = File.CreateText(bottomSP)) { for (int i = 0; i < subPressureBottom.GetLength(0); i++) { string tmp = string.Empty; for (int j = 0; j < subPressureBottom.GetLength(1); j++) { tmp = tmp + subPressureBottom[i, j].ToString() + " "; } writer.WriteLine(tmp.Substring(0, tmp.Length - 1)); } } } else { if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } subPressureTop = new int[t_Bottom - t_Top + 1, t_Right - t_Left + 1]; for (int i = 0; i < t_Bottom - t_Top + 1; i++) { for (int j = 0; j < t_Right - t_Left + 1; j++) { subPressureTop[i, j] = pressureInfo.allFrames[index].pressureValue[t_Top + i, t_Left + j]; } } string SavePath = savePath + "\\" + string.Format("{0}{1}{2}", baiwei, shiwei, gewei) + ".txt"; using (StreamWriter writer = File.CreateText(SavePath)) { for (int i = 0; i < subPressureTop.GetLength(0); i++) { string tmp = string.Empty; for (int j = 0; j < subPressureTop.GetLength(1); j++) { tmp = tmp + subPressureTop[i, j].ToString() + " "; } writer.WriteLine(tmp.Substring(0, tmp.Length - 1)); } } } } MessageBox.Show("所有帧数据保存完毕!"); } }
private void SaveAll_Click(object sender, RoutedEventArgs e) { if (pressureInfo == null) return; SaveFrames saveFrames = new SaveFrames(); saveFrames.toFrame = pressureInfo.allFrames.Count - 1; if (saveFrames.ShowDialog() == true) { string savePath = saveFrames.savePath + "\\ " + pressureInfo.GetFileName(); string topSavePath = savePath + "_top"; string bottomSavePath = savePath + "_bottom"; int backindex; int[,] subPressureTop, subPressureBottom; for (int index = saveFrames.fromFrame; index <= saveFrames.toFrame; index = index + saveFrames.interval) { backindex = pressureInfo.allFrames[index].backIndex; //背景索引 FrameInfo backFrame = pressureInfo.backFrames[backindex]; //默认帧数小于1000帧 //int tmpIndex = frameInfo.frameIndex - saveFrames.fromFrame; //保存的文件名从0开始 int tmpIndex = index; //保存的文件名以真实的帧数 int baiwei = tmpIndex / 100; int shiwei = (tmpIndex - baiwei * 100) / 10; int gewei = tmpIndex % 10; int t_Top = backFrame.t_Top; int t_Bottom = backFrame.t_Bottom; int t_Left = backFrame.t_Left; int t_Right = backFrame.t_Right; int b_Top = backFrame.b_Top; int b_Bottom = backFrame.b_Bottom; int b_Left = backFrame.b_Left; int b_Right = backFrame.b_Right; if (backFrame.twoFeet) { if (!Directory.Exists(topSavePath)) Directory.CreateDirectory(topSavePath); if (!Directory.Exists(bottomSavePath)) Directory.CreateDirectory(bottomSavePath); subPressureTop = new int[t_Bottom - t_Top + 1, t_Right - t_Left + 1]; for (int i = 0; i < t_Bottom - t_Top + 1; i++) for (int j = 0; j < t_Right - t_Left + 1; j++) { subPressureTop[i, j] = pressureInfo.allFrames[index].pressureValue[t_Top + i, t_Left + j]; } subPressureBottom = new int[b_Bottom - b_Top + 1, b_Right - b_Left + 1]; for (int i = 0; i < b_Bottom - b_Top + 1; i++) for (int j = 0; j < b_Right - b_Left + 1; j++) { subPressureBottom[i, j] = pressureInfo.allFrames[index].pressureValue[b_Top + i, b_Left + j]; } string topSP = topSavePath + "\\" + string.Format("{0}{1}{2}", baiwei, shiwei, gewei) + ".txt"; string bottomSP = bottomSavePath + "\\" + string.Format("{0}{1}{2}", baiwei, shiwei, gewei) + ".txt"; using (StreamWriter writer = File.CreateText(topSP)) { for (int i = 0; i < subPressureTop.GetLength(0); i++) { string tmp = string.Empty; for (int j = 0; j < subPressureTop.GetLength(1); j++) tmp = tmp + subPressureTop[i, j].ToString() + " "; writer.WriteLine(tmp.Substring(0, tmp.Length - 1)); } } using (StreamWriter writer = File.CreateText(bottomSP)) { for (int i = 0; i < subPressureBottom.GetLength(0); i++) { string tmp = string.Empty; for (int j = 0; j < subPressureBottom.GetLength(1); j++) tmp = tmp + subPressureBottom[i, j].ToString() + " "; writer.WriteLine(tmp.Substring(0, tmp.Length - 1)); } } } else { if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath); subPressureTop = new int[t_Bottom - t_Top + 1, t_Right - t_Left + 1]; for (int i = 0; i < t_Bottom - t_Top + 1; i++) for (int j = 0; j < t_Right - t_Left + 1; j++) { subPressureTop[i, j] = pressureInfo.allFrames[index].pressureValue[t_Top + i, t_Left + j]; } string SavePath = savePath + "\\" + string.Format("{0}{1}{2}", baiwei, shiwei, gewei) + ".txt"; using (StreamWriter writer = File.CreateText(SavePath)) { for (int i = 0; i < subPressureTop.GetLength(0); i++) { string tmp = string.Empty; for (int j = 0; j < subPressureTop.GetLength(1); j++) tmp = tmp + subPressureTop[i, j].ToString() + " "; writer.WriteLine(tmp.Substring(0, tmp.Length - 1)); } } } } MessageBox.Show("所有帧数据保存完毕!"); } }