Exemple #1
0
        public async Task OnGetAsync()
        {
            MediaTagsClient mtc = new MediaTagsClient();

            if (!string.IsNullOrEmpty(SearchString))
            {
                var tagsResult = await mtc.QueryTagsAsync(SearchString);

                HashSet <int> mediaIds = new HashSet <int>(tagsResult);

                foreach (int mediaId in mediaIds)
                {
                    var m = await mtc.GetMediaAsync(mediaId);

                    IList <TagDTO> Tags = new List <TagDTO>();
                    MediaDTO       md   = new MediaDTO();
                    md.Id            = m.Id;
                    md.Creation_Date = m.Creation_Date;
                    md.Description   = m.Description;
                    md.Path          = m.Path;
                    Media.Add(md);
                }
                resultNumber = Media.Count;
            }
        }
Exemple #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            filePaths.Clear();
            imageList           = new ImageList();
            imageList.ImageSize = new Size(64, 64);
            listViewFile.Items.Clear();
            string          toSearch = textBox1.Text.ToLower();
            MediaTagsClient c        = new MediaTagsClient();

            if (checkBox1.Checked)
            {
                var mediaResult = c.QueryMediaDate(toSearch, dateTimePickerFrom.Value.Date, dateTimePickerTo.Value.Date)
                                  .ToList();

                var tagsResult = c.QueryTags(toSearch);

                HashSet <int> mediaIds = new HashSet <int>(tagsResult);
                foreach (int mediaId in mediaIds)
                {
                    Media m = c.GetMedia(mediaId);
                    if (m.Creation_Date >= dateTimePickerFrom.Value.Date && m.Creation_Date <= dateTimePickerTo.Value.Date)
                    {
                        mediaResult.Add(m);
                    }
                }
                foreach (Media m in mediaResult)
                {
                    filePaths.Add(m.Path);
                }
                AddFilesToListView(mediaResult);
            }
            else
            {
                var mediaResult = c.QueryMedia(toSearch)
                                  .ToList();

                var tagsResult = c.QueryTags(toSearch);

                HashSet <int> mediaIds = new HashSet <int>(tagsResult);
                foreach (int mediaId in mediaIds)
                {
                    Media m = c.GetMedia(mediaId);
                    mediaResult.Add(m);
                }
                foreach (Media m in mediaResult)
                {
                    filePaths.Add(m.Path);
                }
                AddFilesToListView(mediaResult);
            }
            c.Close();
        }
Exemple #3
0
        private void AddFilesToListView(List <string> fp)
        {
            MediaTagsClient c   = new MediaTagsClient();
            int             cnt = 0;

            foreach (string filePath in fp)
            {
                Media result = c.GetMediaByPath(filePath);
                Color clr;
                if (result != null)
                {
                    clr = Color.Green;
                }
                else
                {
                    clr = Color.AliceBlue;
                }
                if (IsImage(Path.GetExtension(filePath)))
                {
                    using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                    {
                        imageList.Images.Add(Image.FromStream(stream));
                    }
                }
                else
                {
                    using (FileStream stream = new FileStream("./videoicon.png", FileMode.Open, FileAccess.Read))
                    {
                        imageList.Images.Add(Image.FromStream(stream));
                    }
                }
                listViewFile.LargeImageList = imageList;
                listViewFile.Items.Add(new ListViewItem
                {
                    ImageIndex = cnt,
                    Text       = filePath.Substring(filePath.LastIndexOf("\\") + 1),
                    Tag        = filePath,
                    BackColor  = clr
                });
                cnt++;
            }
            c.Close();
        }
Exemple #4
0
 private void frmAddMedia_Load(object sender, EventArgs e)
 {
     this.c = new MediaTagsClient();
     axWindowsMediaPlayer1.URL = this.path;
     this.lblFilePath.Text     = this.path;
     mediaLoaded = c.GetMediaByPath(this.path);
     if (mediaLoaded != null)
     {
         foreach (Tags t in mediaLoaded.Tags)
         {
             AddRow(t.Name);
         }
         dateTimePicker.Value = mediaLoaded.Creation_Date.Date;
         txtDescription.Text  = mediaLoaded.Description;
         result = "IN DB";
     }
     else
     {
         mediaLoaded      = new Media();
         mediaLoaded.Path = this.path;
         mediaLoaded.Tags = new List <Tags>();
         result           = "NOT IN DB";
     }
 }