Esempio n. 1
0
        private void listViewTypes_Click(object sender, EventArgs e)
        {
            if (listViewTypes.SelectedItems.Count == 0)
            {
                return;
            }

            var selectedItem = listViewTypes.SelectedItems[0];

            int key = 0;

            if (int.TryParse(selectedItem.Text, out key) == false)
            {
                return;
            }

            ResultTypeInfo pResultTypeInfo = null;

            for (int i = 0; i < listResultTypeInfo.Count; ++i)
            {
                if (listResultTypeInfo[i].index == key)
                {
                    pResultTypeInfo = listResultTypeInfo[i];
                    break;
                }
            }

            if (pResultTypeInfo == null)
            {
                return;
            }

            var dlg = new FormTypeEdit();

            dlg.SetData(pResultTypeInfo.index, onFormTypeEdit_Edit, _get_result_type_info_);
            dlg.SetDataTryEdit(_try_edit_type_index_, _get_analyze_result_info_);
            dlg.Show();
        }
Esempio n. 2
0
        private EnumFailedReason ExecCropAnalize(ExecType eExecType, int index, string Name, string path)
        {
            if (File.Exists(path) == false)
            {
                return(EnumFailedReason.FileNotExist);
            }

            var rectCrop = new Rect(rRectCrop.XMin, rRectCrop.YMin, rRectCrop.XMax, rRectCrop.YMax);

            if (rectCrop.XMin == rectCrop.XMax || rRectCrop.YMin == rRectCrop.YMax)
            {
                return(EnumFailedReason.RectCropInvalid);
            }

            var bitmapOrigin = Util.LoadBitmap(path);

            if (null == bitmapOrigin)
            {
                return(EnumFailedReason.BitmapLoadFailed);
            }

            var cropRectangle = new Rectangle(rectCrop.XMin, rectCrop.YMin, rectCrop.Width, rectCrop.Height);
            var bitmapClone   = bitmapOrigin.Clone(cropRectangle, bitmapOrigin.PixelFormat);

            if (null == bitmapClone)
            {
                bitmapOrigin.Dispose();
                return(EnumFailedReason.BitmapCloneFailed);
            }

            ResultTypeInfo pResultTypeInfo = null;
            bool           isEqual         = false;

            for (int i = 0; i < listResultTypeInfo.Count; ++i)
            {
                isEqual = false;
                switch (eExecType)
                {
                case ExecType.NORMAL:
                    isEqual = Util.CompareBitmaps(listResultTypeInfo[i].bitmap, bitmapClone, ColorDiffMax);
                    break;

                case ExecType.SSIM:
                    isEqual = Util.CompareBitmapsSSIM(listResultTypeInfo[i].bitmap, bitmapClone, SSIMPercent * 0.01f);
                    break;

                default:
                    break;
                }

                if (isEqual)
                {
                    pResultTypeInfo = listResultTypeInfo[i];
                    break;
                }
            }

            if (null == pResultTypeInfo)
            {
                pResultTypeInfo          = new ResultTypeInfo();
                pResultTypeInfo.index    = listResultTypeInfo.Count;
                pResultTypeInfo.typeName = string.Format("type{0}", pResultTypeInfo.index);
                pResultTypeInfo.bitmap   = bitmapClone;

                listResultTypeInfo.Add(pResultTypeInfo);
            }

            var kAnalyzeResult = new AnalyzeResultInfo();

            kAnalyzeResult.index      = index;
            kAnalyzeResult.Name       = Name;
            kAnalyzeResult.Path       = path;
            kAnalyzeResult.ResultType = pResultTypeInfo;

            listAnalyzeResultInfo.Add(kAnalyzeResult);

            bitmapOrigin.Dispose();
            return(EnumFailedReason.None);
        }