Пример #1
0
        /// <summary>
        /// Load data from XML file and store into a list
        /// </summary>
        public void load()
        {
            String dataDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\";
            XmlDocument doc = new XmlDocument();
            doc.Load(dataDir + "NewCollection.xml");
            if (doc.HasChildNodes)
            {
                foreach (XmlNode docNode in doc.ChildNodes)
                {
                    if (docNode.Name == "Collection")
                    {

                        foreach (XmlNode node in docNode.ChildNodes)
                        {
                            if (node.Name == "Image")
                            {
                                catalogEntry newEntry = new catalogEntry(this);
                                newEntry.catalogNumber = EntryListBox.Items.Count;
                                String path = node.Attributes.GetNamedItem("path").InnerText;
                                String artist = node.Attributes.GetNamedItem("artist").InnerText;
                                String title = node.Attributes.GetNamedItem("title").InnerText;
                                String year = node.Attributes.GetNamedItem("year").InnerText;
                                String medium = node.Attributes.GetNamedItem("medium").InnerText;

                                String fullPath = dataDir + "Images\\" + "Thumbnail\\" + path;

                                Image wpfImage = new Image();
                                FileStream stream = new FileStream(fullPath, FileMode.Open);
                                System.Drawing.Image dImage = System.Drawing.Image.FromStream(stream);
                                wpfImage = _helpers.ConvertDrawingImageToWPFImage(dImage);
                                stream.Close();

                                //set image source
                                newEntry.image1.Source = wpfImage.Source;
                                newEntry.year_tag.Text = year;
                                newEntry.artist_tag.Text = artist;
                                newEntry.title_tag.Text = title;
                                newEntry.medium_tag.Text = medium;
                                Utils.setAspectRatio(newEntry.imageCanvas, newEntry.imageRec, newEntry.image1, wpfImage, 4);
                                if (node.Attributes.GetNamedItem("description") != null)
                                {
                                    String description = node.Attributes.GetNamedItem("description").InnerText;
                                    newEntry.summary.Text = description;
                                }
                                newEntry.setImagePath(fullPath);
                                newEntry.setImageTitle(title);
                                Console.Out.WriteLine("TITLE" + title);
                                newEntry.setImageName(path);
                                EntryListBox.Items.Add(newEntry);
                            }

                        }
                    }
                }
            }
        }
        public void load()
        {
            //String dataDir = "Data\\";
            String dataDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\";
            //String dataDir = "F://lads_data/";
            //String dataDir = "C://LADS-yc60/data/";
            Console.WriteLine("DataDir: " + dataDir);
            XmlDocument doc = new XmlDocument();
            doc.Load(dataDir + "NewCollection.xml");
            if (doc.HasChildNodes)
            {
                foreach (XmlNode docNode in doc.ChildNodes)
                {
                    if (docNode.Name == "Collection")
                    {

                        foreach (XmlNode node in docNode.ChildNodes)
                        {
                            if (node.Name == "Image")
                            {
                                catalogEntry newEntry = new catalogEntry(this);
                                String path = node.Attributes.GetNamedItem("path").InnerText;
                                String artist = node.Attributes.GetNamedItem("artist").InnerText;
                                String title = node.Attributes.GetNamedItem("title").InnerText;
                                String year = node.Attributes.GetNamedItem("year").InnerText;

                                String fullPath = dataDir + "Images\\" + "Thumbnail\\" + path;

                                BitmapImage myBitmapImage = new BitmapImage();
                                myBitmapImage.BeginInit();
                                myBitmapImage.UriSource = new Uri(@fullPath);
                                myBitmapImage.EndInit();

                                //set image source
                                newEntry.image1.Source = myBitmapImage;
                                newEntry.year_tag.Text = year;
                                newEntry.artist_tag.Text = artist;
                                newEntry.title_tag.Text = title;
                                newEntry.setImagePath(fullPath);
                                newEntry.setImageTitle(title);

                                EntryListBox.Items.Add(newEntry);
                            }

                        }
                    }
                }
            }
        }
Пример #3
0
 public void addOneArtworkToCatalog()
 {
     catalogEntry newEntry = new catalogEntry(this);
     EntryListBox.Items.Add(newEntry);
 }