Exemple #1
0
        private void ExecuteModifyImages()
        {
            AddPicViewModel AddPVM = new AddPicViewModel(OriginalPicsList.ToList());

            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();
        }
Exemple #2
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();
                }
            }
        }