C#画线控件的开发应用实例解析
C#画线控件的应用实例介绍之前我们要明白在C#中没有画线的控件,这里写了一个,大家分享。共有两个控件分别是画横线和画竖线的,关于怎么画斜线有兴趣的可以做一个大家分享。
C#画线控件之横线
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Jiashi.WinControls
{
///
/// LineX 画横线控件
///
public class LineX : System.Windows.Forms.UserControl
{
#region 属性定义
private System.Drawing.Color lineColor;
private int lineWidth;
///
/// 线的颜色属性
///
public System.Drawing.Color LineColor
{
set
{
this.lineColor=value;
System.Windows.Forms.PaintEventArgs ep=
new PaintEventArgs(this.CreateGraphics(),
this.ClientRectangle);
this.LineX_Paint(this,ep);
}
get{return this.lineColor;}
}
///
/// 线的粗细
///
public int LineWidth
{
set
{
this.lineWidth=value;
System.Windows.Forms.PaintEventArgs ep=
new PaintEventArgs(this.CreateGraphics(),
this.ClientRectangle);
this.LineX_Paint(this,ep);
}
get{return this.lineWidth;}
}
#endregion
private System.ComponentModel.Container components = null;
///
/// 构造函数初始颜色和线粗细
///
public LineX()
{
InitializeComponent();
this.lineColor=this.ForeColor;
this.lin
相关文档:
c#中写一个多线程应用是非常简单的,本章将介绍如何在c#种开发多线程程序。在.net中线程是由System.Threading 名字空间所定义的。所以你必须包含这个名字空间。
using System.Threading;
开始一个线程
System.Threading 名字空间的线程类描述了一个线程对象,通过使用类对象,你可以创建、删除、停止及恢复一个线程。 ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortScanner
{
class Program
{
//已扫描端口数目
internal static int scannedCount = 0;
//正在运行的线程数目
internal static int ru ......
1.c++的到处函数只要在函数申明的时候加个导出关键字就可以了
2.参数类型问题,
一般的c++中char * 对应 c#中的string
而c++中 char **类型的参数对应c#中 ref string 这种一般都是用来返回字符串的!
3.函数入口问题,一般会出现 "找不到入口点" 这个问题不是由你引起的,而是系统自己把名字改了,改成什么样的名字建议你用 ......
大家在实际工作学习C#的时候,可能会问:为什么我们要为一些已经存在的功能(比如Windows中的一些功能,C++中已经编写好的一些方法)要重新编写代码,C#有没有方法可以直接都用这些原本已经存在的功能呢?答案是肯定的,大家可以通过C#中的DllImport直接调用这些功能。
DllImport所在的名字空间 using System.Runtime.Inte ......