Exemple #1
0
        private void LstPhotos_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            Photograph p         = Manager.Album[e.Index];
            Rectangle  scaleRect = ImageUtility.ScaleToFit(p.Image, DrawRect);//当图像根据它的绘图矩形进行缩放时,确定它的正确大小
            Font       f         = lstPhotos.Font;
            string     text      = lstPhotos.GetItemText(p);
            int        textWidth = (int)e.Graphics.MeasureString(text, f).Width;

            e.ItemWidth  = scaleRect.Width + textWidth + 2;
            e.ItemHeight = Math.Max(scaleRect.Height, f.Height) + 2;
        }
Exemple #2
0
        public PhotoEditDialog(Photograph photo)
            : this()
        {
            if (photo == null)
            {
                throw new ArgumentNullException(
                          "The photo parameter cannot be null");
            }

            InitializeDialog(photo);
        }
 private void AssignSubItems(ListViewItem item, Photograph photo)
 {
     item.SubItems.Clear();
     item.Text = photo.Caption;
     item.Tag  = photo;
     ListViewItem.ListViewSubItem subitem;
     item.SubItems.Add(photo.Photographer);
     subitem     = item.SubItems.Add(photo.DateTaken.ToString("dd MMM yyyy"));
     subitem.Tag = photo.DateTaken;
     item.SubItems.Add(photo.FileName);
 }
Exemple #4
0
        private void UpdateDialog()
        {
            int index = trackAlbum.Value;

            if (index < Manager.Album.Count)
            {
                Photograph p = Manager.Album[index];
                pbxSlide.Image = p.Image;
                Text           = p.caption;
            }
        }
 public void SelectChild(AlbumNode node, Photograph photo)
 {
     foreach (TreeNode n in node.Nodes)
     {
         PhotoNode pNode = n as PhotoNode;
         if (pNode != null && pNode.Photograph == photo)
         {
             SelectedNode = n;
             break;
         }
     }
 }
Exemple #6
0
        public async Task <IImageResolver> GetAsync(HttpContext context)
        {
            var photoId = ExtractPhotographId(context.Request.Path);

            this.logger.LogInformation($"Resolving {photoId}");

            Photograph photograph = await this.photographRepository.GetPhotographByIdAsync(photoId);

            this.logger.LogInformation($"Got Photograph for {photoId}");

            return(this.mongoDbResolverFactory.CreateResolver(photograph));
        }
Exemple #7
0
        private void treeViewPhoto_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Level == 1)
            {
                setVisible(true);
                currentPhotograph = Photos.Photographs.Where(p => p.Name == e.Node.Name && p.Category == e.Node.Parent.Name).First();

                pictureBoxPhoto.Image = ClassConvert.ConvertBase64ToImage(currentPhotograph.Photo);
                tbKeyWorlds.Text      = ClassConvert.getKeyString(currentPhotograph.KeyWords);
                rtbDescription.Text   = currentPhotograph.Description;
            }
        }
Exemple #8
0
 public PhotoNode(Photograph photo)
     : base()
 {
     if (photo == null)
     {
         throw new ArgumentNullException("photo");
     }
     _photo           = photo;
     Text             = photo.Caption;
     ImageKey         = "Photo";
     SelectedImageKey = "Photo";
 }
        private void SaveSettings()
        {
            Photograph photo = Photo;

            if (photo != null)
            {
                photo.Caption      = txtCaption.Text;
                photo.Photographer = comboPhotographer.Text;
                photo.Notes        = txtNotes.Text;
                photo.DateTaken    = dtpDateTaken.Value;
            }
        }
Exemple #10
0
        public async Task <IActionResult> Next(string searchString, string accessionNo, string direction, string searchOption, string searchArea, string classNo, bool classSearch)
        {
            var cacheKey = string.Empty;

            if (classSearch)
            {
                cacheKey = classNo.Trim();
            }
            else
            {
                cacheKey = searchString.Trim() + searchOption + searchArea;                 // + classNo.Trim();
            }

            if (!_memoryCache.TryGetValue(cacheKey, out IndexViewModel searchResults))
            {
                searchResults = await search.SearchPhotographsByTitle(searchString, searchOption, searchArea);

                var cachExpirationOptions = new MemoryCacheEntryOptions
                {
                    AbsoluteExpiration = DateTime.Now.AddHours(6),
                    Priority           = CacheItemPriority.Normal,
                    SlidingExpiration  = TimeSpan.FromMinutes(5)
                };

                _memoryCache.Set(cacheKey, searchResults, cachExpirationOptions);
            }

            Photograph nextPhotograph = searchResults.Photographs.FirstOrDefault();

            try
            {
                Photograph currentPhotograph   = searchResults.Photographs.Where(x => x.AccessionNo.Trim() == accessionNo.Trim()).FirstOrDefault();
                int        indexOfCurrentImage = searchResults.Photographs.IndexOf(currentPhotograph);

                if (direction == "next")
                {
                    nextPhotograph = searchResults.Photographs[indexOfCurrentImage + 1];
                }
                else
                {
                    nextPhotograph = searchResults.Photographs[indexOfCurrentImage - 1];
                }
            }
            catch (Exception)
            {
                if (direction == "next")
                {
                    nextPhotograph = searchResults.Photographs.Last();
                }
            }
            return(RedirectToAction("Photograph", new { accessionno = nextPhotograph.AccessionNo.Trim(), searchString = searchString, searchOption = searchOption, searchArea = searchArea, classSearch = classSearch }));
        }
Exemple #11
0
    public void OverlayEvidence(string _identifier, Photograph _photo)
    {
        foreach (BookEvidence _evidence in evidencePhotos)
        {
            if (_evidence._evidenceIdentifier == _identifier && _evidence.gameObject.GetComponent <Image>().sprite == null)
            {
                _evidence.gameObject.GetComponent <Image>().sprite = _photo.Image;
                _evidence.gameObject.GetComponent <Image>().color  = new Color(255, 255, 255, 255);

                GameManager.Instance.cryptidStats[0].EvidencePhotos.Add(_photo);
            }
        }
    }
Exemple #12
0
        protected override void ResetDialog()
        {
            Photograph photo = Photo;

            if (photo != null)
            {
                txtPhotoFile.Text    = photo.FileName;
                mskDateTaken.Text    = photo.Caption;
                mskDateTaken.Text    = photo.DateTaken.ToString();
                txtPhotographer.Text = photo.Photographer;
                txtNotes.Text        = photo.Notes;
            }
        }
        public MongoDbResolver CreateResolver(Photograph photograph)
        {
            if (this.resolverCache.ContainsKey(photograph.Id))
            {
                return(this.resolverCache[photograph.Id]);
            }

            var resolver = new MongoDbResolver(this.photographRepository, photograph);

            this.resolverCache.Add(photograph.Id, resolver);

            return(resolver);
        }
Exemple #14
0
 /// <summary>
 /// this method will select photograph information given its unique ID
 /// </summary>
 /// <param name="imageUID">unique ID of the photograph in question</param>
 /// <returns>Photograph Entity</returns>
 public Photograph GetFlickrPhotographByImageUID(string imageUID)
 {
     try
     {
         PhotoInfo  imageInfo = flickr.PhotosGetInfo(imageUID);
         Photograph photo     = new Photograph(imageUID, imageInfo.ThumbnailUrl, imageInfo.MediumUrl, imageInfo.Title);
         return(photo);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemple #15
0
    //convert photo taken in game to content to display on page
    public PageContent PhotoToPage(Photograph photo)
    {
        PageContent content = new PageContent();

        content.image      = photo.pic;
        content.name       = photo.subjectName;
        content.photoScore = photo.finalScore;
        if (Constants.tedsWriting.ContainsKey(photo.subjectName))
        {
            content.flavorText = Constants.tedsWriting[photo.subjectName];
        }

        return(content);
    }
        private void mnuFilePageSetup_MouseDown(object sender, MouseEventArgs e)
        {
            Photograph photo = Manager.Current;

            if (photo != null)
            {
                DataObject data      = new DataObject();
                string[]   fileArray = new string[1];
                fileArray[0] = photo.FileName;
                data.SetData(DataFormats.FileDrop, fileArray);
                data.SetData(DataFormats.Text, photo.Caption);
                pbxPhoto.DoDragDrop(data, DragDropEffects.Copy);
            }
        }
        public async Task <ActionResult> GetFullPhoto(int pId, int cId)
        {
            Photograph photo = await _db.Photographs
                               .FirstOrDefaultAsync(p => p.PhotoId == pId && p.Category.CategoryId == cId);

            if (photo == null)
            {
                return(new JsonResult(string.Empty));
            }
            else
            {
                return(File(photo.LargeImage, photo.FileType));
            }
        }
        public ActionResult Details(int?galleryId, int?id, string resolution)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Photograph photograph = db.Photograph.Find(id);

            if (photograph == null)
            {
                return(HttpNotFound());
            }
            return(View(photograph));
        }
Exemple #19
0
        public ActionResult genrePhoto(Photograph photo)
        {
            var photomanager = new PhotoManager();
            var issucced     = photomanager.photos(out List <Photograph> genrePhoto);

            if (issucced)
            {
                return(View(genrePhoto));
            }
            else
            {
                return(RedirectToAction("Photograph", "genrePhoto"));
            }
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Photograph photograph = db.Photograph.Find(id);

            if (photograph == null)
            {
                return(HttpNotFound());
            }
            return(View(photograph));
        }
Exemple #21
0
        /// <summary>
        /// this method will get photograph info and context information (previous/next thumbnail URLs) given its unique image ID
        /// </summary>
        /// <param name="imageUID">unique ID of image</param>
        /// <param name="setUID">unique ID of set</param>
        /// <returns>Photograph Entity</returns>
        public Photograph GetFlickrPhotoContextByImageUID(string imageUID, string setUID)
        {
            try
            {
                Photograph photo = new Photograph();

                //HACK NOTE: for some reaon GetFlickrPhotographByImageUID wasn't working here so I decided to get the whole set
                List <Photograph> photoList = GetPhotoSetPhotoListBySetID(setUID);

                //get the correct photo out of the collection
                foreach (Photograph p in photoList)
                {
                    if (p.ImageUID == imageUID)
                    {
                        //photo = GetFlickrPhotographByImageUID(imageUID);
                        photo = p;
                        break;
                    }
                }

                //add attributes to photo meta data
                Context photosetContext = flickr.PhotosetsGetContext(imageUID, setUID);
                if (photosetContext.PreviousPhoto.PhotoId != "0")
                {
                    photo.PreviousThumbnailURL = photosetContext.PreviousPhoto.ThumbnailUrl;
                    photo.PreviousImageUID     = photosetContext.PreviousPhoto.PhotoId;
                }
                if (photosetContext.NextPhoto.PhotoId != "0")
                {
                    photo.NextThumbnailURL = photosetContext.NextPhoto.ThumbnailUrl;
                    photo.NextImageUID     = photosetContext.NextPhoto.PhotoId;
                }
                return(photo);
            }
            catch (Exception ex)
            {
                System.IO.StreamWriter sw = System.IO.File.AppendText(ConfigurationManager.AppSettings["ErrorLogPath"].ToString() + "SkiChairErrorLogFile.txt");
                try
                {
                    string logLine = System.String.Format("{0:G}: {1}.", System.DateTime.Now, "Error: " + ex.Message);
                    sw.WriteLine(logLine);
                }
                finally
                {
                    sw.Close();
                }
                return(null);
            }
        }
Exemple #22
0
        public async Task <Photograph> PublishPhotograph(string id)
        {
            Photograph photograph = await this.photographRepository.GetPhotographByIdAsync(id);

            if (photograph == null)
            {
                return(null);
            }

            photograph.IsPublished   = true;
            photograph.PublishedDate = DateTime.Now;
            await this.photographRepository.UpdatePhotographAsync(photograph);

            return(photograph);
        }
Exemple #23
0
        public async Task <Photograph> RetractPhotograph(string id)
        {
            Photograph photograph = await this.photographRepository.GetPhotographByIdAsync(id);

            if (photograph == null)
            {
                return(null);
            }

            photograph.IsPublished   = false;
            photograph.PublishedDate = null;
            await this.photographRepository.UpdatePhotographAsync(photograph);

            return(photograph);
        }
Exemple #24
0
        private void lstPhotos_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            Graphics   g = e.Graphics;
            Photograph p = _album[e.Index];

            Rectangle scaledRect = p.ScaleToFit(_drawRect);
            Rectangle imageRect  = e.Bounds;

            imageRect.Y     += 1;
            imageRect.Height = scaledRect.Height;
            imageRect.X     += 2;
            imageRect.Width  = scaledRect.Width;

            g.DrawImage(p.Thumbnail, imageRect);
            g.DrawRectangle(Pens.Black, imageRect);

            Rectangle textRect = new Rectangle(
                imageRect.Right + 2,
                imageRect.Y + ((imageRect.Height - e.Font.Height) / 2),
                e.Bounds.Width - imageRect.Width - 4,
                e.Font.Height);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                _textBrush.Color = SystemColors.Highlight;
                g.FillRectangle(_textBrush, textRect);
                _textBrush.Color = SystemColors.HighlightText;
            }
            else
            {
                _textBrush.Color = SystemColors.Window;
                g.FillRectangle(_textBrush, textRect);
                _textBrush.Color = SystemColors.WindowText;
            }

            // Note that DisplayMember can be null here, causing pi to be null
            PropertyInfo pi = typeof(Photograph).GetProperty(lstPhotos.DisplayMember);

            if (pi != null)
            {
                object propValue = pi.GetValue(p, null);
                g.DrawString(propValue.ToString(), e.Font, _textBrush, textRect);
            }
            else
            {
                g.DrawString(p.ToString(), e.Font, _textBrush, textRect);
            }
        }
Exemple #25
0
        void DrawPhoto(CGContext ctx)
        {
            ctx.SaveState();

            ctx.AddPath(PhotoBorder);
            ctx.Clip();

            Photograph.Draw(PhotoRect);

            ctx.AddPath(PhotoBorder);
            ctx.SetStrokeColor(0.5f, 0.5f, 0.5f, 1.0f);
            ctx.SetLineWidth(0.5f);
            ctx.StrokePath();

            ctx.RestoreState();
        }
Exemple #26
0
        private void SaveSettings()
        {
            Photograph photo = Photo;

            if (photo != null)
            {
                photo.Caption      = txtCaption.Text;
                photo.Photographer = cmbPhotographer.Text;
                photo.Notes        = txtNotes.Text;
                try
                {
                    photo.DateTaken = dtpDateTaken.Value;
                }
                catch (FormatException) { }
            }
        }
Exemple #27
0
		/// <summary>
		/// Constructs an instance of Completed screen with the set of pictures to put
		/// onto the photographs.
		/// </summary>
		public CompletedScreen( PictureSet pictureSet ) {
			this.pictureSet = pictureSet;

			Audio.Play( "Puzzle Completed" );
			photographs = new List<Photograph>();

			int photographCount = 40;
			for( int i = 0; i < photographCount; i++ ) {
				Photograph newphotograph = new Photograph();
				ResetPhotograph( newphotograph );
				photographs.Add( newphotograph );
			}

			TransitionOnTime = Puzzle3D.TransitionTime;
			TransitionOffTime = TimeSpan.FromSeconds( 0.75f );
		}
        public PhotoViewModel BuildViewModel(Photograph repositoryModel)
        {
            PhotoViewModel viewModel = new PhotoViewModel();

            viewModel.PhotoId     = repositoryModel.PhotoId;
            viewModel.Orientation = repositoryModel.Orientation;
            if (repositoryModel.Category.StatusCode == CategoryStatusCodes.Completed)
            {
                viewModel.Title = $"'{repositoryModel.AnonymousPhotoName}' by {repositoryModel.Photographer.Nickname}";
            }
            else
            {
                viewModel.Title = $"'{repositoryModel.AnonymousPhotoName}'";
            }
            return(viewModel);
        }
        protected void SaveSettings()
        {
            Photograph photo = Photo;

            if (photo != null)
            {
                photo.Caption      = txtCaption.Text;
                photo.Photographer = txtPhotographer.Text;
                photo.Notes        = txtNotes.Text;
                try
                {
                    photo.DateTaken = DateTime.Parse(txtDateTaken.Text);
                }
                catch (FormatException) { }
            }
        }
        private void lstPhotos_DrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;

            if (e.Index < 0 || e.Index > Manager.Album.Count - 1)
            {
                return;
            }

            Photograph p = Manager.Album[e.Index];

            // Determine image rectangle
            Rectangle imageRect = ImageUtility.ScaleToFit(p.Image, DrawRect);

            imageRect.X = e.Bounds.X + 2;
            imageRect.Y = e.Bounds.Y + 1;

            // Draw text image
            g.DrawImage(p.Image, imageRect);
            g.DrawRectangle(Pens.Black, imageRect);
            p.ReleaseImage();

            // Determine text rectangle
            Rectangle textRect = new Rectangle();

            textRect.X      = imageRect.Right + 2;
            textRect.Y      = imageRect.Y + ((imageRect.Height - e.Font.Height) / 2);
            textRect.Width  = e.Bounds.Width - imageRect.Width - 4;
            textRect.Height = e.Font.Height;

            // Determine text brush (handle selection)
            Brush textBrush;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                g.FillRectangle(SystemBrushes.Highlight, textRect);
                textBrush = SystemBrushes.HighlightText;
            }
            else
            {
                g.FillRectangle(SystemBrushes.Window, textRect);
                textBrush = SystemBrushes.WindowText;
            }

            // Draw the text
            g.DrawString(lstPhotos.GetItemText(p), e.Font, textBrush, textRect);
        }
Exemple #31
0
        public ActionResult Add(Book bookView, HttpPostedFileBase image)
        {
            var category = db.Categories.ToList();

            if (ModelState.IsValid == false)
            {
                ViewBag.Category = new SelectList(category, "categoryID", "name");
                return(View());
            }
            Photograph photograph = new Photograph();

            if (image != null)
            {
                string returnValue = photograph.Add(image, "/Content/Photograph/Book/");
                if (returnValue == "extention")
                {
                    ViewBag.Hata     = "Resim uzantısı jpg ve png den başka olamaz";
                    ViewBag.Category = new SelectList(category, "categoryID", "name");
                    return(View());
                }
                else if (returnValue == "length")
                {
                    ViewBag.Hata     = "Resmin boyutu maksimum 3MB olabilir";
                    ViewBag.Category = new SelectList(category, "categoryID", "name");
                    return(View());
                }
                bookView.imageName = returnValue;
            }
            else
            {
                bookView.imageName = "default.jpg";
            }
            Book book = new Book();

            book.name          = bookView.name.ToUpper(new CultureInfo("tr-TR", false));
            book.writer        = bookView.writer.ToUpper(new CultureInfo("tr-TR", false));
            book.publisher     = bookView.publisher.ToUpper(new CultureInfo("tr-TR", false));
            book.numberOfPages = bookView.numberOfPages;
            book.statusID      = 1;
            book.categoryID    = bookView.categoryID;
            book.imageName     = bookView.imageName;
            db.Books.Add(book);
            db.SaveChanges();
            TempData["Basari"] = "Kayıt başarı ile oluşturulmuştur";
            ViewBag.Category   = new SelectList(category, "categoryID", "name");
            return(RedirectToAction("Add"));
        }
Exemple #32
0
		/// <summary>
		///  Resets a photograph for another fall. Also puts a random picture on it.
		/// </summary>
		/// <param name="photograph">The photograph to reset.</param>
		void ResetPhotograph( Photograph photograph ) {
			photograph.Texture =
				pictureSet.GetTexture( RandomHelper.Random.Next( pictureSet.Count ) );
			photograph.Reset();
		}