/// <summary>
 /// Initializes a new instance of the <see cref="GroupedRegionUpdateMessage"/> class.
 /// </summary>
 /// <param name="lastKnownRegion">The last known region.</param>
 /// <param name="coordinates">The coordinates of the region being updated.</param>
 /// <param name="messages">The set of the messages to be sent.</param>
 public GroupedRegionUpdateMessage(Position lastKnownRegion, RegionCoordinates coordinates,
                                   HashSet <RegionUpdateMessage> messages)
 {
     _lastKnownRegion = lastKnownRegion;
     _update          = new Position(coordinates.AbsoluteX, coordinates.AbsoluteY);
     _messages        = messages;
 }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (obj is RegionCoordinates)
            {
                RegionCoordinates other = (RegionCoordinates)obj;
                return(X == other.X && Y == other.Y);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public ActionResult Index(string sortOrder, string currentFilter, string categoryString, string searchString, string regionString, int?page)
        {
            var coord = from r in db.RegionCoordinates
                        where r.RegionName == regionString
                        select r;

            ViewBag.Latitude      = 46;
            ViewBag.Latitude      = 20;
            ViewBag.CurrentRegion = "Hello";
            RegionCoordinates rc = new RegionCoordinates();

            foreach (var c in coord)
            {
                rc.RegionName = c.RegionName;
                rc.Latitude   = c.Latitude;
                rc.Longitude  = c.Longitude;
            }


            ViewData["CurrentRegion"] = rc;
            ViewBag.CurrentSort       = sortOrder;
            ViewBag.NameSortParm      = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.PriceParm         = sortOrder == "Price" ? "price_desc" : "Price";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var CategoryList = new List <string>();

            var q = from d in db.Categories
                    select d.Name;

            CategoryList.AddRange(q.Distinct());
            ViewBag.categoryString = new SelectList(CategoryList);

            var RegionList = new List <string>();

            var region = from d in db.Products
                         select d.WeinRegion;

            RegionList.AddRange(region.Distinct());
            ViewBag.regionString = new SelectList(RegionList);

            ViewBag.categoryString = new SelectList(CategoryList);

            var products = db.Products.Include(p => p.Category);

            if (!String.IsNullOrEmpty(searchString))
            {
                products = products.Where(p => p.Name.Contains(searchString));
            }
            if (!string.IsNullOrEmpty(categoryString))
            {
                products = products.Where(p => p.Category.Name == categoryString);
            }
            if (!string.IsNullOrEmpty(regionString))
            {
                products = products.Where(p => p.WeinRegion == regionString);
            }

            switch (sortOrder)
            {
            case "name_desc":
                products = products.OrderByDescending(p => p.Name);
                break;

            case "Price":
                products = products.OrderBy(p => p.Price);
                break;

            case "date_desc":
                products = products.OrderByDescending(p => p.Price);
                break;

            default:
                products = products.OrderBy(s => s.Name);
                break;
            }

            int pageSize   = 6;
            int pageNumber = (page ?? 1);

            return(View(products.ToPagedList(pageNumber, pageSize)));
            //return View(products.ToList());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns whether or not this position is inside the specified <seealso cref="Region"/>.
        /// </summary>
        /// <param name="region"> The region. </param>
        /// <returns> {@code true} if this position is inside the specified region, otherwise {@code false}. </returns>
        public bool Inside(IRegion region)
        {
            RegionCoordinates coordinates = region.Coordinates;

            return(coordinates.Equals(RegionCoordinates));
        }