Ejemplo n.º 1
0
        private void spaceKeyDown(object sender, KeyEventArgs e)
        {
            StackPanel sp  = (StackPanel)selectListBox.SelectedItem;
            Image      img = sp.Children[0] as Image;

            if (e.Key == Key.Space)
            {
                ImagePopUp imgPopUp = new ImagePopUp(selectListBox);
                imgPopUp.Owner = this;
                //StackPanel parent = (StackPanel) img.Parent;
                //int imgIndex = parent.Children.IndexOf(img);
                string childXaml = XamlWriter.Save(img);

                //Load it into a new object:
                StringReader stringReader = new StringReader(childXaml);
                XmlReader    xmlReader    = XmlReader.Create(stringReader);
                Image        clonedImage  = (Image)XamlReader.Load(xmlReader);
                //clonedImage.Stretch = Stretch.None;
                clonedImage.Height         = img.Source.Height;
                clonedImage.Width          = img.Source.Width;
                imgPopUp.photoWindow.Title = "Preview of " + System.IO.Path.GetFileName(img.Source.ToString());
                //if (clonedImage.Height < imgPopUp.Height)
                //{
                //    imgPopUp.photoScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
                //}
                //if (clonedImage.Width < imgPopUp.Width)
                //{
                //    imgPopUp.photoScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
                //}
                imgPopUp.Height = clonedImage.Height * 1.2;
                imgPopUp.Width  = clonedImage.Width * 1.2;
                imgPopUp.photoGrid.Children.Add(clonedImage);
                imgPopUp.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void spaceKeyDown(object sender, KeyEventArgs e)
        {
            StackPanel sp = (StackPanel)selectListBox.SelectedItem;
            Image img = sp.Children[0] as Image;
            if (e.Key == Key.Space)
            {
                ImagePopUp imgPopUp = new ImagePopUp(selectListBox);
                imgPopUp.Owner = this;
                //StackPanel parent = (StackPanel) img.Parent;
                //int imgIndex = parent.Children.IndexOf(img);
                string childXaml = XamlWriter.Save(img);

                //Load it into a new object:
                StringReader stringReader = new StringReader(childXaml);
                XmlReader xmlReader = XmlReader.Create(stringReader);
                Image clonedImage = (Image)XamlReader.Load(xmlReader);
                //clonedImage.Stretch = Stretch.None;
                clonedImage.Height = img.Source.Height;
                clonedImage.Width = img.Source.Width;
                imgPopUp.photoWindow.Title = "Preview of " + System.IO.Path.GetFileName(img.Source.ToString());
                //if (clonedImage.Height < imgPopUp.Height)
                //{
                //    imgPopUp.photoScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
                //}
                //if (clonedImage.Width < imgPopUp.Width)
                //{
                //    imgPopUp.photoScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
                //}
                imgPopUp.Height = clonedImage.Height * 1.2;
                imgPopUp.Width = clonedImage.Width * 1.2;
                imgPopUp.photoGrid.Children.Add(clonedImage);
                imgPopUp.ShowDialog();
            }
        }