public ViewControl() { InitializeComponent(); //控制控件闪烁 SetStyle(ControlStyles.AllPaintingInWmPaint, true); //禁止擦除背景 SetStyle(ControlStyles.DoubleBuffer, true); //双缓冲 SetStyle(ControlStyles.UserPaint, true); //自行绘制图片 GraphicsConfig graphicsConfig = new GraphicsConfig(); graphicsConfig.BackColor = BackColor; graphicsConfig.CorrectColorForBackgroundColor = true; gdiGraphics3D = new GDIGraphics3D(graphicsConfig); gdiGraphics3D.EnableDrawablesUpdate(); graphicsCache = new WireframeGraphicsCache(false, true); graphicsCache.Config = graphicsConfig; graphicsHelper = new GraphicsHelper(System.Drawing.Color.Blue); bounds = new Bounds3D(); transformationProvider = new SimpleTransformationProvider3D(); transformationProvider.TransformsChanged += new EventHandler(transformationProvider_TransformsChanged); panInteractor = new SimplePanInteractor(transformationProvider); rectZoomInteractor = new SimpleRectZoomInteractor(transformationProvider); zoomWheelInteractor = new SimpleZoomWheelInteractor(transformationProvider); rectZoomInteractorDrawable = new SimpleRectZoomInteractor.WinFormsDrawable(rectZoomInteractor); }
internal static void smethod_0( IInteractorWinFormsDrawable drawable, DxfEntity entity, PaintEventArgs e, GraphicsHelper graphicsHelper, InteractionContext context) { DxfLine dxfLine = (DxfLine)entity; Matrix4D projectionTransform = context.ProjectionTransform; PointF pointF1 = projectionTransform.TransformToPointF(dxfLine.point3D_0); PointF pointF2 = projectionTransform.TransformToPointF(dxfLine.End); if ((double)pointF1.Y == (double)pointF2.Y) { return; } PointF pointF3 = projectionTransform.TransformToPointF(WW.Math.Point3D.GetMidPoint(dxfLine.point3D_0, dxfLine.point3D_1)); double num = System.Math.Atan2((double)pointF2.Y - (double)pointF1.Y, (double)pointF2.X - (double)pointF1.X); if (context.ProjectionFlipsOrientation) { num = -num; } e.Graphics.DrawString((num * (180.0 / System.Math.PI)).ToString(context.AngleFormatString) + "°", graphicsHelper.DefaultFont, graphicsHelper.DefaultBrush, pointF3); }
//库自带 public void StartInteraction(IInteractor interactor, IInteractorWinFormsDrawable interactorDrawable) { if (interactor != null) { this.interactor = interactor; this.interactorDrawable = interactorDrawable; interactor.Deactivated += interactor_Deactivated; interactor.Activate(); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); this.bool_0 = false; if (this.iinteractor_0 != null) { this.iinteractor_0.ProcessMouseButtonUp(new CanonicalMouseEventArgs(e), this.method_4()); this.iinteractor_0.Deactivate(); this.Invalidate(); this.iinteractor_0 = (IInteractor)null; } this.iinteractorWinFormsDrawable_2 = (IInteractorWinFormsDrawable)null; }
public void SetTransformationProvider( SimpleTransformationProviderBase transformationProvider) { if (this.simpleTransformationProviderBase_0 != null) { this.simpleTransformationProviderBase_0.TransformsChanged -= new EventHandler(this.method_3); } this.simpleTransformationProviderBase_0 = transformationProvider; transformationProvider.TransformsChanged += new EventHandler(this.method_3); this.simplePanInteractor_0 = new SimplePanInteractor(transformationProvider); this.simpleRotateInteractor_0 = new SimpleRotateInteractor(transformationProvider); this.simpleRectZoomInteractor_0 = new SimpleRectZoomInteractor(transformationProvider); this.simpleZoomWheelInteractor_0 = new SimpleZoomWheelInteractor(transformationProvider); this.iinteractorWinFormsDrawable_0 = (IInteractorWinFormsDrawable) new SimpleRectZoomInteractor.WinFormsDrawable(this.simpleRectZoomInteractor_0); this.iinteractorWinFormsDrawable_1 = (IInteractorWinFormsDrawable) new SimpleRotateInteractor.WinFormsDrawable(this.simpleRotateInteractor_0); }
public Form11( DxfEntity.Interactor interactor, Control hostControl, IInteractorWinFormsDrawable baseDrawable) : base(interactor, baseDrawable) { this.control_0 = hostControl; this.fieldEditControl_0 = FieldEditControl.Create(Class675.Length); this.fieldEditControl_0.TextBox.KeyPress += new KeyPressEventHandler(this.method_0); interactor.Activated += new EventHandler(this.method_2); interactor.Deactivated += new EventHandler(this.method_4); if (!interactor.IsActive) { return; } this.method_3(); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); mouseClickLocation = e.Location; mouseDown = true; shiftPressed = ModifierKeys == Keys.Shift; if (shiftPressed) { rectZoomInteractor.Activate(); rectZoomInteractor.ProcessMouseButtonDown(new CanonicalMouseEventArgs(e), GetInteractionContext()); currentInteractorDrawable = rectZoomInteractorDrawable; } else { panInteractor.Activate(); panInteractor.ProcessMouseButtonDown(new CanonicalMouseEventArgs(e), GetInteractionContext()); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); this.point_0 = e.Location; this.bool_0 = true; this.bool_1 = Control.ModifierKeys == Keys.Shift; if (this.bool_1) { this.iinteractor_0 = (IInteractor)this.simpleRectZoomInteractor_0; this.iinteractorWinFormsDrawable_2 = this.iinteractorWinFormsDrawable_0; } else if (e.Button == MouseButtons.Middle) { this.iinteractor_0 = (IInteractor)this.simplePanInteractor_0; } else { this.iinteractor_0 = (IInteractor)this.simpleRotateInteractor_0; this.iinteractorWinFormsDrawable_2 = this.iinteractorWinFormsDrawable_1; } this.iinteractor_0.Activate(); this.iinteractor_0.ProcessMouseButtonDown(new CanonicalMouseEventArgs(e), this.method_4()); }
public Form10(DxfEntity.Interactor interactor, IInteractorWinFormsDrawable baseDrawable) { this.interactor_0 = interactor; this.iinteractorWinFormsDrawable_0 = baseDrawable; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); mouseDown = false; //使用shift键放大缩小 if (shiftPressed) { rectZoomInteractor.ProcessMouseButtonUp(new CanonicalMouseEventArgs(e), GetInteractionContext()); rectZoomInteractor.Deactivate(); Invalidate(); } else { panInteractor.Deactivate(); // Select entity at mouse location if mouse didn't move // and show entity in property grid. if (mouseClickLocation == e.Location) { Point2D referencePoint = new Point2D(e.X, e.Y); double distance; IList <RenderedEntityInfo> closestEntities = EntitySelector.GetClosestEntities( model, GraphicsConfig.BlackBackgroundCorrectForBackColor, gdiGraphics3D.To2DTransform, referencePoint, out distance ); if (highlightedEntity != null) { IList <IWireframeDrawable> drawables = graphicsCache.GetDrawables(highlightedEntity); IWireframeGraphicsFactory graphicsFactory = null; gdiGraphics3D.UpdateDrawables( highlightedEntity, () => { foreach (IWireframeDrawable drawable in drawables) { drawable.Draw(graphicsFactory); } }, o => graphicsFactory = o ); Invalidate(); highlightedEntity = null; } if (closestEntities.Count > 0) { // Chose the last entity as it is drawn last, so will be on top. highlightedEntity = closestEntities[closestEntities.Count - 1]; IList <IWireframeDrawable> drawables = graphicsCache.GetDrawables(highlightedEntity); WireframeGraphicsFactoryColorChanger graphicsFactoryColorChanger = null; gdiGraphics3D.UpdateDrawables( highlightedEntity, () => { foreach (IWireframeDrawable drawable in drawables) { drawable.Draw(graphicsFactoryColorChanger); } }, o => graphicsFactoryColorChanger = new WireframeGraphicsFactoryColorChanger(o, ColorChanger) ); Invalidate(); DxfEntity entity = highlightedEntity.Entity; OnEntitySelected(new EntityEventArgs(entity)); } } } currentInteractorDrawable = null; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); mouseDown = false; // Use shift key for rectangle zoom. if (shiftPressed) { rectZoomInteractor.ProcessMouseButtonUp(new CanonicalMouseEventArgs(e), GetInteractionContext()); rectZoomInteractor.Deactivate(); Invalidate(); } else { panInteractor.Deactivate(); // Select entity at mouse location if mouse didn't move // and show entity in property grid. if (mouseClickLocation == e.Location) { Point2D referencePoint = new Point2D(e.X, e.Y); double distance; IList<RenderedEntityInfo> closestEntities = EntitySelector.GetClosestEntities( model, GraphicsConfig.BlackBackgroundCorrectForBackColor, gdiGraphics3D.To2DTransform, referencePoint, out distance ); if (closestEntities.Count > 0) { DxfEntity entity = closestEntities[0].Entity; //OnEntitySelected(new EntityEventArgs(entity)); } } } currentInteractorDrawable = null; }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); mouseClickLocation = e.Location; mouseDown = true; shiftPressed = ModifierKeys == Keys.Shift; if (shiftPressed) { rectZoomInteractor.Activate(); rectZoomInteractor.ProcessMouseButtonDown(new CanonicalMouseEventArgs(e), GetInteractionContext()); currentInteractorDrawable = rectZoomInteractorDrawable; } else { panInteractor.Activate(); panInteractor.ProcessMouseButtonDown(new CanonicalMouseEventArgs(e), GetInteractionContext()); } }
public void initParameter() { model=null; gdiGraphics3D=null; bounds=null; //Matrix4D tempfrom2DTransform; //from2DTransform=tempfrom2DTransform; //Point tempmouseClickLocation; //mouseClickLocation=tempmouseClickLocation; mouseDown=false; shiftPressed=false; SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); GraphicsConfig graphicsConfig = new GraphicsConfig(); //graphicsConfig.BackColor = BackColor; graphicsConfig.CorrectColorForBackgroundColor = true; gdiGraphics3D = new GDIGraphics3D(graphicsConfig); bounds = new Bounds3D(); transformationProvider = new SimpleTransformationProvider3D(); transformationProvider.TransformsChanged += new EventHandler(transformationProvider_TransformsChanged); panInteractor = new SimplePanInteractor(transformationProvider); rectZoomInteractor = new SimpleRectZoomInteractor(transformationProvider); zoomWheelInteractor = new SimpleZoomWheelInteractor(transformationProvider); rectZoomInteractorDrawable = new SimpleRectZoomInteractor.WinFormsDrawable(rectZoomInteractor); }
public void StartInteraction(IInteractor interactor, IInteractorWinFormsDrawable interactorDrawable) { if (interactor != null) { this.interactor = interactor; this.interactorDrawable = interactorDrawable; interactor.Deactivated += interactor_Deactivated; interactor.Activate(); } }