public void MouseMove(View.GraphicView graphicView, System.Drawing.Point startPt, System.Drawing.Point lastPt) { int minX = graphicView.Viewport.X, maxX = minX + graphicView.Viewport.Width; int minY = graphicView.Viewport.Y, maxY = minY + graphicView.Viewport.Height; lastPt.X = (lastPt.X < minX) ? minX : ((lastPt.X > maxX) ? maxX : lastPt.X); lastPt.Y = (lastPt.Y < minY) ? minY : ((lastPt.Y > maxY) ? maxY : lastPt.Y); // Set vertices positions verts[0].X = startPt.X; verts[0].Y = startPt.Y; verts[1].X = lastPt.X; verts[1].Y = startPt.Y; verts[2].X = startPt.X; verts[2].Y = lastPt.Y; verts[3].X = lastPt.X; verts[3].Y = lastPt.Y; // Outline... lineVertices[0] = verts[0]; lineVertices[1] = verts[1]; lineVertices[2] = verts[3]; lineVertices[3] = verts[2]; lineVertices[4] = verts[0]; }
public void PaintLine(Device device, Vector3 iPos, Vector3 jPos) { Cull cull = device.RenderState.CullMode; bool alphaEnable = device.RenderState.AlphaBlendEnable; device.RenderState.CullMode = Cull.None; device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.BothSourceAlpha; device.RenderState.DestinationBlend = Blend.DestinationColor; Line l1 = GraphicViewManager.Instance.ResourceManager.SnapLines[2]; Line l2 = GraphicViewManager.Instance.ResourceManager.SnapLines[1]; View.GraphicView gv = View.GraphicViewManager.Instance.ActiveView; gv.Project(ref iPos); gv.Project(ref jPos); if (GraphicViewManager.Instance.Layout != GraphicViewManager.ViewportsLayout.OneView) { Viewport vp = device.Viewport; iPos.X -= vp.X; iPos.Y -= vp.Y; jPos.X -= vp.X; jPos.Y -= vp.Y; } l1.Begin(); l1.Draw(new Vector2[] { new Vector2(iPos.X, iPos.Y), new Vector2(jPos.X, jPos.Y) }, Color.FromArgb(192, Color.SteelBlue)); l1.End(); l2.Begin(); l2.Draw(new Vector2[] { new Vector2(iPos.X, iPos.Y), new Vector2(jPos.X, jPos.Y) }, Color.FromArgb(128, Color.White)); l2.End(); device.RenderState.AlphaBlendEnable = alphaEnable; device.RenderState.CullMode = cull; }