C#二次开发

  • 格式:pdf
  • 大小:234.77 KB
  • 文档页数:7
double WallHeight = Convert.ToDouble(txbWallHeight.Text); double LanewayWidth = Convert.ToDouble(txbWallWidth.Text); double WallThick = Convert.ToDouble(txbWallThick.Text); double x, y, z; x = y = 20; z = 0; //左内侧直墙
public partial class LanewayDesigner : Form {
public LanewayDesigner() {
InitializeComponent(); } private void btnSubmit_Click(object sender, EventArgs e) {
ObjectId loopId1 =ModelSpace.AddLine(new Point3d(x - LanewayWidth / 2, y, z), new Point3d(x LanewayWidth / 2, y + WallHeight, z));
//左外侧直墙 ObjectId loopId2 = ModelSpace.AddLine(new Point3d(x - LanewayWidth / 2 - WallThick, y, z), new Point3d(x - LanewayWidth / 2 - WallThick, y + WallHeight, z)); //左墙底
Console.WriteLine(i + j); } else if (k=="-") {
Console.WriteLine(i-j);
} else if (k=="*") { Console.WriteLine(i*j); } else if (k=="/") { Console.WriteLine(i/j); }
Point3d(x + LanewayWidth / 2, y, z)); //顶板内弧 ObjectId loopId7 =ModelSpace.AddArc(new Point3d(x, y + WallHeight, z), LanewayWidth / 2,
创建二维优化多段线的命令.
[CommandMethod("netPline")] public void CreatePline() {
Point2d[] pt = new Point2d[4]; pt[0] = new Point2d(0, 0); pt[1] = new Point2d(10, 0); pt[2] = new Point2d(30, 20); pt[3] = new Point2d(-20, 50); Point2dCollection pts = new Point2dCollection(pt); ObjectId plineId = ModelSpace.AddPline(pts, 0); }
ObjectId loopId3 =ModelSpace.AddLine(new Point3d(x - LanewayWidth / 2 - WallThick, y, z), new Point3d(x - LanewayWidth / 2, y, z));
//右内侧直墙 ObjectId loopId4 =ModelSpace.AddLine(new Point3d(x + LanewayWidth / 2, y, z), new Point3d(x +
[CommandMethod("LanewayDesigner2")] public void LanewayDesigner2() {
LanewayDesigner2 form = new LanewayDesigner2(); form.ShowDialog(); }
3. //经纬网
[CommandMethod("Mesh")] public void Mesh() {
double scale = 5000; int vMesh = 20; int hMesh = 10; //经线 for (int i = 0; i < vMesh + 1; i++) {
Point3d pt1 = new Point3d(i * scale / 10, 0, 0); Point3d pt2 = new Point3d(i * scale / 10, hMesh * scale / 10, 0); ModelSpace.AddLine(pt1, pt2); //添加经线坐标值 ModelSpace.AddText(new Point3d(pt1.X - 18, pt1.Y - 6, 0), (37123000 + i * scale / 10).ToString(), 5, 0, 0); ModelSpace.AddText(new Point3d(pt2.X - 18, pt2.Y + 6, 0), (37123000 + i * scale / 10).ToString(), 5, 0, 0); } //纬线 for (int j = 0; j < hMesh + 1; j++) { Point3d pt3 = new Point3d(0, j * scale / 10, 0); Point3d pt4 = new Point3d(vMesh * scale / 10, j * scale / 10, 0); ModelSpace.AddLine(pt3, pt4); //添加纬线坐标 ModelSpace.AddText(new Point3d(pt3.X - 6, pt3.Y - 18, 0), (4223000 + j * scale / 10).ToString(), 5, 0, ModelSpace.Ang2Rad(90)); ModelSpace.AddText(new Point3d(pt4.X + 6, pt4.Y - 18, 0), (4223000 + j * scale / 10).ToString(), 5, 0, ModelSpace.Ang2Rad(90)); }
Console.WriteLine("请输入一个数"); Double i = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("请输入另一个数"); Double j = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("请输入运算符"); String k=Convert.ToString(Console.ReadLine()); if (k=="+") {
class Program {
static void Main(string[] args) {
Console.WriteLine("请输入一个数"); double i = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("请输入另一个数"); double j = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("答案是" + (i + j)); Console.ReadLine(); } } }
LanewayWidth / 2, y + WallHeight, z)); //右外侧直墙 ObjectId loopId5 =ModelSpace.AddLine(new Point3d(x + LanewayWidth / 2 + WallThick, y, z), new
Point3d(x + LanewayWidth / 2 + WallThick, y + WallHeight, z)); //右墙底 ObjectId loopId6 =ModelSpace.AddLine(new Point3d(x + LanewayWidth / 2 + WallThick, y, z), new
Point3d[] pt = new Point3d[4]; pt[0] = new Point3d(0, 0, 0); pt[1] = new Point3d(10, 0, 0); pt[2] = new Point3d(30, 20, 0); pt[3] = new Point3d(60, 50, 0); Point3dCollection pts = new Point3dCollection(pt); ObjectId splineId = ModelSpace.AddSpline(pts); }
1.常见控件属性值
Checkbox
属性
Name Text
Timer
属性
Enabled Name Interval
2. MessageBox.Show();
3. 控制台程序
实例 1:输入两个数,求其和。
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 {
4.巷道断面设计
LanewayDesigner.cs
using System; using System.Collections.Generic; using ponentModel;