/// <summary> /// Open a new window for users to add new image to the collection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addImage_Click(object sender, RoutedEventArgs e) { AddImageWindow newWindow = new AddImageWindow(); newWindow.mainWindow = this; newWindow.big_window1.setCatalogNumber(EntryListBox.Items.Count); newWindow.big_window1.mainWindow = this; newWindow.big_window1.setImageProperty(false); MetaDataEntry newSmall = new MetaDataEntry(); newWindow.big_window1.MetaDataList.Items.Add(newSmall); newSmall.setBigWindow(newWindow.big_window1); //Initially set the two buttons disabled, after the user save to the catalog then will these two be abled newWindow.big_window1.mapButton.IsEnabled = false; newWindow.big_window1.hotspot.IsEnabled = false; Canvas.SetLeft(newWindow.big_window1.save, 349); Canvas.SetLeft(newWindow.big_window1.mapButton, 513); Canvas.SetLeft(newWindow.big_window1.hotspot, 713); newWindow.WindowState = System.Windows.WindowState.Normal; newWindow.ShowDialog(); }
/// <summary> /// Loads and opens the addImageWindow /// </summary> private void edit_Click(object sender, EventArgs e) { AddImageWindow newBigWindow = new AddImageWindow(); newBigWindow.mainWindow = _newWindow; newBigWindow.WindowState = System.Windows.WindowState.Normal; newBigWindow.big_window1.setCatalogNumber(catalogNumber); newBigWindow.big_window1.browse.Visibility = Visibility.Hidden; newBigWindow.big_window1.createDZ.Visibility = Visibility.Hidden; newBigWindow.big_window1.setMainWindow(_newWindow); //pass the main window to the addImage Control Image wpfImage = new Image(); FileStream stream = new FileStream(imagePath, FileMode.Open); System.Drawing.Image dImage = System.Drawing.Image.FromStream(stream); wpfImage = _helpers.ConvertDrawingImageToWPFImage(dImage); stream.Close(); //The image of the window is set according to its ratio of length and width Utils.setAspectRatio(newBigWindow.big_window1.imageCanvas, newBigWindow.big_window1.imageRec, newBigWindow.big_window1.image1, wpfImage, 7); //set image source newBigWindow.big_window1.image1.Source = wpfImage.Source; String dataDir = "Data/"; String dataUri = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\"; // String dataDir = "C:\\Users\\MISATRAN\\Desktop\\LADS-new\\GCNav\\bin\\Debug\\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") { String title = node.Attributes.GetNamedItem("title").InnerText; String path = node.Attributes.GetNamedItem("path").InnerText; if (imageName == path) { String artist = node.Attributes.GetNamedItem("artist").InnerText; String year = node.Attributes.GetNamedItem("year").InnerText; String medium = node.Attributes.GetNamedItem("medium").InnerText; //Loads the information about the imgae newBigWindow.big_window1.year_tag.Text = year; newBigWindow.big_window1.artist_tag.Text = artist; newBigWindow.big_window1.title_tag.Text = title; newBigWindow.big_window1.medium_tag.Text = medium; newBigWindow.big_window1.setImageName(path); newBigWindow.big_window1.setImagePath(dataUri + "Images\\" + "Thumbnail\\" + path); newBigWindow.big_window1.setImageProperty(true); if(node.Attributes.GetNamedItem("description")!=null){ String summary = node.Attributes.GetNamedItem("description").InnerText; newBigWindow.big_window1.summary.Text = summary; } //Loads the keywords String keyword = ""; foreach (XmlNode imgnode in node.ChildNodes) { if (imgnode.Name == "Keywords") { foreach (XmlNode keywd in imgnode.ChildNodes) { if (keywd.Name == "Keyword") { if (keyword == "") { keyword = keyword + keywd.Attributes.GetNamedItem("Value").InnerText; } else { keyword = keyword + "," + keywd.Attributes.GetNamedItem("Value").InnerText; } } } } //Load metadatas if there is any if (imgnode.Name == "Metadata") { foreach (XmlNode meta in imgnode.ChildNodes) { if (meta.Name == "Group") { //This needs to specify group A,B,C or D. Groups are not specified in this release foreach (XmlNode file in meta) { String fileName = file.Attributes.GetNamedItem("Filename").InnerText; //this is to save the imageName //need to special case this for videos images and audio files System.Windows.Controls.Image wpfImage2 = new System.Windows.Controls.Image(); _helpers = new Helpers(); if (_helpers.IsImageFile(fileName)) { String fullPath = dataUri + "Images/" + "Metadata/" + fileName; FileStream stream2 = new FileStream(fullPath, FileMode.Open); System.Drawing.Image dImage2 = System.Drawing.Image.FromStream(stream2); wpfImage2 = _helpers.ConvertDrawingImageToWPFImage(dImage2); stream2.Close(); //set image source MetaDataEntry newSmallwindow = new MetaDataEntry(); //Utils.setAspectRatio(newSmallwindow.imageCanvas, newSmallwindow.imageRec, newSmallwindow.image1, metaBitmapImage, 4); newSmallwindow.image1.Source = wpfImage2.Source; newSmallwindow.title_tag.Text = fileName; if (file.Attributes.GetNamedItem("Name") != null) { String name = file.Attributes.GetNamedItem("Name").InnerText; newSmallwindow.name_tag.Text = name; } if (file.Attributes.GetNamedItem("Description") != null) { String description = file.Attributes.GetNamedItem("Description").InnerText; newSmallwindow.summary.Text = description; } newSmallwindow.tags.Text = keyword; newBigWindow.big_window1.MetaDataList.Items.Add(newSmallwindow); newSmallwindow.setBigWindow(newBigWindow.big_window1); } //loads videos else if (_helpers.IsVideoFile(fileName)) { String fullPath = dataUri + "Videos/" + "Metadata/" + fileName; BitmapImage metaBitmapImage = new BitmapImage(); metaBitmapImage.BeginInit(); String thumbPath = fullPath; int decrement = System.IO.Path.GetExtension(thumbPath).Length; thumbPath = thumbPath.Remove(thumbPath.Length - decrement, decrement); thumbPath += ".bmp"; metaBitmapImage.UriSource = new Uri(thumbPath); metaBitmapImage.EndInit(); //set image source MetaDataEntry newSmallwindow = new MetaDataEntry(); newSmallwindow.image1.Source = metaBitmapImage; newSmallwindow.title_tag.Text = fileName; if (file.Attributes.GetNamedItem("Name") != null) { String name = file.Attributes.GetNamedItem("Name").InnerText; newSmallwindow.name_tag.Text = name; } if (file.Attributes.GetNamedItem("description") != null) { String description = file.Attributes.GetNamedItem("description").InnerText; newSmallwindow.summary.Text = description; } newSmallwindow.tags.Text = keyword; newBigWindow.big_window1.MetaDataList.Items.Add(newSmallwindow); newSmallwindow.setBigWindow(newBigWindow.big_window1); } } } } } } newBigWindow.big_window1.tags.Text = keyword; } } } } } } if (newBigWindow.big_window1.MetaDataList.Items.Count == 0) { MetaDataEntry newSmallwindow = new MetaDataEntry(); newBigWindow.big_window1.MetaDataList.Items.Add(newSmallwindow); newSmallwindow.setBigWindow(newBigWindow.big_window1); } newBigWindow.Show(); }