private void DataAssigment()
        {
            Tags    dataTag     = TagsLibraryFunctions.CreateDateTag(dateTimePicker1.Value.ToString());
            TagType dataTagType = TagTypesLibraryFunctions.CreateAndReturn("Data");
            Media   dataMedia   = MediaLibraryFunctions.GetMedia(pictureBoxModifyProety.Tag.ToString());

            TableWaysLibraryFunctions.CreateTableWay(dataMedia, dataTag, dataTagType);
        }
        private void buttonDeleteTag_Click(object sender, EventArgs e)
        {
            string forDeteleTags = this.textBoxNewTags.Text.ToString();

            Regex           usedRegex        = new Regex(@"^((?<key>[A-Za-z]+)\s*[;]\s*)+$", RegexOptions.Compiled);
            MatchCollection forDeleteTagList = usedRegex.Matches(forDeteleTags);

            Media mediaDB;

            //foreach (var item in forDeleteTagList)
            //{
            //    Console.WriteLine(item.ToString());
            //}
            if (forDeleteTagList.Count == 0)
            {
                ErrForm errForm = new ErrForm("Format Incorect Please use this format: tagName;");
                errForm.ShowDialog();
            }

            try {
                foreach (Match match in forDeleteTagList)
                {
                    GroupCollection groups     = match.Groups;
                    var             countGroup = groups["key"].Captures.Count;

                    Console.WriteLine("countGroup");
                    Console.WriteLine(countGroup);

                    for (int i = 0; i < countGroup; i++)
                    {
                        string itemTagDelete = groups["key"].Captures[i].ToString();
                        //string itemTagType = groups["value"].Captures[i].ToString();
                        Console.WriteLine("itemTagDelete");
                        Console.WriteLine(itemTagDelete);

                        Tags tagDB = TagsLibraryFunctions.GetTag(itemTagDelete);
                        if (tagDB == null)
                        {
                            continue;
                        }

                        TagsLibraryFunctions.DeleteTag(tagDB);
                        //Console.WriteLine(TagsLibraryFunctions.DeleteTag(tagDB));

                        mediaDB = MediaLibraryFunctions.GetMedia(pictureBoxModifyProety.Tag.ToString());
                        TableWaysLibraryFunctions.DeleteTableWay(mediaDB);
                        ShowTags(mediaDB.Media_path);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrForm errForm = new ErrForm(ex.ToString());
                errForm.ShowDialog();
            }
        }
        public void ShowTags(String fileToDisplay)
        {
            textBox1.Text = String.Empty;

            Media mediaDB     = MediaLibraryFunctions.GetMedia(fileToDisplay);
            Tags  tagCategory = TableWaysLibraryFunctions.GetTableWaysIdTagsCategoryForDATE(mediaDB.Id_Media);

            DataDelete(tagCategory);
            textBox1.Text += "Numele pozei:  ";
            textBox1.Text += mediaDB.Media_name;
            textBox1.AppendText(Environment.NewLine);
            foreach (var item in mediaDB.TableWays)
            {
                if (item.Tag.Is_Deleted != true)
                {
                    textBox1.Text += "->";
                    textBox1.Text += item.Tag.Value_tag;
                    textBox1.Text += " (";
                    textBox1.Text += item.TagType.Value_tagType;
                    textBox1.Text += " )";
                    textBox1.AppendText(Environment.NewLine);
                }
            }
        }
        private void buttonSaveInModifyPropety_Click(object sender, EventArgs e)
        {
            Console.WriteLine(dateTimePicker1.Value);

            try
            {
                string newTagsString = this.textBoxNewTags.Text.ToString();
                Regex  regex         = new Regex(@"^((?<key>[A-Za-z]+)\s*-\s*(?<value>[A-Za-z]+)\s*[,;]\s*)+$", RegexOptions.Compiled);
                /*Regex regex = new Regex(@"(?<key>\w)", RegexOptions.Compiled);*/

                MatchCollection newTagList = regex.Matches(newTagsString);
                Console.WriteLine("count new tag list");
                Console.WriteLine(newTagList.Count);
                if (newTagList.Count == 0)
                {
                    ErrForm errForm = new ErrForm("Format Incorect Please use this format: tagName - tagCategory;");
                    errForm.ShowDialog();
                }
                Media mediaDB;
                foreach (Match match in newTagList)
                {
                    GroupCollection groups     = match.Groups;
                    var             countGroup = groups["key"].Captures.Count;
                    //Console.WriteLine("countGroup");
                    //Console.WriteLine(countGroup);

                    for (int i = 0; i < countGroup; i++)
                    {
                        string itemTag     = groups["key"].Captures[i].ToString();
                        string itemTagType = groups["value"].Captures[i].ToString();
                        //Console.WriteLine("itemTag");
                        //Console.WriteLine(itemTag);
                        //Console.WriteLine("itemTagType");
                        //Console.WriteLine(itemTagType);

                        var tagDB = TagsLibraryFunctions.CreateTagAnReturnTag(itemTag);
                        mediaDB = MediaLibraryFunctions.GetMedia(pictureBoxModifyProety.Tag.ToString());

                        TagType tagTypeDB = new TagType();
                        if (TagTypesLibraryFunctions.GetTagTypes(itemTagType) != null)
                        {
                            tagTypeDB = TagTypesLibraryFunctions.GetTagTypes(itemTagType);
                            //Console.WriteLine("gasit");
                        }
                        else
                        {
                            tagTypeDB = TagTypesLibraryFunctions.CreateTagTypeAndReturnIt(itemTagType);
                            //Console.WriteLine("nou");
                        }

                        TableWaysLibraryFunctions.CreateTableWay(mediaDB, tagDB, tagTypeDB);

                        //Console.WriteLine(pictureBoxModifyProety.Tag.ToString());
                        ShowTags(mediaDB.Media_path);
                    }
                }
                DataAssigment();
            }
            catch (Exception ex)
            {
                ErrForm errForm = new ErrForm(ex.ToString());
                errForm.ShowDialog();
            }
        }
Exemplo n.º 5
0
        private void tableTagsManagerT()
        {
            tableTagsManager.AutoSize    = true;
            tableTagsManager.RowCount    = 1;
            tableTagsManager.ColumnCount = 4;
            tableTagsManager.RowStyles.Add(new RowStyle());

            tableTagsManager.ColumnStyles.Add(new ColumnStyle());
            tableTagsManager.ColumnStyles.Add(new ColumnStyle());
            tableTagsManager.ColumnStyles.Add(new ColumnStyle());
            tableTagsManager.ColumnStyles.Add(new ColumnStyle());

            Label tagValue = new Label();

            tagValue.Text      = "Tag Value";
            tagValue.BackColor = Color.FromArgb(103, 146, 137);
            //tagValue.AutoSize = true;
            Label tagID = new Label();

            tagID.Text      = "Tag Category Id";
            tagID.BackColor = Color.FromArgb(103, 146, 137);
            //tagID.AutoSize = true;
            Label tagCategory = new Label();

            tagCategory.Text      = "Tag Category";
            tagCategory.BackColor = Color.FromArgb(103, 146, 137);
            //tagCategory.AutoSize = true;
            Label tagSerach = new Label();

            tagSerach.Text      = "Search";
            tagSerach.BackColor = Color.FromArgb(103, 146, 137);
            //tagSerach.AutoSize = true;
            tableTagsManager.Controls.Add(tagID, 0, 0);
            tableTagsManager.Controls.Add(tagCategory, 1, 0);
            tableTagsManager.Controls.Add(tagValue, 2, 0);
            tableTagsManager.Controls.Add(tagSerach, 3, 0);

            List <Tags> newTag = TagsLibraryFunctions.GetTagAll();
            int         count  = 1;

            foreach (var item in newTag)
            {
                tableTagsManager.RowStyles.Add(new RowStyle());
                Label newLabelValue    = new Label();
                Label newLabelId       = new Label();
                Label newLabelCategory = new Label();
                var   newLabelSearch   = new Button();
                newLabelValue.Text = item.Value_tag;

                var init = TableWaysLibraryFunctions.GetTableWaysIdTagsCategory(item.Id_Tags);
                newLabelCategory.Text      = TagTypesLibraryFunctions.GetTagTypes(init).Value_tagType;
                newLabelId.Text            = TagTypesLibraryFunctions.GetTagTypes(init).Id_TagType.ToString();
                newLabelValue.BackColor    = Color.FromArgb(244, 192, 149);
                newLabelCategory.BackColor = Color.FromArgb(244, 192, 149);
                newLabelId.BackColor       = Color.FromArgb(244, 192, 149);

                tableTagsManager.Controls.Add(newLabelId, 0, count);
                tableTagsManager.Controls.Add(newLabelCategory, 1, count);
                tableTagsManager.Controls.Add(newLabelValue, 2, count);


                newLabelSearch.Text      = "Vezi tot";
                newLabelSearch.BackColor = Color.FromArgb(244, 192, 149);
                newLabelSearch.Tag       = TagTypesLibraryFunctions.GetTagTypes(init).Id_TagType;
                newLabelSearch.Click    += NewLabelSearch_Click;
                tableTagsManager.Controls.Add(newLabelSearch, 3, count);

                count++;
                tableTagsManager.RowCount++;
            }
        }