public void Run() { string[] lines = File.ReadAllLines("script.hbs", Encoding.UTF8); foreach (string line in lines) { if (line.Trim().StartsWith("#线程数")) { int.TryParse(line.Replace("#线程数", "").Trim(), out threadCount); } if (line.Trim().StartsWith("#开启RGB")) { rgb = true; } if (line.Trim().StartsWith("#关闭回显")) { BomberUtils.showEcho = false; } script += line + "\r\n"; } System.Net.ServicePointManager.DefaultConnectionLimit = threadCount; ScriptedBomber sb = new ScriptedBomber(script); sb.OnBomberComplete += Sb_OnBomberComplete; BomberPerformer bp = new BomberPerformer(sb); resultHandler = new showResult(delegate(int speed, string args) { monitorChart1.Value = speed; textBox1.Text = args; }); bp.ThreadCount = threadCount; bp.StartBomber(); }
private void axMapcontrol_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { sMapunits = GetMapunits(this.axMapcontrol.Map.MapUnits); this.barCoortxt.Text = string.Format("当前坐标:X={0:#.###} Y={1:#.###} {2}", e.mapX, e.mapY, sMapunits); movepnt = new PointClass(); movepnt.PutCoords(e.mapX, e.mapY); switch (pMouseOperate) { case "MeasureLength": if (m_newline != null && movepnt != null) { m_newline.MoveTo(movepnt); //计算两点距离 double deltaX = 0; double deltaY = 0; deltaX = movepnt.X - Dwnpoint.X; deltaY = movepnt.Y - Dwnpoint.Y; SegmentLength = Math.Round(Math.Sqrt(deltaX * deltaX + deltaY * deltaY)); TotalLength = TotalLength + SegmentLength; if (frmMeasureResult != null) { //绑定事件 ShowResultEvent += new showResult(frmMeasureResult.showResult); ShowResultEvent(new double[] { SegmentLength, TotalLength }, sMapunits, pMouseOperate); TotalLength = TotalLength - SegmentLength; //鼠标移动到新点重新开始算 } } break; case "MeasureArea": if (m_newpolygon != null && Area_Pocoll != null) { m_newpolygon.MoveTo(movepnt); IPointCollection pocoll = new PolygonClass(); IGeometry pGeo = null; IPolygon polygon = null; ITopologicalOperator topo = null; for (int i = 0; i < Area_Pocoll.PointCount; i++) { pocoll.AddPoint(Area_Pocoll.get_Point(i), missing, missing); } if (movepnt == null || movepnt.IsEmpty) { return; } pocoll.AddPoint(movepnt, missing, missing); if (pocoll.PointCount < 3) { return; } polygon = pocoll as IPolygon; if (polygon == null) { return; } //多边形闭合 polygon.Close(); pGeo = polygon as IGeometry; topo = pGeo as ITopologicalOperator; //使几何图形的拓扑正确 topo.Simplify(); pGeo.Project(this.axMapcontrol.SpatialReference); IArea area = pGeo as IArea; if (frmMeasureResult != null && !frmMeasureResult.IsDisposed) { ShowResultEvent += new showResult(frmMeasureResult.showResult); ShowResultEvent(new double[] { area.Area, polygon.Length }, sMapunits, pMouseOperate); } } break; } }