コード例 #1
0
 /// <summary>Draw Line to canvas according coordinates</summary>
 public void DrawLine(float x1, float y1, float x2, float y2)
 {
     if (_strokeColor.Color.A > 0)
     {
         var clipped = PushRenderStates();
         _drawingContext.DrawLine(_stroke.Clone(), new System.Windows.Point(x1, y1), new System.Windows.Point(x2, y2));
         PopRenderStates(clipped);
     }
 }
コード例 #2
0
 protected override void OnRender(System.Windows.Media.DrawingContext dc)
 {
     base.OnRender(dc);
     IsGridVisible = ZoomValue > 4.75 ? true : false;
     if (IsGridVisible)
     {
         // Draw GridLines
         Pen pen = new Pen(Brushes.Black, 1 / ZoomValue);
         pen.DashStyle = DashStyles.Solid;
         for (double x = 0; x < this.ActualWidth; x += 1)
         {
             dc.DrawLine(pen, new Point(x, 0), new Point(x, this.ActualHeight));
         }
         for (double y = 0; y < this.ActualHeight; y += 1)
         {
             dc.DrawLine(pen, new Point(0, y), new Point(this.ActualWidth, y));
         }
     }
 }
コード例 #3
0
 protected override void OnRender(System.Windows.Media.DrawingContext dc)
 {
     if (ShowColumnSeparator)
     {
         // Draw vertical lines as column separators.
         for (int i = 0; i < _numberOfColumns - 1; i++)
         {
             double x = (i * HorizontalColumnPadding * 2) + (i + 1) * _columnWidth + HorizontalColumnPadding;
             dc.DrawLine(ColumnSeparatorPen, new Point(x, 0), new Point(x, ActualHeight));
         }
     }
     base.OnRender(dc);
 }
コード例 #4
0
 public override void Draw(System.Windows.Media.DrawingContext drawingContext)
 {
     drawingContext.DrawLine(Outline, StartPoint, EndPoint);
 }
コード例 #5
0
        /// <summary>
        /// Border를 그리기 위한 OnRender 재정의
        /// </summary>
        /// <param name="dc"></param>
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            CustomGrid customGrid = this.Parent as CustomGrid;

            if (customGrid == null)
            {
                dc.DrawRectangle(null, line, new Rect(0, 0, this.ActualWidth, this.ActualHeight));
            }

            double linePoint = 0;
            double posFrom   = 0.0;
            double posTo     = 0.0;

            int rowCount    = Math.Max(this.RowDefinitions.Count, 1);
            int columnCount = Math.Max(this.ColumnDefinitions.Count, 1);

            bool[,] rowCellStatus;
            bool[,] columnCellStatus;

            GetRowLineCellStatus(rowCount, columnCount, out rowCellStatus, out columnCellStatus);

            if (this.ColumnDefinitions.Count != 0)
            {
                for (int row = 0; row < rowCount - 1; row++)
                {
                    var r = this.RowDefinitions[row];

                    linePoint += r.ActualHeight;
                    for (int column = 0; column < columnCount; column++)
                    {
                        bool drawLine = rowCellStatus[row + 1, column];
                        posTo += this.ColumnDefinitions[column].ActualWidth;

                        if (drawLine == true)
                        {
                            dc.DrawLine(line, new System.Windows.Point(posFrom, linePoint), new System.Windows.Point(posTo, linePoint));
                        }

                        posFrom = posTo;
                    }

                    posFrom = 0.0;
                    posTo   = 0.0;
                }
            }

            linePoint = 0;
            posFrom   = 0.0;
            posTo     = 0.0;

            if (this.RowDefinitions.Count != 0)
            {
                for (int column = 0; column < columnCount - 1; column++)
                {
                    var r = this.ColumnDefinitions[column];

                    linePoint += r.ActualWidth;
                    for (int row = 0; row < rowCount; row++)
                    {
                        bool drawLine = columnCellStatus[row, column + 1];
                        posTo += this.RowDefinitions[row].ActualHeight;

                        if (drawLine == true)
                        {
                            dc.DrawLine(line, new System.Windows.Point(linePoint, posFrom), new System.Windows.Point(linePoint, posTo));
                        }

                        posFrom = posTo;
                    }

                    posTo   = 0.0;
                    posFrom = 0.0;
                }
            }
        }
コード例 #6
0
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     drawingContext.DrawLine(new System.Windows.Media.Pen(new SolidColorBrush(Colors.Red), 1), drawLocation.BottomLeft, drawLocation.BottomRight);
 }
コード例 #7
0
        protected override void ComposeCore(System.Windows.Media.DrawingContext drawingContext, System.Windows.Media.DrawingVisual visual)
        {
            //Text and Caption size
            string tempText     = string.Empty;
            double textWidth    = Utilities.GetTextWidth(this.Text);
            double captionWidth = Utilities.GetTextWidth(this.Caption);

            if (this.Text.Count() > 25)
            {
                tempText  = this.Text.Substring(0, 25);
                tempText += "...";
                textWidth = Utilities.GetTextWidth(tempText);
            }
            else
            {
                tempText = this.Text;
            }

            //Node width
            if (textWidth > captionWidth)
            {
                this.nodeDimension.Width = (int)(Configurations.NodeWidthProperty + textWidth + 1);
            }
            else
            {
                this.nodeDimension.Width = (int)(Configurations.NodeWidthProperty + captionWidth + 1);
            }

            //Node height
            this.nodeDimension.Height = Configurations.NodeHeightProperty;

            base.ComposeCore(drawingContext, visual);

            Rect rect = new Rect(new Point(1, 1), new Size((int)(this.nodeDimension.Width - 1), (int)(this.nodeDimension.Height - 1)));

            drawingContext.DrawRectangle(Configurations.RectGrey, Configurations.NoBorderPen, rect);

            //horizontal Line
            Point p1 = new Point(1, 1);

            p1.Offset(Configurations.TextHorizontalOffset, (int)(this.Height) / 2);
            p1.Offset(0, 0.5);
            Point p2 = p1;

            p2.X = (this.Width - 1) - Configurations.TextHorizontalOffset;
            drawingContext.DrawLine(Configurations.BorderPen, p1, p2);

            //draw caption and text
            p1 = new Point(1, 1);
            p1.Offset(0, Configurations.TextVerticalOffset);
            p1.X = (this.Width / 2) - captionWidth / 2;
            Utilities.DrawText(drawingContext, this.Caption, p1, Configurations.TextNormalColor);
            p1.Y = ((this.Height - 3) / 2) + Configurations.TextVerticalOffset;
            p1.X = (this.Width / 2) - textWidth / 2;
            Utilities.DrawBoldText(drawingContext, tempText, p1);

            //OutputSlot
            p1    = new Point(this.Width, (this.Height / 4));
            p1.Y += (this.Height / 2) - 2;
            DrawingUtilities.DrawDots(drawingContext, DotTypes.TopRight | DotTypes.MiddleRight | DotTypes.BottomRight, p1, AnchorPoint.TopRight, false);
            //OutputSlotHittestPixels
            p1.Y -= (this.Height / 4) - 1;
            drawingContext.DrawRectangle(Configurations.SlotHitTestColor, Configurations.NoBorderPen, new Rect(p1, new Size(Configurations.HittestPixels, this.Height / 2)));

            //NorthEast
            Point p = new Point(0, 0);

            p.Offset(this.Width, Configurations.ContextMenuMargin);
            if (dotsFlag.HasFlag(MenuDots.NorthEast))
            {
                DrawingUtilities.DrawDots(drawingContext, DotTypes.Top | DotTypes.TopRight | DotTypes.MiddleRight, p, AnchorPoint.TopRight, false);
            }

            //NorthWest
            p = new Point(0, 0);
            p.Offset(Configurations.ContextMenuMargin, Configurations.ContextMenuMargin);
            //DrawingUtilities.DrawDots(drawingContext, DotTypes.TopLeft | DotTypes.Top | DotTypes.MiddleLeft, p, AnchorPoint.TopLeft, false);

            //South
            p = new Point(0, 0);
            p.Offset(Configurations.ContextMenuMargin, this.Height);
            //DrawingUtilities.DrawDots(drawingContext, DotTypes.MiddleLeft | DotTypes.BottomLeft | DotTypes.Bottom, p, AnchorPoint.BottomLeft, false);

            //input Slots
            if (this.inputSlots.Count != 0)
            {
                p1    = new Point(-1, 1);
                p1.Y += Configurations.TextVerticalOffset + Configurations.SlotSize / 2;
                Utilities.DrawSlot(drawingContext, p1);
            }

            // Fix: IDE-1616 Geometry property previews are not showing up.
            // Fix: IDE-1623 Preview not coming for the property nodes.
            if (previewBubble != null)
            {
                this.previewBubble.Compose();
            }
        }