コード例 #1
0
 private void EditImageInformationsButton_Click(object sender, RoutedEventArgs e)
 {
     CurrentGalleryCard.ImageTitle.Text = CurrentImageTitle.Text;
     ImageViewTitle.Text = CurrentImageTitle.Text;
     if (CurrentGalleryCard.Image.protectionLevel != "private")
     {
         if (CurrentImagePassword.Text == "")
         {
             CurrentGalleryCard.Image.password        = null;
             CurrentGalleryCard.Image.protectionLevel = "public";
         }
         else
         {
             ServerService.instance.Socket.Emit("imageProtectionLevelChanged", CurrentGalleryCard.Image.id);
             CurrentGalleryCard.Image.password        = CurrentImagePassword.Text;
             CurrentGalleryCard.Image.protectionLevel = "protected";
         }
         CurrentGalleryCard.ConfigIcon();
     }
     ImageDao.Put(CurrentGalleryCard.Image);
 }
コード例 #2
0
ファイル: ImageFacade.cs プロジェクト: dhq-boiler/Sunctum
        public static ImageViewModel FindBy(Guid id, DataOperationUnit dataOpUnit = null, int challengeMaxCount = 3)
        {
            List <Exception> trying = new List <Exception>();

            while (trying.Count() < challengeMaxCount)
            {
                try
                {
                    ImageDao dao = new ImageDao();
                    return(dao.FindBy(new Dictionary <string, object>()
                    {
                        { "ID", id }
                    }, dataOpUnit?.CurrentConnection).SingleOrDefault().ToViewModel());
                }
                catch (SQLiteException e)
                {
                    trying.Add(e);
                    Thread.Sleep(500);
                    continue;
                }
            }
            throw new QueryFailedException($"設定回数({challengeMaxCount})の問い合わせに失敗しました.", trying);
        }
コード例 #3
0
ファイル: SyncCore.cs プロジェクト: ciker/WPYoudaonNote
        /// <summary>
        /// Download and save image to local.
        /// </summary>
        /// <param name="belongedNotePath">The path of belonged note.</param>
        /// <param name="imgNode">The image HtmlNode object.</param>
        /// <param name="imgRemoteUrl">The remote url of the image.</param>
        /// <param name="imgNameWithoutExt">The image name without extension.</param>
        /// <returns></returns>
        private string downloadAndSaveImageToLocal(string belongedNotePath, HtmlNode imgNode, string imgRemoteUrl, string imgNameWithoutExt)
        {
            Debug.WriteLine("Thread Id: " + Thread.CurrentThread.ManagedThreadId + " downloadAndSaveImageToLocal: " + imgRemoteUrl);
            var res = _api.DownloadAttach(imgRemoteUrl);

            var imgType   = ImageUtil.GetImageType(res.Buffer);
            var localPath = "Images\\" + imgNameWithoutExt + "." + imgType;

            double width;

            if (imgNode.Attributes.Contains("width"))
            {
                if (Double.TryParse(imgNode.Attributes["width"].Value, out width))
                {
                    if (width > _screenWidth)
                    {
                        width = _screenWidth - 25;
                    }
                }
                imgNode.Attributes["width"].Value = width.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                var actualSize = ImageUtil.GetImageSize(imgType, res.Buffer);
                width = actualSize.Width > _screenWidth ? _screenWidth - 25 : actualSize.Width;
                imgNode.Attributes.Add("width", width.ToString(CultureInfo.InvariantCulture));
            }
            // Save to disk.
            var savePath = IsoStoreUtil.SaveToIsoStore(localPath, res.Buffer);
            // Save to db.
            var imageEntity = new ImageEntity(imgNameWithoutExt, imgType.ToString(), savePath, imgRemoteUrl, belongedNotePath);

            ImageDao.InsertIfNotExist(imageEntity);

            return(savePath);
        }
コード例 #4
0
ファイル: ImageFacade.cs プロジェクト: dhq-boiler/Sunctum
        public static IEnumerable <ImageViewModel> FindAll(DataOperationUnit dataOpUnit = null)
        {
            ImageDao dao = new ImageDao();

            return(dao.FindAll(dataOpUnit?.CurrentConnection).ToViewModel());
        }
コード例 #5
0
ファイル: ImageFacade.cs プロジェクト: dhq-boiler/Sunctum
        public static long SumTotalFileSize()
        {
            var imageDao = new ImageDao();

            return(imageDao.SumTotalFileSize());
        }
コード例 #6
0
ファイル: ImageFacade.cs プロジェクト: dhq-boiler/Sunctum
        public static void Update(ImageViewModel image)
        {
            ImageDao dao = new ImageDao();

            dao.Update(image.ToEntity());
        }