예제 #1
0
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            if (!CanEnterState(State.Working))
            {
                return;
            }

            var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            configuration.AppSettings.Settings["imageFinder.dir1"].Value = txtDir1.Text.Trim();
            configuration.AppSettings.Settings["imageFinder.dir2"].Value = txtDir2.Text.Trim();
            configuration.AppSettings.Settings["imageFinder.dir3"].Value = txtDir3.Text.Trim();
            configuration.AppSettings.Settings["imageFinder.dir4"].Value = txtDir4.Text.Trim();
            configuration.AppSettings.Settings["imageFinder.dir5"].Value = txtDir5.Text.Trim();
            configuration.Save();

            var dirs = new List <string>();

            AddValidDir(dirs, txtDir1);
            AddValidDir(dirs, txtDir2);
            AddValidDir(dirs, txtDir3);
            AddValidDir(dirs, txtDir4);
            AddValidDir(dirs, txtDir5);
            if (dirs.Count > 0)
            {
                if (_files != null)
                {
                    _files.SelectionChanged -= files_SelectionChanged;
                }

                _files = new FileItemCollection();
                _files.SelectionChanged += files_SelectionChanged;
                fileList.ItemsSource     = _files;
                _task = new FinderTask(this, dirs.ToArray());
                _task.Start();
            }
            else
            {
                MessageBox.Show("请输入目录");
            }
        }
예제 #2
0
        public void EnterState(State state)
        {
            _state = state;
            switch (state)
            {
            case State.Stopped:
                EnableButtons(true, false);
                break;

            case State.Working:
                EnableButtons(false, true);
                break;
            }
            if (_state != State.Stopped)
            {
                return;
            }
            sbiText.Content = "";
            progress.Show(false);
            _task = null;
        }