Esempio n. 1
0
        private void ExecuteAddImages()
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.InitialDirectory = MyImgDirectory.path;
            ofd.Multiselect      = true;

            if ((bool)ofd.ShowDialog())
            {
                List <Pic> lst = new List <Pic>();

                // cambiar por loadtags() ???
                XDocument d = XDocument.Parse(File.ReadAllText(XmlTags));
                var       t = d.Document;

                var settings = new XmlWriterSettings();
                settings.OmitXmlDeclaration  = true;
                settings.Indent              = true;
                settings.NewLineOnAttributes = true;

                var selectedFiles = ofd.FileNames;

                foreach (var item in selectedFiles)
                {
                    lst.Add(ExtMeth.NewPic(
                                item.Split('\\').Last(),
                                item
                                ));
                }

                AddPicViewModel AddPVM = new AddPicViewModel(lst);
                AddPic          f      = new AddPic();
                f.DataContext = AddPVM;
                f.ShowDialog();

                var myResult = AddPVM.Result_PicListAfterSave;

                if (myResult.Count > 0)
                {
                    foreach (var file in myResult)
                    {
                        File.Copy(file.Path, MyImgDirectory.path + "\\" + file.Name);
                        var tmpFile = new XElement("Pic", file.Name, new XAttribute("Tags", file.TagsAsString));

                        d.Document.Element("Pics").Add(tmpFile);
                    }

                    File.WriteAllText(XmlTags, d.Document.ToString(), Encoding.UTF8);
                    LoadImagesFromTMPfolder();
                }
            }
        }
Esempio n. 2
0
        private void LoadPicsInfo(XElement xDocTags, string tagToRead)
        {
            foreach (var item in xDocTags.Elements(tagToRead))
            {
                var tagList = item.FirstAttribute.Value.Split(',').ToList().Select(x => x.Trim());

                MyImgDirectory.Files.Add(ExtMeth.NewPic(
                                             item.Value,
                                             MyImgDirectory.path + "\\" + item.Value,
                                             System.Drawing.Image.FromFile(MyImgDirectory.path + "\\" + item.Value),
                                             new List <string>(tagList)
                                             ));
            }
        }
Esempio n. 3
0
        internal AddPicViewModel(IEnumerable <Pic> Files)
        {
            saveCommand = new DelegateCommand(ExecuteSaveCommand, () => { return(true); });
            picsList    = new ObservableCollection <Pic>();

            foreach (var item in Files)
            {
                PicsList.Add(ExtMeth.NewPic(
                                 item.Name,
                                 item.Path,
                                 item.Image,
                                 item.Tags,
                                 item.TagsAsString,
                                 item.TagsForUI
                                 ));
            }
        }