Пример #1
0
        public void Execute(object parameter)
        {
            SpecificationPageViewModel specificationPageViewModel =
                parameter as SpecificationPageViewModel;

            _openFileDialog = new OpenFileDialog
            {
                DefaultExt       = ".xml",
                InitialDirectory = Environment.CurrentDirectory,
                Filter           = "XML File (*.xml)|*.xml"
            };
            _openFileDialog.ShowDialog();

            // ReSharper disable once PossibleNullReferenceException
            specificationPageViewModel.Path = _openFileDialog.FileName;
        }
Пример #2
0
        private void Animation(SpecificationPageViewModel specificationPageViewModel)
        {
            string defaultStr = specificationPageViewModel.ButtonDownLoadContent;

            while (CheckLoadStatus())
            {
                string newStr = specificationPageViewModel.ButtonDownLoadContent;

                for (int index = 0; index < specificationPageViewModel.ButtonDownLoadContent.Length;
                     index++)
                {
                    if (!CheckLoadStatus())
                    {
                        break;
                    }

                    char[] chars = newStr.ToCharArray();
                    chars[index] = '.';
                    newStr       = new string(value : chars);
                    Thread.Sleep(millisecondsTimeout: PauseAnimation);
                    specificationPageViewModel.ButtonDownLoadContent = newStr;
                }

                if (!CheckLoadStatus())
                {
                    break;
                }
                int maxIndex = specificationPageViewModel.ButtonDownLoadContent.Length - 1;

                for (int index = maxIndex; index >= 0; index--)
                {
                    if (!CheckLoadStatus())
                    {
                        break;
                    }
                    char[] charsOldStr = newStr.ToCharArray();
                    char[] charsNewStr = defaultStr.ToCharArray();
                    charsOldStr[maxIndex - index] = charsNewStr[maxIndex - index];
                    newStr = new string(value : charsOldStr);
                    Thread.Sleep(millisecondsTimeout: PauseAnimation);
                    specificationPageViewModel.ButtonDownLoadContent = newStr;
                }
            }

            specificationPageViewModel.ButtonDownLoadContent = defaultStr;
        }
Пример #3
0
        public void Execute(object parameter)
        {
            SpecificationPageViewModel specificationPageViewModel =
                parameter as SpecificationPageViewModel;

            // ReSharper disable once PossibleNullReferenceException
            if (string.IsNullOrEmpty(value: specificationPageViewModel.Path))
            {
                Log.Log.SetLog(tag: Tag, message: "Параметр команды оказался пустым!");

                return;
            }

            _loaderXml = new LoaderXml
                             (pathXml: specificationPageViewModel.Path, model: new Specification());
            _loaderXml.LoadData();
            _specificationWork = new SpecificationXmlWork(model: _loaderXml.Model);
            ArrayList listResult;
            Task      task = new Task
                             (
                action: () =>
            {
                //TODO: Если файл небольшой, то потребности в ногопотоке нет
                listResult = _specificationWork.GetResultAsync().ArrayList;
                specificationPageViewModel.ResultSpecificationsItems = null;
                specificationPageViewModel.ResultSpecificationsItems =
                    listResult.Cast <ResultSpecification>();
                _loadFile = false;
                specificationPageViewModel.StatusTime =
                    "Время операци: " + $"{_stopwatch.Elapsed:g}";
                _stopwatch.Stop();
                _stopwatch.Reset();
            }
                             );
            Task animationTask = new Task
                                     (action: () => Animation(specificationPageViewModel: specificationPageViewModel));

            _stopwatch.Start();
            _loadFile = true;
            task.Start();
            animationTask.Start();
        }