1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193:
| using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Research.Kinect.Nui; using Microsoft.Xna.Framework;
namespace KiMotion { public class KMMovement {
List<KMFrame> frames; List<KMMotion> motions; List<KMMotionDiff> motionDiffs; KMOptions options; int totalTime; int totalFrames;
public KMMovement(KMOptions options) { frames = new List<KMFrame>(); motions = new List<KMMotion>(); motionDiffs = new List<KMMotionDiff>(); this.options = options; totalTime = 0; totalFrames = 0; }
public void addFrame(SkeletonData skeletonData, int timeElapsed) { frames.Add(new KMFrame(skeletonData, timeElapsed, options.KMSKELETON)); totalFrames++; totalTime += timeElapsed;
if (totalFrames > 1) { motions.Add(new KMMotion(frames[totalFrames - 1], frames[totalFrames], options.KMSKELETON.Achsen, options.MAXJOINTS, options.ZEITANPASSUNG)); } if (totalFrames > 2) { motionDiffs.Add(new KMMotionDiff(motions[totalFrames - 2], motions[totalFrames - 1], timeElapsed, options.ZEITANPASSUNG)); } }
public KMFrame getFrame(int frame) { return frames[frame]; }
public int TotalFrames { get { return totalFrames; } }
public int TotalTime { get { return totalTime; } }
} }
void saveMovement(string filename) { using (StreamWriter sw = new StreamWriter(filename)) { for (int i = 0; i < frames.Count; i++) { for (int j = 0; j < options.MAXJOINTS; j++) { sw.Write(frames[i].Gelenke[j].X) + "\t"; sw.Write(frames[i].Gelenke[j].Y); sw.Write(frames[i].Gelenke[j].Z); sw.Write(frames[i].TimeElapsed); } } sw.Write(frames[0].Gelenke[0].X); sw.WriteLine("header for the file."); sw.WriteLine("-------------------"); sw.Write("The date is: "); sw.WriteLine(DateTime.Now); } }
MEINE IDEE WÄRE FOLGENDE: (wobei ich mir da aber auch nicht wirklich sicher bin!!!)
private const string SafeData = "SafeData.txt"; public static void Main(String[] args) { if (File.Exists(SafeData)) { Console.WriteLine("{0} already exists.", SafeData); return; } using (StreamWriter sw = File.CreateText(SafeData)) { sw.WriteLine("Folgendes wird gespeichert"); sw.WriteLine("{0};{1};{2}", X, Y, Z); sw.Close(); } }
public class TextToFile { private const string SafeData = "SafeData.txt"; public static void Main(String[] args) { if (File.Exists(SafeData)) { Console.WriteLine("{0} already exists.", totalTime); return; } using (StreamWriter sw = File.CreateText(SafeData)) { sw.WriteLine("The total Time is"); sw.WriteLine("{0}; {1}, and so on.",totalTime); sw.Close(); } } }
private const string SafeData = "SafeData.txt"; public static void Main(String[] args) { if (File.Exists(totalFrames)) { Console.WriteLine("{0} already exists.", totalFrames); return; } using (StreamWriter sw = File.CreateText(SafeData)) { sw.WriteLine("....."); sw.WriteLine(".... {0} .... {1}",totalFrames); sw.Close(); } }
private const string SafeData = "SafeData.txt"; public static void Main(String[] args) { if (File.Exists(saveMovement)) { Console.WriteLine("{0} already exists.", saveMovements); return; } using (StreamWriter sw = File.CreateText(SafeData)) { sw.WriteLine("{0};{1};{2}", saveMovement); sw.WriteLine("{0};{1};{2}", X, Y, Z); sw.Close(); } }
private const string SafeData = "SafeData.txt"; public static void Main(String[] args) { if (!File.Exists(SafeData)) { Console.WriteLine("{0} does not exist.", SafeData); return; } using (StreamReader sr = File.OpenText(SafeData)) { String input; while ((input = sr.ReadLine()) != null) { Console.WriteLine(input); } Console.WriteLine("The end of the stream has been reached."); sr.Close(); } } |