private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            var m          = (ContextMenu)Resources["ImageCtxMenu"];
            var rawOptions = new RawOptions
            {
                Owner       = this,
                DataContext = m.DataContext
            };

            rawOptions.ShowDialog();
        }
Beispiel #2
0
        public void ImportFiles(MainWindow sender, string[] strs, FolderWrapper folder)
        {
            Model.Types.RawOptions overrideOptions = null;

            foreach (var str in strs)
            {
                var f = new FileInfo(str);
                if (!f.Exists)
                {
                    MessageBox.Show(sender, $"File does not exist.\r\n{str}", "RAW Import Error");
                    continue;                     // Doesn't exist
                }

                var rawExts = Resources.RawExts.Split('|')[1].Replace("*", "").Split(';');

                if (rawExts.Contains(f.Extension))
                {
                    // RAW!
                    var p = new Process
                    {
                        StartInfo = new ProcessStartInfo(".\\Exec\\dcraw.exe", $"-i \"{f.FullName}\"")
                        {
                            RedirectStandardOutput = true,
                            UseShellExecute        = false,
                            CreateNoWindow         = true
                        }
                    };

                    p.Start();
                    p.WaitForExit();

                    if (p.ExitCode != 0)
                    {
                        MessageBox.Show(sender, $"Cannot decode RAW file.\r\n{str}", "RAW Import Error");
                        continue;                         // Can't decode!
                    }

                    // RAW Import Options
                    if (overrideOptions == null)
                    {
                        p.StartInfo.Arguments = $"-i -v \"{f.FullName}\"";
                        p.Start();
                        var info = p.StandardOutput.ReadToEnd();



                        var x = new RawOptions {
                            Owner = sender, DataContext = new FileWrapper(f.FullName)
                            {
                                RawOptions = new Model.Types.RawOptions(info)
                            }
                        };
                        if (x.ShowDialog() == false)
                        {
                            continue;                                                  // Cancelled!
                        }
                        if (x.ApplyToAll)
                        {
                            overrideOptions = (x.DataContext as FileWrapper)?.RawOptions;
                        }
                        ((FileWrapper)x.DataContext).IsRaw = true;
                        folder.Files.Add(x.DataContext as FileWrapper);

                        x.Close();
                        continue;
                    }
                    folder.Files.Add(new FileWrapper(str)
                    {
                        RawOptions = BatchImageProcessor.Model.Utility.ObjectCopier.Clone(overrideOptions), IsRaw = true
                    });
                }
                else
                {
                    folder.AddFile(str);
                }
            }
        }