Beispiel #1
0
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            var adornedElementRect = new Rect(AdornedElement.RenderSize);

            switch (State)
            {
            case HighlightAdornerState.HighlightAccept:
                renderBrush         = AcceptBackgroundBrush.Clone();
                renderBrush.Opacity = AcceptBackgroundOpacity;
                renderPen           = new Pen(AcceptBorderBrush, AcceptBorderThickness);
                drawingContext.DrawRoundedRectangle(renderBrush, renderPen, adornedElementRect, AcceptBorderCornerRadius, AcceptBorderCornerRadius);
                break;

            case HighlightAdornerState.HighlightRefuse:
                renderBrush         = RefuseBackgroundBrush.Clone();
                renderBrush.Opacity = RefuseBackgroundOpacity;
                renderPen           = new Pen(RefuseBorderBrush, RefuseBorderThickness);
                drawingContext.DrawRoundedRectangle(renderBrush, renderPen, adornedElementRect, RefuseBorderCornerRadius, RefuseBorderCornerRadius);
                break;

            case HighlightAdornerState.Visible:
                renderBrush         = BackgroundBrush.Clone();
                renderBrush.Opacity = BackgroundOpacity;
                renderPen           = new Pen(BorderBrush, BorderThickness);
                drawingContext.DrawRoundedRectangle(renderBrush, renderPen, adornedElementRect, BorderCornerRadius, BorderCornerRadius);
                break;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Creates an exact, independent copy of the GraphingArgs structure.
 /// </summary>
 /// <returns>An exact, independent copy of the GraphingArgs structure.</returns>
 public object Clone()
 {
     return(new GraphingArgs(
                IndentFromBounds,
                (BackgroundBrush == null ? null : BackgroundBrush.Clone() as Brush),
                (CoordPen == null ? null : CoordPen.Clone() as Pen),
                (CoordFont == null ? null : CoordFont.Clone() as Font),
                (GridPen == null ? null : GridPen.Clone() as Pen),
                (CurvePen == null ? null : CurvePen.Clone() as Pen),
                CurveType
                ));
 }
        public void SetParameter(int framePerSecond = 30, FontFamily fontFamily = null, int fontSize = 16, Brush backgroundBrush = null, Brush textBrush = null, String characterToDisplay = "")
        {
            bool dispRunning = false;

            if (DispatcherTimer.Enabled)
            {
                DispatcherTimer.Stop();
                dispRunning = true;
            }

            if (fontSize > 0)
            {
                RenderingEmSize = fontSize;
            }
            else
            {
                RenderingEmSize = 16;
            }

            if (fontFamily == null)
            {
                if (TextFontFamily == null)
                {
                    TextFontFamily = new FontFamily("Arial");
                }
            }
            else
            {
                TextFontFamily = fontFamily;
            }

            if (characterToDisplay == "")
            {
                AvaiableLetterChars = "abcdefghijklmnopqrstuvwxyz1234567890";
            }
            else
            {
                AvaiableLetterChars = characterToDisplay;
            }

            new Typeface(TextFontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal).TryGetGlyphTypeface(out this.GlyphTypeface);
            LetterAdvanceWidth  = this.GlyphTypeface.AdvanceWidths[0] * this.RenderingEmSize + 4;
            LetterAdvanceHeight = this.GlyphTypeface.Height * this.RenderingEmSize;
            BaselineOrigin      = new Point(2, 2);

            if (backgroundBrush == null)
            {
                if (BackgroundBrush == null)
                {
                    BackgroundBrush = new SolidColorBrush(Color.FromArgb(255, 15, 15, 15));
                }
            }
            else
            {
                BackgroundBrush         = backgroundBrush;
                BackgroundBrush.Opacity = 1;
            }
            MainCanvas.Background   = BackgroundBrush.Clone();
            BackgroundBrush.Opacity = 0.1;

            if (textBrush == null)
            {
                if (TextBrush == null)
                {
                    TextBrush = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
                }
            }
            else
            {
                TextBrush = textBrush;
            }

            if (framePerSecond > 0)
            {
                FramePerSecond = framePerSecond;
            }
            else
            {
                if (FramePerSecond == 0)
                {
                    FramePerSecond = 30;
                }
            }

            DispatcherTimer.Interval = 1000D / FramePerSecond;

            Drops = new int[(int)(CanvasRect.Width / LetterAdvanceWidth)];
            for (var x = 0; x < Drops.Length; x++)
            {
                Drops[x] = 1;
            }

            if (dispRunning)
            {
                DispatcherTimer.Start();
            }
        }