示例#1
0
 internal void Run()
 {
     using (_ps)
     {
         bool started;
         lock (_syncRoot)
         {
             started = _ps.Start();
             if (started)
             {
                 try
                 {
                     _name             = _ps.ProcessName;
                     _ps.PriorityClass = ProcessPriorityClass.BelowNormal;
                 }
                 catch (Exception)
                 {
                     // The properties are only accessible if the process is running.
                     // We're actually in a race condition: It might happen that the
                     // process already exited when we access those properties. In
                     // this case, an exception will be thrown.
                 }
                 _state = EToolState.Running;
                 _pool.OnToolSpawned(this);
                 _ps.BeginOutputReadLine();
                 _ps.BeginErrorReadLine();
             }
             else
             {
                 _state = EToolState.StartFailure;
                 _pool.OnFailedToolStart(this);
             }
             _isStarted.Set();
         }
         if (started)
         {
             _ps.WaitForExit();
             lock (_syncRoot)
             {
                 ExitCode = _ps.ExitCode;
                 _state   = EToolState.Exited;
                 _pool.OnToolExited(this);
             }
         }
         _isExited.Set();
     }
 }
        /// <summary>
        /// Calculates the brush size and raycasts from the Stylus to see if a surface is hit. Upon hitting the surface,
        /// start drawing.
        /// </summary>
        protected override void TriggerValid()
        {
            // Save the tool state at the start of surface drawing.
            if (!_firstRaycastFrame)
            {
                _ogToolState       = DrawingVariables.Instance.PenToolState;
                _firstRaycastFrame = true;
            }

            CalculateAverageVelocity();
            CheckBrushMode();

            // If you miss the surface with your raycast, finish up your drawing.
            if (!RaycastOntoSurface())
            {
                // TODO: use the raycast only to get the position and have the raycast as a second trigger for this action.
                TriggerInvalid();
                return;
            }

            DrawingVariables.Instance.PenToolState = EToolState.SurfaceDrawing;

            CalculateAverageAngularVelocity();

            // Save the brush size at the start of drawing a new line and change the size based on modifiers.
            _previousBrushSize = _brushSize;
            ChangeSize();
            ApplyBrushSizeModifiers();

            // If your brush size is greater than 0, draw the line.
            if (_brushSize > 0)
            {
                DetermineDrawingAction(_hit.textureCoord);
                return;
            }

            // However, if your brush size is 0 cause of the modifiers, finish up the line.
        }
示例#3
0
 internal void Run()
 {
     using (_ps)
     {
         bool started;
         lock (_syncRoot)
         {
             started = _ps.Start();
             if (started)
             {
                 try
                 {
                     _name = _ps.ProcessName;
                     _ps.PriorityClass = ProcessPriorityClass.BelowNormal;
                 }
                 catch (Exception)
                 {
                     // The properties are only accessible if the process is running.
                     // We're actually in a race condition: It might happen that the
                     // process already exited when we access those properties. In
                     // this case, an exception will be thrown.
                 }
                 _state = EToolState.Running;
                 _pool.OnToolSpawned(this);
                 _ps.BeginOutputReadLine();
                 _ps.BeginErrorReadLine();
             }
             else
             {
                 _state = EToolState.StartFailure;
                 _pool.OnFailedToolStart(this);
             }
             _isStarted.Set();
         }
         if (started)
         {
             _ps.WaitForExit();
             lock (_syncRoot)
             {
                 ExitCode = _ps.ExitCode;
                 _state = EToolState.Exited;
                 _pool.OnToolExited(this);
             }
         }
         _isExited.Set();
     }
 }