コード例 #1
0
        /// <summary>
        /// Regenerate stereogram using the same options (but with a dialog to allow you to change them, or there'd really be no point)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CmdRegenerateStereogramExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Stereogram src = e.Parameter as Stereogram;

            if (src == null || src.HasOptions == false)
            {
                throw new ArgumentException("Cannot regenerate stereogram");
            }

            Options saveOptions = new Options(src.options);

            DialogGenerateStereogram dialog = new DialogGenerateStereogram(saveOptions, theViewModel.GetDepthmaps(), theViewModel.GetTextures(), false);
            bool?ok = dialog.ShowDialog();

            if (ok != true)
            {
                return;
            }

            bool bSave = dialog.SaveStereogram;

            // Adopt the options from the dialog if they were accepted
            this.DataContext = null;
            Options          = saveOptions;
            this.DataContext = theViewModel;

            theViewModel.GenerateStereogram(saveOptions, stereogram => StereogramGeneratedCallback(stereogram, bSave));
        }
コード例 #2
0
        /// <summary>
        /// Geneate a stereogram using an option selection dialog (and optionally save it to a file)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CmdGenerateStereogramExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Options.texture  = (e.Parameter as Texture) ?? theViewModel.SelectedTexture;
            Options.depthmap = (e.Parameter as Depthmap) ?? theViewModel.SelectedDepthmap;

            Options saveOptions = new Options(Options);

            DialogGenerateStereogram dialog = new DialogGenerateStereogram(saveOptions, theViewModel.GetDepthmaps(), theViewModel.GetTextures(), false);
            bool?ok = dialog.ShowDialog();

            if (ok != true)
            {
                return;
            }

            bool bSave = dialog.SaveStereogram;

            // Adopt the options from the dialog if they were accepted
            this.DataContext = null;
            Options          = saveOptions;
            this.DataContext = theViewModel;

            theViewModel.GenerateStereogram(saveOptions, stereogram => StereogramGeneratedCallback(stereogram, bSave));
        }