/// <summary> Initializes a new instance of the <see cref="MainPage"/> class. </summary>
        public MainPage()
        {
            this.InitializeComponent();

            // Initialize the canvas state collections.
            this.images           = new Dictionary <string, Image>();
            this.imagesTransforms = new Dictionary <string, CompositeTransform>();

            // Initialize the photo services.
            this.saveAsPhotoService = new SavePhotoService();
            this.loadPhotoService   = new LoadPhotoService();

            // Register the buttons event handlers.
            this.SaveButton.Click   += new RoutedEventHandler(this.SaveClick_OnClickAsync);
            this.AddButton.Click    += new RoutedEventHandler(this.AddClick_OnClickAsync);
            this.DeleteButton.Click += new RoutedEventHandler(this.DeleteButton_OnClickAsync);

            // Do not render anything outside the canvas bounds.
            Rect r = new Rect(new Point(0, 0), new Point(this.CollageCanvas.MaxWidth, this.CollageCanvas.MaxHeight));

            this.CollageCanvas.Clip = new RectangleGeometry {
                Rect = r
            };

            // Register the default images for the collage.
            this.images[this.ForestPhoto.Name] = this.ForestPhoto;
            this.images[this.OceanPhoto.Name]  = this.OceanPhoto;
            this.images[this.DesertPhoto.Name] = this.DesertPhoto;

            foreach (Image image in this.images.Values)
            {
                this.SetDefaultImageConfiguration(image);
            }
        }
        public ActionResult Create(Gallery gallery, HttpPostedFileBase photo)
        {
            if (!ModelState.IsValid)
            {
                return(View(gallery));
            }

            gallery.CoverPhotoPath = SavePhotoService.UploadPhoto(photo);

            gallery = _repository.Insert(gallery);
            return(RedirectToAction("Details", new{ gallery.Id }));
        }
Exemple #3
0
        public ActionResult Upload(Photo model, HttpPostedFileBase image)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var path = SavePhotoService.UploadPhoto(image);

            _photoService.AddPhotoToGallery(path, model);

            return(RedirectToAction("Details", "Galleries", new { Id = model.GalleryId }));
        }