private void reset_position_tube(double left) { _currentSegmentTube = 0; Label1.Content = _currentSegmentTube.ToString(CultureInfo.InvariantCulture); _moveTubeTimer.Stop(); _animation1.From = Canvas.GetLeft(RectangleTube); _animation1.To = -left; RectangleTube.BeginAnimation(Canvas.LeftProperty, _animation1); PacOut3(); }
private void move_tube(object sender, EventArgs e) { if (_randomizeState) { var rand = new Random(); if (rand.Next(0, 100) <= 10) { _errorState = true; } } try { _animation1.From = RectangleTube.Width; _animation1.To = RectangleTube.Width + 5; RectangleTube.BeginAnimation(WidthProperty, _animation1); if (Canvas.GetLeft(Rectangle5) <= (Canvas.GetLeft(RectangleTube) + RectangleTube.Width) && _currentSegmentTube < _segmentsTube) { if (_errorState && _positionDefectoscope) { if (!_sampleState) { PacOut2(_currentSegmentTube, 1); _errorState = false; } else { PacOut1(1); _errorState = false; } } else { if (!_sampleState) { _errorState = false; PacOut2(_currentSegmentTube, 0); } else { _errorState = false; PacOut1(0); } } _currentSegmentTube++; } else { if (Canvas.GetLeft(Rectangle5) <= (Canvas.GetLeft(RectangleTube) + RectangleTube.Width) && _currentSegmentTube > _segmentsTube - 1) { if (!_sampleState) PacOut3(); _currentSegmentTube = 0; } } Label1.Content = _currentSegmentTube.ToString(CultureInfo.InvariantCulture); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }