Ejemplo n.º 1
0
        void OnTimerTick(object sender, EventArgs e)
        {
            if (_state == StateEnum.Finish)
            {
                _timer.Stop();
                var closeProgressWindow = new Action(_windowService.CloseProgressWindow);
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, closeProgressWindow);
            }
            else
            {
                double progress = 0;
                int    total = 0, currentFirst = 0, currentSecond = 0;
                string path = "";

                CoreStatus mainThreadStatus = _core.StatusGet(CoreDll.ThreadType.Main, 0);
                if (mainThreadStatus != null)
                {
                    total = mainThreadStatus.total;
                    if (mainThreadStatus.current > 0)
                    {
                        if (_mainViewModel.Options.CompareOptions.CheckOnEquality)
                        {
                            for (int i = 0; ; i++)
                            {
                                CoreStatus compareThreadStatus = _core.StatusGet(CoreDll.ThreadType.Compare, i);
                                if (compareThreadStatus == null)
                                {
                                    break;
                                }
                                if (i == 0)
                                {
                                    path = compareThreadStatus.path;
                                }
                                currentFirst  += compareThreadStatus.current;
                                currentSecond += compareThreadStatus.total;
                            }
                        }
                        else
                        {
                            currentFirst = mainThreadStatus.current;
                            for (int i = 0; ; i++)
                            {
                                CoreStatus collectThreadStatus = _core.StatusGet(CoreDll.ThreadType.Collect, i);
                                if (collectThreadStatus == null)
                                {
                                    break;
                                }
                                if (i == 0)
                                {
                                    path = collectThreadStatus.path;
                                }
                                currentFirst += collectThreadStatus.current;
                                currentFirst -= collectThreadStatus.total;
                            }
                        }
                    }
                    else
                    {
                        path = mainThreadStatus.path;
                    }
                }
                _progressDialogViewModel.ProgressMax   = (uint)(mainThreadStatus.total);
                _progressDialogViewModel.Progress      = (uint)(currentFirst);
                _progressDialogViewModel.CurrentSecond = (uint)currentSecond;
                //_progressDialogViewModel.ProgressMessage = status.path;
            }
        }