private object CreatePhotoLayoutItem(PhotoInfo photoInfo, int index)
 {
     return(new PhotoComboBoxItem()
     {
         PhotoInfo = photoInfo, PhotoLayout = photoInfo.PhotoLayout, Name = "Item " + index.ToString()
     });
 }
Exemple #2
0
        public static Discuz.Common.Generic.List <PhotoInfo> GetSpacePhotosInfo(DataTable dt)
        {
            if (dt == null || dt.Rows.Count == 0)
            {
                return(new Discuz.Common.Generic.List <PhotoInfo>());
            }

            Discuz.Common.Generic.List <PhotoInfo> photosinfoarray = new Discuz.Common.Generic.List <PhotoInfo>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PhotoInfo photo = new PhotoInfo();
                photo.Photoid       = TypeConverter.ObjectToInt(dt.Rows[i]["photoid"]);
                photo.Filename      = dt.Rows[i]["filename"].ToString();
                photo.Attachment    = dt.Rows[i]["attachment"].ToString();
                photo.Filesize      = TypeConverter.ObjectToInt(dt.Rows[i]["filesize"]);
                photo.Description   = dt.Rows[i]["description"].ToString();
                photo.Postdate      = dt.Rows[i]["postdate"].ToString();
                photo.Albumid       = TypeConverter.ObjectToInt(dt.Rows[i]["albumid"]);
                photo.Userid        = TypeConverter.ObjectToInt(dt.Rows[i]["userid"]);
                photo.Title         = dt.Rows[i]["title"].ToString();
                photo.Views         = TypeConverter.ObjectToInt(dt.Rows[i]["views"]);
                photo.Commentstatus = (PhotoStatus)TypeConverter.ObjectToInt(dt.Rows[i]["commentstatus"]);
                photo.Tagstatus     = (PhotoStatus)TypeConverter.ObjectToInt(dt.Rows[i]["tagstatus"]);
                photo.Comments      = TypeConverter.ObjectToInt(dt.Rows[i]["comments"]);

                photosinfoarray.Add(photo);
            }
            dt.Dispose();
            return(photosinfoarray);
        }
Exemple #3
0
        public string GetPhotoPath(int orderID, PhotoInfo photo)
        {
            string targetDirectory = GetDownloadedPhotosFolderName(orderID);
            string fileName        = Path.GetFileName(photo.FilePath);

            return(Path.Combine(targetDirectory, fileName));
        }
Exemple #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (chooserCancelled == true)
            {
                // The user did not choose a photo so return to the main page;
                // the added PhotoInfo is already removed.
                NavigationService.GoBack();

                // Void out the binding so that we don't try and bind
                // to an empty PhotoInfo object.
                this.DataContext = null;

                return;
            }

            // Get the selected PhotoInfo object.
            string indexAsString = this.NavigationContext.QueryString["selectedIndex"];
            int    index         = int.Parse(indexAsString);

            this.DataContext             = currentPhoto
                                         = (PhotoInfo)App.ViewModel.Photos[index];

            // If this is a new photo, we need to get the image file.
            if (currentPhoto.PhotoId == 0 &&
                currentPhoto.FileName == string.Empty)
            {
                // Call the OnSelectPhoto method to open the chooser.
                this.OnSelectPhoto(this, new EventArgs());
            }
        }
Exemple #5
0
        public void SavePhoto(PhotoInfo photoInfo)
        {
            Data.Photo photo = ConvertToDb(photoInfo);

            _context.Photos.Add(photo);
            _context.SaveChanges();
        }
Exemple #6
0
        public List <PhotoInfo> GetRecommandPhotoList(string nodeName)
        {
            if (__recommandPhotoList != null)
            {
                return(__recommandPhotoList);
            }
            __recommandPhotoList = new List <PhotoInfo>();
            XmlNodeList xmlNodeList = AggregationData.xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/" + nodeName + "_photolist/Photo");

            foreach (XmlNode xmlnode in xmlNodeList)
            {
                PhotoInfo photoInfo = new PhotoInfo();
                photoInfo.Photoid       = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "photoid") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "photoid")));
                photoInfo.Filename      = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "filename") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "filename"));
                photoInfo.Attachment    = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "attachment") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "attachment"));
                photoInfo.Filesize      = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "filesize") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "filesize")));
                photoInfo.Description   = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "description") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "description"));
                photoInfo.Postdate      = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "postdate") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "postdate"));
                photoInfo.Albumid       = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "albumid") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "albumid")));
                photoInfo.Userid        = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "userid") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "userid")));
                photoInfo.Title         = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "title"));
                photoInfo.Views         = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "views") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "views")));
                photoInfo.Commentstatus = (PhotoStatus)((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "commentstatus") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "commentstatus")));
                photoInfo.Tagstatus     = (PhotoStatus)((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "tagstatus") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "tagstatus")));
                photoInfo.Comments      = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "comments") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "comments")));
                photoInfo.Username      = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "username") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "username"));
                __recommandPhotoList.Add(photoInfo);
            }
            return(__recommandPhotoList);
        }
Exemple #7
0
        private static void AddPhoto(HttpClient client, int albumId, string name, string url)
        {
            var newPhoto = new PhotoInfo()
            {
                Name         = name,
                Url          = url,
                PhotoAlbumId = albumId
            };

            HttpContent postContent = new StringContent(JsonConvert.SerializeObject(newPhoto));

            postContent.Headers.ContentType            = new MediaTypeHeaderValue("application/json");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);

            var response = client.PostAsync("api/photos/create", postContent).Result;

            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine("Picture {0} added!", name);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
Exemple #8
0
        /// <summary>
        /// 获得推荐图片列表
        /// </summary>
        /// <param name="nodename">节点名称</param>
        /// <returns></returns>
        public Discuz.Common.Generic.List <PhotoInfo> GetRecommandPhotoList(string nodeName)
        {
            //当文件未被修改时将直接返回相关记录
            if (__recommandPhotoList != null)
            {
                return(__recommandPhotoList);
            }

            __recommandPhotoList = new Discuz.Common.Generic.List <PhotoInfo>();
            XmlNodeList xmlnodelist = xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/" + nodeName + "_photolist/Photo");

            foreach (XmlNode xmlnode in xmlnodelist)
            {
                PhotoInfo recommandPhoto = new PhotoInfo();

                recommandPhoto.Photoid       = (xmlDoc.GetSingleNodeValue(xmlnode, "photoid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "photoid"));
                recommandPhoto.Filename      = (xmlDoc.GetSingleNodeValue(xmlnode, "filename") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "filename");
                recommandPhoto.Attachment    = (xmlDoc.GetSingleNodeValue(xmlnode, "attachment") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "attachment");
                recommandPhoto.Filesize      = (xmlDoc.GetSingleNodeValue(xmlnode, "filesize") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "filesize"));
                recommandPhoto.Description   = (xmlDoc.GetSingleNodeValue(xmlnode, "description") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "description");
                recommandPhoto.Postdate      = (xmlDoc.GetSingleNodeValue(xmlnode, "postdate") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "postdate");
                recommandPhoto.Albumid       = (xmlDoc.GetSingleNodeValue(xmlnode, "albumid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "albumid"));
                recommandPhoto.Userid        = (xmlDoc.GetSingleNodeValue(xmlnode, "userid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "userid"));
                recommandPhoto.Title         = (xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "title");
                recommandPhoto.Views         = (xmlDoc.GetSingleNodeValue(xmlnode, "views") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "views"));
                recommandPhoto.Commentstatus = (xmlDoc.GetSingleNodeValue(xmlnode, "commentstatus") == null) ? PhotoStatus.Owner : (PhotoStatus)Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "commentstatus"));
                recommandPhoto.Tagstatus     = (xmlDoc.GetSingleNodeValue(xmlnode, "tagstatus") == null) ? PhotoStatus.Owner : (PhotoStatus)Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "tagstatus"));
                recommandPhoto.Comments      = (xmlDoc.GetSingleNodeValue(xmlnode, "comments") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "comments"));
                recommandPhoto.Username      = (xmlDoc.GetSingleNodeValue(xmlnode, "username") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "username");
                __recommandPhotoList.Add(recommandPhoto);
            }
            return(__recommandPhotoList);
        }
        private void getCurrentPhoto()
        {
            // Get the currently selected photo.
            currentPhoto =
                (PhotoInfo)this.photoComboBox.SelectedItem;

            // Get the image for the selected PhotoData not an added one.
            if (currentPhoto != null && currentPhoto.PhotoId != 0)
            {
                try
                {
                    // Use the ReadStreamUri of the Media Resource for selected PhotoInfo object
                    // as the URI source of a new bitmap image.
                    photoImage.Source = new BitmapImage(context.GetReadStreamUri(currentPhoto));
                }
                catch (DataServiceClientException ex)
                {
                    XElement error = XElement.Parse(ex.Message);

                    // Display the error messages.
                    MessageBox.Show(error.Value,
                                    string.Format("Error Status Code: {0}", ex.StatusCode));
                }
            }
        }
Exemple #10
0
        private void openImage(Image isend)
        {
            if (isend.Clip != null)
            {
                Geometry g  = isend.Clip;
                Rect     re = g.Bounds;
                double   b  = re.Bottom;
                double   t  = re.Top;
                double   l  = re.Left;
                double   r  = re.Right;
            }
            if (isend.Tag != null)
            {
                PhotoInfo pi      = (PhotoInfo)isend.Tag;
                WrapPanel spp     = (WrapPanel)isend.Parent;
                int       iThis   = spp.Children.GetIndex(isend);
                Image     imgPrev = iThis > 1 ? (Image)spp.Children.ElementAt <UIElement>(iThis - 1) : null;
                Image     imgNext = iThis < spp.Children.Count - 1 ? (Image)spp.Children.ElementAt <UIElement>(iThis + 1) : null;

                OnImageIsChanged(new ImageIsChangedEventArgs()
                {
                    photoinfo = pi, nextPhotoInfo = imgNext != null ? imgNext.Tag != null ? (PhotoInfo)imgNext.Tag : null : null, prevPhotoInfo = imgPrev != null ? imgPrev.Tag != null ? (PhotoInfo)imgPrev.Tag : null : null,
                });
            }
        }
        public bool AddPhoto(int orderID, PhotoInfo photo, byte[] photoBytes, string fileExtension)
        {
            assertConnected();
            try
            {
                // The initial FilePath property of the info object is ignored.  The web service will
                // decide on the final file name

                // Upload photo
                string claimToken = uploadFileIncrementally(photoBytes);
                if (claimToken == null)
                {
                    return(false);
                }

                // add the photo record.  the claim token is used to allow the service to
                if (wsClient.AddPhoto(accessToken(), orderID, photo, fileExtension, claimToken) == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw TranslateException(ex);
            }
        }
        private static void DownloadImage(PhotoInfo info)
        {
            string path = ConfigurationManager.AppSettings["location"];

            try
            {
                string filePath = Path.Combine(path, $"photos/{info.PhotoId}.{info.OriginalFormat}");
                var    request  = WebRequest.CreateHttp(info.OriginalUrl);
                var    response = request.GetResponse();
                using (Stream output = File.OpenWrite(filePath))
                    using (Stream input = response.GetResponseStream())
                    {
                        input.CopyTo(output);
                    }
            }
            catch (Exception ex)
            {
                string exceptionPath = Path.Combine(path, $"photos/{info.PhotoId}-EXCEPTION.txt");
                string message       = ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace;
                if (ex.InnerException != null)
                {
                    message += new string('-', 80) + Environment.NewLine + Environment.NewLine + "INNER EXCEPTION : " +
                               Environment.NewLine + ex.InnerException.Message + Environment.NewLine +
                               Environment.NewLine + ex.InnerException.StackTrace;
                }
                File.WriteAllText(exceptionPath, message);
                exceptionPath = Path.Combine(path, $"photos/EXCEPTION-{info.PhotoId}.txt");
                File.WriteAllText(exceptionPath, message);
            }
        }
Exemple #13
0
        /// <summary>
        /// 保存添加数据 Add(PhotoInfo entity)
        /// </summary>
        /// <param name="entity">实体类(PhotoInfo)</param>
        ///<returns>返回新增的ID</returns>
        public void Add(PhotoInfo entity)
        {
            var strSql = new StringBuilder();

            strSql.Append("insert into XSBlog_Photo(");
            strSql.Append("Guid,Name,Tag,Image_Url,Image_Key,User_Guid,Album_Guid,Create_time,Is_Cover");
            strSql.Append(") values (");
            strSql.Append("@Guid,@Name,@Tag,@Image_Url,@Image_Key,@User_Guid,@Album_Guid,@Create_time,@Is_Cover");
            strSql.Append(") ");

            DbParameter[] parameters =
            {
                SqlHelper.MakeInParam("@Guid",        (DbType)SqlDbType.UniqueIdentifier, Guid.NewGuid()),
                SqlHelper.MakeInParam("@Name",        (DbType)SqlDbType.VarChar,          entity.Name),
                SqlHelper.MakeInParam("@Tag",         (DbType)SqlDbType.VarChar,          entity.Tag),
                SqlHelper.MakeInParam("@Image_Url",   (DbType)SqlDbType.VarChar,          entity.ImageUrl),
                SqlHelper.MakeInParam("@Image_Key",   (DbType)SqlDbType.UniqueIdentifier, ConvertHelper.GetGuid(entity.ImageKey)),
                SqlHelper.MakeInParam("@User_Guid",   (DbType)SqlDbType.UniqueIdentifier, ConvertHelper.GetGuid(entity.UserGuid)),
                SqlHelper.MakeInParam("@Album_Guid",  (DbType)SqlDbType.UniqueIdentifier, ConvertHelper.GetGuid(entity.AlbumGuid)),
                SqlHelper.MakeInParam("@Create_time", (DbType)SqlDbType.DateTime,         entity.Createtime),
                SqlHelper.MakeInParam("@Is_Cover",    (DbType)SqlDbType.Bit,              entity.IsCover)
            };

            SqlHelper.ExecuteNonQuery(strSql.ToString(), parameters);
        }
Exemple #14
0
        private PhotoInfo getSize(String item)
        {
            if (strUtil.IsNullOrEmpty(item))
            {
                return(null);
            }
            String[] arr = item.Split('=');
            if (arr.Length != 2)
            {
                return(null);
            }

            String[] wh = arr[1].Trim().Split('/');
            if (wh.Length != 2)
            {
                return(null);
            }
            PhotoInfo x = new PhotoInfo();

            x.Width  = cvt.ToInt(wh[0]);
            x.Height = cvt.ToInt(wh[1]);

            if (x.Width <= 0 || x.Height <= 0)
            {
                return(null);
            }

            return(x);
        }
Exemple #15
0
        private string GetDescription(string photoId)
        {
            Flickr    flickr = new Flickr(WebConfigurationManager.AppSettings["apiKey"], WebConfigurationManager.AppSettings["sharedSecret"]);
            PhotoInfo info   = flickr.PhotosGetInfo(photoId);

            return(info.Description);
        }
Exemple #16
0
        public bool AddPhoto(string accessToken, int orderID, PhotoInfo photo, string fileExtension, string uploadedFileClaimToken)
        {
            logMethodInvocation();
            checkAccessToken(accessToken);
            try
            {
                using (CFIEntities db = new CFIEntities())
                {
                    Order order = getOrderByID(orderID, db);

                    // the file name will depend on the po number and how many other photos may have already been added
                    string fileName = getPhotoFileName(order.OrderID, fileExtension);
                    photo.FilePath = fileName;

                    // claim the uploaded file and name it and store it in the proper location
                    byte[] photoBytes = Globals.FileTransferManager.Uploader.ClaimFile(uploadedFileClaimToken);
                    savePhoto(order.OrderID, fileName, photoBytes);

                    POPhoto poPhoto = ConversionUtils.ToPOPhoto(photo, orderID);
                    order.POPhotos.Add(poPhoto);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                logException(ex);
                return(false);
            }
        }
Exemple #17
0
 public string GetPhotos(string accessToken, int orderID)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             POPhoto[] poPhotos = getPOPhotosByOrderID(orderID, db);
             if (poPhotos == null)
             {
                 return(null);
             }
             else
             {
                 PhotoInfo[] photos = ConversionUtils.ToPhotoInfoArray(poPhotos, db);
                 return(PhotoInfo.BuildPhotosXml(photos));
             }
         }
     }
     catch (Exception ex)
     {
         logException(ex);
         return(null);
     }
 }
Exemple #18
0
        public ActionResult ViewPhoto(string photo)
        {
            photosModel = new PhotosModel(outputDir);
            PhotoInfo p = photosModel.GetPhotoInfo(photo);

            return(View(p));
        }
Exemple #19
0
        public ActionResult PhotosView(string id)
        {
            photosModel = new PhotosModel(outputDir);
            PhotoInfo p = photosModel.GetPhotoInfo(id);

            return(View(p)); //check that is not null
        }
Exemple #20
0
        private bool uploadPhoto(int orderID, PhotoInfo photo, out string errorMessage)
        {
            errorMessage = "";
            bool failed = false;

            byte[] photoBytes = null;
            try
            {
                photoBytes = System.IO.File.ReadAllBytes(photo.FilePath);
            }
            catch
            {
                errorMessage = string.Format("Failed to read cached photo {0}", photo.FilePath);
                return(false);
            }

            string extension = System.IO.Path.GetExtension(photo.FilePath).TrimStart('.');

            if (this.wsAPI.AddPhoto(orderID, photo, photoBytes, extension) == false)
            {
                errorMessage = string.Format("Failed to add a new photo to existing order ID == {0}", orderID);
                return(false);
            }
            return(true);
        }
        private void addPhoto_Click(object sender, RoutedEventArgs e)
        {
            // Create a new PhotoInfo object.
            PhotoInfo newPhotoEntity = new PhotoInfo();

            // Ceate an new PhotoDetailsWindow instance with the current
            // context and the new photo entity.
            PhotoDetailsWindow addPhotoWindow =
                new PhotoDetailsWindow(newPhotoEntity, context);

            addPhotoWindow.Title = "Select a new photo to upload...";

            // We need to have the new entity tracked to be able to
            // call DataServiceContext.SetSaveStream.
            trackedPhotos.Add(newPhotoEntity);

            // If we successfully created the new image, then display it.
            if (addPhotoWindow.ShowDialog() == true)
            {
                // Set the index to the new photo.
                photoComboBox.SelectedItem = newPhotoEntity;
            }
            else
            {
                // Remove the new entity since the add operation failed.
                trackedPhotos.Remove(newPhotoEntity);
            }
        }
Exemple #22
0
        public virtual Dictionary <String, PhotoInfo> GetInfo(String str)
        {
            Dictionary <String, PhotoInfo> dic = new Dictionary <String, PhotoInfo>();

            if (strUtil.IsNullOrEmpty(str))
            {
                return(dic);
            }

            String[] arr = str.Split(',');
            foreach (String item in arr)
            {
                String    key  = getKey(item);
                PhotoInfo size = getSize(item);

                if (strUtil.IsNullOrEmpty(key))
                {
                    continue;
                }
                if (size == null)
                {
                    continue;
                }

                dic.Add(key, size);
            }
            return(dic);
        }
        public PhotoDetailsWindow(PhotoInfo photo, DataServiceContext context)
        {
            InitializeComponent();

            this.photoEntity = photo;
            this.context     = context;
        }
Exemple #24
0
        protected override string OnAttachCreated(Discuz.Entity.AttachmentInfo[] attachs, int usergroupid, int userid, string username)
        {
            if (attachs == null)
            {
                return("");
            }
            string[] albumsid = DNTRequest.GetString("albums") == "" ? null : DNTRequest.GetString("albums").Split(',');
            if (albumsid == null)
            {
                return("");
            }
            int maxphotosize     = UserGroups.GetUserGroupInfo(usergroupid).Maxspacephotosize;
            int currentphotisize = DbProvider.GetInstance().GetPhotoSizeByUserid(userid);

            if (attachs.Length + 2 == albumsid.Length)//验证提交上来的albums数据是否是合法可用数据,因为albums数据提交逗号数组头尾各有一个0,则合法数据位附件list长度加2==albums元素个数
            {
                for (int i = 0; i < attachs.Length; i++)
                {
                    if (attachs[i].Filename != "" && (attachs[i].Filetype == "image/pjpeg") || (attachs[i].Filetype == "image/gif") || (attachs[i].Filetype == "image/x-png"))
                    {
                        //由于提交上来的albums数据是头尾各含有一个值为0的元素的数组,则和第一个附件对应的相册ID其实是第二个值
                        string aid = albumsid[i + 1];
                        if (aid != "0")
                        {
                            if ((maxphotosize - currentphotisize - (int)attachs[i].Filesize) > 0)
                            {
                                string filename  = Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" + attachs[i].Filename.Replace('\\', '/'));
                                string extension = Path.GetExtension(filename);
                                Common.Thumbnail.MakeThumbnailImage(filename, filename.Replace(extension, "_thumbnail" + extension), 150, 150);
                                Common.Thumbnail.MakeSquareImage(filename, filename.Replace(extension, "_square" + extension), 100);
                                PhotoInfo photoinfo = new PhotoInfo();
                                photoinfo.Filename      = "upload/" + attachs[i].Filename.Replace('\\', '/');
                                photoinfo.Attachment    = attachs[i].Attachment;
                                photoinfo.Filesize      = (int)attachs[i].Filesize;
                                photoinfo.Title         = attachs[i].Attachment.Remove(attachs[i].Attachment.IndexOf("."));
                                photoinfo.Description   = attachs[i].Description;
                                photoinfo.Albumid       = int.Parse(aid);
                                photoinfo.Userid        = userid;
                                photoinfo.Username      = username;
                                photoinfo.Views         = 0;
                                photoinfo.Commentstatus = 0;
                                photoinfo.Tagstatus     = 0;
                                photoinfo.Comments      = 0;
                                photoinfo.IsAttachment  = 1;
                                DbProvider.GetInstance().AddSpacePhoto(photoinfo);
                                AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(Convert.ToInt32(aid));
                                albumInfo.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(int.Parse(aid));
                                DbProvider.GetInstance().SaveSpaceAlbum(albumInfo);
                                currentphotisize += (int)attachs[i].Filesize;
                            }
                            else
                            {
                                return("相册空间不足,可能有图片未能加入相册");
                            }
                        }
                    }
                }
            }
            return("");
        }
Exemple #25
0
        private void AddImage(PhotoInfo[] pis)
        {
            int imax = LayoutRoot.Children.Count;
            int icnt = 0;
            if (imax > 50)
            {
                LayoutRoot.Children.RemoveAt(1);
                LayoutRoot.Children.RemoveAt(1);
                LayoutRoot.Children.RemoveAt(1);
            }
            foreach (UIElement el in LayoutRoot.Children)
            {
                if (el.GetType() == typeof(Image))
                {
                    icnt++;
                    Image elimg = (el as Image);
                    elimg.RenderTransform = new SkewTransform() { AngleX = 360 - (imax - icnt), AngleY = 360 - (imax - icnt) };
                    double dop = double.Parse(icnt.ToString()) / double.Parse(imax.ToString());
                    elimg.Opacity = dop;

                }
            }
            int ipcnt = 0;
            foreach (PhotoInfo photoInfo in pis)
            {
                if (photoInfo != null)
                {
                    Image img = new Image() { Source = photoInfo.ImageSource, Height = LayoutRoot.RowDefinitions[0].Height.Value - 150, Margin = new Thickness(30), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = ipcnt == 0 ? HorizontalAlignment.Left : ipcnt == 1 ? HorizontalAlignment.Center : ipcnt == 2 ? HorizontalAlignment.Right : HorizontalAlignment.Stretch, Stretch = Stretch.Uniform };
                    img.SetValue(Grid.RowProperty, 0);
                    LayoutRoot.Children.Add(img);
                    ipcnt++;
                }
            }
        }
Exemple #26
0
        private void AddImage(PhotoInfo photoInfo)
        {
            int imax = LayoutRoot.Children.Count;
            int icnt = 0;

            if (imax > 50)
            {
                LayoutRoot.Children.RemoveAt(1);
            }
            foreach (UIElement el in LayoutRoot.Children)
            {
                if (el.GetType() == typeof(Image))
                {
                    icnt++;
                    Image elimg = (el as Image);
                    elimg.RenderTransform = new SkewTransform()
                    {
                        AngleX = 360 - (imax - icnt), AngleY = 360 - (imax - icnt)
                    };
                    double dop = double.Parse(icnt.ToString()) / double.Parse(imax.ToString());
                    elimg.Opacity = dop;
                }
            }
            Image img = new Image()
            {
                Source = photoInfo.ImageSource, Height = LayoutRoot.RowDefinitions[0].Height.Value, Margin = new Thickness(30), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Stretch = Stretch.Uniform
            };

            img.SetValue(Grid.RowProperty, 0);
            LayoutRoot.Children.Add(img);
        }
Exemple #27
0
        private List <PhotoItemEntity> GetPhotosWithLoad(long[] ids)
        {
            List <PhotoItemEntity> photos = GetPhotos(ids);

            if (photos.Count != ids.Length)
            {
                List <long> needToLoadPhotos = ids.Where(x => photos.All(p => p.Id != x)).ToList();
                List <long> loadedPhotoIds   = new List <long>();

                foreach (long id in needToLoadPhotos)
                {
                    PhotoInfo photoInfo = webService.GetPhotoInfo(id);
                    DownLoadPhotoItem(photoInfo);
                    PhotoItemEntity photo = dataService.DataBaseContext.PhotoItemEntities.Find(id);

                    if (photo != null)
                    {
                        photos.Add(photo);
                        loadedPhotoIds.Add(photo.Id);
                    }
                }

                if (loadedPhotoIds.Any())
                {
                    webService.ConfirmUpdatePhotos(loadedPhotoIds);
                }
            }

            return(photos);
        }
Exemple #28
0
        public void PhotosGetInfoBasicTest()
        {
            PhotoInfo info = AuthInstance.PhotosGetInfo("4268023123");

            Assert.IsNotNull(info);

            Assert.AreEqual("4268023123", info.PhotoId);
            Assert.AreEqual("a4283bac01", info.Secret);
            Assert.AreEqual("2795", info.Server);
            Assert.AreEqual("3", info.Farm);
            Assert.AreEqual(UtilityMethods.UnixTimestampToDate("1263291891"), info.DateUploaded);
            Assert.AreEqual(false, info.IsFavorite);
            Assert.AreEqual(LicenseType.AttributionNoncommercialShareAlikeCC, info.License);
            Assert.AreEqual(0, info.Rotation);
            Assert.AreEqual("9d3d4bf24a", info.OriginalSecret);
            Assert.AreEqual("jpg", info.OriginalFormat);
            Assert.IsTrue(info.ViewCount > 87, "ViewCount should be greater than 87.");
            Assert.AreEqual(MediaType.Photos, info.Media);

            Assert.AreEqual("12. Sudoku", info.Title);
            Assert.AreEqual("It scares me sometimes how much some of my handwriting reminds me of Dad's " +
                            "- in this photo there is one 5 that especially reminds me of his handwriting.", info.Description);

            //Owner
            Assert.AreEqual("41888973@N00", info.OwnerUserId);

            //Dates
            Assert.AreEqual(new DateTime(2010, 01, 12, 11, 01, 20), info.DateTaken, "DateTaken is not set correctly.");

            //Editability
            Assert.IsTrue(info.CanComment, "CanComment should be true when authenticated.");
            Assert.IsTrue(info.CanAddMeta, "CanAddMeta should be true when authenticated.");

            //Permissions
            Assert.AreEqual(PermissionComment.Everybody, info.PermissionComment);
            Assert.AreEqual(PermissionAddMeta.Everybody, info.PermissionAddMeta);

            //Visibility

            // Notes

            Assert.AreEqual(1, info.Notes.Count, "Notes.Count should be one.");
            Assert.AreEqual("72157623069944527", info.Notes[0].NoteId);
            Assert.AreEqual("41888973@N00", info.Notes[0].AuthorId);
            Assert.AreEqual("Sam Judson", info.Notes[0].AuthorName);
            Assert.AreEqual(267, info.Notes[0].XPosition);
            Assert.AreEqual(238, info.Notes[0].YPosition);

            // Tags

            Assert.AreEqual(5, info.Tags.Count);
            Assert.AreEqual("78188-4268023123-586", info.Tags[0].TagId);
            Assert.AreEqual("green", info.Tags[0].Raw);

            // URLs

            Assert.AreEqual(1, info.Urls.Count);
            Assert.AreEqual("photopage", info.Urls[0].UrlType);
            Assert.AreEqual("https://www.flickr.com/photos/samjudson/4268023123/", info.Urls[0].Url);
        }
Exemple #29
0
        public void PhotoInfoParseFull()
        {
            const string xml = "<photo id=\"7519320006\">"
                               + "<location latitude=\"54.971831\" longitude=\"-1.612683\" accuracy=\"16\" context=\"0\" place_id=\"Ke8IzXlQV79yxA\" woeid=\"15532\">"
                               + "<neighbourhood place_id=\"Ke8IzXlQV79yxA\" woeid=\"15532\">Central</neighbourhood>"
                               + "<locality place_id=\"DW0IUrFTUrO0FQ\" woeid=\"20928\">Gateshead</locality>"
                               + "<county place_id=\"myqh27pQULzLWcg7Kg\" woeid=\"12602156\">Tyne and Wear</county>"
                               + "<region place_id=\"2eIY2QFTVr_DwWZNLg\" woeid=\"24554868\">England</region>"
                               + "<country place_id=\"cnffEpdTUb5v258BBA\" woeid=\"23424975\">United Kingdom</country>"
                               + "</location>"
                               + "</photo>";

            var sr = new System.IO.StringReader(xml);
            var xr = new System.Xml.XmlTextReader(sr);

            xr.Read();

            var info = new PhotoInfo();

            ((IFlickrParsable)info).Load(xr);

            Assert.AreEqual("7519320006", info.PhotoId);
            Assert.IsNotNull(info.Location);
            Assert.AreEqual((GeoAccuracy)16, info.Location.Accuracy);

            Assert.IsNotNull(info.Location.Country);
            Assert.AreEqual("cnffEpdTUb5v258BBA", info.Location.Country.PlaceId);
        }
Exemple #30
0
        private void OnExecuteCompleted(IAsyncResult result)
        {
            // Use the Dispatcher to ensure that the response is
            // marshaled back to the UI thread.
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    // Complete the query by assigning the returned
                    // entity, which materializes the new instance
                    // and attaches it to the context. We also need to assign the
                    // new entity in the collection to the returned instance.
                    PhotoInfo entity = _photos[_photos.Count - 1] =
                        _context.EndExecute <PhotoInfo>(result).FirstOrDefault();

                    // Report that that media resource URI is updated.
                    entity.ReportStreamUriUpdated();
                }
                catch (DataServiceQueryException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    // Raise the event by using the () operator.
                    if (SaveChangesCompleted != null)
                    {
                        SaveChangesCompleted(this, new AsyncCompletedEventArgs());
                    }
                }
            });
        }
Exemple #31
0
        private static PhotoInfo InsertPhoto(string filePath, int siteId, int channelId, int contentId)
        {
            var configInfo = Main.GetConfigInfo(siteId);
            var largeUrl   = Context.SiteApi.GetSiteUrlByFilePath(filePath);
            var smallUrl   = largeUrl;
            var middleUrl  = largeUrl;

            var srcImage = Image.FromFile(filePath);

            if (srcImage.Width > configInfo.PhotoSmallWidth)
            {
                smallUrl = Resize(siteId, filePath, srcImage, configInfo.PhotoSmallWidth);
            }
            if (srcImage.Width > configInfo.PhotoMiddleWidth)
            {
                middleUrl = Resize(siteId, filePath, srcImage, configInfo.PhotoMiddleWidth);
            }

            var repository = new PhotoRepository();

            var photoInfo = new PhotoInfo
            {
                SiteId    = siteId,
                ChannelId = channelId,
                ContentId = contentId,
                SmallUrl  = smallUrl,
                MiddleUrl = middleUrl,
                LargeUrl  = largeUrl
            };

            photoInfo.Id = repository.Insert(photoInfo);
            return(photoInfo);
        }
Exemple #32
0
 public PhotoInfo AddPhotoInfo(Photo photo, ImageInfo imageInfo)
 {
     Image sImg = Image.FromFile(imageInfo.LinkAccess);
     PhotoInfo photoInfo = new PhotoInfo()
     {
         Photo = photo,
         FileName = imageInfo.FileName,
         FileSize = imageInfo.FileSize,
         MimeType = imageInfo.MimeType,
         Extension = Path.GetExtension(imageInfo.FileName),
         Description = "",
         Width = sImg.Width,
         Height = sImg.Height
     };
     return photoInfoRepo.Create(photoInfo);
 }
Exemple #33
0
        private bool IsPhotoMatch(SyncFolder sf, PhotoInfo pi, ImageInfo ii, string name)
        {
            if (sf.SyncMethod == SyncFolder.Methods.SyncFilename && pi.Title == name)
            {
                return true;
            }

            if (sf.SyncMethod == SyncFolder.Methods.SyncDateTaken && pi.DateTaken == ii.GetDateTaken())
            {
                return true;
            }

            if (sf.SyncMethod == SyncFolder.Methods.SyncTitleOrFilename)
            {
                string title = ii.GetTitle();
                if (string.IsNullOrEmpty(title))
                {
                    title = name;
                }

                if (pi.Title == title)
                {
                    return true;
                }
            }

            return false;
        }
Exemple #34
0
 public CItem(XPathNavigator nav)
 {
     var farm = Byte.Parse(nav.GetAttribute("farm", ""));
     var server = UInt16.Parse(nav.GetAttribute("server", ""));
     var id = UInt32.Parse(nav.GetAttribute("id", ""));
     var secret = Int64.Parse(nav.GetAttribute("secret", ""), System.Globalization.NumberStyles.HexNumber);
     this.Photo = new PhotoInfo(farm, server, id, secret);
 }
Exemple #35
0
        private static void UpdateSourceField(Page page)
        {
            Match m;
            if ((m = picasaAlbumUrlRegex.Match(page.text)).Success ||
                (m = picasaUserUrlRegex.Match(page.text)).Success)
            {
                page.DownloadImage("temp_wiki_image");

                string userId = m.Groups[2].ToString();
                string chosenAlbumName = m.Groups.Count >= 3 ? m.Groups[3].ToString() : null;

                // A common existing error
                if (chosenAlbumName == "Eakins")
                {
                    chosenAlbumName = "EakinsThomas";
                }

                string userApiUrl = "http://picasaweb.google.com/data/feed/api/user/" + userId;
                string userApiPage = WgetToString(userApiUrl);
                if (userApiPage == null) return;

                Console.WriteLine("Searching for image URL. Retrieving info about candidate images...");
                List<string> photoIds = new List<string>();
                foreach (Match m2 in userPageAlbumIdRegex.Matches(userApiPage))
                {
                    string albumName = m2.Groups[2].ToString();
                    if (chosenAlbumName == null || albumName == chosenAlbumName)
                    {
                        string albumId = m2.Groups[1].ToString();
                        string albumApiUrl = "http://picasaweb.google.com/data/feed/api/user/" + userId + "/albumid/" + albumId;
                        string albumApiPage = WgetToString(albumApiUrl);

                        foreach (Match m3 in albumPageImageIdRegex.Matches(albumApiPage))
                        {
                            string photoId = m3.Groups[1].ToString();
                            string licenseName = null;
                            PhotoInfo info = new PhotoInfo();
                            info.albumId = albumId;
                            info.albumName = albumName;

                            photoIds.Add(photoId);
                            if (idToPhotoInfo.ContainsKey(photoId)) continue;
                            if (!GetImageInfo(userId, albumId, photoId, out licenseName, out info.mediaUrl, out info.summary))
                            {
                                photoIds.Remove(photoId);
                                continue;
                            }
                            idToPhotoInfo.Add(photoId, info);
                        }
                    }
                }

                // Sort by the longest common substring between the summary and filename
                photoIds.Sort(new Comparison<string>(delegate(string leftId, string rightId)
                    {
                        string titleNoPrefix = page.title.Substring("File:".Length);
                        return LongestCommonSubstring(idToPhotoInfo[rightId].summary, titleNoPrefix)
                              .CompareTo(LongestCommonSubstring(idToPhotoInfo[leftId].summary, titleNoPrefix));
                    }));

                Console.WriteLine("Doing image comparisons...");
                foreach (string photoId in photoIds)
                {
                    PhotoInfo info = idToPhotoInfo[photoId];
                    string photoCachedFilename = "photo" + photoId;

                    while (!File.Exists(photoCachedFilename) || new FileInfo(photoCachedFilename).Length == 0)
                    {
                        string mediaUrlFull = new Regex("^(.*)/([^/]*)$").Replace(info.mediaUrl, "${1}/d/${2}");
                        Console.WriteLine("Fetching photo with ID " + photoId + "...");
                        WgetToFile(mediaUrlFull, photoCachedFilename);
                    }

                    if (FilesAreIdentical(photoCachedFilename, "temp_wiki_image"))
                    {
                        UpdateSource(page, userId, info.albumName, photoId);
                        return;
                    }

                    string failureReason;
                    if (UploadOriginalVersion(out failureReason, page, info.mediaUrl, "temp_wiki_image", photoCachedFilename, /*fetchThumbnailVersion*/false, /*allowWikiBigger*/true))
                    {
                        UpdateSource(page, userId, info.albumName, photoId);
                        return;
                    }
                }

                Console.WriteLine("Image not found");
            }
            else
            {
                if (!page.text.Contains("waldemar"))
                {
                    // For debugging, catch ones where we couldn't figure out the Picasa URL
                    //Debugger.Break();
                }
            }
        }
Exemple #36
0
 public Set(string path)
 {
     Folder = new DirectoryInfo(path);
     Photos = new List<PhotoInfo>();
     if (System.IO.File.Exists(Path.Combine(path, "ignore")))
         return;
     foreach (FileInfo file in Folder.EnumerateFiles("*.jpg")) {
         PhotoInfo p = new PhotoInfo(file);
         Photos.Add(p);
     }
 }
Exemple #37
0
        private List<PhotoInfo> GetPhotos(SyncFolder sf)
        {
            var photosInSet = new List<PhotoInfo>();

            if (string.IsNullOrEmpty(sf.SetId))
            {
                return photosInSet;
            }

            int retryCount = 0;
            bool success = false;

            while (!success)
            {
                try
                {
                    photosInSet.Clear();

                    foreach (Photo p in FlickrSync.ri.SetPhotos(sf.SetId))
                    {
                        // workaround since media type and p.MachineTags is not working on FlickrNet 2.1.5
                        if (p.CleanTags != null)
                        {
                            if (p.CleanTags.IndexOf("flickrsync:type=video", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                p.CleanTags.IndexOf("flickrsync:cmd=skip", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                p.CleanTags.IndexOf("flickrsync:type:video", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                p.CleanTags.IndexOf("flickrsync:cmd:skip", StringComparison.OrdinalIgnoreCase) >= 0)
                                continue;
                        }

                        PhotoInfo pi = new PhotoInfo();
                        pi.Title = p.Title;
                        pi.DateTaken = p.DateTaken;
                        pi.DateSync = sf.LastSync;
                        pi.DateUploaded = p.DateUploaded;
                        pi.PhotoId = p.PhotoId;
                        pi.Found = false;
                        photosInSet.Add(pi);
                    }

                    success = true;
                }
                catch (Exception)
                {
                    if (retryCount++ <= 5)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(1));
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return photosInSet;
        }
Exemple #38
0
        private void AddImage(dynamic obj)
        {
            if (obj.link!=null)
            {
                PhotoInfo pi = new PhotoInfo(obj, true);
                if (pi.link.Length > 0)
                {
                    Image img = new Image { Name = pi.title, Width = ThumbnailSize.Width, Height = ThumbnailSize.Height, Margin = new Thickness(1), Stretch = System.Windows.Media.Stretch.Uniform };
                    img.Opacity = .01;
                    pi.DownloadProgressChanged += (a, b) =>
                    {
                        img.Opacity = b.ProgressPercentage * 1e-2;
                        if(RotateOnLoading)
                            img.RenderTransform = new RotateTransform() { Angle = b.ProgressPercentage * 3.6, CenterX = (img.Width / 2), CenterY = (img.Height / 2) };
                        System.GC.Collect();
                    };
                    pi.ImageSourceIsLoaded += (a, b) =>
                    {
                        img.Opacity = 1;
                        img.RenderTransform = null;
                        if (AutoGotoNextDate)
                        {
                            var list1 = ImageWrapPanel.Children.Cast<Image>().Where(x => x.Tag != null && x.Tag.GetType() == typeof(PhotoInfo));
                            if (list1.All(x => (x.Tag as PhotoInfo).ImageIsLoaded))
                                PlayPauseClick(Statuses.Playing);
                        }

                        System.GC.Collect();
                    };
                    pi.SmallImageSourceIsLoaded += (a, b) =>
                    {
                        img.Source = pi.SmallImageSource;
                        try
                        {
                            //ImageWrapPanel.Children.Add(img);
                            Random rnd = new Random(System.DateTime.Now.Millisecond);
                            double didx = double.Parse(ImageWrapPanel.Children.Count.ToString());
                            didx = Math.Round(didx / 2);
                            int idx = 0;
                            switch (ImagePlacements)
                            {
                                case ImagePlacements.Random:
                                    idx = rnd.Next(0, ImageWrapPanel.Children.Count); //int.Parse(didx.ToString());
                                    ImageWrapPanel.Children.Insert(idx, img);
                                    break;
                                case ImagePlacements.Split:
                                    idx = int.Parse(didx.ToString());
                                    ImageWrapPanel.Children.Insert(idx, img);
                                    break;
                                case ImagePlacements.ZeroToEnd:
                                    ImageWrapPanel.Children.Add(img);
                                    break;
                            
                            }
                                img.MouseLeftButtonDown += (a1, b1) =>
                                {
                                    WrapPanel spp = (WrapPanel)img.Parent;
                                    if (spp == null)
                                        return;
                                    int iThis = spp.Children.GetIndex(img);
                                    Image imgPrev = (iThis - 1) > 0 ? (Image)spp.Children.ElementAt<UIElement>(iThis - 1) : null;
                                    Image imgNext = (iThis + 1) < spp.Children.Count ? (Image)spp.Children.ElementAt<UIElement>(iThis + 1) : null;
                                    OnMouseDownImage(new MouseDownImageEventArgs()
                                    {
                                        image = img,
                                        photoinfo = pi,
                                        nextPhotoInfo = imgNext != null ? imgNext.Tag != null ? (PhotoInfo)imgNext.Tag : null : null,
                                        prevPhotoInfo = imgPrev != null ? imgPrev.Tag != null ? (PhotoInfo)imgPrev.Tag : null : null,
                                        point = b1.GetPosition(a1 as UIElement)
                                    });
                                };

                                img.MouseEnter += (a2, b2) =>
                                {
                                    WrapPanel spp = (WrapPanel)img.Parent;
                                    if (spp == null)
                                        return;
                                    int iThis = spp.Children.GetIndex(img);
                                    Image imgPrev = (iThis - 1) > 0 ? (Image)spp.Children.ElementAt<UIElement>(iThis - 1) : null;
                                    Image imgNext = (iThis + 1) < spp.Children.Count ? (Image)spp.Children.ElementAt<UIElement>(iThis + 1) : null;
                                    OnMouseEnterImage(new MouseEnterImageEventArgs()
                                    {
                                        image = img,
                                        photoinfo = pi,
                                        nextPhotoInfo = imgNext != null ? imgNext.Tag != null ? (PhotoInfo)imgNext.Tag : null : null,
                                        prevPhotoInfo = imgPrev != null ? imgPrev.Tag != null ? (PhotoInfo)imgPrev.Tag : null : null,
                                        point = b2.GetPosition(a2 as UIElement)
                                    });

                                };
                            }
                        
                        catch { }
                        ImageSource isi = pi.ImageSource;
                        
                    };
                    img.Tag = pi;

                    img.MouseLeave += (a, b) =>
                        {
                            OnMouseLeaveImage(new MouseLeaveImageEventArgs() { image = img, photoinfo = pi, point = b.GetPosition(a as UIElement) });                        
                        };

                    
                    
                    img.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(img_ImageFailed);
                }
            }
        }