示例#1
0
 /// <summary>
 /// Set a window property (refer to Platform SDK)
 /// </summary>
 /// <param name="hWnd">Window to set the pointer</param>
 /// <param name="nIndex">Type of data to set</param>
 /// <param name="newLong">Value to set</param>
 /// <returns></returns>
 public static IntPtr SetWindowLongPtr(IntPtr hWnd, SWL nIndex, IntPtr newLong)
 {
     try
     {
         if (IntPtr.Size == 8)
         {
             return(SetWindowLongPtr64(hWnd, nIndex, newLong));
         }
         else
         {
             return(new IntPtr(SetWindowLong32(hWnd, nIndex, newLong)));
         }
     }
     catch (Exception) { }
     return(IntPtr.Zero);
 }
        public Speaker_Balloon(string[] Ballooncode_in, string SWL_in, int Type_in, Hare.Geometry.Point Center)//int sym_in,
        {
            code = Ballooncode_in;
            Type = Type_in;
            if (SWL_in != "" || SWL_in != null)
            {
                SWL = SWL_in;
            }
            else
            {
                SWL_in = "120; 120; 120; 120; 120; 120; 120; 120";
            }
            string[] swl        = SWL.Split(';');
            double[] swl_values = new double[8];

            Vector upper = new Vector(0, 1, 0);

            int umax, vmax;

            switch (Type)
            {
            case 0:
                umax = 19;
                vmax = 36;
                break;

            case 1:
                umax = 37;
                vmax = 72;
                break;

            default:
                throw new Exception();
            }

            m_HareMesh = new Topology[8];
            for (int oct = 1; oct < 9; oct++)
            {
                string[] values;
                swl_values[oct - 1] = double.Parse(swl[oct - 1]);
                if (code[oct - 1] != "")
                {
                    values = code[oct - 1].Split(';');
                }
                else
                {
                    values = new string[umax * vmax];
                    for (int i = 0; i < values.Length; i++)
                    {
                        values[i] = "0";
                    }
                }

                Vector[,] Magnitude = new Vector[umax, vmax];
                double Theta, Phi;
                int    idx = 0;

                for (int v = 0; v < vmax; v++)
                {
                    for (int u = 0; u < umax; u++)
                    {
                        if (double.IsInfinity(swl_values[oct - 1]) || double.IsNaN(swl_values[oct - 1]))
                        {
                            Magnitude[u, v] = new Vector();
                        }
                        else
                        {
                            Theta           = u * System.Math.PI / (umax - 1);
                            Phi             = 2 * v * System.Math.PI / (vmax) + System.Math.PI / 2;
                            Magnitude[u, v] = new Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Cos(Theta), Math.Sin(Theta) * Math.Sin(Phi));
                            Magnitude[u, v].Normalize();
                            double swlmag = (double.Parse(values[idx]) + 60);
                            if (swlmag < 0)
                            {
                                swlmag = 0;
                            }
                            Magnitude[u, v] *= swlmag;
                        }
                        idx++;
                    }
                }

                //Create a mesh of the points...
                List <Hare.Geometry.Point[]> list = new List <Hare.Geometry.Point[]>();
                double Minx = double.MaxValue, Miny = double.MaxValue, Minz = double.MaxValue, Maxx = double.MinValue, Maxy = double.MinValue, Maxz = double.MinValue;

                for (int u = 0; u < umax - 1; u++)
                {
                    for (int v = 0; v < vmax; v++)
                    {
                        Hare.Geometry.Point[] Poly = new Hare.Geometry.Point[4];
                        Poly[0] = Magnitude[u, v];
                        Poly[1] = Magnitude[u, (v + 1) % vmax];
                        Poly[2] = Magnitude[u + 1, (v + 1) % vmax];
                        Poly[3] = Magnitude[u + 1, v];
                        list.Add(Poly);

                        foreach (Hare.Geometry.Point p in Poly)
                        {
                            if (p.x < Minx)
                            {
                                Minx = p.x;
                            }
                            if (p.y < Miny)
                            {
                                Miny = p.y;
                            }
                            if (p.z < Minz)
                            {
                                Minz = p.z;
                            }
                            if (p.x > Maxx)
                            {
                                Maxx = p.x;
                            }
                            if (p.y > Maxy)
                            {
                                Maxy = p.y;
                            }
                            if (p.z > Maxz)
                            {
                                Maxz = p.z;
                            }
                        }
                    }
                }

                m_HareMesh[oct - 1] = new Topology(new Hare.Geometry.Point(Minx, Miny, Minz), new Hare.Geometry.Point(Maxx, Maxy, Maxz));
                foreach (Hare.Geometry.Point[] Poly in list)
                {
                    m_HareMesh[oct - 1].Add_Polygon(Poly);
                }
                if (oct == 4)
                {
                    m_DisplayMesh = new Topology(new Hare.Geometry.Point(Minx, Miny, Minz), new Hare.Geometry.Point(Maxx, Maxy, Maxz));
                    foreach (Hare.Geometry.Point[] Poly in list)
                    {
                        m_DisplayMesh.Add_Polygon(Poly);
                    }
                }
            }
            Update_Position(Center);
        }
示例#3
0
 public static extern int SetWindowLong32(IntPtr hWnd, SWL nIndex, IntPtr newLong);
示例#4
0
 public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, SWL nIndex, IntPtr dw);