예제 #1
0
        /// <summary>
        /// Handles the <see cref="Control.MouseDoubleClick"/> event for a <see
        /// cref="ListViewItem"/> of the "Image File" <see cref="ListView"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="MouseButtonEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnFileActivate</b> shows an error message if the <see cref="ImageFile.Bitmap"/>
        /// property of the double-clicked item in the "Image File" list view is a null reference.
        /// </para><para>
        /// Otherwise, <b>OnFileActivate</b> displays an independent form containing a <see
        /// cref="ScrollViewer"/> that shows the image file bitmap.</para></remarks>

        private void OnFileActivate(object sender, MouseButtonEventArgs args)
        {
            args.Handled = true;

            // retrieve double-clicked item, if any
            var source = args.OriginalSource as DependencyObject;
            var item   = ItemsControl.ContainerFromElement(FileList, source) as ListViewItem;

            if (item == null)
            {
                return;
            }

            // retrieve corresponding image file, if any
            ImageFile file = item.Content as ImageFile;

            if (file == null)
            {
                return;
            }

            // abort if no image file bitmap present
            if (file.Bitmap == null)
            {
                string message = String.Format(ApplicationInfo.Culture,
                                               Global.Strings.DialogImageError, file.Path);

                MessageBox.Show(MainWindow.Instance, message,
                                Global.Strings.TitleImageError, MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            Window window = null;

            try {
                // show image file bitmap in separate window
                window       = new ShowImage(file.Bitmap);
                window.Title = file.Path;
                window.Icon  = MainWindow.Instance.Icon;
                window.Show();
            }
            catch (Exception e) {
                string message = String.Format(ApplicationInfo.Culture,
                                               Global.Strings.DialogImageError, file.Path);

                MessageDialog.Show(MainWindow.Instance, message,
                                   Global.Strings.TitleImageError, e, MessageBoxButton.OK, Images.Error);

                if (window != null)
                {
                    window.Close();
                }
            }
        }
예제 #2
0
 protected void ShowImage(Texture img)
 {
     whiteboardImage.SetTexture(img);
     whiteboardText.Hide();
     whiteboardImage.Show();
 }