private void Copy() { byte[] buffer = new byte[this.copyBufferSize]; using (BinaryWriter binaryWriter = new BinaryWriter(this.destinationStream)) { int readBytes; while ((readBytes = this.sourceStream.Read(buffer, 0, buffer.Length)) != 0) { binaryWriter.Write(buffer, 0, readBytes); this.Position = this.destinationStream.Position; if (this.GetState() == WorkerState.Canceled || this.GetState() == WorkerState.Finished) { this.completedState = CompletedState.Canceled; return; } } this.completedState = CompletedState.Succeeded; } }
private void EarleyComplete(CompletedState completed, int location) { var earleySet = Chart[completed.Origin]; // Predictions may grow var p = 0; for (; p < earleySet.Predictions.Count; ++p) { var prediction = earleySet.Predictions[p]; if (!prediction.IsSource(completed.LeftHandSide)) { continue; } var dottedRule = DottedRules.GetNext(prediction.DottedRule); var origin = prediction.Origin; // this will not create a node if the state already exists var parseNode = CreateParseNode( dottedRule, origin, prediction.ParseNode, completed.ParseNode, location); if (Chart.Contains(location, dottedRule, origin)) { continue; } var nextState = StateFactory.NewState(dottedRule, origin, parseNode); if (Chart.Enqueue(location, nextState)) { Log(completeLogName, location, nextState); } } }
private void RunCopyProcess() { if (!InitializeCopyProcess()) { return; } System.Exception error = null; try { Copy(); EmitFinalProgress(); } catch (System.Exception ex) { //this.logger.Warn("StreamCopyWorker caught exception: {0}", ex.Message); this.completedState = CompletedState.Failed; error = ex; } FinalizeCopyProcess(error); }
private void Copy() { byte[] buffer = new byte[copyBufferSize]; using (BinaryWriter binaryWriter = new BinaryWriter(destinationStream)) { int readBytes; while ((readBytes = sourceStream.Read(buffer, 0, buffer.Length)) != 0) { binaryWriter.Write(buffer, 0, readBytes); Position = destinationStream.Position; if (GetState() == WorkerState.Canceled || GetState() == WorkerState.Finished) { logger.Debug("StreamCopyWorker cancelled."); completedState = CompletedState.Canceled; return; } } completedState = CompletedState.Succeeded; } }
private void RunCopyProcess() { if (!this.InitializeCopyProcess()) { return; } Exception error = null; try { this.Copy(); this.EmitFinalProgress(); } catch (Exception ex) { this.completedState = CompletedState.Failed; error = ex; } this.FinalizeCopyProcess(error); }
private void DrawStates(CompletedState[] states, FlowWindow window) { if (states == null) return; var oldColor = GUI.color; var style = ME.Utilities.CacheStyle("FlowEditor.DrawStates.Styles", "Grad Down Swatch"); var elemWidth = style.fixedWidth - 3f; var width = window.rect.width - 6f; var posY = -9f; var color = Color.black; color.a = 0.6f; var posX = width - elemWidth; var shadowOffset = 1f; for (int i = states.Length - 1; i >= 0; --i) { GUI.color = color; GUI.Label(new Rect(posX + shadowOffset, posY + shadowOffset, elemWidth, style.fixedHeight), string.Empty, style); posX -= elemWidth; } posX = width - elemWidth; for (int i = states.Length - 1; i >= 0; --i) { var state = states[i]; if (state == CompletedState.NotReady) { color = new Color(1f, 0.3f, 0.3f, 1f); } else if (state == CompletedState.Ready) { color = new Color(0.3f, 1f, 0.3f, 1f); } else if (state == CompletedState.ReadyButWarnings) { color = new Color(1f, 1f, 0.3f, 1f); } GUI.color = color; GUI.Label(new Rect(posX, posY, elemWidth, style.fixedHeight), string.Empty, style); posX -= elemWidth; } GUI.color = oldColor; }
public void SetCompletedState(int index, CompletedState state) { if (this.states == null || this.states.Length != STATES_COUNT) this.states = new CompletedState[STATES_COUNT]; var oldState = this.states[index]; if (oldState != state) { this.states[index] = state; FlowSystem.SetDirty(); } }
internal ActiveState(AnimationInstance animation) { //this.animation = animation; Update = (GameTime gameTime) => { IAnimationState toReturn = this; if (animation.IsPlaying) { // Add to the time counter. - J Mor animation.timeSinceLastFrameChange += (float)gameTime.ElapsedGameTime.TotalSeconds; // If enough time has gone by to actually change frames... while (animation.timeSinceLastFrameChange >= animation.SecondsPerFrame) { // ...then update the frame, and... animation.CurrentFrame++; // ...if the current frame is the last, ... if (animation.CurrentFrame >= animation.Animation.NumFrames) { if (animation.IsLooped) // ...and the animation is set to wrap... { // ...then update the frame # & the times looped. animation.CurrentFrame = 0; animation.TimesLooped++; } else // if not, the animation is done, and should be removed soon. { toReturn = new CompletedState(animation); animation.CurrentFrame--; // To avoid IndexOutOfBounds error in draw func. } } // Remove one "frame" worth of time animation.timeSinceLastFrameChange -= animation.SecondsPerFrame; // If the animation isn't allowed to skip animation frames, then break out of the loop. if (!animation.CanSkipFrames) { break; } } } else { toReturn = new PausedState(animation); } return(toReturn); }; Draw = (SpriteBatch batch) => { if (animation.Posit == null) { if (animation.Animation.UseEachFramesDrawEffects) { animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch); } else { animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch, animation.Animation.DrawEffects); } } else { if (animation.Animation.UseEachFramesDrawEffects) { animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch, null, animation.Posit.Value); } else { animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch, animation.Animation.DrawEffects, animation.Posit.Value); } } //throw new NotImplementedException(); }; }