コード例 #1
0
        public void AddFilter(KinTemplates.Cursor.Tools.IToolFilter filter, FeedbackParameter r)
        {
            // forces
            if (filter is Tools.ConveyorBeltFilter
                || filter is Tools.ConveyorBeltFilter2
                || filter is Tools.OrbitFilter
                || filter is Tools.OrbitFilter2
                || filter is Tools.OrbitFilter3
                || filter is Tools.MagneticLineAttractionFilter
                || filter is Tools.MagneticPointAttractionFilter
                || filter is Tools.RubberBandFilter
                // || filter is Tools.TunnelLineFilter
                )
            {
                if (m_forces == null)
                {
                    Rectangle screenBounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
                    m_forces = new PointD[screenBounds.Width / FORCE_GRID][];
                    for (int i = 0; i < m_forces.Length; i++)
                    {
                        m_forces[i] = new PointD[screenBounds.Height / FORCE_GRID];
                    }

                    //m_renderedForces = new Bitmap(screenBounds.Width, screenBounds.Height);
                }

                for (int i = 0; i < m_forces.Length; i++)
                {
                    for (int j = 0; j < m_forces[i].Length; j++)
                    {
                        Point thePoint = new Point(i * FORCE_GRID, j * FORCE_GRID);
                        if (filter.HitTest((PointD)thePoint))
                        {
                            // test all points with the filter
                            Position.VirtualMousePosition mouse = new Position.VirtualMousePosition(thePoint);
                            Position.ParameterizedMousePosition fakeMouse = new Position.ParameterizedMousePosition(mouse, 20);// TODO: instrument from the computer
                            m_forces[i][j] += filter.GetVelocity(fakeMouse) * Render.DrawHelper.SPEED_AMPLIFIER;
                        }
                    }
                }
            }

            /*
            // we have rendered something, let's cache this picture
            if (m_forces != null)
            {
                Graphics fromBitmap = Graphics.FromImage(m_renderedForces);
                InternalRenderForces(fromBitmap, r);
                fromBitmap.Dispose();
            }
            */
        }
コード例 #2
0
        public override void DrawRegionRepresentation(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            RectangleF bounds = m_Param.Path.GetBounds();
            for (double i = bounds.Width / (Render.DrawHelper.X_ARROWS + 1); i < bounds.Width; i += bounds.Width / (Render.DrawHelper.X_ARROWS + 1))
            {
                for (double j = bounds.Height / (Render.DrawHelper.Y_ARROWS + 1); j < bounds.Height; j += bounds.Height / (Render.DrawHelper.Y_ARROWS + 1))
                {
                    Point thePoint = new Point((int) (bounds.Left + i), (int) (bounds.Top + j));
                    if (m_Param.Path.IsVisible(thePoint))
                    {
                        Position.VirtualMousePosition mouse = new Position.VirtualMousePosition((Point)thePoint);
                        PointD vector = GetVelocity(mouse) * Render.DrawHelper.SPEED_AMPLIFIER * (m_Param.C + 0.1);
                        drawMethods.DrawArrow(gc, r, (PointD)thePoint, vector);
                    }
                }

            }
        }