Ejemplo n.º 1
0
        void Open()
        {
            var openDlg = new OpenFileDialog {
                Filter           = DotNetAssemblyOrModuleFilter,
                RestoreDirectory = true,
                Multiselect      = true,
            };

            if (openDlg.ShowDialog() != true)
            {
                return;
            }
            OpenFilesHelper.OpenFiles(fileTreeView, appWindow.MainWindow, openDlg.FileNames);
        }
Ejemplo n.º 2
0
        void HandleAppArgs(IAppCommandLineArgs appArgs)
        {
            if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
            {
                WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);
            }

            var decompiler = GetDecompiler(appArgs.Language);

            if (decompiler != null)
            {
                decompilerManager.Value.Decompiler = decompiler;
            }

            if (appArgs.FullScreen != null)
            {
                appWindow.MainWindow.IsFullScreen = appArgs.FullScreen.Value;
            }

            if (appArgs.NewTab)
            {
                fileTabManager.Value.OpenEmptyTab();
            }

            var files = appArgs.Filenames.ToArray();

            if (files.Length > 0)
            {
                OpenFilesHelper.OpenFiles(fileTabManager.Value.FileTreeView, appWindow.MainWindow, files, false);
            }

            // The files were lazily added to the treeview. Make sure they've been added to the TV
            // before we process the remaining command line args.
            if (files.Length > 0)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => HandleAppArgs2(appArgs)));
            }
            else
            {
                HandleAppArgs2(appArgs);
            }
        }
Ejemplo n.º 3
0
        public OpenFilesResult OpenFiles(OpenFilesRequest request)
        {
            if (request == null)
            {
                const string message = "The open files request cannot be null.";
                Platform.Log(LogLevel.Debug, message);
                throw new FaultException(message);
            }

            if (request.Files == null || request.Files.Count == 0)
            {
                const string message = "At least one file or directory must be specified.";
                Platform.Log(LogLevel.Debug, message);
                throw new FaultException(message);
            }

            var helper = new OpenFilesHelper();

            try
            {
                foreach (var file in request.Files)
                {
                    FileProcessor.Process(file, null, helper.AddFile, true);
                }
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e);
                const string message = "There was a problem with the files/directories specified.";
                throw new FaultException <OpenFilesFault>(new OpenFilesFault {
                    FailureDescription = message
                }, message);
            }

            if (request.WaitForFilesToOpen.HasValue && !request.WaitForFilesToOpen.Value)
            {
                SynchronizationContext.Current.Post(ignore => helper.OpenFiles(), null);
                return(new OpenFilesResult());
            }

            try
            {
                helper.HandleErrors = false;
                var viewer   = helper.OpenFiles();
                var viewerId = ViewerAutomationTool.GetViewerId(viewer);
                return(new OpenFilesResult {
                    Viewer = new Viewer(viewerId.Value, GetPrimaryStudyIdentifier(viewer))
                });
            }
            catch (Exception e)
            {
                if (!request.ReportFaultToUser.HasValue || request.ReportFaultToUser.Value)
                {
                    SynchronizationContext.Current.Post(
                        ignore => ExceptionHandler.Report(e, ImageViewer.StudyManagement.SR.MessageFailedToOpenImages, Application.ActiveDesktopWindow), null);
                }

                const string message = "There was a problem opening the files/directories specified in the viewer.";
                throw new FaultException <OpenFilesFault>(new OpenFilesFault {
                    FailureDescription = message
                }, message);
            }
        }