Example #1
0
        public TagEntity(VideoTag _tag, BindingList <TagEntityBase> _parent)
        {
            Text      = _tag.Text;
            Intensity = _tag.Intensity;
            Deleted   = false;

            var bytes = BitConverter.GetBytes((int)Intensity);

            Background = new Observable <SolidColorBrush>()
            {
                Value = new SolidColorBrush(Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]))
            };

            RemoveTag = new Command(new Action(() => {
                Deleted = true;
                NotifyPropertyChanged("Deleted");
                _parent.Remove(this);
            }));

            PossibleIntensityStates = new List <IntensityState>()
            {
                new IntensityState(Intensity.Lowest, this),
                new IntensityState(Intensity.Low, this),
                new IntensityState(Intensity.Neutral, this),
                new IntensityState(Intensity.High, this),
                new IntensityState(Intensity.Highest, this)
            };
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            VideoTag videoTag = db.VideoTags.Find(id);

            db.VideoTags.Remove(videoTag);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        public void AddTagToMediaFile(MediaFile file, VideoTag tag)
        {
            using (var db = DataAccessUtil.CreateSqlConnection()) {
                db.Open();

                var command = new SqliteCommand("INSERT INTO tag_on_media_file VALUES (@TagId, @FileId)", db);
                command.Parameters.AddWithValue("@TagId", tag.TagId);
                command.Parameters.AddWithValue("@FileId", file.MediaId);
                command.ExecuteNonQuery();
            }
        }
Example #4
0
        public void RemoveTagFromMediaFile(MediaFile file, VideoTag tag)
        {
            using (var db = DataAccessUtil.CreateSqlConnection()) {
                db.Open();

                var command = new SqliteCommand("DELETE FROM tag_on_media_file WHERE tag_id = @TagId AND media_file_id = @FileId", db);
                command.Parameters.AddWithValue("@TagId", tag.TagId);
                command.Parameters.AddWithValue("@FileId", file.MediaId);
                command.ExecuteNonQuery();
            }
        }
Example #5
0
 public ActionResult Edit([Bind(Include = "ID,VideoID,TagID")] VideoTag videoTag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(videoTag).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TagID   = new SelectList(db.Tags, "ID", "TagName", videoTag.TagID);
     ViewBag.VideoID = new SelectList(db.Videos, "ID", "Title", videoTag.VideoID);
     return(View(videoTag));
 }
Example #6
0
        public IActionResult Edit(EditViewModel editViewModel)
        {
            string hash = editViewModel.Hash;

            if (ModelState.IsValid)
            {
                string   newTagName = editViewModel.TagName;
                int      tagId;
                VideoTag videoTag;

                //input tag nonexists
                if (context.Tags.Where(t => t.Name == newTagName).SingleOrDefault() == null)
                {
                    Tag newTag = new Tag(newTagName);
                    tagId = newTag.Id;

                    videoTag = new VideoTag
                    {
                        VideoHash = hash,
                        Tag       = newTag,
                        TagId     = tagId
                    };

                    context.VideoTags.Add(videoTag);
                    context.SaveChanges();
                }
                // input tag exists
                else
                {
                    tagId = context.Tags.Where(t => t.Name == newTagName).Single().Id;

                    List <VideoTag> existingVideoTags = context.VideoTags
                                                        .Where(vt => vt.VideoHash == hash)
                                                        .Where(vt => vt.TagId == tagId)
                                                        .ToList();

                    // if pair nonexsits, add pair
                    if (existingVideoTags.Count == 0)
                    {
                        videoTag = new VideoTag
                        {
                            VideoHash = hash,
                            TagId     = tagId
                        };

                        context.VideoTags.Add(videoTag);
                        context.SaveChanges();
                    }
                }
            }
            return(Redirect("/Video/Edit/" + editViewModel.VideoId));
        }
Example #7
0
        // GET: VideoTags/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VideoTag videoTag = db.VideoTags.Find(id);

            if (videoTag == null)
            {
                return(HttpNotFound());
            }
            return(View(videoTag));
        }
Example #8
0
        // GET: VideoTags/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VideoTag videoTag = db.VideoTags.Find(id);

            if (videoTag == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TagID   = new SelectList(db.Tags, "ID", "TagName", videoTag.TagID);
            ViewBag.VideoID = new SelectList(db.Videos, "ID", "Title", videoTag.VideoID);
            return(View(videoTag));
        }
Example #9
0
        public List <Tag> GetTagsOnSeries(long seriesId)
        {
            using (var db = DataAccessUtil.CreateSqlConnection()) {
                db.Open();
                var command = new SqliteCommand($"SELECT t.tag_id, t.name, t.type, t.unique_id FROM tag_on_series v, tag t WHERE v.series_id = {seriesId} AND v.tag_id = t.tag_id AND t.deleted = false", db);
                var reader  = command.ExecuteReader();

                var tags = new List <Tag>();
                while (reader.Read())
                {
                    var tag = new VideoTag(reader.GetInt64(0), reader.GetString(1), reader.GetString(2), reader.GetString(3));
                    tags.Add(tag);
                }

                return(tags);
            }
        }
Example #10
0
 private void DeleteTags()
 {
     if (vListBox.Items.Count <= 0 || MessageBox.Show(this, LangCtrl.GetString("tp_DeleteMarks", "Delete checked Marks?"), "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
     {
         return;
     }
     foreach (ListItem listItem in vListBox.Items)
     {
         using (RPM_VideoTag rpmVideoTag = new RPM_VideoTag())
         {
             if (listItem.IsChecked.Value)
             {
                 VideoTag tag1 = (VideoTag)listItem.Tag;
                 VideoTag tag2 = rpmVideoTag.GetTag(tag1.Id);
                 rpmVideoTag.DeleteVideoTag(tag2);
                 rpmVideoTag.Save();
                 Global.Log("MARK-DELETE", string.Format("Delete: {0} / {1} for {2}", listItem.Text.ToUpper(), listItem.Description, FileName));
             }
         }
     }
     ListTags(File_ID);
 }
Example #11
0
            public static Tag Parse(byte[] headerBytes, byte[] bodyBytes)
            {
                TagType tagType = (TagType)(headerBytes[0] & 0b00011111);
                Tag     tagBase;

                switch (tagType)
                {
                case TagType.Audio:
                    tagBase = new AudioTag(headerBytes, bodyBytes);
                    break;

                case TagType.Video:
                    tagBase = new VideoTag(headerBytes, bodyBytes);
                    break;

                case TagType.Script:
                    tagBase = new ScriptTag(headerBytes, bodyBytes);
                    break;

                default:
                    throw new UnsupportedFormat(string.Format("Unsupported Tag type 0x{0}", ((uint)tagType).ToString("X2")));
                }
                return(tagBase);
            }
Example #12
0
 public void DeleteVideoTag(VideoTag tag)
 {
     SetTagDeletedStatus(tag, true);
 }
Example #13
0
 public void PermanentlyRemoveVideoTag(VideoTag tag)
 {
     PermanentlyRemoveTag(tag);
 }
Example #14
0
 public async Task PermanentlyRemoveVideoTag(VideoTag tag)
 {
     tagRepository.PermanentlyRemoveVideoTag(tag);
 }
Example #15
0
 public void UpdateVideoTag(VideoTag tag)
 {
     tagRepository.UpdateTag(tag);
 }
Example #16
0
 public async Task RestoreVideoTag(VideoTag tag)
 {
     tagRepository.RestoreVideoTag(tag);
 }
Example #17
0
 public async Task DeleteVideoTag(VideoTag tag)
 {
     tagRepository.DeleteVideoTag(tag);
 }
Example #18
0
 internal static FlvTag ReadTag(Stream stream)
 {
     try {
         FlvTag tag;
         byte[] buffer = new byte[4];
         int rtn;
         rtn = stream.Read(buffer, 0, 4);
         if (rtn <= 0) {
             return null;
         }
         int type = stream.ReadByte();
         if (type == 8)
             tag = new AudioTag();
         else if (type == 9)
             tag = new VideoTag();
         else if (type == 0x12)
             tag = new ScriptTag();
         else
             tag = new FlvTag();
         tag.presize = ByteUtil.ByteToUInt(buffer, 4);
         tag.tagtype = type;
         tag.datasize = ByteUtil.ReadUI24(stream);
         tag.timestamp = ByteUtil.ReadUI24(stream);
         tag.timestamp_ex = stream.ReadByte();
         tag.streamid = ByteUtil.ReadUI24(stream);
         tag.offset = stream.Position;
         if (tag is ScriptTag) {
             (tag as ScriptTag).ReadScript(stream);
             stream.Seek(tag.offset + tag.DataSize, SeekOrigin.Begin);
         } else if (tag is AudioTag) {
             rtn = stream.Read(buffer, 0, 1);
             if (rtn <= 0)
                 return null;
             tag.taginfo = buffer[0];
             stream.Seek(tag.DataSize - 1, SeekOrigin.Current);
         } else if (tag is VideoTag) {
             rtn = stream.Read(buffer, 0, 2);
             if (rtn <= 0)
                 return null;
             tag.taginfo = buffer[0];
             tag.avcpaktype = buffer[1];
             stream.Seek(tag.DataSize - 2, SeekOrigin.Current);
         }
         return tag;
     } catch {
         return null;
     }
 }
Example #19
0
 internal static FlvTag ReadTag(Stream stream)
 {
     try {
         FlvTag tag;
         byte[] buffer = new byte[4];
         int    rtn;
         rtn = stream.Read(buffer, 0, 4);
         if (rtn <= 0)
         {
             return(null);
         }
         int type = stream.ReadByte();
         if (type == 8)
         {
             tag = new AudioTag();
         }
         else if (type == 9)
         {
             tag = new VideoTag();
         }
         else if (type == 0x12)
         {
             tag = new ScriptTag();
         }
         else
         {
             tag = new FlvTag();
         }
         tag.presize      = ByteUtil.ByteToUInt(buffer, 4);
         tag.tagtype      = type;
         tag.datasize     = ByteUtil.ReadUI24(stream);
         tag.timestamp    = ByteUtil.ReadUI24(stream);
         tag.timestamp_ex = stream.ReadByte();
         tag.streamid     = ByteUtil.ReadUI24(stream);
         tag.offset       = stream.Position;
         if (tag is ScriptTag)
         {
             (tag as ScriptTag).ReadScript(stream);
             stream.Seek(tag.offset + tag.DataSize, SeekOrigin.Begin);
         }
         else if (tag is AudioTag)
         {
             rtn = stream.Read(buffer, 0, 1);
             if (rtn <= 0)
             {
                 return(null);
             }
             tag.taginfo = buffer[0];
             stream.Seek(tag.DataSize - 1, SeekOrigin.Current);
         }
         else if (tag is VideoTag)
         {
             rtn = stream.Read(buffer, 0, 2);
             if (rtn <= 0)
             {
                 return(null);
             }
             tag.taginfo    = buffer[0];
             tag.avcpaktype = buffer[1];
             stream.Seek(tag.DataSize - 2, SeekOrigin.Current);
         }
         return(tag);
     } catch {
         return(null);
     }
 }
Example #20
0
 public void DeleteVideoTag(VideoTag rec)
 {
     context.VideoTags.Remove(rec);
 }
Example #21
0
 public void RestoreVideoTag(VideoTag tag)
 {
     SetTagDeletedStatus(tag, false);
 }