Exemple #1
0
        /// <summary>
        /// Gets the connections whose start vertex is within the specified bounds.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The out parameters will be null if the return result is zero.
        /// </para>
        /// </remarks>
        /// <param name="xmin">The minimum x-axis bounds.</param>
        /// <param name="zmin">The minimum z-axis bounds.</param>
        /// <param name="xmax">The maximum x-axis bounds.</param>
        /// <param name="zmax">The maximum z-axis bounds.</param>
        /// <param name="rverts">The connection vertices. [(start, end) * connCount]</param>
        /// <param name="rradii">The connection radii. [Length: connCount]</param>
        /// <param name="rdirs">The connection direction flags. [Length: connCount]</param>
        /// <param name="rareas">The connection areas. [Length: connCount]</param>
        /// <param name="rflags">The connection flags. [Length: connCount]</param>
        /// <param name="ruserIds">The connection user ids. [Length: connCount]</param>
        /// <returns>The number of connection returned.</returns>
        public int GetConnections(float xmin, float zmin, float xmax, float zmax
                                  , out Vector3[] rverts, out float[] rradii
                                  , out byte[] rdirs, out byte[] rareas, out ushort[] rflags, out uint[] ruserIds)
        {
            rverts   = null;
            rradii   = null;
            rdirs    = null;
            rareas   = null;
            rflags   = null;
            ruserIds = null;

            if (radii.Length == 0)
            {
                return(0);
            }

            List <Vector3> rlverts   = new List <Vector3>();
            List <float>   rlradii   = new List <float>();
            List <byte>    rldirs    = new List <byte>();
            List <byte>    rlareas   = new List <byte>();
            List <ushort>  rlflags   = new List <ushort>();
            List <uint>    rluserIds = new List <uint>();

            for (int i = 0; i < radii.Length; i++)
            {
                Vector3 v = verts[i * 2 + 0];
                if (Rectangle2.Contains(xmin, zmin, xmax, zmax, v.x, v.z))
                {
                    rlverts.Add(v);
                    rlverts.Add(verts[i * 2 + 1]);

                    rlradii.Add(radii[i]);
                    rldirs.Add(dirs[i]);
                    rlareas.Add(areas[i]);
                    rlflags.Add(flags[i]);
                    rluserIds.Add(userIds[i]);
                }
            }

            if (rlradii.Count == 0)
            {
                return(0);
            }

            rverts   = rlverts.ToArray();
            rradii   = rlradii.ToArray();
            rdirs    = rldirs.ToArray();
            rareas   = rlareas.ToArray();
            rflags   = rlflags.ToArray();
            ruserIds = rluserIds.ToArray();

            return(rradii.Length);
        }
        private void OnMouseIsDownOverview(int x, int y, int width, int height)
        {
            Size2      overview = GraphUtil.CalcOverviewSize(width, height, main.TotalWidth(), main.TotalHeight());
            Rectangle2 win      = GraphUtil.CalcWin(overview, main.TotalSize, main.VisibleWin, main.ZoomFactor, main.ZoomFactor);

            if (win.Contains(x, y))
            {
                navigatorData.Start(x, y, main.VisibleX, main.VisibleY);
            }
            else
            {
                float x1   = x - win.Width / 2;
                float y1   = y - win.Height / 2;
                int   newX = (int)Math.Round(x1 * main.TotalWidth() / overview.Width);
                int   newY = (int)Math.Round(y1 * main.TotalHeight() / overview.Height);
                newX          = (int)Math.Min(Math.Max(newX, 0), main.TotalWidth() - main.VisibleWidth / main.ZoomFactor);
                main.VisibleX = newX;
                newY          = (int)Math.Min(Math.Max(newY, 0), main.TotalHeight() - main.VisibleHeight / main.ZoomFactor);
                main.VisibleY = newY;
                invalidate();
            }
        }