Пример #1
0
    public static void Main()
    {
        if (PlacesManager.Loaded)
        {
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("Places initialised");
        }
        SetupWeight();
        DateTime startTime = DateTime.Now;

        foreach (var item in ReturnFilePath())
        {
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine();
            Console.WriteLine("Opening file: " + item);
            XmlReader xr = new XmlReader(item, true, weight);


            //// Split into days
            List <XmlReader> daysInXml = XmlReader.Split(xr);
            JsonParser.Parse(daysInXml, xr.originalName + ".json", true);
        }

        // On finish
        PlacesManager.SavePlaces();
        Console.WriteLine(DateTime.Now - startTime);
    }
Пример #2
0
 private void Apply()
 {
     _place.MetersRadious = int.Parse(tbRadious.Text);
     _place.Name          = tbPlaceName.Text;
     PlacesManager.Save();
     SettingsApplied?.Invoke(this, new EventsArgs <GeolocationPlace>(_place));
 }
Пример #3
0
 public void AddPlace(GeolocationPlace place)
 {
     this.Places        = this.Places.Union(new[] { place }).ToArray();
     this.SelectedPlace = place;
     PlacesManager.Current.Places.Add(place);
     PlacesManager.Save();
 }
Пример #4
0
 public void RemovePlace(GeolocationPlace place)
 {
     this.Places        = this.Places.Where(x => x != place).ToArray();
     this.SelectedPlace = this.Places.FirstOrDefault();
     PlacesManager.Current.Places.Remove(place);
     PlacesManager.Save();
 }
Пример #5
0
        protected void linkDirections_Click(object sender, EventArgs e)
        {
            LinkButton myButton = (LinkButton)sender;
            int        idPlace  = Convert.ToInt32(myButton.CommandArgument.ToString());
            string     querry   = PlacesManager.GetGoogleMapsQuery(idPlace);

            Response.Redirect("https://" + "www.google.com/maps/dir/?api=1&destination=" + Server.UrlEncode(querry));
        }
Пример #6
0
        protected void btnDeleteReview_Click(object sender, EventArgs e)
        {
            LinkButton myButton = (LinkButton)sender;
            int        idReview = Convert.ToInt32(myButton.CommandArgument);

            PlacesManager.DeleteReview(idReview);
            lwReviews.DataBind();
        }
Пример #7
0
    private void Awake()
    {
        Instance = this;

        raycaster    = GetComponent <PhysicsRaycaster>();
        _mapMovement = _map.GetComponent <QuadTreeCameraMovement>();

        Load();
    }
Пример #8
0
        protected void btnDeletePlace_Click(object sender, EventArgs e)
        {
            LinkButton    myButton = (LinkButton)sender;
            int           idPlace  = Convert.ToInt32(myButton.CommandArgument.ToString());
            List <string> paths    = PlacesManager.GetAllPhotoPaths(idPlace);

            DeletePhotos(paths);
            PlacesManager.DeletePlace(idPlace);
            lwPlaces.DataBind();
        }
Пример #9
0
        protected void btnDetails_Click(object sender, EventArgs e)
        {
            Button myButton = (Button)sender;
            int    idPlace  = Convert.ToInt32(myButton.CommandArgument.ToString());

            if (UserId != null)
            {
                PlacesManager.AddUserSearchHistory(idPlace, UserId, DateTime.Now);
            }

            Response.Redirect("ShowDetails.aspx?placeId=" + idPlace);
        }
Пример #10
0
        protected void btnReview_Click(object sender, EventArgs e)
        {
            int idPlace = Convert.ToInt32(Session["placeId"]);

            if (PlacesManager.UserReviewedBefore(idPlace, UserId))
            {
                ErrorMessage.Text    = "You already have a review for this place";
                ErrorMessage.Visible = true;
            }
            else
            {
                ErrorMessage.Visible = false;
                int rating = Convert.ToInt32(ddlReview.SelectedItem.Value);
                PlacesManager.AddReview(idPlace, UserId, Email, txtReview.Text, rating, DateTime.Now);
                txtReview.Text = null;
                lwReviews.DataBind();
            }
        }
Пример #11
0
                public Place(string name, Location location, DateTime startTime, DateTime endTime, string link)
                {
                    this.name     = name;
                    this.location = location;
                    this.id       = PlacesManager.ReturnPlaceId(this, startTime, endTime);

                    if (!string.IsNullOrEmpty(link))
                    {
                        if (link.StartsWith("http://facebook.com/", StringComparison.Ordinal))
                        {
                            type            = "facebook";
                            facebookPlaceId = link.Replace("http://facebook.com/", "");
                        }
                        else if (link.StartsWith("http://foursquare.com/", StringComparison.Ordinal))
                        {
                            type         = "foursquare";
                            foursquareId = link.Replace("http://foursquare.com/venue/", "");
                        }
                    }
                }
Пример #12
0
        protected void btnAddPlace_Click(object sender, EventArgs e)
        {
            Place place = new Place();

            place.Type         = ddlPlaceTypes.SelectedItem.Text;
            place.IdCity       = Convert.ToInt32(ddlPlaceCities.SelectedItem.Value);
            place.Name         = PlaceName.Text;
            place.Adress       = PlaceAdress.Text;
            place.Telephone    = PlaceTelephone.Text;
            place.Website      = PlaceWebsite.Text;
            place.Rating       = 1;
            place.RatingFloat  = 1;
            place.AveragePrice = Convert.ToInt32(PlaceAveragePrice.Text);
            if (PlaceLat.Text != null)
            {
                place.Lat = PlaceLat.Text;
            }
            if (PlaceLong.Text != null)
            {
                place.Long = PlaceLong.Text;
            }
            place.OpenTime    = TimeSpan.Parse(PlaceOpenTime.Text.ToString());
            place.CloseTime   = TimeSpan.Parse(PlaceCloseTime.Text.ToString());
            place.Confirmed   = true;
            place.IdPartner   = UserId;
            place.Description = PlaceDescription.Text;
            // Check file exist or not
            if (PlaceUploadPhoto.PostedFile != null)
            {
                // Check the extension of image
                string extension = Path.GetExtension(PlaceUploadPhoto.FileName);
                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg")
                {
                    Stream strm = PlaceUploadPhoto.PostedFile.InputStream;
                    using (var image = System.Drawing.Image.FromStream(strm))
                    {
                        // Resize image
                        int newWidth   = 1500; // New Width of Image in Pixel
                        int newHeight  = 1000; // New Height of Image in Pixel
                        var thumbImg   = new Bitmap(newWidth, newHeight);
                        var thumbGraph = Graphics.FromImage(thumbImg);
                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph.DrawImage(image, imgRectangle);
                        // Save the file
                        string filename   = place.Name + Guid.NewGuid().ToString() + extension;
                        string targetPath = Server.MapPath(@"~\Content\Images\Places\" + filename);
                        place.Photo = "~/Content/Images/Places/" + filename;
                        thumbImg.Save(targetPath, image.RawFormat);
                    }
                }
            }
            PlacesManager.AddPlace(place);
            if (PlaceUploadPhotos.PostedFiles != null)
            {
                foreach (var file in PlaceUploadPhotos.PostedFiles)
                {
                    PlacesPhoto photo = new PlacesPhoto();
                    photo.IdPlace = PlacesManager.GetLastIdPlaceForUserId(UserId);
                    photo.IdUser  = UserId;
                    // Check the extension of image
                    string extension = Path.GetExtension(file.FileName);
                    photo.Extension  = extension;
                    photo.UploadDate = DateTime.Now;
                    if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg")
                    {
                        Stream strm = file.InputStream;
                        using (var image = System.Drawing.Image.FromStream(strm))
                        {
                            // Resize image
                            int newWidth   = 730; // New Width of Image in Pixel
                            int newHeight  = 346; // New Height of Image in Pixel
                            var thumbImg   = new Bitmap(newWidth, newHeight);
                            var thumbGraph = Graphics.FromImage(thumbImg);
                            thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                            thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                            thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                            var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                            thumbGraph.DrawImage(image, imgRectangle);
                            // Save the file
                            string filename = place.Name + Guid.NewGuid().ToString() + extension;
                            photo.Name = filename;
                            string targetPath = Server.MapPath(@"~\Content\Images\PlacesPhotos\" + filename);
                            photo.Path = "~/Content/Images/PlacesPhotos/" + filename;
                            thumbImg.Save(targetPath, image.RawFormat);
                        }
                    }
                    PlacesManager.AddPlacePhoto(photo);
                }
            }
            Response.Redirect("~/Pages/ShowPlaces.aspx?cityId=" + place.IdCity);
        }