예제 #1
0
        public void OpenInternal(string filename, bool newWindow)
        {
            MessageBoxService.SetOwner(Application.Current.MainWindow);

            if (newWindow)
            {
                Process.Start(Process.GetCurrentProcess().MainModule.FileName, filename);
                return;
            }

            CloseCommand.Execute(null);
            try {
                PEFile   = new PEFile(_stm = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), false);
                PEHeader = PEFile.Header;
                if (PEHeader == null)
                {
                    throw new InvalidOperationException("No PE header detected.");
                }
                FileName = Path.GetFileName(filename);
                PathName = filename;
                RaisePropertyChanged(nameof(Title));
                MapFile();

                BuildTree();
                RecentFiles.Remove(PathName);
                RecentFiles.Insert(0, PathName);
                if (RecentFiles.Count > 10)
                {
                    RecentFiles.RemoveAt(RecentFiles.Count - 1);
                }
            }
            catch (Exception ex) {
                MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName);
            }
        }