Esempio n. 1
0
        public void PictureSelected(PictureItem pictureItem)
        {
            Album.SelectedPage    = ((pictureItem as TreeViewItem).Parent as PageItem).Model;
            Album.SelectedPicture = (pictureItem as PictureItem).Model;

            RefreshCommands();
        }
Esempio n. 2
0
        private static void GetFiles(string path, List <PictureItem> items)
        {
            if (!Directory.Exists(path))
            {
                return;
            }

            string[] files = Directory.GetFiles(path);
            if (files != null && files.Length > 0)
            {
                foreach (string file in files)
                {
                    FileInfo fi = new FileInfo(Path.Combine(path, file));
                    if (Array.IndexOf(PICFILE_EXTENSIONS, fi.Extension.ToLower()) > -1)
                    {
                        PictureItem item = new PictureItem()
                        {
                            FullName = fi.FullName
                        };
                        items.Add(item);
                    }
                }
            }

            string[] dirs = Directory.GetDirectories(path);
            if (dirs != null && dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    GetFiles(dir, items);
                }
            }
        }
Esempio n. 3
0
        public async Task <ActionResult> EditAsync(string id, string category)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            await this.galleryRepository.InitAsync("Pictures");

            Document document = await this.galleryRepository.GetDocumentAsync(id, category);

            //PictureItem item = await this.galleryRepository.GetItemAsync<PictureItem>(id, category);
            PictureItem item = Mapper.Map <PictureItem>(document);

            // You could use the followings as well

            /*
             * PictureItem itemWithNewtonSoft = JsonConvert.DeserializeObject<PictureItem>(document.ToString());
             * PictureItem itemWithDynamic = (dynamic)document;
             */

            if (item == null)
            {
                return(NotFound());
            }

            await FillCategoriesAsync(category);

            return(View(item));
        }
        private void SetItemInfo(PictureItem item, string id)
        {
            if (item == null && id.Length != m_idNum)
            {
                Debug.LogWarning("立绘图片获取失败,数据错误");
                return;
            }

            string roleID = id;

            item.Initialize(id);

            PrefabManager.Instance.LoadAssetsAsync <Sprite>(new List <string>()
            {
                roleID
            }, (RequestResult) =>
            {
                if (RequestResult.status == RequestStatus.FAIL)
                {
                    Debug.LogWarning("立绘图片获取失败,加载失败");
                    return;
                }
                item.SetBody(RequestResult.result as Sprite);
            }, null);
        }
    private void PictureRemoved(PictureCanvas canvas)
    {
        PictureItem item = pictures[canvas];

        pictures.Remove(canvas);
        item.gameObject.SetActive(false);
        Destroy(item.gameObject);
    }
    private void PictureAdded(PictureCanvas canvas)
    {
        PictureItem item = Instantiate(refPictureItemPrefab, contentHolder.transform).GetComponent <PictureItem>();

        pictures.Add(canvas, item);
        item.canvas = canvas;
        item.ChangeVisibilityButton();
        PictureNameUpdated(canvas);
    }
Esempio n. 7
0
            public override void BindData(RecycleItem item)
            {
                PictureItem target = item as PictureItem;
                PictureData data   = Data[target.DataIndex] as PictureData;

                target.Picture.ResourceUrl = data.FilePath;
                target.Picture.FittingMode = FittingModeType.Center;
                target.Number.Text         = (target.DataIndex + 1).ToString();
            }
        public override List <PictureItem> GetFiles()
        {
            if (!m_Initialized)
            {
                string msg = string.Empty;
                if (!Validate(ref msg))
                {
                    throw new Exception(msg);
                }
            }

            List <PictureItem> picItems = new List <PictureItem>();

            if (URLsinTxtFile)
            {
                StreamReader sr   = File.OpenText(m_PicSource);
                string       line = sr.ReadLine();

                string        msg   = string.Empty;
                List <string> files = new List <string>();
                string        fileTmp;
                while (line != null)
                {
                    line = line.Trim();
                    if (Validate(line, ref msg))
                    {
                        fileTmp = line.ToLower();
                        if (!files.Contains(fileTmp))
                        {
                            files.Add(fileTmp);
                            PictureItem item = new PictureItem()
                            {
                                FullName = line
                            };
                            picItems.Add(item);
                        }
                    }
                    line = sr.ReadLine();
                }
            }
            else
            {
                //for (int i = 0; i < m_PicSource.Count; i++)
                //{
                //    PictureItem picItem = new PictureItem()
                //    {
                //        FullName = string.Format("{0}{1}.{2}", m_HttpBase, m_StartId + i, m_ImageFileExtenstion)
                //    };
                //    picItems.Add(picItem);
                //}
            }

            return(picItems);
        }
Esempio n. 9
0
        public async Task <ActionResult> EditAsync(PictureItem item, [Bind("oldCategory")] string oldCategory, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                await this.galleryRepository.InitAsync("Pictures");

                Document document = null;

                if (item.Category == oldCategory)
                {
                    document = await this.galleryRepository.UpdateItemAsync(item.Id, item);

                    if (file != null)
                    {
                        var        attachLink = UriFactory.CreateAttachmentUri("Gallery", "Pictures", document.Id, "wallpaper");
                        Attachment attachment = await this.galleryRepository.ReadAttachmentAsync(attachLink.ToString(), item.Category);

                        var input = new byte[file.OpenReadStream().Length];
                        file.OpenReadStream().Read(input, 0, input.Length);
                        attachment.SetPropertyValue("file", input);
                        ResourceResponse <Attachment> createdAttachment = await this.galleryRepository.ReplaceAttachmentAsync(attachment, new RequestOptions()
                        {
                            PartitionKey = new PartitionKey(item.Category)
                        });
                    }
                }
                else
                {
                    await this.galleryRepository.DeleteItemAsync(item.Id, oldCategory);

                    document = await this.galleryRepository.CreateItemAsync(item);

                    if (file != null)
                    {
                        var attachment = new Attachment {
                            ContentType = file.ContentType, Id = "wallpaper", MediaLink = string.Empty
                        };
                        var input = new byte[file.OpenReadStream().Length];
                        file.OpenReadStream().Read(input, 0, input.Length);
                        attachment.SetPropertyValue("file", input);
                        ResourceResponse <Attachment> createdAttachment = await this.galleryRepository.CreateAttachmentAsync(document.AttachmentsLink, attachment, new RequestOptions()
                        {
                            PartitionKey = new PartitionKey(item.Category)
                        });
                    }
                }

                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
Esempio n. 10
0
        public ActionResult AjaxForm()
        {
            var pictureModel = new PictureItem();

            if (DoAction == ActionType.Edit)
            {
                pictureModel = _galleryPictureApi.GetPictureItem(ArrId.FirstOrDefault());
            }
            ViewBag.PictureCategoryID = _categoryApi.GetChildByParentId(false);
            ViewData.Model            = pictureModel;
            ViewBag.Action            = DoAction;
            ViewBag.ActionText        = ActionText;
            return(View());
        }
Esempio n. 11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter = @"Image Files(*.jpg;*.jpeg;*.icon;*.ico;*.gif;*.png)|*.jpg;*.gpeg;*.icon;*.ico;*.gif;*.png";
            openFileDialog.Title  = @"请选择32x32大小的图像文件";
            var iSuccess = 0;

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // 设置鼠标繁忙状态,并保留原先的状态
            var holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            foreach (var selectedName in openFileDialog.FileNames)
            {
                string fileName = FileHelper.GetName(selectedName);
                var    fs       = new FileStream(selectedName, FileMode.Open, FileAccess.Read);
                var    buffByte = new byte[fs.Length];
                fs.Read(buffByte, 0, (int)fs.Length);
                fs.Close();
                fs = null;
                var statusCode    = string.Empty;
                var statusMessage = string.Empty;
                RDIFrameworkService.Instance.FileService.Add(this.UserInfo, this.FolderId, fileName, buffByte, string.Empty, this.FolderName, true, out statusCode, out statusMessage);
                if (statusCode == StatusCode.OKAdd.ToString())
                {
                    iSuccess++;
                    //将图像读入到字节数组
                    var pictureItem = new PictureItem {
                        Pic = new Bitmap(selectedName), Text = fileName
                    };
                    ucImageList.AddPictureItem(pictureItem);
                    ucImageList.Draw();
                    this.Changed = true;
                }
                else
                {
                    MessageBoxHelper.ShowWarningMsg(statusMessage);
                }
            }
            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;

            if (SystemInfo.ShowInformation)
            {
                MessageBoxHelper.ShowSuccessMsg("成功增加" + iSuccess.ToString(CultureInfo.InvariantCulture) + "条图标文件。");
            }
        }
Esempio n. 12
0
        public ActionResult EditForm(int? id)
        {
            var obj = new PictureItem();

            var listPictureType = pictureTypeRepository.GetListForTree<object>();

            if (id.HasValue)
                obj = pictureRepository.GetItemById<PictureItem>(id.Value);

            return Json(new
            {
                data = obj,
                listType = listPictureType
            }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult AjaxForm()
        {
            var model = new PictureItem();

            if (DoAction == ActionType.Edit)
            {
                model = _da.GetPictureItem(ArrId.FirstOrDefault());
            }
            ViewBag.PictureCategoryID = _categoryDa.GetChildByParentId(false);


            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View(model));
        }
Esempio n. 14
0
    public void OnClickItemPicked(PictureItem picItem)
    {
        FileSystemInfo fInfo = picItem.info;

        if (fInfo is DirectoryInfo)
        {
            DrawPictureList((DirectoryInfo)fInfo);
        }
        else
        {
            //LoadImageFile(fInfo.FullName, popupImage, 280, 280);
            LoadBitmapFile(fInfo.FullName, popupImage, 280, 280);
            popup.SetActive(true);
        }
    }
Esempio n. 15
0
        public ActionResult EditForm(int?id)
        {
            var obj = new PictureItem();

            var listPictureType = pictureTypeRepository.GetListForTree <object>();

            if (id.HasValue)
            {
                obj = pictureRepository.GetItemById <PictureItem>(id.Value);
            }

            return(Json(new
            {
                data = obj,
                listType = listPictureType
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 16
0
    public void CreatePictureItem(FileSystemInfo fInfo)
    {
        if (fInfo is FileInfo)
        {
            string ext = fInfo.Extension.ToLower();
            if (System.Array.IndexOf(extFilters, ext) == -1)
            {
                return;
            }
        }

        GameObject go = Instantiate <GameObject>(itemPrefab);
        Transform  tf = go.transform;

        tf.SetParent(grid);
        tf.localScale = Vector3.one;
        PictureItem script = go.GetComponent <PictureItem>();

        script.manager = this;
        script.info    = fInfo;
        string fname = fInfo.Name;

        if (fInfo is FileInfo)
        {
            //LoadImageFile(fInfo.FullName, script.image, maxWidth, maxHeight, true);
            LoadBitmapFile(fInfo.FullName, script.image, maxWidth, maxHeight, true);
            string str = Path.GetFileNameWithoutExtension(fname);
            if (str.Length > 9)
            {
                fname = str.Substring(0, 8) + ".." + fInfo.Extension;
            }
        }
        else
        {
            if (fInfo.FullName.Equals(nowDir.Parent.FullName))
            {
                fname = "..";
            }
            else if (fname.Length > 13)
            {
                fname = fname.Substring(0, 12) + "...";
            }
            fname = "[" + fname + "]";
        }
        script.label.text = fname;
    }
Esempio n. 17
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            var picItem = new PictureItem();

            picItem = ucImageList.GetCurrentPictureItem();
            if (!picItem.Pic.Equals(null))
            {
                ucImageView.AddImage(picItem.Pic);
                this.SelectedBitMap = picItem.Pic;
                this.SelectedFileId = ((PictureItem)ucImageList.data[ucImageList.CurrentImg]).tag.ToString();
                this.DialogResult   = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBoxHelper.ShowWarningMsg("没有选择任何图标文件!");
            }
        }
Esempio n. 18
0
    public MultiDepthPictureMove(PosAndDir [] datas, DepthInfo [] infos, Canvas canvas)
    {
        //触摸点最大为十个
        List <Vector3> clicks = new List <Vector3>();

        _canvas = canvas.transform;
        for (int i = 0; i < 10; i++)
        {
            clicks.Add(Vector3.one * 100000);
        }


        items = new List <PictureItem>();

        _datas = new List <PosAndDir>(datas);

        _depthInfos = infos;

        GameObject item = Resources.Load <GameObject>("Prefabs/PictureItem");

        Shader shader = Shader.Find("Unlit/MultiDepthCPU");

        Material mat = new Material(shader);

        foreach (PosAndDir data in datas)
        {
            if (data.moveTarget.y >= 1000)
            {
                continue;
            }


            GameObject go = Object.Instantiate(item);

            Material newMat = Object.Instantiate(mat);

            PictureItem pitm = go.GetComponent <PictureItem>();

            pitm.SetData(data, _depthInfos, _canvas.transform, newMat);
            pitm.name = data.picIndex.ToString();
            items.Add(pitm);
        }
    }
        /// <summary>
        /// копирование картинки в папку вопроса
        /// </summary>
        /// <param name="_to">выходная папка</param>
        /// <param name="pi">экземпляр изображения</param>
        private void CopyPic(string _to, PictureItem pi)
        {
            if (pi == null)
            {
                throw new ArgumentNullException("Отсутствует изображение вопроса " + item.identifier);
            }
            try
            {
                string picOrigPath = System.IO.Path.Combine(OriginFullTestPath, pi.fileName);
                string picName     = System.IO.Path.GetFileName(pi.fileName);
                string picNewPath  = System.IO.Path.Combine(_to, picName);

                System.IO.File.Copy(picOrigPath, picNewPath, true);
            }
            catch (Exception ex)
            {
                throw new Exception("Ошибка при копировании файлов вопроса " + this.Id + ". " + ex.Message);
            }
        }
Esempio n. 20
0
        private void ucImageList_MouseDoubleClick(object sender, EventArgs e)
        {
            if (ucImageList.CurrentImg < 0)
            {
                return;
            }
            var picItem = new PictureItem();

            picItem = ucImageList.GetCurrentPictureItem();
            if (!picItem.Pic.Equals(null))
            {
                ucImageView.AddImage(picItem.Pic);
                this.SelectedBitMap = picItem.Pic;
                this.SelectedFileId = ((PictureItem)ucImageList.data[ucImageList.CurrentImg]).tag.ToString();
            }
            else
            {
                MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.MSGC023);
            }
        }
Esempio n. 21
0
    void CreateImage()
    {
        //图片/xx/xx /xx.jpg
        Sprite sprite = ReadDataUtil.ReadPicture(picPath);

        go = Instantiate(Resources.Load <GameObject>("productPic"));
        go.transform.SetParent(parent);
        go.transform.localScale    = Vector3.one;
        go.transform.localPosition = Vector3.zero;
        //给图片预设物传值
        productPicTransform = go.transform.GetChild(0);
        productPicTransform = go.transform.GetChild(0);
        productPicTransform.GetComponent <Image>().sprite            = sprite;
        productPicTransform.GetComponent <RectTransform>().sizeDelta = picSize;
        productPicTransform.GetComponent <BoxCollider>().size        = new Vector3(picSize.x, picSize.y, 10);
        //让图片能够点击
        PictureItem pictureItem = productPicTransform.gameObject.AddComponent <PictureItem>();

        //图片隐藏时 恢复自己的碰撞
        pictureItem.unityAction = ResetCollider;
    }
Esempio n. 22
0
        public async Task <IViewComponentResult> InvokeAsync(PictureItem item)
        {
            await this.galleryRepository.InitAsync("Pictures");

            string   image    = string.Empty;
            Document document = await this.galleryRepository.GetDocumentAsync(item.Id, item.Category);

            var        attachLink = UriFactory.CreateAttachmentUri("Gallery", "Pictures", document.Id, "wallpaper");
            Attachment attachment = await this.galleryRepository.ReadAttachmentAsync(attachLink.ToString(), item.Category);

            var file = attachment.GetPropertyValue <byte[]>("file");

            if (file != null)
            {
                string bytes = Convert.ToBase64String(file);
                image = string.Format("data:{0};base64,{1}", attachment.ContentType, bytes);
            }

            return(View(new ImageVM()
            {
                Id = "img-" + item.Id, Src = image
            }));
        }
Esempio n. 23
0
        public async Task <ActionResult> CreateAsync([Bind("Id,Title,Category")] PictureItem item, IFormFile file)
        {
            if (ModelState.IsValid & file != null)
            {
                await this.galleryRepository.InitAsync("Pictures");

                RequestOptions options = new RequestOptions {
                    PreTriggerInclude = new List <string> {
                        "createDate"
                    }
                };

                Document document = await this.galleryRepository.CreateItemAsync <PictureItem>(item, options);

                if (file != null)
                {
                    var attachment = new Attachment {
                        ContentType = file.ContentType, Id = "wallpaper", MediaLink = string.Empty
                    };
                    var input = new byte[file.OpenReadStream().Length];
                    file.OpenReadStream().Read(input, 0, input.Length);
                    attachment.SetPropertyValue("file", input);
                    ResourceResponse <Attachment> createdAttachment = await this.galleryRepository.CreateAttachmentAsync(document.AttachmentsLink, attachment, new RequestOptions()
                    {
                        PartitionKey = new PartitionKey(item.Category)
                    });
                }

                return(RedirectToAction("Index"));
            }

            await FillCategoriesAsync();

            ViewBag.FileRequired = true;
            return(View());
        }
Esempio n. 24
0
 public void ReleasePictureItem(PictureItem item)
 {
     item.Release();
     m_pictureItems.Enqueue(item);
 }
Esempio n. 25
0
 private void PictureItem(PictureItem item)
 {
 }
Esempio n. 26
0
        public ActionResult AjaxFormPictureSubmit()
        {
            var date         = DateTime.Now;
            var msg          = new JsonMessage(true, "Không có hình ảnh nào được thêm mới");
            var folder       = date.Year + "\\" + date.Month + "\\" + date.Day + "\\";
            var fileinsert   = date.Year + "/" + date.Month + "/" + date.Day + "/";
            var folderinsert = fileinsert;

            var urlFolder = ConfigData.TempFolder;
            var lstFile   = Request["lstFile"];
            var lstP      = JsonConvert.DeserializeObject <List <FileUploadItem> >(lstFile);

            try
            {
                foreach (var item in lstP)
                {
                    var fileName    = item.Url;
                    var imageSource = Image.FromFile(urlFolder + fileName);
                    var checkfolder = false;
                    if (Request["ckImage_" + (int)FolderImage.Originals] != null)
                    {
                        checkfolder = true;
                        ImageProcess.CreateForder(ConfigData.OriginalFolder); // tạo forder Năm / Tháng / Ngày
                        if (imageSource.Width > ConfigData.ImageFullHdFile.Width)
                        {
                            var image = ImageProcess.ResizeImage(imageSource, ConfigData.ImageFullHdFile);
                            ImageProcess.SaveJpeg(ConfigData.OriginalFolder + folder + fileName, new Bitmap(image), 92L); // Save file Original
                        }
                        else
                        {
                            System.IO.File.Copy(urlFolder + fileName, ConfigData.OriginalFolder + folder + fileName);
                        }
                        folderinsert = "Originals/" + fileinsert;
                    }

                    if (Request["ckImage_" + (int)FolderImage.Images] != null)
                    {
                        checkfolder = true;
                        ImageProcess.CreateForder(ConfigData.ImageFolder); // tạo forder Năm / Tháng / Ngày
                        if (imageSource.Width > ConfigData.ImageHdFile.Width)
                        {
                            var image = ImageProcess.ResizeImage(imageSource, ConfigData.ImageHdFile);
                            ImageProcess.SaveJpeg(ConfigData.ImageFolder + folder + fileName, new Bitmap(image), 92L); // Save file Images
                        }
                        else
                        {
                            System.IO.File.Copy(ConfigData.ImageFolder + fileName, ConfigData.ImageFolder + folder + fileName);
                        }
                        folderinsert = "Images/" + fileinsert;
                    }

                    //Resize ảnh 640
                    if (Request["ckImage_" + (int)FolderImage.Mediums] != null)
                    {
                        checkfolder = true;
                        ImageProcess.CreateForder(ConfigData.ImageUploadMediumFolder); // tạo forder Năm / Tháng / Ngày
                        if (imageSource.Width > ConfigData.ImageMediumFile.Width)
                        {
                            var image = ImageProcess.ResizeImage(imageSource, ConfigData.ImageFullHdFile);
                            ImageProcess.SaveJpeg(ConfigData.ImageUploadMediumFolder + folder + fileName, new Bitmap(image), 92L); // Save file Medium
                        }
                        else
                        {
                            System.IO.File.Copy(urlFolder + fileName, ConfigData.ImageUploadMediumFolder + folder + fileName);
                        }
                        folderinsert = "Mediums/" + fileinsert;
                    }

                    if (!checkfolder)
                    {
                        folderinsert = "Thumbs/" + fileinsert;
                    }

                    if (Request["ckImage_" + (int)FolderImage.Thumbs] != null)
                    {
                        ImageProcess.CreateForder(ConfigData.ThumbsFolder);
                    }

                    if (imageSource.Width < ConfigData.ImageThumbsSize.Width)
                    {
                        ImageProcess.SaveJpeg(ConfigData.ThumbsFolder + folder + fileName, new Bitmap(imageSource), 92L); // Save file Thumbs
                    }
                    else
                    {
                        imageSource = ImageProcess.ResizeImage(imageSource, ConfigData.ImageThumbsSize);
                        ImageProcess.SaveJpeg(ConfigData.ThumbsFolder + folder + fileName, new Bitmap(imageSource), 92L); // Save file Thumbs
                    }
                    imageSource.Dispose();
                    //Lấy thông tin cần thiết
                    var picture = new PictureItem
                    {
                        Type       = !string.IsNullOrEmpty(Request["type"]) ? Convert.ToInt32(Request["type"]) : 0,
                        CategoryID =
                            !string.IsNullOrEmpty(Request["CategoryID"]) ? Convert.ToInt32(Request["CategoryID"]) : 1,
                        AgencyId    = UserItem.AgencyID,
                        Folder      = folderinsert,
                        Name        = item.Name,
                        DateCreated = date.TotalSeconds(),
                        IsShow      = true,
                        Url         = fileName,
                        IsDeleted   = false
                    };
                    var json = new JavaScriptSerializer().Serialize(picture);
                    msg = _galleryPictureApi.Add(json);
                }
                try
                {
                    var di = new DirectoryInfo(urlFolder);
                    foreach (var file in di.GetFiles())
                    {
                        file.Delete();
                    }
                    foreach (var dir in di.GetDirectories())
                    {
                        dir.Delete(true);
                    }
                }
                catch { }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Thêm mới hình ảnh thất bại.";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Esempio n. 27
0
    protected void on_search_text_results(List<Tuple<string[], File>> search_results, string search_text)
    {
        if (!search_result_valid)
            return;

        System.Console.WriteLine("got search text results {0}", search_results.Count);

        List<Nemo.Item> items = new List<Nemo.Item>();

        //		int height_left = calendar_event_box.Allocation.Height;

        foreach (Tuple<string[], File> result in search_results)
        {
            Nemo.Item item;

            System.Console.WriteLine("type {0}", result.first[0]);

            if (DocumentItem.is_document(result.first[0]))
                item = new DocumentItem(result.second, result.first, search_input.Text);
            else if (PictureItem.is_image(result.first[0]))
                item = new PictureItem(result.second, result.first);
            else
            {
                item = new Nemo.Item(result.second);
                item.mime_type = result.first[0];
            }

            item.search_func = do_search;

            items.Add(item);
        }

        //		System.Console.WriteLine("{0} - {1} - {2} - {3}", root_x, root_y, search_input.Allocation.Width, search_input.Allocation.Height);

        SearchPopup popup = new SearchPopup(calendar_driver.update_view_set_next);
        popup.get_size = delegate { return calendar_event_box.Allocation.Height; };
        popup.calculate_start_position = delegate {
            int root_x = 0, root_y = 0;
            calendar_event_box.GdkWindow.GetOrigin(out root_x, out root_y);

            int tmp = 0; // throw away
            search_input.GdkWindow.GetOrigin(out root_x, out tmp);

            return new Nemo.Tuple<int, int>(root_x + search_input.Allocation.Width, root_y + calendar_event_box.Allocation.Height);
        };

        popup.set_files_and_show(items, search_text);

        Singleton<OverlayTracker>.Instance.add_overlay_and_show(popup);
    }
Esempio n. 28
0
 public async Task <IViewComponentResult> InvokeAsync(PictureItem item)
 {
     return(View(item));
 }
Esempio n. 29
0
        public static void FiltPicture(Statuses statues, ItemViewModel model)
        {
            try
            {
                if (statues.attachments != null && statues.attachments.Count > 0)
                {
                    foreach (Statuses.Attachment attach in statues.attachments)
                    {
                        if (attach.media != null && attach.media.Count > 0)
                        {
                            foreach (Statuses.Attachment.Media media in attach.media)
                            {
                                if (media.type == "image")
                                {
                                    model.ImageURL = media.src;
                                    model.MidImageURL = GenerateDoubanSrc(model.ImageURL, "median");
                                    model.FullImageURL = GenerateDoubanSrc(model.ImageURL, "raw");

                                    PictureItem picItem = new PictureItem();
                                    picItem.Url = model.MidImageURL;
                                    picItem.FullUrl = model.FullImageURL;
                                    picItem.Id = model.ID;
                                    picItem.Type = model.Type;
                                    picItem.Title = model.Title;
                                    picItem.Content = model.Content;
                                    picItem.TimeObject = model.TimeObject;
                                    App.ViewModel.DoubanPicItems.Add(picItem);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {

            }
        }
        /// <summary>
        /// копирование картинки в папку вопроса
        /// </summary>
        /// <param name="_to">выходная папка</param>
        /// <param name="pi">экземпляр изображения</param>
        private void CopyPic(string _to, PictureItem pi)
        {
            if(pi==null)
                throw new ArgumentNullException("Отсутствует изображение вопроса "+item.identifier);
            try
            {
                string picOrigPath = System.IO.Path.Combine(OriginFullTestPath, pi.fileName);
                string picName = System.IO.Path.GetFileName(pi.fileName);
                string picNewPath = System.IO.Path.Combine(_to, picName);

                System.IO.File.Copy(picOrigPath, picNewPath, true);
            }
            catch(Exception ex)
            {
                throw new Exception("Ошибка при копировании файлов вопроса " + this.Id + ". " + ex.Message);
            }
        }
Esempio n. 31
0
        public static ItemViewModel ConvertSharePhoto(RenrenNews news)
        {
            if (news == null || news.attachment == null)
            {
                return null;
            }

            ItemViewModel model = new ItemViewModel();
            model.IconURL = news.headurl;
            model.LargeIconURL = PreferenceHelper.GetPreference("Renren_FollowerAvatar2");
            model.Title = news.name;
            model.Content = news.message;
            model.TimeObject = ExtHelpers.GetRenrenTimeFullObject(news.update_time);
            model.Type = EntryType.Renren;
            model.ID = news.source_id;
            model.OwnerID = news.actor_id;
            model.RenrenFeedType = RenrenNews.FeedTypeSharePhoto;
            model.CommentCount = news.comments.count;
            model.SharedCount = "";
            foreach (RenrenNews.Attachment attach in news.attachment)
            {
                // 分享图片上传
                if (attach.media_type == RenrenNews.Attachment.AttachTypePhoto)
                {
                    model.ForwardItem = new ItemViewModel();
                    ItemViewModel forwardItem = model.ForwardItem;
                    forwardItem.Title = attach.owner_name;
                    forwardItem.Content = MiscTool.RemoveHtmlTag(news.description);

                    forwardItem.ImageURL = MiscTool.MakeFriendlyImageURL(attach.src);
                    forwardItem.MidImageURL = MiscTool.MakeFriendlyImageURL(attach.raw_src);
                    forwardItem.FullImageURL = MiscTool.MakeFriendlyImageURL(attach.raw_src);

                    // 创建图片项
                    PictureItem picItem = new PictureItem();
                    picItem.Url = MiscTool.MakeFriendlyImageURL(attach.raw_src);
                    picItem.FullUrl = MiscTool.MakeFriendlyImageURL(attach.raw_src);
                    picItem.Id = attach.media_id;
                    picItem.Type = EntryType.Renren;
                    picItem.Title = news.name;
                    picItem.Content = MiscTool.RemoveHtmlTag(news.message);
                    picItem.TimeObject = ExtHelpers.GetRenrenTimeFullObject(news.update_time);

                    // 之所以这里还要检测,是因为有gif图的情况需要过滤掉
                    if (!string.IsNullOrEmpty(picItem.Url))
                    {
                        App.ViewModel.RenrenPicItems.Add(picItem);
                    }
                    break;
                }
            }
            return model;
        }
        private static async Task InitGalleryAsync(IConfiguration configuration)
        {
            // Init Pictures
            GalleryDBRepository galleryRepository = new GalleryDBRepository(configuration);

            await galleryRepository.InitAsync("Pictures");

            var pictures = await galleryRepository.GetItemsAsync <PictureItem>();

            if (pictures.Count() == 0)
            {
                foreach (var directory in Directory.GetDirectories(Path.Combine(Config.ContentRootPath, @"wwwroot\images\gallery")))
                {
                    foreach (var filePath in Directory.GetFiles(directory))
                    {
                        string category = Path.GetFileName(Path.GetDirectoryName(filePath));
                        string title    = Path.GetFileNameWithoutExtension(filePath);
                        string fileName = Path.GetFileName(filePath);
                        string contentType;

                        PictureItem item = new PictureItem()
                        {
                            Category = category,
                            Title    = title
                        };

                        RequestOptions options = new RequestOptions {
                            PreTriggerInclude = new List <string> {
                                "createDate"
                            }
                        };
                        Document document = await galleryRepository.CreateItemAsync(item, options);

                        new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider().TryGetContentType(fileName, out contentType);
                        var attachment = new Attachment {
                            ContentType = contentType, Id = "wallpaper", MediaLink = string.Empty
                        };
                        var input = new byte[File.OpenRead(filePath).Length];
                        File.OpenRead(filePath).Read(input, 0, input.Length);
                        attachment.SetPropertyValue("file", input);
                        ResourceResponse <Attachment> createdAttachment = await galleryRepository.CreateAttachmentAsync(document.AttachmentsLink, attachment, new RequestOptions()
                        {
                            PartitionKey = new PartitionKey(item.Category)
                        });
                    }
                }
            }

            // Init Categories

            await galleryRepository.InitAsync("Categories");

            var Categories = new List <string>()
            {
                "3D & Abstract", "Animals & Birds", "Anime", "Beach", "Bikes", "Cars", "Celebrations", "Celebrities", "Christmas", "Creative Graphics", "Cute", "Digital Universe", "Dreamy & Fantasy", "Flowers", "Games", "Inspirational", "Love", "Military",
                "Music", "Movies", "Nature", "Others", "Photography", "Sports", "Technology", "Travel & World", "Vector & Designs"
            };

            var categories = await galleryRepository.GetItemsAsync <CategoryItem>();

            if (categories.Count() == 0)
            {
                foreach (var category in Categories)
                {
                    CategoryItem item = new CategoryItem()
                    {
                        Title = category
                    };

                    Document document = await galleryRepository.CreateItemAsync(item);
                }
            }
        }
Esempio n. 33
0
        private void GetFiles(string folder, List <PictureItem> picItems, bool includeChildFolder)
        {
            Console.WriteLine(DateTime.Now.ToString("HH:mm:ss,fff") + "GetFiles:" + folder);
            string cd = folder.Trim('/');

            if (cd == "")
            {
                cd = "/";
            }
            else
            {
                cd = "/" + cd;
            }
            //m_FTPFileService.SetCurrentDirectory(cd);
            var ftplist = m_FTPFileService.GetFilesDetailList(folder).Where(it => it.IsDir == false).ToList().ConvertAll <string>(it => it.Name);

            if (ftplist != null && ftplist.Count > 0)
            {
                PictureItem picItem;
                string      fileExt;

                foreach (var item in ftplist)
                {
                    fileExt = Path.GetExtension(item);
                    if (Array.IndexOf(DataModel.Constant.PICFILE_EXTENSIONS, fileExt.ToLower()) > -1)
                    {
                        picItem = new PictureItem()
                        {
                        };
                        if (!string.IsNullOrEmpty(m_ftpUser) && !string.IsNullOrEmpty(m_ftpPass))
                        {
                            picItem.FullName = string.Format("ftp://{0}:{1}@{2}:{3}{4}", m_ftpUser, m_ftpPass,
                                                             m_ftpIP,
                                                             m_ftpPort,
                                                             string.IsNullOrEmpty(cd) ? "/" + item : string.Format("{0}/{1}", cd, item));
                        }
                        else
                        {
                            picItem.FullName = string.Format("ftp://{0}:{1}{2}",
                                                             m_ftpIP,
                                                             m_ftpPort,
                                                             string.IsNullOrEmpty(cd) ? "/" + item : string.Format("{0}/{1}", cd, item));
                        }
                        picItems.Add(picItem);
                    }
                }
            }


            if (includeChildFolder)
            {
                var dirs = m_FTPFileService.GetDirectoryList(folder);
                if (dirs != null && dirs.Count > 0)
                {
                    string tmp;
                    foreach (var dir in dirs)
                    {
                        tmp = string.Format("{0}/{1}", folder, dir);
                        GetFiles(tmp, picItems, includeChildFolder);
                    }
                }
            }
        }