}     // simple getter & setter for Y

    void ForceValidate()
    {
        const MAX = 1000;
        const MIN = -1000;

        if (this.X >= MIN && this.X <= MAX && this.Y >= MIN && this.Y <= MAX)
        {
            return;
        }
        this = default(Point);     // Yes you can reasign "this" in structs using C#
    }
Esempio n. 2
0
        private PrimesBigInteger IsGmpBigInteger(string s)
        {
            PrimesBigInteger ipt = null;

            validator.Value = s;
            Primes.WpfControls.Validation.ValidationResult res = validator.Validate(ref ipt);
            if (res != Primes.WpfControls.Validation.ValidationResult.OK)
            {
                log.Info(string.Format(rsc.proot_novalidnumber, new object[] { s, MIN.ToString(), MAX.ToString() }));
                return(null);
            }
            return(ipt);
        }
Esempio n. 3
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            string hour, min, sec;

            hour = HOUR.ToString();
            min  = MIN.ToString();
            sec  = SEC.ToString();


            if (hour.Length < 2 && int.Parse(hour) < 10)
            {
                hour = "0" + hour;
            }
            if (min.Length < 2 && int.Parse(min) < 10)
            {
                min = "0" + min;
            }
            if (sec.Length < 2 && int.Parse(sec) < 10)
            {
                sec = "0" + sec;
            }


            label2.Text = hour + ":" + min + ":" + sec;

            if (SEC != 0)
            {
                SEC--;
            }
            else if (MIN != 0)
            {
                MIN--;
                SEC = 59;
            }
            else
            {
                HOUR--;
                MIN = 59;
            }
            if (HOUR == 0 && MIN == 0 && SEC == 0)
            {
                label2.Text      = "Время истекло!";
                textBox1.Enabled = true;
                textBox2.Enabled = true;
                textBox3.Enabled = true;
                timer2.Stop();
            }
        }
Esempio n. 4
0
        public DocumentCollector AddAggregateFunction(AggregateFunctionType type, IEvaluable field)
        {
            if (_aggregations == null)
            {
                _aggregations = new List <DocumentCollector>();
            }
            IAggregation function;

            switch (type)
            {
            case AggregateFunctionType.AVG:
                function = new AVG();
                break;

            case AggregateFunctionType.COUNT:
                function = new COUNT();
                break;

            case AggregateFunctionType.MAX:
                function = new MAX();
                break;

            case AggregateFunctionType.MIN:
                function = new MIN();
                break;

            case AggregateFunctionType.SUM:
                function = new SUM();
                break;

            //case AggregateFunctionType.FIRST:
            //    function = new FIRST(field);
            //    break;
            //case AggregateFunctionType.LAST:
            //    function = new LAST(field);
            //    break;
            default:
                throw new QuerySystemException(ErrorCodes.Query.AGGREGATION_INVALID_FUNCTION);
            }
            var aggregator = new DocumentCollector(function, field);

            _aggregations.Add(aggregator);
            return(aggregator);
        }
Esempio n. 5
0
        private void Execute(bool doExecute)
        {
            ClearLog();
            intervals.Clear();

            string _input = tbInput.Text;

            if (!string.IsNullOrEmpty(_input))
            {
                string[] input = _input.Trim().Split(',');
                if (input != null && input.Length > 0)
                {
                    foreach (string s in input)
                    {
                        if (!string.IsNullOrEmpty(s))
                        {
                            string[] _inputrange = s.Split(':');
                            if (_inputrange.Length == 1)
                            {
                                PrimesBigInteger ipt = null;
                                validator.Value = s;
                                Primes.WpfControls.Validation.ValidationResult res = validator.Validate(ref ipt);
                                if (res == Primes.WpfControls.Validation.ValidationResult.OK)
                                {
                                    if (ipt.IsPrime(10))
                                    {
                                        intervals.Add(new List <PrimesBigInteger> {
                                            ipt, ipt
                                        });
                                        if (ipt.CompareTo(MAX) > 0)
                                        {
                                            log.Info(string.Format(rsc.proot_warningbignumber, s));
                                        }
                                    }
                                    else
                                    {
                                        log.Info(string.Format(rsc.proot_noprime, s));
                                    }
                                }
                                else
                                {
                                    log.Info(string.Format(rsc.proot_novalidnumber, new object[] { s, MIN.ToString(), MAX.ToString() }));
                                }
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(_inputrange[0]) && string.IsNullOrEmpty(_inputrange[1]))
                                {
                                    log.Info(rsc.proot_rangeboth);
                                }
                                else if (string.IsNullOrEmpty(_inputrange[0]))
                                {
                                    log.Info(string.Format(rsc.proot_rangeupper, _inputrange[1]));
                                }
                                else if (string.IsNullOrEmpty(_inputrange[1]))
                                {
                                    log.Info(string.Format(rsc.proot_rangedown, _inputrange[0]));
                                }
                                else
                                {
                                    PrimesBigInteger i1 = IsGmpBigInteger(_inputrange[0]);
                                    PrimesBigInteger i2 = IsGmpBigInteger(_inputrange[1]);
                                    if (i1 != null && i2 != null)
                                    {
                                        if (i1.CompareTo(i2) >= 0)
                                        {
                                            log.Info(string.Format(rsc.proot_wronginterval, s));
                                        }
                                        else
                                        {
                                            intervals.Add(new List <PrimesBigInteger> {
                                                i1, i2
                                            });
                                            if (i2.CompareTo(MAXWARN) > 0)
                                            {
                                                log.Info(string.Format(rsc.proot_warningbiginterval, s));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (doExecute && intervals.Count > 0)
                {
                    StartThread();
                }
            }
            else
            {
                Info(rsc.proot_insert);
            }
        }