示例#1
0
        protected override void Execute(CodeActivityContext context)
        {
            this.ImgReview = InputImage.Get(context);
            this.StrText   = InputText.Get(context);

            IsUnRead = false;
            IsModify = false;
            FormMain fm = new FormMain(this);

            fm.ShowDialog();

            IsModified.Set(context, this.IsModify);
            IsUnreadable.Set(context, this.IsUnRead);
            ReviewedText.Set(context, this.StrText);
        }
示例#2
0
        protected override void Execute(CodeActivityContext context)
        {
            this.ImgReview        = InputImage.Get(context);
            this.StrText          = InputText.Get(context);
            this.ListStrCandidate = CandidateStringList.Get(context);

            this.IntFrameWidth           = FrameWidth.Get(context);
            this.IntImageFrameHeight     = ImageFrameHeight.Get(context);
            this.IntTextFrameHeight      = TextFrameHeight.Get(context);
            this.IntFontSize             = FontSize.Get(context);
            this.IsDisableEnterKeySubmit = DisableEnterKeySubmit.Get(context);

            this.IsUnRead = false;
            this.IsModify = false;

            FormMain fm = new FormMain(this);

            fm.ShowDialog();

            IsModified.Set(context, this.IsModify);
            IsUnreadable.Set(context, this.IsUnRead);
            ReviewedText.Set(context, this.StrText);
        }
示例#3
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Inputs
            var timeout    = TimeoutMS.Get(context);
            var inputImage = InputImage.Get(context);
            var positionX  = PositionX.Get(context);
            var positionY  = PositionY.Get(context);
            var width      = Width.Get(context);
            var height     = Height.Get(context);
            var blur       = Blur.Get(context);
            var blurAmount = BlurAmount.Get(context);

            // Set a timeout on the execution
            var task = ExecuteWithTimeout(context, cancellationToken);

            if (await Task.WhenAny(task, Task.Delay(timeout, cancellationToken)) != task)
            {
                throw new TimeoutException(Resources.Timeout_Error);
            }

            Image returnImage;

            // Check if activity should blur or hide part of the image

            if (blur)
            {
                // Convert image to bytestream
                ImageConverter _imageConverter = new ImageConverter();
                byte[]         imageByteStream = (byte[])_imageConverter.ConvertTo(inputImage, typeof(byte[]));

                // Create image from bytestream for MagickImage use
                var magickimage = new MagickImage(imageByteStream);

                // Blur part of image
                magickimage.RegionMask(new MagickGeometry(positionX, positionY, width, height));
                magickimage.GaussianBlur(blurAmount, 25);
                magickimage.RemoveRegionMask();

                // Convert MagickInmage to Bytestream
                var          imageBytesOut = magickimage.ToByteArray();
                MemoryStream ms            = new MemoryStream(imageBytesOut);

                // Create return image from bytestream
                returnImage = Image.FromStream(ms);
            }
            else
            {
                // Create graphics context with returnImage
                returnImage = inputImage;

                using (Graphics g = Graphics.FromImage(returnImage))
                {
                    // Define brush and rectangle
                    SolidBrush blackBrush = new SolidBrush(Color.Black);
                    Rectangle  rect       = new Rectangle(positionX, positionY, width, height);

                    // Fill rectangle
                    g.FillRectangle(blackBrush, rect);

                    // Cleanup
                    g.Dispose();
                }
            }

            // Outputs
            return((ctx) => {
                OutputImage.Set(ctx, returnImage);
            });
        }