コード例 #1
0
ファイル: Areas.cs プロジェクト: atoi2008/CraigslistWatcher
 public void GetAreaDetails(string country, string state, string city, string section, string subSection, out AreaDetails areaDetails)
 {
     areaDetails = areasList.Find(area => (area.Country == country) &&
                                 area.State == state &&
                                 area.City == city &&
                                 area.Section == section &&
                                 area.Subsection == subSection);
 }
コード例 #2
0
 public BackgroundAreaPoller(AreaDetails _areaDetails)
 {
     aggregatedEntryParsedHandlers = null;
     entryCallbacks = new Dictionary<string, BaseBackgroundPoller.EntryParsedHandler>();
     this.areaDetails = _areaDetails;
     worker = new BackgroundWorker();
     waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
     entriesSearched = 0;
     numEntriesToSearch = 0;
     stopWatch = new System.Diagnostics.Stopwatch();
     clwParseURLCompletedHandler = new CLWParseFilter.CLWParseURLCompletedHandler(this.OnEntryParsed);
     worker.DoWork += this.PollCity;
     worker.RunWorkerCompleted += this.OnPollDone;
 }
コード例 #3
0
        public ActionResult Search(string AreaName, string CityName, string StateName, string CountryName)
        {
            AreaDetails             areaDetails       = areaBusinessLayer.AreaCoordinates(AreaName, CityName, StateName, CountryName);
            RestaurantBusinessLayer restBusinessLayer = new RestaurantBusinessLayer();
            List <Restaurant>       allrestaurants    = restBusinessLayer.AllRestaurants();
            List <Restaurant>       closerestaurants  = new List <Restaurant>();

            foreach (var rest in allrestaurants)
            {
                double distanceinkms = Distance.Calculate(Convert.ToDouble(areaDetails.Latitude), Convert.ToDouble(areaDetails.Longitude), Convert.ToDouble(rest.Latitude), Convert.ToDouble(rest.Longitude));
                if (distanceinkms <= 5)
                {
                    closerestaurants.Add(rest);
                }
            }
            return(View(closerestaurants));
        }
コード例 #4
0
    public Area(Vector2 coords, Transform parent, Material material, LODDetails[] lodDetails, int colliderLODIndex, AreaNoiseDetails areaNoiseDetails, AreaDetails areaDetails, Transform player)
    {
        this.areaNoiseDetails = areaNoiseDetails;
        this.areaDetails      = areaDetails;

        center = coords * areaDetails.resolution / areaDetails.scale;

        Vector3 position = coords * areaDetails.resolution;

        instance = new GameObject("Area" + parent.childCount);
        instance.transform.position = new Vector3(position.x, 0, position.y);
        instance.transform.parent   = parent;

        bounds = new Bounds(position, Vector2.one * areaDetails.resolution);

        SetVisible(false);

        meshRenderer          = instance.AddComponent <MeshRenderer>();
        meshFilter            = instance.AddComponent <MeshFilter>();
        meshRenderer.material = material;

        this.lodDetails = lodDetails;
        lodMeshes       = new LODMesh[lodDetails.Length];

        for (int index = 0; index < lodDetails.Length; index++)
        {
            lodMeshes[index]         = new LODMesh(lodDetails[index].lod);
            lodMeshes[index].update += UpdateArea;

            if (index == colliderLODIndex)
            {
                lodMeshes[index].update += UpdateCollider;
            }
        }

        this.colliderLODIndex = colliderLODIndex;
        collider = instance.AddComponent <MeshCollider>();

        this.coords = coords;
        this.player = player;
        viewRange   = lodDetails[lodDetails.Length - 1].distance;
    }
コード例 #5
0
 public void RequestMesh(AreaNoise noiseArea, AreaDetails areaSettings)
 {
     requested = true;
     ThreadHandler.RequestDetails(() => MeshController.BuildMesh(noiseArea.area, lod, areaSettings), OnMeshDetailsReceived);
 }
コード例 #6
0
    public static MeshDetails BuildMesh(float[,] noiseArea, int lod, AreaDetails areaDetails)
    {
        int lodIncrement    = lod == 0 ? 1 : lod * 2;
        int verticesPerLine = areaDetails.verticesPerLine;

        Vector2 topLeftCorner = new Vector2(-1, 1) * areaDetails.resolution / 2f;

        MeshDetails meshDetails = new MeshDetails(verticesPerLine, areaDetails.useFlatshading, lodIncrement);

        int[,] vertexIndexes = new int[verticesPerLine, verticesPerLine];
        int meshVertexIndex    = 0;
        int outsideVertexIndex = -1;

        for (int yIndex = 0; yIndex < verticesPerLine; yIndex++)
        {
            for (int xIndex = 0; xIndex < verticesPerLine; xIndex++)
            {
                bool isOutsideVertex = yIndex == 0 || xIndex == 0 || yIndex == verticesPerLine - 1 || xIndex == verticesPerLine - 1;
                bool isUselessVertex = xIndex > 2 && xIndex < verticesPerLine - 3 && yIndex > 2 && yIndex < verticesPerLine - 3 && ((xIndex - 2) % lodIncrement != 0 || (yIndex - 2) % lodIncrement != 0);

                if (isOutsideVertex)
                {
                    vertexIndexes[xIndex, yIndex] = outsideVertexIndex;
                    outsideVertexIndex--;
                }
                else if (!isUselessVertex)
                {
                    vertexIndexes[xIndex, yIndex] = meshVertexIndex;
                    meshVertexIndex++;
                }
            }
        }

        for (int yIndex = 0; yIndex < verticesPerLine; yIndex++)
        {
            for (int xIndex = 0; xIndex < verticesPerLine; xIndex++)
            {
                bool isUselessVertex = xIndex > 2 && xIndex < verticesPerLine - 3 && yIndex > 2 && yIndex < verticesPerLine - 3 && ((xIndex - 2) % lodIncrement != 0 || (yIndex - 2) % lodIncrement != 0);

                if (!isUselessVertex)
                {
                    bool isOutsideVertex  = yIndex == 0 || xIndex == 0 || yIndex == verticesPerLine - 1 || xIndex == verticesPerLine - 1;
                    bool isFrontierVertex = (yIndex == 1 || yIndex == verticesPerLine - 2 || xIndex == 1 || xIndex == verticesPerLine - 2) && !isOutsideVertex;
                    bool isMainVertex     = (xIndex - 2) % lodIncrement == 0 && (yIndex - 2) % lodIncrement == 0 && !isOutsideVertex && !isFrontierVertex;
                    bool isInsideVertex   = (yIndex == 2 || yIndex == verticesPerLine - 3 || xIndex == 2 || xIndex == verticesPerLine - 3) && !isOutsideVertex && !isFrontierVertex && !isMainVertex;

                    int vertexIndex = vertexIndexes[xIndex, yIndex];

                    Vector2 uv           = new Vector2(xIndex - 1, yIndex - 1) / (verticesPerLine - 3);
                    Vector2 vertexCoords = topLeftCorner + new Vector2(uv.x, -uv.y) * areaDetails.resolution;
                    float   height       = noiseArea[xIndex, yIndex];

                    if (isInsideVertex)
                    {
                        bool isVertical = xIndex == 2 || xIndex == verticesPerLine - 3;

                        int distanceToMainVertexA = (isVertical ? yIndex - 2 : xIndex - 2) % lodIncrement;
                        int distanceToMainVertexB = lodIncrement - distanceToMainVertexA;

                        float distancePercentage = distanceToMainVertexA / (float)lodIncrement;

                        float heightVertexA = noiseArea[isVertical ? xIndex : xIndex - distanceToMainVertexA, isVertical ? yIndex - distanceToMainVertexA : yIndex];
                        float heightVertexB = noiseArea[isVertical ? xIndex : xIndex + distanceToMainVertexB, isVertical ? yIndex + distanceToMainVertexB : yIndex];

                        height = heightVertexA * (1 - distancePercentage) + heightVertexB * distancePercentage;
                    }

                    meshDetails.AddVertex(new Vector3(vertexCoords.x, height, vertexCoords.y), uv, vertexIndex);

                    bool createTriangle = xIndex < verticesPerLine - 1 && yIndex < verticesPerLine - 1 && (!isInsideVertex || (xIndex != 2 && yIndex != 2));

                    if (createTriangle)
                    {
                        int currentIncrement = (isMainVertex && xIndex != verticesPerLine - 3 && yIndex != verticesPerLine - 3) ? lodIncrement : 1;

                        int vertexAIndex = vertexIndexes[xIndex, yIndex];
                        int vertexBIndex = vertexIndexes[xIndex + currentIncrement, yIndex];
                        int vertexCIndex = vertexIndexes[xIndex, yIndex + currentIncrement];
                        int vertexDIndex = vertexIndexes[xIndex + currentIncrement, yIndex + currentIncrement];

                        meshDetails.AddTriangle(vertexAIndex, vertexDIndex, vertexCIndex);
                        meshDetails.AddTriangle(vertexDIndex, vertexAIndex, vertexBIndex);
                    }
                }
            }
        }

        meshDetails.BuildLighting();

        return(meshDetails);
    }
コード例 #7
0
        public static WorkerCollection GetTypedWorkers(string subArea, eMobileIdentityType identityType)
        {
            AreaDetails areaDetails = new AreaDetails();
            areaDetails.SubArea = new Area();
            areaDetails.SubArea.Name = subArea;

            return GetTypedWorkers(areaDetails, identityType);
        }
コード例 #8
0
        public static bool SaveUserDetails(string userID, AreaDetails areaDetails, eMobileIdentityType identityType, string displayName, string isClickEngineer)
        {
            DataAccess objADO = new DataAccess();
            ArrayList colParameters = new ArrayList();
            string strStoredProcedure = "updUserDetails";

            colParameters.Add(new SqlParameter("@UserID", userID));
            colParameters.Add(new SqlParameter("@PrimaryArea", areaDetails.PrimaryArea.Name));
            if (areaDetails.SubArea != null && areaDetails.SubArea.Name != null && areaDetails.SubArea.Name != string.Empty)
            {
                colParameters.Add(new SqlParameter("@SubArea", areaDetails.SubArea.Name));
            }
            if (displayName != null && displayName != string.Empty)
            {
                colParameters.Add(new SqlParameter("@DisplayName", displayName));
            }
            colParameters.Add(new SqlParameter("@MobileIdentityType", identityType.ToString()));

            if (isClickEngineer != null && isClickEngineer != string.Empty)
            {
                bool isClickEngineerValue = false;
                if (isClickEngineer == "1")
                    isClickEngineerValue = true;
 
                colParameters.Add(new SqlParameter("@IsClickEngineer", isClickEngineerValue));
            }

            int intReturn = objADO.ExecuteSQL(strStoredProcedure, (SqlParameter[])colParameters.ToArray(typeof(SqlParameter)));
            objADO = null;

            return (intReturn > 0);
        }
コード例 #9
0
 public static bool SaveUserDetails(string userID, AreaDetails areaDetails)
 {
     return SaveUserDetails(userID, areaDetails, eMobileIdentityType.WindowsIdentity, null, null);
 }
コード例 #10
0
 public static bool SaveUserDetails(string userID, AreaDetails areaDetails, bool isClickEngineer)
 {
     return SaveUserDetails(userID, areaDetails, eMobileIdentityType.WindowsIdentity, null, "1");
 }
コード例 #11
0
 public void Unsubscribe(AreaDetails areaDetails, BasePollEventHandler handler)
 {
     List<BasePollEventHandler> areaHandlers = null;
     if (areaDetailsDictionary.TryGetValue(areaDetails, out areaHandlers))
     {
         areaHandlers.Remove(handler);
         if (areaHandlers.Count == 0)
             areaDetailsDictionary.Remove(areaDetails);
     }
 }
コード例 #12
0
 public void Subscribe(AreaDetails areaDetails, BasePollEventHandler handler)
 {
     List<BasePollEventHandler> areaHandlers = null;
     if (areaDetailsDictionary.TryGetValue(areaDetails, out areaHandlers))
         areaHandlers.Add(handler);
     else
     {
         areaHandlers = new List<BasePollEventHandler>();
         areaHandlers.Add(handler);
         areaDetailsDictionary.Add(areaDetails, areaHandlers);
     }
 }