private void LoadImageOperationControl(ImageOperation imageOperation)
        {
            buttonEditStep.Text = "Choose Control";
            panelControl.Controls.Clear();
            UserControl c = null;
            if (imageOperation.GetType().IsAssignableFrom(typeof(MonoClusterDetect)))
            {
                MonoClusterDetectionControl_White d = new MonoClusterDetectionControl_White();
                MonoClusterDetect e = ((MonoClusterDetect)imageOperation);
                d.textBoxMinArea.Text = e.clusterAreaLowerBound.ToString();
                d.textBoxExclusionColor.Text = e.exclusionColor.ToString();
                d.textBoxMaxArea.Text = e.maxArea.ToString();
                d.textBoxMaxColor.Text = e.maxcolor.ToString();
                d.textBoxMinColor.Text = e.mincolor.ToString();
                if (!e.fillColorEnabled)
                    d.textBoxFillColor.Text = "-1";
                if (!e.exclusionColorEnabled)
                    d.textBoxExclusionColor.Text = "-1";
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoCircleDetect)))
            {
                MonoCircleDetectControl d = new MonoCircleDetectControl();
                MonoCircleDetect e = ((MonoCircleDetect)imageOperation);

                d.textBoxAngleTolerance.Text = e.angleTolerance.ToString();
                d.textBoxArcSigmaTolerance.Text = e.arcSigmaTolerance.ToString();
                c = d;

            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoClusterHighlighting)))
            {
                MonoClusterHighlightingControl d = new MonoClusterHighlightingControl();
                d.textBoxColorValue.Text = ((MonoClusterHighlighting)imageOperation).colorValue.ToString();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoCratersFromClusters)))
            {
                MonoCratersFromClustersControl d = new MonoCratersFromClustersControl();
                d.textBoxMinSize.Text = ((MonoCratersFromClusters)imageOperation).minSize.ToString();
                d.textBoxMaxSize.Text = ((MonoCratersFromClusters)imageOperation).maxSize.ToString();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoEqualize)))
            {
                MonoEqualizeControl d = new MonoEqualizeControl();
                d.textBoxLowerboundMax.Text = ((MonoEqualize)imageOperation).minSearch.ToString();
                d.textBoxUpperboundMax.Text = ((MonoEqualize)imageOperation).maxSearch.ToString();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoIdentity)))
            {
                MonoIdentityControl d = new MonoIdentityControl();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoInvert)))
            {
                MonoInvertControl d = new MonoInvertControl();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoLinearColorStretch)))
            {
                LinearColorStretchControl d = new LinearColorStretchControl();
                d.textBoxMin.Text = ((MonoLinearColorStretch)imageOperation).min.ToString();
                d.textBoxMax.Text = ((MonoLinearColorStretch)imageOperation).max.ToString();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(MonoNormalize)))
            {
                NormalizeControl d = new NormalizeControl();
                d.textBoxX1.Text = ((MonoNormalize)imageOperation).x1.ToString();
                d.textBoxY1.Text = ((MonoNormalize)imageOperation).y1.ToString();
                d.textBoxX2.Text = ((MonoNormalize)imageOperation).x2.ToString();
                d.textBoxY2.Text = ((MonoNormalize)imageOperation).y2.ToString();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(DualAdjacentClusterMerge)))
            {
                DualAdjacentClusterMergeControl d = new DualAdjacentClusterMergeControl();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(DualDarkCraterStatisticExtend)))
            {
                DualDarkCraterStatisticExtendControl d = new DualDarkCraterStatisticExtendControl();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(DualSubtraction)))
            {
                DualSubtractionControl d = new DualSubtractionControl();
                c = d;
            }
            else if (imageOperation.GetType().IsAssignableFrom(typeof(DualImageUnderlay)))
            {
                DualImageUnderlayControl d = new DualImageUnderlayControl();
                d.textBoxTransparentColor.Text = ((DualImageUnderlay)imageOperation).transparentColor.ToString();
                c = d;
            }
            else
            {
                throw new NotImplementedException();
            }

            if (typeof(MonoUserControl).IsAssignableFrom(c.GetType()))
            {
                MonoUserControl e = (MonoUserControl)c;
                e.UnderlyingWidget.ImageOperator.Source = batch.Images[currentStep.Source1];
                e.UnderlyingWidget.ImageOperator.Result = batch.Images[currentStep.OperationResult];
            }
            if (typeof(DualUserControl).IsAssignableFrom(c.GetType()))
            {
                DualUserControl e = (DualUserControl)c;
                e.UnderlyingWidget.ImageOperator.Source = batch.Images[currentStep.Source1];
                ((DualImageOperator)e.UnderlyingWidget.ImageOperator).Source2 = batch.Images[currentStep.Source2];
                e.UnderlyingWidget.ImageOperator.Result = batch.Images[currentStep.OperationResult];
            }
            panelControl.Controls.Add(c);
            ShowList(false);
        }
        public EditableOperationBatchStep(EditableOperationBatch batch, DataImage image)
        {
            this.batch = batch;
            TagImage(image);

            this.operationResult = GetImageString(image);
            if (image.ResultOf != null)
            {
                TagImage(image.ResultOf.Source);
                this.source1 = GetImageString(image.ResultOf.Source);

                this.imageOperation = image.ResultOf.ImageOperation;
                try
                {

                    //if (typeof(DualImageOperation).IsAssignableFrom(imageOperation.GetType()))
                    //{
                        DualImageOperation d = (DualImageOperation)imageOperation;
                        TagImage(d.imageSource2);
                        this.source2 = GetImageString(d.imageSource2);
                    //}
                }
                catch (Exception)
                {
                }
            }
        }