示例#1
0
        public static bool Cmp(CmpType cmp, int lv, int rv)
        {
            switch (cmp)
            {
            case CmpType.lt:
            {
                return(lv < rv);
            }

            case CmpType.le:
            {
                return(lv <= rv);
            }

            case CmpType.eq:
            {
                return(lv == rv);
            }

            case CmpType.ge:
            {
                return(lv >= rv);
            }

            case CmpType.gt:
            {
                return(lv > rv);
            }
            }
            return(false);
        }
示例#2
0
 public static bool Cmp(CmpType cmp, int lv, int rv)
 {
     switch (cmp)
     {
         case CmpType.lt:
             {
                 return lv < rv;
             }
         case CmpType.le:
             {
                 return lv <= rv;
             }
         case CmpType.eq:
             {
                 return lv == rv;
             }
         case CmpType.ge:
             {
                 return lv >= rv;
             }
         case CmpType.gt:
             {
                 return lv > rv;
             }
     }
     return false;
 }
示例#3
0
 public void SetParams(int intA, int intB)
 {
     type      = CmpType.Int;
     this.intA = intA;
     this.intB = intB;
     strA      = strB = null;
     floatA    = floatB = 0f;
 }
示例#4
0
 public void SetParams(float floatA, float floatB)
 {
     type        = CmpType.Float;
     this.floatA = floatA;
     this.floatB = floatB;
     strA        = strB = null;
     intA        = intB = 0;
 }
示例#5
0
 public CmpEnemyNum(CmpType cmp, int num)
 {
     _cmp = cmp;
     _num = num;
 }
示例#6
0
 public CmpTeammateNum(CmpType cmp, int num)
 {
     _cmp = cmp;
     _num = num;
 }
示例#7
0
 public CmpEnemyHP(CmpType cmp, int percent)
 {
     _cmp = cmp;
     _percent = percent;
 }
示例#8
0
 public CmpSelfHP(CmpType cmp, int percent)
 {
     _cmp = cmp;
     _percent = percent;
 }
示例#9
0
 public CmpRate(CmpType cmp, int rate)
 {
     _cmp  = cmp;
     _rate = rate;
 }
示例#10
0
        private Image <Gray, byte> CreateMaskOfOverInappropriateColorProportions(Image <Gray, byte> grayImage, Image <Bgr, byte> image, double tone, BgrColor color, CmpType cmpType, double margin)
        {
            double             interval = 0;
            float              count    = (image?.CountNonzero()[(int)color]) ?? 1;
            float              nonZeroCount;
            Image <Gray, byte> resultMask = grayImage.CopyBlank();

            switch (cmpType)
            {
            case CmpType.LessThan: { interval = Math.Round((1 - margin) * tone, 3); } break;

            case CmpType.GreaterThan: { interval = Math.Round((1 + margin) * tone, 3); } break;

            default: { interval = tone; } break;
            }

            using (Image <Gray, byte> model = grayImage.Mul(interval * 3.0))
            {
                using (Image <Gray, byte> cmpImage = _image[(int)color].Cmp(model[0], cmpType))
                {
                    using (Image <Gray, byte> disColorMask = cmpImage.ThresholdBinary(new Gray(1), new Gray(255)))
                    {
                        Mat kernel = CvInvoke.GetStructuringElement(ElementShape.Ellipse, new Size(3, 3), new Point(-1, -1));
                        CvInvoke.MorphologyEx(disColorMask, resultMask, MorphOp.Open, kernel, new Point(-1, -1), 1, BorderType.Replicate, new MCvScalar(1.0));

                        nonZeroCount = resultMask[0]?.CountNonzero()[0] ?? 0;
                    }
                }
            }

            if (nonZeroCount / count > 0.20 && margin < 1.0)
            {
                margin += 0.05;
                return(CreateMaskOfOverInappropriateColorProportions(grayImage, image, tone, color, cmpType, margin));
            }
            else
            {
                return(resultMask);
            }
        }
示例#11
0
 public CmpTargetDistance(CmpType cmp, int distance)
 {
     _cmp = cmp;
     _distance = distance;
 }
示例#12
0
 public CmpLastSkillCoord(CmpType cmp, int distance)
 {
     _cmp      = cmp;
     _distance = distance;
 }
示例#13
0
 public CmpSkillUseCount(int skillId, CmpType cmp, int useCount)
 {
     _skillId  = skillId;
     _cmp      = cmp;
     _useCount = useCount;
 }
示例#14
0
 public CmpEnemyNum(CmpType cmp, int num)
 {
     _cmp = cmp;
     _num = num;
 }
示例#15
0
 public CmpTeammateNum(CmpType cmp, int num)
 {
     _cmp = cmp;
     _num = num;
 }
示例#16
0
 public CmpEnemyHP(CmpType cmp, int percent)
 {
     _cmp     = cmp;
     _percent = percent;
 }
示例#17
0
 public CmpSelfHP(CmpType cmp, int percent)
 {
     _cmp     = cmp;
     _percent = percent;
 }
示例#18
0
 public CmpSkillUseCount(int skillId, CmpType cmp, int useCount)
 {
     _skillId = skillId;
     _cmp = cmp;
     _useCount = useCount;
 }
示例#19
0
 public CmpLastSkillCoord(CmpType cmp, int distance)
 {
     _cmp = cmp;
     _distance = distance;
 }
示例#20
0
 public CmpTargetDistance(CmpType cmp, int distance)
 {
     _cmp      = cmp;
     _distance = distance;
 }
示例#21
0
        private void RepairColor(ref Image <Bgr, byte> cleanedImage, Image <Gray, byte> grayImage, Image <Gray, byte> generalImageMask, BgrColor bgrColor, double colorTone, CmpType cmpType)
        {
            using (Image <Gray, byte> defectsMask = CreateMaskOfOverInappropriateColorProportions(grayImage, cleanedImage /*_image*/, colorTone, bgrColor, cmpType, _margin))
            {
                using (Image <Gray, byte> repairMask = generalImageMask.Mul(defectsMask))
                {
                    Image <Bgr, byte> cleanedPatchImage = cleanedImage.CopyBlank();
                    cleanedPatchImage[0] = cleanedImage[(int)bgrColor].Mul(BlueTone * 3);
                    cleanedPatchImage[1] = cleanedImage[(int)bgrColor].Mul(GreenTone * 3);
                    cleanedPatchImage[2] = cleanedImage[(int)bgrColor].Mul(RedTone * 3);

                    cleanedImage = MorphologicalProcessing.CombineTwoImages(cleanedImage, cleanedPatchImage, repairMask);
                }
            }
        }
示例#22
0
            /// <summary>
            /// Moves to the next item in the current scope (skips over subitems of the current item). Returns
            /// false if there are no more items in the current scope.
            /// </summary>
            /// <returns>True if an item is selected after the operation.</returns>
            public bool NextItem()
            {
                // If we are currently pointing at the beginning of a group, we need to skip past it.
                if (currentItemType == CmpType.Group)
                {
                    // Do this by opening (half-assedly) the group, then closing it
                    cursorPos++;
                    currentLevel++;
                    CloseItem();
                }

                // Selection will be empty unless we find something
                UnselectItem();

                // Grab item name. If we didn't find an item name, set itemSelected to false.
                SkipWhitespace();
                if (cursorPos < document.Length)
                {
                    currentItemName = GrabIdentifier();
                }
                itemSelected = currentItemName != null;

                if (itemSelected)
                {
                    SkipWhitespace(); // Move to value

                    if (cursorPos >= document.Length)
                    {
                        throw new CmpDocumentException("Item does not have a value.");
                    }
                    if (document[cursorPos] == '"')
                    {
                        // string
                        cursorPos++;
                        var startOfString = cursorPos;
                        SkipPastString();
                        var strLen = cursorPos - startOfString - 1;
                        currentItemValue = document.Substring(startOfString, strLen);
                        currentItemType  = CmpType.String;
                    }
                    else if (document[cursorPos] == '(')
                    {
                        // Group
                        currentItemType = CmpType.Group;
                    }
                    else
                    {
                        // Unquoted string ("Literal")
                        var value = GrabLiteral();
                        if (value == null)
                        {
                            throw new CmpDocumentException("Item does not have a value.");
                        }
                        currentItemValue = value;
                        currentItemType  = CmpType.Literal;
                    }
                }
                else
                {
                    // If we didn't find an item, one of the following is true
                    // - We are at the end of a group (a closing paren must be present)
                    // - We are at the end of the document (cursor points past last char)
                    // - There is a syntax error

                    if (cursorPos < document.Length)
                    {
                        if (document[cursorPos] != ')')
                        {
                            throw new CmpDocumentException("Unexpected text in document at position " + cursorPos.ToString());
                        }
                    }
                    else
                    {
                        // If we reached the end of the document and there is a group that wasn't closed, that's an error
                        if (currentLevel > 0)
                        {
                            ErrEndOfDoc();
                        }
                    }
                }

                return(itemSelected);
            }
示例#23
0
 public CmpRate(CmpType cmp, int rate)
 {
     _cmp = cmp;
     _rate = rate;
 }
示例#24
0
 private void UnselectItem()
 {
     currentItemName = currentItemValue = null;
     currentItemType = CmpType.None;
     itemSelected    = false;
 }
示例#25
0
 public void SetType(CmpType type)
 {
     this.type = type;
 }
示例#26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isFirst">是否第一个查询条件,如果true,则忽略CompositeType</param>
        /// <returns></returns>
        public string Parse(bool isFirst = false)
        {
            //条件模板:and/or ag.gp_name like '%asdfasd%'
            string sql = string.Format(" {0} {1} ", (isFirst || CmpType == CompositeType.None) ? "" : CmpType.ToString(), Field);

            switch (ConditionType)
            {
            //字符串
            case ConditionType.Contain:
                sql += string.Format("{0} like '%{1}%'", Not ? "not" : "", (string)Value);
                break;

            case ConditionType.StartWith:
                sql += string.Format("{0} like '{1}%'", Not ? "not" : "", (string)Value);
                break;

            case ConditionType.EndWith:
                sql += string.Format("{0} like '%{1}'", Not ? "not" : "", (string)Value);
                break;

            case ConditionType.GreaterThan:
                sql += ParseNumberAndDateTime(ConditionType.GreaterThan);
                break;

            case ConditionType.GreaterOrEqual:
                sql += ParseNumberAndDateTime(ConditionType.GreaterOrEqual);
                break;

            case ConditionType.LessThan:
                sql += ParseNumberAndDateTime(ConditionType.LessThan);
                break;

            case ConditionType.LessOrEqual:
                sql += ParseNumberAndDateTime(ConditionType.LessOrEqual);
                break;

            case ConditionType.Equal:
                sql += string.Format("{0} {1}", Not ? "<>" : "=", FieldType == FieldType.Number ? (string)Value : ("'" + (string)Value + "'"));
                break;

            case ConditionType.In:
                sql += ParseIn();
                break;

            case ConditionType.IsEmpty:
                sql += string.Format("is {0} null", Not ? "not" : "");
                break;

            case ConditionType.Between:
                sql += ParseBetween();
                break;
            }

            return(sql);
        }