예제 #1
0
        private void buttonSelectMediaInAdding_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "*|*.png;*.jpg";
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Multiselect      = true;

                this.listViewPicsInAdding.View = View.LargeIcon;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    ImageList imageList = new ImageList();
                    foreach (var item in openFileDialog.FileNames)
                    {
                        //Console.WriteLine(item);
                        if (MediaLibraryFunctions.CreateMedia(item))
                        {
                            ShowMyImage(item);
                            /*Console.WriteLine(pictureBox1.Name);*/
                            imageList.Images.Add(item, Image.FromFile(item));
                        }
                        else
                        {
                            ErrForm errForm = new ErrForm("Err occured at CREAT MEDIA");
                            errForm.ShowDialog();
                        }
                    }
                    int count = 0;
                    if (this.listViewPicsInAdding.LargeImageList != null)
                    {
                        count = this.listViewPicsInAdding.LargeImageList.Images.Count;
                    }
                    else
                    {
                        this.listViewPicsInAdding.LargeImageList = new ImageList();
                    }

                    for (int i = 0; i < imageList.Images.Count; i++)
                    {
                        this.listViewPicsInAdding.LargeImageList.Images.Add(imageList.Images.Keys[i], imageList.Images[i]);
                    }
                    for (int i = 0; i < imageList.Images.Count; i++)
                    {
                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.ImageIndex = i + count;



                        this.listViewPicsInAdding.Items.Add(listViewItem);
                    }
                }
            }

            RefreshDB();
        }
        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();
            }
        }
예제 #3
0
        private void buttonDeleteMediaIInAdding_Click(object sender, EventArgs e)
        {
            if (this.pictureBox1.Image == null)
            {
                return;
            }
            var item = pictureBox1.Tag.ToString();

            Console.WriteLine(item);
            /*Console.WriteLine(pictureBox1.Name);*/

            /*var itemListed = this.listViewPicsInAdding.Items.Find(item, true).ToList()[0];
             * this.listViewPicsInAdding.Items.Remove(itemListed);*/
            var indexPic = this.listViewPicsInAdding.LargeImageList.Images.IndexOfKey(item);

            /*Console.WriteLine(indexPic);
             * Console.WriteLine("\n");*/
            foreach (ListViewItem itemPic in this.listViewPicsInAdding.Items)
            {
                if (itemPic.ImageIndex == indexPic)
                {
                    this.listViewPicsInAdding.Items.Remove(itemPic);

                    break;
                }
            }
            if (this.listViewPicsInAdding.Items.Count == 0)
            {
                this.pictureBox1.Image = null;
                //Console.WriteLine("this.listViewPicsInAdding.Items.Count == 0");
                //Console.WriteLine(this.listViewPicsInAdding.Items.Count == 0);
                //Console.WriteLine("\n");
            }
            else
            {
                //Console.WriteLine(this.listViewPicsInAdding.Items.Count);
                ListViewItem validare = this.listViewPicsInAdding.Items[0];
                //Console.WriteLine("validare.ImageIndex");
                //Console.WriteLine(validare.ImageIndex);
                /*Console.WriteLine("\n");*/
                this.pictureBox1.Image = this.listViewPicsInAdding.LargeImageList.Images[validare.ImageIndex];
                this.pictureBox1.Tag   = this.listViewPicsInAdding.LargeImageList.Images.Keys[validare.ImageIndex];

                /*Console.WriteLine("this.listViewPicsInAdding.LargeImageList.Images.Keys[validare.ImageIndex]");
                 * Console.WriteLine(this.listViewPicsInAdding.LargeImageList.Images.Keys[validare.ImageIndex]);
                 * Console.WriteLine("\n");*/
            }
            if (!(MediaLibraryFunctions.DeleteMedia(item)))
            {
                ErrForm errForm = new ErrForm("Err occured at DELETE MEDIA");
                errForm.ShowDialog();
            }
        }
예제 #4
0
 private void buttonSendEmail_Click(object sender, EventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start("damocsimonalina@gmail,com");
     }
     catch (Exception ex)
     {
         ErrForm errForm = new ErrForm(ex.ToString());
         errForm.ShowDialog();
     }
 }
        private void buttonDeletePicturesModify_Click(object sender, EventArgs e)
        {
            if (this.pictureBoxModifyProety.Image == null)
            {
                return;
            }
            var item = pictureBoxModifyProety.Tag.ToString();

            Console.WriteLine(item);

            if (!(MediaLibraryFunctions.DeleteMedia(item)))
            {
                ErrForm errForm = new ErrForm("Err occured at DELETE MEDIA");
                errForm.ShowDialog();
            }
            Form.ActiveForm.Close();
        }
 private void buttonEditInModify_Click(object sender, EventArgs e)
 {
     try {
         if (pictureBoxModifyProety.Image == null)
         {
             return;
         }
         var             path            = pictureBoxModifyProety.Tag;
         var             idMedia         = MediaLibraryFunctions.GetMediaId((string)path);
         EditInformation editInformation = new EditInformation(idMedia);
         editInformation.ShowDialog();
     }
     catch (Exception ex)
     {
         ErrForm errForm = new ErrForm(ex.ToString());
         errForm.ShowDialog();
     }
 }
        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();
            }
        }