SetValue() public method

public SetValue ( ParserValue value ) : void
value ParserValue
return void
コード例 #1
0
        public void StartButtonClick(object sender, EventArgs e)
        {
            ParserData.Parser data = m_data.Data[parserBox.SelectedIndex];

            PageParser parser = m_parsers[data.ParserType];
            parser.Parser = data;
            parser.Locale = (Locale)localeBox.SelectedItem;
            parser.Flags = GetSubparsers();

            ParsingType type = (ParsingType)parsingControl.SelectedIndex;

            m_worker = new Worker(type, parser, WorkerPageDownloaded);

            Worker.ParserValue value = default(Worker.ParserValue);
            switch (type)
            {
                case ParsingType.TypeBySingleValue:
                    {
                        value.Id = (uint)valueBox.Value;
                        break;
                    }
                case ParsingType.TypeByList:
                    {
                        value.Array = GetEntriesList().Data;
                        numericUpDown.Maximum = progressBar.Maximum = value.Array.Length;
                        break;
                    }
                case ParsingType.TypeByMultipleValue:
                    {
                        value.Start = (uint)rangeStart.Value;
                        value.End = (uint)rangeEnd.Value;

                        if (value.Start > value.End)
                        {
                            ShowMessageBox(MessageType.MultipleTypeBigger);
                            return;
                        }

                        if (value.Start == value.End)
                        {
                            ShowMessageBox(MessageType.MultipleTypeEqual);
                            return;
                        }

                        numericUpDown.Maximum = progressBar.Maximum = (int)(value.End - value.Start) + 1;
                        break;
                    }
                case ParsingType.TypeByWoWHeadFilter:
                    {
                        value.Maximum = (data.CountLimit / MaxIdCountPerRequest);
                        numericUpDown.Maximum = progressBar.Maximum = (int)value.Maximum + 1;
                        break;
                    }
                default:
                    return;
            }

            m_worker.SetValue(value);

            abortButton.Enabled = true;
            subparsersListBox.Enabled = settingsBox.Enabled = startButton.Enabled = false;
            numericUpDown.Value = progressBar.Value = 0;
            SetLabelText(Resources.Label_Working);

            Requests.Compress = Settings.Default.DataCompression;

            backgroundWorker.RunWorkerAsync();
        }
コード例 #2
0
        public void StartButtonClick(object sender, EventArgs e)
        {
            ConstructorInfo cInfo = _parsers[parserBox.SelectedIndex].Value.GetConstructor(new[] { typeof(Locale), typeof(int) });

            if (cInfo == null)
            {
                return;
            }

            int        flags  = GetSubparsers();
            PageParser parser = (PageParser)cInfo.Invoke(new [] { localeBox.SelectedItem, flags });

            if (parser == null)
            {
                throw new InvalidOperationException("parser");
            }

            ParsingType type = (ParsingType)parsingControl.SelectedIndex;

            _worker = new Worker(type, parser, WorkerPageDownloaded);

            switch (type)
            {
            case ParsingType.TypeBySingleValue:
            {
                uint value = (uint)valueBox.Value;
                _worker.SetValue(value);
                break;
            }

            case ParsingType.TypeByList:
            {
                uint[] entries = GetEntriesList();
                numericUpDown.Maximum = progressBar.Maximum = entries.Length;
                _worker.SetValue(entries);
                break;
            }

            case ParsingType.TypeByMultipleValue:
            {
                uint startValue = (uint)rangeStart.Value;
                uint endValue   = (uint)rangeEnd.Value;

                if (startValue > endValue)
                {
                    ShowMessageBox(MessageType.MultipleTypeBigger);
                    return;
                }

                if (startValue == endValue)
                {
                    ShowMessageBox(MessageType.MultipleTypeEqual);
                    return;
                }

                numericUpDown.Maximum = progressBar.Maximum = (int)(endValue - startValue) + 1;
                _worker.SetValue(startValue, endValue);
                break;
            }

            case ParsingType.TypeByWoWHeadFilter:
            {
                int maxValue = (parser.MaxCount / 200);
                numericUpDown.Maximum = progressBar.Maximum = maxValue + 1;
                _worker.SetValue((uint)maxValue);
                break;
            }

            default:
                return;
            }

            abortButton.Enabled       = true;
            subparsersListBox.Enabled = settingsBox.Enabled = startButton.Enabled = false;
            numericUpDown.Value       = progressBar.Value = 0;
            SetLabelText(Resources.Label_Working);

            Requests.Compress = Settings.Default.DataCompression;

            backgroundWorker.RunWorkerAsync();
        }
コード例 #3
0
        public void StartButtonClick(object sender, EventArgs e)
        {
            ParserData.Parser data = m_data.Data[parserBox.SelectedIndex];

            PageParser parser = m_parsers[data.ParserType];

            parser.Parser = data;
            parser.Locale = (Locale)localeBox.SelectedItem;
            parser.Flags  = GetSubparsers();

            ParsingType type = (ParsingType)parsingControl.SelectedIndex;

            m_worker = new Worker(type, parser, WorkerPageDownloaded);

            Worker.ParserValue value = default(Worker.ParserValue);
            switch (type)
            {
            case ParsingType.TypeBySingleValue:
            {
                value.Id = (uint)valueBox.Value;
                break;
            }

            case ParsingType.TypeByList:
            {
                value.Array           = GetEntriesList().Data;
                numericUpDown.Maximum = progressBar.Maximum = value.Array.Length;
                break;
            }

            case ParsingType.TypeByMultipleValue:
            {
                value.Start = (uint)rangeStart.Value;
                value.End   = (uint)rangeEnd.Value;

                if (value.Start > value.End)
                {
                    ShowMessageBox(MessageType.MultipleTypeBigger);
                    return;
                }

                if (value.Start == value.End)
                {
                    ShowMessageBox(MessageType.MultipleTypeEqual);
                    return;
                }

                numericUpDown.Maximum = progressBar.Maximum = (int)(value.End - value.Start) + 1;
                break;
            }

            case ParsingType.TypeByWoWHeadFilter:
            {
                value.Maximum         = (data.CountLimit / MaxIdCountPerRequest);
                numericUpDown.Maximum = progressBar.Maximum = (int)value.Maximum + 1;
                break;
            }

            default:
                return;
            }

            m_worker.SetValue(value);

            abortButton.Enabled       = true;
            subparsersListBox.Enabled = settingsBox.Enabled = startButton.Enabled = false;
            numericUpDown.Value       = progressBar.Value = 0;
            SetLabelText(Resources.Label_Working);

            Requests.Compress = Settings.Default.DataCompression;

            backgroundWorker.RunWorkerAsync();
        }
コード例 #4
0
        public void StartButtonClick(object sender, EventArgs e)
        {
            ConstructorInfo cInfo = _parsers[parserBox.SelectedIndex].Value.GetConstructor(new[] { typeof(Locale), typeof(int) });
            if (cInfo == null)
                return;

            int flags = GetSubparsers();
            PageParser parser = (PageParser)cInfo.Invoke(new [] { localeBox.SelectedItem, flags });
            if (parser == null)
                throw new InvalidOperationException("parser");

            ParsingType type = (ParsingType)parsingControl.SelectedIndex;

            _worker = new Worker(type, parser, WorkerPageDownloaded);

            switch (type)
            {
                case ParsingType.TypeBySingleValue:
                    {
                        uint value = (uint)valueBox.Value;
                        _worker.SetValue(value);
                        break;
                    }
                case ParsingType.TypeByList:
                    {
                        uint[] entries = GetEntriesList();
                        numericUpDown.Maximum = progressBar.Maximum = entries.Length;
                        _worker.SetValue(entries);
                        break;
                    }
                case ParsingType.TypeByMultipleValue:
                    {
                        uint startValue = (uint)rangeStart.Value;
                        uint endValue = (uint)rangeEnd.Value;

                        if (startValue > endValue)
                        {
                            ShowMessageBox(MessageType.MultipleTypeBigger);
                            return;
                        }

                        if (startValue == endValue)
                        {
                            ShowMessageBox(MessageType.MultipleTypeEqual);
                            return;
                        }

                        numericUpDown.Maximum = progressBar.Maximum = (int)(endValue - startValue) + 1;
                        _worker.SetValue(startValue, endValue);
                        break;
                    }
                case ParsingType.TypeByWoWHeadFilter:
                    {
                        int maxValue = (parser.MaxCount / 200);
                        numericUpDown.Maximum = progressBar.Maximum = maxValue + 1;
                        _worker.SetValue((uint)maxValue);
                        break;
                    }
                default:
                    return;
            }

            abortButton.Enabled = true;
            subparsersListBox.Enabled = settingsBox.Enabled = startButton.Enabled = false;
            numericUpDown.Value = progressBar.Value = 0;
            SetLabelText(Resources.Label_Working);

            Requests.Compress = Settings.Default.DataCompression;

            backgroundWorker.RunWorkerAsync();
        }