Exemple #1
0
        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;
        }