Example #1
0
        public void Run()
        {
            //在排序任务中 - 继续执行
            if (_thread != null && _thread.IsAlive && _thread.ThreadState == ThreadState.Suspended)
            {
                _thread.Resume();
                _currentMode   = ModeCategory.Running;
                ConsoleContent = "开始继续执行。";
                SetButtonsEnable(false, false, true, true, true);
                return;
            }
            //没有数据
            if (_currentData == null)
            {
                Generate();
            }
            //开始执行
            _thread = new Thread(() =>
            {
                ExecuteSteps();
            });

            _thread.Start();

            SetButtonsEnable(false, false, true, true, true);
            IsSortCategoriesEnabled            = false;
            (GetView() as PUWindow).ResizeMode = ResizeMode.CanMinimize;
        }
Example #2
0
        public void SingleStep()
        {
            if (_thread != null && _thread.IsAlive)
            {
                if (_currentMode == ModeCategory.SingleStep || _currentMode == ModeCategory.Paused)
                {
                    _thread.Resume();
                }
                else
                {
                    _currentMode = ModeCategory.SingleStep;
                    SetButtonsEnable(false, true, true, false, true);
                    IsSortCategoriesEnabled = false;
                    ConsoleContent          = "已进入单步模式。";
                }
                return;
            }
            //没有数据
            if (_currentData == null)
            {
                Generate();
            }

            _currentMode = ModeCategory.SingleStep;
            var stepList = SortStepGenerator.Sort(_sortCategory, _currentData);

            _thread = new Thread(() =>
            {
                ExecuteSteps();
            });
            _thread.Start();
            SetButtonsEnable(false, true, true, false, true);
            IsSortCategoriesEnabled            = false;
            (GetView() as PUWindow).ResizeMode = ResizeMode.CanMinimize;
        }
Example #3
0
 public void Pause()
 {
     if (_thread == null || !_thread.IsAlive)
     {
         ConsoleContent = "没有可以暂停的排序任务,请先从数据区生成画布。";
         return;
     }
     _currentMode              = ModeCategory.Paused;
     IsRunButtonEnabled        = true;
     IsSingleStepButtonEnabled = true;
     IsPauseButtonEnabled      = false;
     ConsoleContent            = "排序已暂停。";
 }
Example #4
0
        public void Stop()
        {
            if (_thread != null && _thread.IsAlive)
            {
                try
                { _thread.Abort(); }
                catch { }
                _thread = null;
            }
            _currentMode = ModeCategory.Stoped;

            SetButtonsEnable();
            ActiveItem.ResetCanvas();
            IsSortCategoriesEnabled = true;

            ConsoleContent = "画布已重置。";
            (GetView() as PUWindow).ResizeMode = ResizeMode.CanResize;
        }
Example #5
0
        //清除画布
        public void Clear()
        {
            if (_thread != null)
            {
                if (_thread.IsAlive && _thread.ThreadState == ThreadState.Suspended)
                {
                    _thread.Resume();
                }
                _thread.Abort();
            }
            _currentData = null;
            _currentMode = ModeCategory.Stoped;

            InputDataString = "";
            ActiveItem.ClearCanvas();
            SetButtonsEnable();
            IsSortCategoriesEnabled            = true;
            (GetView() as PUWindow).ResizeMode = ResizeMode.CanResize;
        }