Пример #1
0
        public void addImage(ImageData img)
        {
            minYear = Math.Min(img.year, minYear);
            maxYear = Math.Max(img.year, maxYear);
            images.Add(img);
            //create border thing, add image
            Border bord = new Border();
            bord.BorderBrush = new SolidColorBrush(Color.FromRgb(0x00, 0x2d, 0x0c));
            bord.Background = new SolidColorBrush(Color.FromRgb(0x00, 0x2d, 0x0c));
            bord.CornerRadius = new CornerRadius(5);
            bord.HorizontalAlignment = HorizontalAlignment.Center;
            bord.VerticalAlignment = VerticalAlignment.Center;
            bord.Padding = new Thickness(bordPadding);
            bord.Margin = new Thickness(bordMargin);
            bord.BorderThickness = new Thickness(bordThickness);

            TextBlock tb = new TextBlock();
            tb.FontSize = 12;
            tb.Width = img.Width;
            tb.Background = new SolidColorBrush(Color.FromArgb(127,0,0,0));
            //tb.Height = 12;
            tb.TextWrapping = TextWrapping.NoWrap;
            tb.TextTrimming = TextTrimming.WordEllipsis;
            tb.Foreground = new SolidColorBrush(Color.FromRgb(0xff,0xff,0xff));
            tb.Text = img.artist;
            tb.VerticalAlignment = VerticalAlignment.Bottom;
            Canvas.SetBottom(tb, 0);

            tb.IsHitTestVisible = false;

            Canvas c = new Canvas();
            c.Height = img.Height;
            c.Width = img.Width;
            c.Children.Add(img);

            c.Children.Add(tb);
            bord.Child = c;
            img.setCluster(this);

            //add border thing to row
            stacks[curRow].Children.Add(bord);

            //increment row
            curRow++;
            curRow %= _numRows;
        }
Пример #2
0
        /// <summary>
        /// parse the xml and create all the imageData objects
        /// </summary>
        public void loadCollection()
        {
            InstructionBox.Width = System.Windows.SystemParameters.PrimaryScreenWidth / 2;
            XmlDocument doc = new XmlDocument();
            doc.Load(dataDir + "NewCollection.xml");
            if (doc.HasChildNodes)
            {
                foreach (XmlNode docNode in doc.ChildNodes)
                {
                    if (docNode.Name == "Collection")
                    {
                        int startY = 1;
                        int endY = 0;
                        foreach (XmlNode node in docNode.ChildNodes)
                        {
                            if (node.Name == "Image")
                            {
                                _collectionEmpty = false;
                                String path = node.Attributes.GetNamedItem("path").InnerText;
                                String artist = node.Attributes.GetNamedItem("artist").InnerText;
                                String medium = node.Attributes.GetNamedItem("medium").InnerText;
                                String title = node.Attributes.GetNamedItem("title").InnerText;
                                int year = Convert.ToInt32(node.Attributes.GetNamedItem("year").InnerText);

                                String fullPath = dataDir + "Images/" + path;
                                String thumbPath = dataDir + "Images/" + "Thumbnail/" + path;
                                String xmlPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/" + dataDir + "Images/" + "DeepZoom/" + path + "/dz.xml";

                                ImageData currentImage = new ImageData(thumbPath);
                                currentImage.xmlpath = xmlPath;
                                currentImage.fullpath = fullPath;
                                currentImage.year = year;
                                currentImage.artist = artist;
                                currentImage.medium = medium;
                                currentImage.title = title;
                                currentImage.filename = path;
                                currentImage.setParent(this);

                                //populate Keywords
                                List<String> keywds = new List<String>();
                                foreach (XmlNode imgnode in node.ChildNodes)
                                {
                                    if (imgnode.Name == "Keywords")
                                    {
                                        foreach (XmlNode keywd in imgnode.ChildNodes)
                                        {
                                            if (keywd.Name == "Keyword")
                                            {
                                                keywds.Add(keywd.Attributes.GetNamedItem("Value").InnerText);
                                            }
                                        }
                                    }
                                    else if (imgnode.Name == "Locations")
                                    {
                                        foreach (XmlNode locInfo in imgnode.ChildNodes)
                                        {

                                            if (locInfo.Name == "Purchase")
                                            {
                                                Point p = this.parceLongLat(locInfo);
                                                currentImage.addButton(new MapControl.MapButton(p.X, p.Y, 2, currentImage));
                                                if (locInfo.Attributes.GetNamedItem("longitude") != null)
                                                {
                                                    String lon = locInfo.Attributes.GetNamedItem("longitude").InnerText;

                                                    String lat = locInfo.Attributes.GetNamedItem("latitude").InnerText;
                                                    String date = "";
                                                    String city = "";
                                                    if (locInfo.Attributes.GetNamedItem("date") != null)
                                                    {
                                                        date = locInfo.Attributes.GetNamedItem("date").InnerText;
                                                    }
                                                    if (locInfo.Attributes.GetNamedItem("city") != null)
                                                    {
                                                        city = locInfo.Attributes.GetNamedItem("city").InnerText;
                                                    }
                                                    currentImage.setLocButtonInfo("red" + "///" + lon + "///" + lat + "///" + date + "///" + city);
                                                }

                                            }
                                            else if (locInfo.Name == "Work")
                                            {
                                                Point p = this.parceLongLat(locInfo);
                                                currentImage.addButton(new MapControl.MapButton(p.X, p.Y, 0, currentImage));
                                                if (locInfo.Attributes.GetNamedItem("longitude") != null)
                                                {
                                                    String lon = locInfo.Attributes.GetNamedItem("longitude").InnerText;
                                                    String lat = locInfo.Attributes.GetNamedItem("latitude").InnerText;

                                                    String date = "";
                                                    String city = "";
                                                    if (locInfo.Attributes.GetNamedItem("date") != null)
                                                    {
                                                        date = locInfo.Attributes.GetNamedItem("date").InnerText;
                                                    }
                                                    if (locInfo.Attributes.GetNamedItem("city") != null)
                                                    {
                                                        city = locInfo.Attributes.GetNamedItem("city").InnerText;
                                                    }
                                                    currentImage.setLocButtonInfo("yellow" + "///" + lon + "///" + lat + "///" + date + "///" + city);

                                                }

                                            }
                                            else if (locInfo.Name == "Display")
                                            {
                                                foreach (XmlNode displayLoc in locInfo.ChildNodes)
                                                {
                                                    if (displayLoc.Name == "Location")
                                                    {
                                                        Point p = this.parceLongLat(displayLoc);

                                                        if (displayLoc.Attributes.GetNamedItem("longitude") != null)
                                                        {
                                                            String lon = displayLoc.Attributes.GetNamedItem("longitude").InnerText;

                                                            String lat = displayLoc.Attributes.GetNamedItem("latitude").InnerText;
                                                            String date = "";
                                                            String city = "";
                                                            if (displayLoc.Attributes.GetNamedItem("date") != null)
                                                            {
                                                                date = displayLoc.Attributes.GetNamedItem("date").InnerText;
                                                            }
                                                            if (displayLoc.Attributes.GetNamedItem("city") != null)
                                                            {
                                                                city = displayLoc.Attributes.GetNamedItem("city").InnerText;
                                                            }
                                                            currentImage.setLocButtonInfo("blue" + "///" + lon + "///" + lat + "///" + date + "///" + city);
                                                        }

                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                currentImage.keywords = keywds;
                                _imageCollection.Add(currentImage);

                                //figure out the time range of the collection
                                if (startY > endY)
                                {
                                    startY = year;
                                    endY = year;
                                }
                                else
                                {
                                    if (year < startY)
                                        startY = year;
                                    if (year > endY)
                                        endY = year;
                                }
                                if (currentImage != null)
                                    OnImageLoaded(new Helpers.ImageLoadedEventArgs(currentImage));
                            }
                        }
                        _starty = startY;
                        _endy = endY;
                    }
                }
            }
            //if the collection is empty, arbitrarily set the start and end values
            if (_starty > +_endy)
            {
                _starty = 1250;
                _endy = 1950;
            }
        }
Пример #3
0
        /*
        * Draw image scaled appropriately in the 'current image' canvas
        * and display text in the information canvas.
        * (called from ImageData when clicked)
        */
        public void imageSelected(ImageData img)
        {
            curImageContainer.Visibility = Visibility.Visible;
            curInfoContainer.Visibility = Visibility.Visible;

            if (currentImage != null && currentImage.Parent != null)
            {
                ((Border)((Canvas)currentImage.Parent).Parent).BorderBrush = new SolidColorBrush(Color.FromRgb(0x00, 0x2d, 0x0c));
                ((Border)((Canvas)currentImage.Parent).Parent).Background = new SolidColorBrush(Color.FromRgb(0x00, 0x2d, 0x0c));
            }
            ((Border)((Canvas)img.Parent).Parent).BorderBrush = new SolidColorBrush(Color.FromRgb(0xff, 0xf6, 0x8b));
            ((Border)((Canvas)img.Parent).Parent).Background = new SolidColorBrush(Color.FromRgb(0xff, 0xf6, 0x8b));

            OnImageSelected(new Helpers.ImageSelectedEventArgs(img));
            curImageCanvas.Children.Clear();

            Image curImage = new Image();
            BitmapImage bitmap = new BitmapImage();
            bitmap.BeginInit();
            bitmap.UriSource = new Uri(img.fullpath, UriKind.Relative);
            bitmap.EndInit();
            curImage.Source = bitmap;

            curImageCanvas.Children.Add(curImage);
            curImageContainer.Height = _windowSize.Height / 3;
            curImageContainer.Width = _windowSize.Width / 4;
            curImageCanvas.Width = _windowSize.Width / 4 - 10;
            curImageCanvas.Height = _windowSize.Height / 3 - 10;
            curImageCanvas1.Width = _windowSize.Width / 4 - 10;
            curImageCanvas1.Height = _windowSize.Height / 3 - 10;
            Double actualWidth = curImage.Source.Width;
            Double actualHeight = curImage.Source.Height;
            Double ratio = actualWidth / actualHeight;
            Double canvasRatio = curImageCanvas.Width / curImageCanvas.Height;
            ScaleTransform tran = new ScaleTransform();
            if (ratio > canvasRatio)
            {
                Double scale = (curImageCanvas.ActualWidth - 30) / actualWidth;
                tran.ScaleX = scale;
                tran.ScaleY = scale;
            }
            else
            {
                Double scale = (curImageCanvas.ActualHeight - 30) / actualHeight;
                tran.ScaleX = scale;
                tran.ScaleY = scale;
            }
            curImage.RenderTransform = tran;
            curImageCanvas.UpdateLayout();
            Canvas.SetTop(curImage, (curImageCanvas.Height - curImage.ActualHeight * tran.ScaleY) / 2);
            Canvas.SetLeft(curImage, (curImageCanvas.Width - curImage.ActualWidth * tran.ScaleX) / 2);
            currentImage = img;
            curImage.TouchDown += HandleImageTouched;
            curImage.MouseDown += HandleImageTouched;

            curInfoCol.Width = _windowSize.Width / 4;
            curInfoCol.Height = _windowSize.Height / 3;

            infoScroll.Height = curInfoCol.Height;
            ColumnDefinition width = new ColumnDefinition();
            GridLength length = new GridLength(_windowSize.Width / 4 - 40);
            width.Width = length;
            curInfoCol.ColumnDefinitions.Add(width);

            title.Text = "";
            artist.Text = "";
            medium.Text = "";
            date.Text = "";
            title.Text += "Title: " + img.title;
            curInfoCol.UpdateLayout();
            titleBack.Width = _windowSize.Width / 4 - 20;
            titleBack.Height = title.ActualHeight + 5;
            artist.Text += "Artist: " + img.artist;
            medium.Text += "Medium: " + img.medium;
            date.Text += "Year: " + img.year;

            title.FontSize = 25 * _windowSize.Height / 1080.0;
            artist.FontSize = 20 * _windowSize.Height / 1080.0;
            medium.FontSize = artist.FontSize;
            date.FontSize = artist.FontSize;
            KeywordsTitle.FontSize = 18 * _windowSize.Height / 1080.0;
            curKeywords.FontSize = 18 * _windowSize.Height / 1080.0;
            curInfoCol.UpdateLayout();
            titleBack.Height = titleBack.ActualHeight + 10;

            if (currentImage.keywords.Count() > 0)
            {
                KeywordsTitle.Visibility = Visibility.Visible;
                curKeywords.Visibility = Visibility.Visible;
                KeywordBack.Visibility = Visibility.Visible;
            }
            else
            {
                KeywordsTitle.Visibility = Visibility.Hidden;
                curKeywords.Visibility = Visibility.Hidden;
                KeywordBack.Visibility = Visibility.Hidden;
            }

            KeywordBack.Width = _windowSize.Width / 4 - 20;
            curKeywords.Text = "";

            bool b = false;
            foreach (String s in currentImage.keywords)
            {
                if (b)
                    curKeywords.Text += ",";
                else
                    b = true;
                curKeywords.Text += s;
            }
            curKeywords.UpdateLayout();
            curInfoCol.UpdateLayout();
            RowDefinition height = new RowDefinition();
            GridLength height1 = new GridLength(curKeywords.ActualHeight);
            height.Height = height1;
            curInfoCol.RowDefinitions.Add(height);
            KeywordBack.Height = KeywordsTitle.ActualHeight * 3 + curKeywords.ActualHeight;
            curInfoCol.UpdateLayout();
            infoScroll.UpdateLayout();

            curInfoCol.Height = titleBack.ActualHeight + artist.ActualHeight + date.ActualHeight + medium.ActualHeight + KeywordBack.ActualHeight;

            if (curInfoCol.Height > _windowSize.Height / 3 - 50)
            {
                curInfoContainer.Height = _windowSize.Height / 3;
                infoScroll.Height = _windowSize.Height / 3 - 50;
                title.MaxWidth = _windowSize.Width / 4 - 80;
                title.UpdateLayout();
                titleBack.Height = title.ActualHeight + 5;
                curKeywords.MaxWidth = _windowSize.Width / 4 - 80;
                curKeywords.UpdateLayout();
                KeywordBack.Height = KeywordsTitle.ActualHeight * 3 + curKeywords.ActualHeight;
                curInfoCol.Height = title.ActualHeight + 5 + artist.ActualHeight +
                    date.ActualHeight + medium.ActualHeight + KeywordsTitle.ActualHeight * 3 + curKeywords.ActualHeight;
            }
            else
            {
                curInfoContainer.Height = curInfoCol.Height + 50;
                infoScroll.Height = curInfoCol.Height + 50;
                title.MaxWidth = _windowSize.Width / 4 - 40;
                curKeywords.MaxWidth = _windowSize.Width / 4 - 40;
            }
        }
Пример #4
0
 //x, y are percentage (your u, v)
 public newMapButton(double x, double y, int type, ImageData img)
 {
     _x = x;
     _y = y;
     _type = type;
     _canvas = new Canvas();
     Canvas.SetZIndex(_canvas, -1);
     _ellipse = new Ellipse();
     switch (type)
     {
         case 0:
             _ellipse.Fill = Brushes.Red;
             break;
         case 1:
             _ellipse.Fill = Brushes.Blue;
             break;
         case 2:
             _ellipse.Fill = Brushes.Yellow;
             break;
         default:
             _ellipse.Fill = Brushes.White;
             break;
     }
     _ellipse.StrokeThickness = 0;
     _ellipse.Width = 20;
     _ellipse.Height = 20;
     _canvas.Children.Add(_ellipse);
     _canvas.Visibility = Visibility.Collapsed;
     _imageData = img;
 }
Пример #5
0
        //This method is called when the user select a new image
        public void HandleImageSelectedEvent(Object sender, Helpers.ImageSelectedEventArgs e)
        {
            data = e.getImage();
            this.hideButtons();
            infoLabel.Text = "";
            // infoLabel1.Text = "";
            List<String> locInfo = e.getImage().getLocButtonInfo();

            foreach (String info in locInfo)
            {
                this.createButtons(info);
            }
        }
Пример #6
0
 public void ShowButton(ImageData img)
 {
     currentImage = img;
     foreach (MapButton b in _mapbuttons)
     {
         if (b.ImageData.Equals(img)) b.canvas.Visibility=Visibility.Visible;
     }
 }
Пример #7
0
 public bool addToSubdiv(int x, int y, ImageData img)
 {
     int xPrime = (int)(x / ((BitmapImage)RegionImage.Source).Width / RegionImage.Width);
     int yPrime = (int)(y / ((BitmapImage)RegionImage.Source).Height / RegionImage.Height);
     mapColor c = TryZoomHitHelper(xPrime, yPrime);
     if (c.a < 0) return false;
     else
     {
         foreach (InternalRegion r in _regions)
         {
             if (r.TestColor(c))
             {
                 r.AddArt(img);
                 break;
             }
         }
         return true;
     }
 }
Пример #8
0
 public void AddArt(ImageData art)
 {
     artworks.Add(art);
 }
Пример #9
0
 public ImageSelectedEventArgs(ImageData i)
 {
     data = i;
 }
Пример #10
0
 public ImageLoadedEventArgs(ImageData i)
 {
     data = i;
 }