예제 #1
0
        private void ImageListBox_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Image item;
                var lstItem = sender as ListBox;
                var elem = lstItem.InputHitTest(e.GetPosition(lstItem)) as UIElement;

                while (elem != lstItem)
                {
                    if (elem is Image)
                    {
                        item = (Image)elem;

                        int id = int.Parse(item.Name.Replace(IMAGE_NAME_SUFFIX, ""));
                        var image = Articles.First(c => c.Images.FirstOrDefault(x => x.ImageId == id) != null).Images.First(c => c.ImageId == id);
                        ImageView view = new ImageView(image);
                        view.ShowDialog();
                        return;
                    }
                    elem = (UIElement)VisualTreeHelper.GetParent(elem);
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, "Ошибка", MessageBoxImage.Error);
            }
        }
예제 #2
0
        private void ImageListBox_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Image item;
                var lstItem = sender as ListBox;
                var elem = lstItem.InputHitTest(e.GetPosition(lstItem)) as UIElement;

                while (elem != lstItem)
                {
                    if (elem is Image)
                    {
                        item = (Image)elem;

                        var image = new BusinessObjects.Domain.Image()
                        {
                            Name = item.Name,
                            Data = JustHelper.GetJpgFromImageControl(item.Source as BitmapImage)
                        };
                        var view = new ImageView(image);
                        view.ShowDialog();
                        return;
                    }
                    elem = (UIElement)VisualTreeHelper.GetParent(elem);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK,MessageBoxImage.Error);
            }
        }