public static Sprite Get(TailState type) { return(_sprites[type]); }
public Tail() { _state = TailState.Idle; }
public void Start(string filename) { _filename = filename; using (var reader = new StreamReader( new FileStream( _filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete ) ) ) { _state = TailState.Started; //start at the end of the file long lastMaxOffset = reader.BaseStream.Length; while (true) { if (_stop) { reader.BaseStream.Close(); reader.Close(); break; } Thread.Sleep(100); //if the file size has not changed, idle if (reader.BaseStream.Length == lastMaxOffset) continue; //seek to the last max offset reader.BaseStream.Seek(lastMaxOffset, SeekOrigin.Begin); //read out of the file until the EOF string output; while ((output = reader.ReadLine()) != null) InvokeOutputRecievedEvent(new OutputRecievedEvent {Output = output}); //update the last max offset lastMaxOffset = reader.BaseStream.Position; } } _state = TailState.Stopped; }
public static void ChangeTailState(TailState state) { _isTailRaised = state == TailState.Raise; }