protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            int colorValue = newToken.GetProperty <Int32Property>(PropertyNames.Int32ColorWheel).Value;

            this.color = ColorBgra.FromOpaqueInt32(colorValue);
            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
Exemple #2
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty <DoubleProperty>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty <Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount3).Value;
            Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount4).Value);
            Amount5 = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Amount5).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);


            Bitmap   puzzleBitmap   = new Bitmap((int)(100 * Amount1), (int)(100 * Amount1), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics puzzleGraphics = Graphics.FromImage(puzzleBitmap);

            puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Pen puzzlePen = new Pen(Amount4, Amount2);

            // Create points that define the horizontal curve.
            Point horPoint0 = new Point((int)(-50 * Amount1), (int)(16 * Amount1));
            Point horPoint1 = new Point((int)(0 * Amount1), (int)(16 * Amount1));
            Point horPoint2 = new Point((int)(13 * Amount1), (int)(28 * Amount1));
            Point horPoint3 = new Point((int)(9 * Amount1), (int)(50 * Amount1));

            Point horPoint4 = new Point((int)(49 * Amount1), (int)(49 * Amount1));

            Point horPoint5 = new Point((int)(90 * Amount1), (int)(49 * Amount1));
            Point horPoint6 = new Point((int)(86 * Amount1), (int)(71 * Amount1));
            Point horPoint7 = new Point((int)(99 * Amount1), (int)(83 * Amount1));
            Point horPoint8 = new Point((int)(149 * Amount1), (int)(83 * Amount1));

            Point[] horCurvePoints = { horPoint0, horPoint1, horPoint2, horPoint3, horPoint4, horPoint5, horPoint6, horPoint7, horPoint8 };

            // Draw the horizontal curve to graphics object.
            puzzleGraphics.DrawCurve(puzzlePen, horCurvePoints);


            // Create points that define the vertical curve.
            Point verPoint0 = new Point((int)(83 * Amount1), (int)(-50 * Amount1));
            Point verPoint1 = new Point((int)(83 * Amount1), (int)(0 * Amount1));
            Point verPoint2 = new Point((int)(73 * Amount1), (int)(13 * Amount1));
            Point verPoint3 = new Point((int)(49 * Amount1), (int)(9 * Amount1));

            Point verPoint4 = new Point((int)(50 * Amount1), (int)(50 * Amount1));

            Point verPoint5 = new Point((int)(50 * Amount1), (int)(90 * Amount1));
            Point verPoint6 = new Point((int)(28 * Amount1), (int)(86 * Amount1));
            Point verPoint7 = new Point((int)(16 * Amount1), (int)(99 * Amount1));
            Point verPoint8 = new Point((int)(16 * Amount1), (int)(149 * Amount1));

            Point[] verCurvePoints = { verPoint0, verPoint1, verPoint2, verPoint3, verPoint4, verPoint5, verPoint6, verPoint7, verPoint8 };

            // Draw the vertical curve to graphics object.
            puzzleGraphics.DrawCurve(puzzlePen, verCurvePoints);

            puzzlePen.Dispose();

            puzzleSurface = Surface.CopyFromBitmap(puzzleBitmap);
            puzzleBitmap.Dispose();
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            scale       = newToken.GetProperty <Int32Property>(PropertyNames.Scale).Value;
            roughness   = newToken.GetProperty <DoubleProperty>(PropertyNames.Roughness).Value;
            minOpacity  = newToken.GetProperty <Int32Property>(PropertyNames.MinimumOpacity).Value;
            reseed      = (byte)newToken.GetProperty <Int32Property>(PropertyNames.Reseed).Value;
            customColor = newToken.GetProperty <BooleanProperty>(PropertyNames.UseCustomColor).Value;
            color       = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Color).Value);

            if (emptySurface == null)
            {
                emptySurface = new Surface(srcArgs.Size);
            }
            if (cloudSurface == null)
            {
                cloudSurface = new Surface(srcArgs.Size);
            }

            // Call the Render Clouds function
            cloudsProps = cloudsEffect.CreatePropertyCollection();
            PropertyBasedEffectConfigToken CloudsParameters = new PropertyBasedEffectConfigToken(cloudsProps);

            CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Scale, scale);
            CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Power, roughness);
            CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Seed, reseed);
            using (EffectEnvironmentParameters environParameters = new EffectEnvironmentParameters(ColorBgra.Black, Color.FromArgb(minOpacity, Color.Black), 0, EnvironmentParameters.GetSelectionAsPdnRegion(), emptySurface))
                cloudsEffect.EnvironmentParameters = environParameters;
            cloudsEffect.SetRenderInfo(CloudsParameters, new RenderArgs(cloudSurface), new RenderArgs(emptySurface));

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
Exemple #4
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.Amount1 = newToken.GetProperty <Int32Property>(PropertyNames.Amount1).Value;
            this.Amount2 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount2).Value;
            this.Amount3 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount3).Value);
            this.Amount4 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount4).Value;
            this.Amount5 = newToken.GetProperty <Int32Property>(PropertyNames.Amount5).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            m_TintStrength = token.GetProperty <DoubleProperty>(PropertyNames.M_TintStrength).Value;
            m_UseRgbPicker = token.GetProperty <BooleanProperty>(PropertyNames.M_UseRgbPicker).Value;
            m_RgbColor     = ColorBgra.FromOpaqueInt32(token.GetProperty <Int32Property>(PropertyNames.M_RgbColor).Value);
            m_H            = token.GetProperty <Int32Property>(PropertyNames.M_H).Value;
            m_S            = token.GetProperty <Int32Property>(PropertyNames.M_S).Value;
            m_V            = token.GetProperty <Int32Property>(PropertyNames.M_V).Value;

            base.OnSetRenderInfo(token, dstArgs, srcArgs);
        }
Exemple #6
0
        void hex_TextChanged(object sender, EventArgs e)
        {
            if (!eventssuspended)
            {
                SuspendEvents();

                try
                {
                    ColorBgra c = ColorBgra.FromOpaqueInt32(int.Parse(hex.Text, System.Globalization.NumberStyles.HexNumber));
                    HsvColor  h = HsvColor.FromColor(c);
                    wheel.Color = c;
                    SetRgbSliders(c);
                    SetHsvSliders(h);
                }
                catch
                {
                    hex.Text = "";
                }

                ResumeEvents();
            }
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.antiAlias   = newToken.GetProperty <BooleanProperty>(PropertyNames.AntiAliasing).Value;
            this.transparent = newToken.GetProperty <BooleanProperty>(PropertyNames.TransparentBack).Value;
            this.backColor   = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.BackColor).Value);

            int radius = newToken.GetProperty <Int32Property>(PropertyNames.Radius).Value;
            int margin = newToken.GetProperty <Int32Property>(PropertyNames.Margin).Value;

            Rectangle selection = EnvironmentParameters.SelectionBounds;

            marginBounds = Rectangle.FromLTRB(selection.Left + margin, selection.Top + margin, selection.Right - margin, selection.Bottom - margin);
            int radiusMax = Math.Min(selection.Width, selection.Height) / 2 - margin;

            radiusValue = Math.Min(radius, radiusMax);

            // create a rectangle that will be used to determine how the pixels should be rendered
            this.rectangleTopCoordinate    = this.marginBounds.Top + this.radiusValue;
            this.rectangleBottomCoordinate = this.marginBounds.Bottom - 1 - this.radiusValue;
            this.rectangleLeftCoordinate   = this.marginBounds.Left + this.radiusValue;
            this.rectangleRightCoordinate  = this.marginBounds.Right - 1 - this.radiusValue;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
Exemple #8
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            string                text       = newToken.GetProperty <StringProperty>(PropertyNames.Text).Value + " ";
            int                   textRepeat = newToken.GetProperty <Int32Property>(PropertyNames.TextRepeat).Value;
            int                   fontSize   = newToken.GetProperty <Int32Property>(PropertyNames.FontSize).Value;
            FontFamily            fontFam    = (FontFamily)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Font).Value;
            bool                  bold       = newToken.GetProperty <BooleanProperty>(PropertyNames.Bold).Value;
            bool                  italic     = newToken.GetProperty <BooleanProperty>(PropertyNames.Italic).Value;
            bool                  underline  = newToken.GetProperty <BooleanProperty>(PropertyNames.Underline).Value;
            bool                  strikeout  = newToken.GetProperty <BooleanProperty>(PropertyNames.Strikeout).Value;
            Pair <double, double> offset     = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Offset).Value;

            this.backColor = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.BackColor).Value);

            Rectangle  selection = EnvironmentParameters.SelectionBounds;
            RectangleF textRect  = new RectangleF(
                (float)offset.First * selection.Width + selection.Left,
                (float)offset.Second * selection.Height + selection.Top,
                selection.Width,
                selection.Height);

            System.Text.StringBuilder textRepeated = new System.Text.StringBuilder();
            for (int i = 0; i < textRepeat; i++)
            {
                textRepeated.Append(text);
            }

            if (this.textSurface == null)
            {
                this.textSurface = new Surface(srcArgs.Surface.Size);
            }
            else
            {
                this.textSurface.Clear(Color.Transparent);
            }

            using (Graphics g = new RenderArgs(this.textSurface).Graphics)
            {
                g.TextRenderingHint = TextRenderingHint.AntiAlias;

                FontStyle fontStyle = FontStyle.Regular;
                if (bold)
                {
                    fontStyle |= FontStyle.Bold;
                }
                if (italic)
                {
                    fontStyle |= FontStyle.Italic;
                }
                if (underline)
                {
                    fontStyle |= FontStyle.Underline;
                }
                if (strikeout)
                {
                    fontStyle |= FontStyle.Strikeout;
                }

                using (SolidBrush fontBrush = new SolidBrush(Color.Black))
                    using (Font font = new Font(fontFam, fontSize, fontStyle))
                    {
                        g.DrawString(textRepeated.ToString(), font, fontBrush, textRect);
                    }
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
Exemple #9
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            scale       = newToken.GetProperty <DoubleProperty>(PropertyNames.Scale).Value;
            lineWidth   = newToken.GetProperty <Int32Property>(PropertyNames.LineWidth).Value;
            pattern     = (Pattern)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Pattern).Value;
            transparent = newToken.GetProperty <BooleanProperty>(PropertyNames.Transparent).Value;
            lineColor   = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.LineColor).Value);
            offset      = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Offset).Value;


            Rectangle selection = EnvironmentParameters.SelectionBounds;

            gridScale = 100 * scale;

            puzzleRect = new Rectangle
            {
                X      = selection.Left + (int)Math.Round((selection.Width % gridScale) / 2 + (offset.First * (selection.Width % gridScale) / 2)),
                Y      = selection.Top + (int)Math.Round((selection.Height % gridScale) / 2 + (offset.Second * (selection.Height % gridScale) / 2)),
                Width  = selection.Width - (int)(selection.Width % gridScale),
                Height = selection.Height - (int)(selection.Height % gridScale)
            };

            horLoops = puzzleRect.Height / (int)(gridScale);
            verLoops = puzzleRect.Width / (int)(gridScale);

            // Puzzle Pattern
            bool horAlt, verAlt;

            switch (pattern)
            {
            case Pattern.AltHorVer:
                horAlt = true;
                verAlt = true;
                break;

            case Pattern.AltNone:
                horAlt = false;
                verAlt = false;
                break;

            case Pattern.AltHor:
                horAlt = true;
                verAlt = false;
                break;

            case Pattern.AltVer:
                horAlt = false;
                verAlt = true;
                break;

            default:
                horAlt = true;
                verAlt = true;
                break;
            }

            if (puzzleSurface == null)
            {
                puzzleSurface = new Surface(srcArgs.Surface.Size);
            }
            else
            {
                puzzleSurface.Fill(ColorBgra.Transparent);
            }

            using (Graphics puzzleGraphics = new RenderArgs(puzzleSurface).Graphics)
                using (Pen puzzlePen = new Pen(lineColor, lineWidth))
                {
                    puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                    PointF[] curvePoints;

                    //Horizontal Lines
                    #region Horizontal Lines
                    for (int i = 0; i < horLoops - 1; i++)
                    {
                        if (horAlt && i % 2 == 0)
                        {
                            for (int i2 = 0; i2 < verLoops; i2++)
                            {
                                Apex apex = (i2 % 2 != 0) ? Apex.Up : Apex.Down;
                                curvePoints = getCurvePoints(apex, i, i2);

                                puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                            }
                        }
                        else
                        {
                            for (int i2 = 0; i2 < verLoops; i2++)
                            {
                                Apex apex = (i2 % 2 == 0) ? Apex.Up : Apex.Down;
                                curvePoints = getCurvePoints(apex, i, i2);

                                puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                            }
                        }
                    }
                    #endregion

                    //Vertical Lines
                    #region Vertical Lines
                    for (int i = 0; i < verLoops - 1; i++)
                    {
                        if (verAlt && i % 2 == 0)
                        {
                            for (int i2 = 0; i2 < horLoops; i2++)
                            {
                                Apex apex = (i2 % 2 != 0) ? Apex.Right : Apex.Left;
                                curvePoints = getCurvePoints(apex, i, i2);

                                puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                            }
                        }
                        else
                        {
                            for (int i2 = 0; i2 < horLoops; i2++)
                            {
                                Apex apex = (i2 % 2 == 0) ? Apex.Right : Apex.Left;
                                curvePoints = getCurvePoints(apex, i, i2);

                                puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                            }
                        }
                    }
                    #endregion
                }


            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
Exemple #10
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty <StringProperty>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty <Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = newToken.GetProperty <Int32Property>(PropertyNames.Amount3).Value;
            FontFamily Amount4FontFamily = (FontFamily)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Amount4).Value;

            Amount4  = new FontFamily(Amount4FontFamily.Name);
            Amount5  = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount5).Value;
            Amount6  = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount6).Value;
            Amount7  = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount7).Value;
            Amount8  = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount8).Value;
            Amount9  = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Amount9).Value;
            Amount10 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount10).Value);

            Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();
            Rectangle textRect  = Rectangle.Round(new RectangleF((float)Amount9.First * selection.Width + selection.Left, (float)Amount9.Second * selection.Height + selection.Top, selection.Width, selection.Height));

            string text = Amount1 + " ";

            System.Text.StringBuilder textRepeated = new System.Text.StringBuilder();
            for (int i = 0; i < Amount2; i++)
            {
                textRepeated.Append(text);
            }

            if (textSurface == null)
            {
                textSurface = new Surface(srcArgs.Surface.Size);
            }
            else
            {
                textSurface.Clear(Color.Transparent);
            }

            using (Graphics g = new RenderArgs(textSurface).Graphics)
            {
                g.TextRenderingHint = TextRenderingHint.AntiAlias;

                FontStyle fontStyle = FontStyle.Regular;
                if (Amount5)
                {
                    fontStyle |= FontStyle.Bold;
                }
                if (Amount6)
                {
                    fontStyle |= FontStyle.Italic;
                }
                if (Amount7)
                {
                    fontStyle |= FontStyle.Underline;
                }
                if (Amount8)
                {
                    fontStyle |= FontStyle.Strikeout;
                }

                TextFormatFlags flags = TextFormatFlags.Top | TextFormatFlags.WordBreak;
                using (Font font = new Font(Amount4, Amount3, fontStyle))
                {
                    TextRenderer.DrawText(g, textRepeated.ToString(), font, textRect, Color.Black, Color.Transparent, flags);
                }
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
Exemple #11
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.Initialize();

            if (this._form == null)
            {
                this._form = Form.ActiveForm;
                if (this._form != null)
                {
                    if (this._form.Text != StaticName)
                    {
                        this._form = null;
                    }
                    else
                    {
                        this._form.FormClosed += (sender, e) =>
                        {
                            if (((Form)sender).DialogResult != DialogResult.OK)
                            {
                                this._cancelToken.SignalCancelRequest();
                            }
                        };
                        if (this._form.CancelButton is Control c)
                        {
                            c.Click += (sender, e) => { this._cancelToken.SignalCancelRequest(); };
                        }
                    }
                }
            }

            this._mode         = (Modes)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Mode).Value;
            this._lowerThres   = (float)newToken.GetProperty <DoubleProperty>(PropertyNames.LowerThreshold).Value;
            this._upperThres   = (float)newToken.GetProperty <DoubleProperty>(PropertyNames.UpperThreshold).Value;
            this._color        = HsvColor.FromColor(ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Color).Value).ToColor());
            this._color2       = HsvColor.FromColor(ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Color2).Value).ToColor());
            this._hueDirection = (HueDirection)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.HueDirection).Value;
            this._radius       = newToken.GetProperty <Int32Property>(PropertyNames.SmoothingRadius).Value;
            this._angle        = MathUtil.DegreesToRadians(newToken.GetProperty <DoubleProperty>(PropertyNames.Angle).Value);
            string diffStr = newToken.GetProperty <StringProperty>(PropertyNames.DifferenceFilter).Value;

            Matrix diff;

            if (Matrix.TryParse(diffStr, out diff))
            {
                if (diff.GetNormalized() != this._diffX.GetNormalized())
                {
                    this._diffX = diff;
                    this._cancelToken.SignalCancelRequest();
                    this._taskSTField = null;
                    this.Initialize();
                }
            }

            int length = 2 * this._radius + 1;

            if (length < 3)
            {
                this._weight = null;
            }
            else if (this._weight == null || length != this._weight.RowCount)
            {
                this._weight = Utils.GetGaussianKernelY(length) * Utils.GetGaussianKernelX(length);
                this._cachedCharacteristics.Invalidate();
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }