// Full-screen view public void CmdFullscreenExecuted(object sender, ExecutedRoutedEventArgs e) { if (e.Parameter is BitmapType || e.Parameter is Thumbnail) { BitmapType target = (BitmapType)e.Parameter; PreviewPane restore = PreviewPane; FullscreenView fsview = new FullscreenView(target, () => PreviewPane = restore); fsview.Show(); PreviewPane = fsview.previewFullScreen; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { // Set the default directories for each resource type string basepath = Environment.CurrentDirectory; basepath = basepath.Replace("\\bin\\Debug", ""); basepath = basepath.Replace("\\bin\\Release", ""); // Check for the existence of the license file FileInfo licensefile = new FileInfo(System.IO.Path.Combine(basepath, "license.txt")); if (licensefile.Exists) { license = System.IO.File.ReadAllLines(licensefile.FullName); // Pop up the about box on first run... clicking OK constitutes acceptance if (Properties.Settings.Default.LicenseAccepted == false) { AboutBox box = new AboutBox(license); box.ShowDialog(); Properties.Settings.Default.LicenseAccepted = true; } } else { MessageBox.Show("License not found!"); Close(); return; } // Restore resource directories or set to defaults string imagepath = System.IO.Path.Combine(basepath, "Images"); if (Properties.Settings.Default.DepthmapPath != null && Properties.Settings.Default.DepthmapPath.Length > 0 && Directory.Exists(Properties.Settings.Default.DepthmapPath)) { theViewModel.DepthmapPalette.sDefaultDirectory = Properties.Settings.Default.DepthmapPath; } else { theViewModel.DepthmapPalette.sDefaultDirectory = System.IO.Path.Combine(imagepath, "Depthmaps"); } if (Properties.Settings.Default.TexturePath != null && Properties.Settings.Default.TexturePath.Length > 0 && Directory.Exists(Properties.Settings.Default.TexturePath)) { theViewModel.TexturePalette.sDefaultDirectory = Properties.Settings.Default.TexturePath; } else { theViewModel.TexturePalette.sDefaultDirectory = System.IO.Path.Combine(imagepath, "Textures"); } if (Properties.Settings.Default.SterogramPath != null && Properties.Settings.Default.SterogramPath.Length > 0 && Directory.Exists(Properties.Settings.Default.SterogramPath)) { theViewModel.StereogramPalette.sDefaultDirectory = Properties.Settings.Default.SterogramPath; } else { theViewModel.StereogramPalette.sDefaultDirectory = System.IO.Path.Combine(imagepath, "Stereograms"); } // Default preview pane is in the main panel PreviewPane = previewMainPanel; // Register callbacks to handle events in the view model theViewModel.OnPaletteSelected += tabControlPalette_PaletteSelected; theViewModel.OnPreviewItemChanged += new Action <object>(item => SetPreviewItem(item)); theViewModel.OnErrorMessage += new Action <string>(message => MessageBox.Show(message, "Error")); // Populate the view model with initial items try { theViewModel.Populate(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error populating resources"); } // Try to restore selected items... will only work if they were saved to file (and the file still exists) if (Properties.Settings.Default.SelectedDepthmap != null && Properties.Settings.Default.SelectedDepthmap.Length > 0) { Thumbnail dm = theViewModel.DepthmapPalette.FindByFilename(Properties.Settings.Default.SelectedDepthmap); if (dm != null && dm.ThumbnailOf is Depthmap) { theViewModel.DepthmapPalette.SelectItem(dm); } } if (Properties.Settings.Default.SelectedTexture != null && Properties.Settings.Default.SelectedTexture.Length > 0) { Thumbnail tx = theViewModel.TexturePalette.FindByFilename(Properties.Settings.Default.SelectedTexture); if (tx != null && tx.ThumbnailOf is Texture) { theViewModel.TexturePalette.SelectItem(tx); } } if (Properties.Settings.Default.SelectedStereogram != null && Properties.Settings.Default.SelectedStereogram.Length > 0) { Thumbnail sg = theViewModel.StereogramPalette.FindByFilename(Properties.Settings.Default.SelectedStereogram); if (sg != null && sg.ThumbnailOf is Stereogram) { theViewModel.StereogramPalette.SelectItem(sg); } } // Show the selected depthmap by default theViewModel.PreviewItem = theViewModel.SelectedDepthmap; // Register the progress bar as a progress reporter theViewModel.RegisterProgressReporter(progress => { progressBar.Value = (progress / 100) * progressBar.Maximum; } , () => { progressBar.Visibility = Visibility.Visible; } , () => { progressBar.Visibility = Visibility.Hidden; }); } catch (Exception ex) { MessageBox.Show(String.Format("Failed to initialise - {0}", ex.Message)); Close(); } }