当前位置: 首页>>代码示例>>C#>>正文


C# Drawing.DrawLine方法代码示例

本文整理汇总了C#中System.Drawing.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# Drawing.DrawLine方法的具体用法?C# Drawing.DrawLine怎么用?C# Drawing.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing的用法示例。


在下文中一共展示了Drawing.DrawLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderLimb

 private void RenderLimb(Gdi.Graphics graphics, Gdi.Pen pen, Vector3D lhs, Vector3D rhs)
 {
     graphics.DrawLine(pen, (float)lhs.X, (float)lhs.Y, (float)rhs.X, (float)rhs.Y);
 }
开发者ID:techx,项目名称:old-techfair-kinect-booth,代码行数:4,代码来源:GdiSkeletonComponentRenderer.cs

示例2: Render

        private void Render(Gdi.Graphics graphics)
        {
            using (var boxPen = new Gdi.Pen(Gdi.Color.White, BoxEdgeThickness))
            using (var jointBrush = new Gdi.SolidBrush(Gdi.Color.White))
            using (var limbPen = new Gdi.Pen(Gdi.Color.White, LimbThickness))
            using (var linePen = new Gdi.Pen(Gdi.Color.Red, LineThickness))
            {
                var skeletonBox = CreateSkeletonBox();
                graphics.DrawRectangle(boxPen, skeletonBox.X, skeletonBox.Y, skeletonBox.Width, skeletonBox.Height);

                if (base.SkeletonComponent.CurrentSkeleton == null) //not initialized yet
                    return;

                var boxJoints = CalculateBoxJoints(skeletonBox);

                boxJoints.Values.ToList().ForEach(location =>
                    RenderJoint(graphics, jointBrush, location));

                Limbs.ForEach(tuple => RenderLimb(graphics, limbPen, boxJoints[tuple.Item1], boxJoints[tuple.Item2]));

                var thresholdLineY = skeletonBox.Top + (1 - ThresholdHeight) * skeletonBox.Height;
                graphics.DrawLine(linePen, skeletonBox.Left, thresholdLineY, skeletonBox.Right, thresholdLineY);
            }
        }
开发者ID:techx,项目名称:old-techfair-kinect-booth,代码行数:24,代码来源:GdiSkeletonComponentRenderer.cs

示例3: DrawNode

    private void DrawNode(TreeNodeEx node, Drawing.Graphics graphics, Drawing2D.Matrix matrix, ref int totalHeight)
    {
        if (node.Visible)
        {
            totalHeight += this.HeightIndent + this.Font.Height;

            // transform coordinates
            Drawing.PointF[] p = new Drawing.PointF[1];
            p[0] = new Drawing.PointF(0.0f, 0.0f);
            matrix.TransformPoints(p);

            // calculate location and size
            node.Location = new Drawing.Point((int)p[0].X, (int)p[0].Y);
            node.Size = new Drawing.Size(this.Width, this.Font.Height);

            if (dragOverNode == node)
            {
                // draw drag over line
                graphics.DrawLine(Drawing.Pens.Black, node.Location.X, node.Location.Y, this.Width, node.Location.Y);
            }

            // draw plus/minus
            if (this.ShowPlusMinus)
            {
                if (node.Nodes.Count > 0)
                {
                    graphics.DrawRectangle(Drawing.Pens.Black, (int)p[0].X + 2, (int)p[0].Y + 2, 8, 8);

                    if (!node.Expanded)
                    {
                        // line across
                        graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6);
                        // down
                        graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 6, (int)p[0].Y + 4, (int)p[0].X + 6, (int)p[0].Y + 8);
                    }
                    else
                    {
                        graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6);
                    }
                }

                p[0].X += 12;
            }

            // draw node image
            if (!this.imageList.Images.Empty)
            {
                this.imageList.Draw(graphics, new Drawing.Point((int)p[0].X, (int)p[0].Y), (node.Expanded) ? node.ExpandedImageIndex : node.CollapsedImageIndex);
                p[0].X += this.imageList.ImageSize.Width;
            }

            // draw node text
            Drawing.Brush textBrush;

            if (node == this.selectedNode && this.ChangeColorOnSelected)
                textBrush = this.TextSelectedBrush;
            else if (node == this.mouseOverNode && this.ChangeColorOnMouseOver)
                textBrush = this.TextMouseOverBrush;
            else
                textBrush = node.TextBrush;

            Drawing.Font font = new Drawing.Font(this.Font.FontFamily.Name, this.Font.Size, node.FontStyle);
            graphics.DrawString(node.Text, font, textBrush, p[0]);

            // go through children
            if (node.Expanded && node.Nodes.Count > 0)
            {
                matrix.Translate((float)this.WidthIndent, 0.0f);

                foreach (TreeNodeEx treeNode in node.Nodes)
                {
                    matrix.Translate(0.0f, this.HeightIndent + this.Font.Height);
                    DrawNode(treeNode, graphics, matrix, ref totalHeight);
                }

                matrix.Translate(-(float)this.WidthIndent, 0.0f);
            }
        }
        else
            matrix.Translate(0.0f, -((float)this.HeightIndent + this.Font.Height));
    }
开发者ID:peteward44,项目名称:nbm-messenger,代码行数:81,代码来源:TreeViewEx.cs


注:本文中的System.Drawing.DrawLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。