public void Attach(IOpenAsDialog dlg) { this.dlg = dlg; dlg.Load += dlg_Load; dlg.BrowseButton.Click += BrowseButton_Click; dlg.AddressTextBox.TextChanged += AddressTextBox_TextChanged; }
public bool OpenBinaryAs(string initialFilename) { IOpenAsDialog dlg = null; try { dlg = dlgFactory.CreateOpenAsDialog(initialFilename); if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(false); } string fileName = dlg.FileName.Text; LoadDetails details = dlg.GetLoadDetails(); CloseProject(); SwitchInteractor(InitialPageInteractor); pageInitial.OpenBinaryAs(fileName, details); if (fileName.EndsWith(Project_v5.FileExtension)) { ProjectFileName = fileName; } } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the file {0}.", dlg.FileName.Text)); } return(true); }
public void Attach(IOpenAsDialog dlg) { this.dlg = dlg; dlg.Load += dlg_Load; dlg.BrowseButton.Click += BrowseButton_Click; dlg.AddressTextBox.TextChanged += AddressTextBox_TextChanged; }
public bool OpenBinaryAs() { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; Platform platform = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.Services = sc; if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(true); } mru.Use(dlg.FileName.Text); var archOption = (ListOption)dlg.Architectures.SelectedValue; Type t = Type.GetType((string)archOption.Value, true); arch = (IProcessorArchitecture)Activator.CreateInstance(t); arch.Description = archOption.Text; var envOption = (ListOption)dlg.Platforms.SelectedValue; t = Type.GetType((string)envOption.Value); if (t == null) { throw new TypeLoadException(string.Format("Unable to load type {0}.", envOption.Value)); } platform = (Platform)Activator.CreateInstance(t, sc, arch); platform.Description = envOption.Text; Address addrBase; var sAddr = dlg.AddressTextBox.Text.Trim(); if (!arch.TryParseAddress(sAddr, out addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", sAddr)); } OpenBinary(dlg.FileName.Text, (f) => pageInitial.OpenBinaryAs( f, arch, platform, addrBase, this)); } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the binary file {0}.", dlg.FileName.Text)); } return(true); }
public void Attach(IOpenAsDialog dlg) { this.dlg = dlg; dlg.Load += dlg_Load; dlg.BrowseButton.Click += BrowseButton_Click; dlg.AddressTextBox.TextChanged += AddressTextBox_TextChanged; dlg.RawFileTypes.TextChanged += RawFileTypes_TextChanged; dlg.Architectures.TextChanged += Architectures_TextChanged; dlg.AddressTextBox.GotFocus += AddressTextBox_GotFocus; dlg.RawFileTypes.GotFocus += RawFileTypes_GotFocus; dlg.Platforms.GotFocus += Platforms_GotFocus; dlg.Architectures.GotFocus += Architectures_GotFocus; }
private void Given_Dialog() { dlg = mr.DynamicMock <IOpenAsDialog>(); var btnBrowse = mr.Stub <IButton>(); var btnOk = mr.Stub <IButton>(); var txtAddress = mr.Stub <ITextBox>(); var fileName = mr.Stub <ITextBox>(); dlg.Stub(d => d.AddressTextBox).Return(txtAddress); dlg.Stub(d => d.Services).Return(sc); dlg.Stub(d => d.FileName).Return(fileName); dlg.Stub(d => d.BrowseButton).Return(btnBrowse); dlg.Stub(d => d.OkButton).Return(btnOk); }
private LoadDetails?ShowOpenBinaryAsDialog(string file) { var uiSvc = Services.RequireService <IDecompilerShellUiService>(); var dlgFactory = Services.RequireService <IDialogFactory>(); using (IOpenAsDialog dlg = dlgFactory.CreateOpenAsDialog(file)) { if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK) { return(dlg.GetLoadDetails()); } else { return(null); } } }
public bool OpenBinaryAs(string initialFilename) { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.FileName.Text = initialFilename; dlg.Services = sc; dlg.ArchitectureOptions = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(false); } var rawFileOption = (ListOption)dlg.RawFileTypes.SelectedValue; string archName = null; string envName = null; string sAddr = null; string loader = null; EntryPointDefinition entry = null; if (rawFileOption != null && rawFileOption.Value != null) { var raw = (RawFileDefinition)rawFileOption.Value; loader = raw.Loader; archName = raw.Architecture; envName = raw.Environment; sAddr = raw.BaseAddress; entry = raw.EntryPoint; } ArchitectureDefinition archOption = dlg.GetSelectedArchitecture(); PlatformDefinition envOption = dlg.GetSelectedEnvironment(); archName = archName ?? archOption?.Name; envName = envName ?? envOption?.Name; sAddr = sAddr ?? dlg.AddressTextBox.Text.Trim(); arch = config.GetArchitecture(archName); if (arch == null) { throw new InvalidOperationException(string.Format("Unable to load {0} architecture.", archName)); } arch.LoadUserOptions(dlg.ArchitectureOptions); if (!arch.TryParseAddress(sAddr, out var addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", sAddr)); } var details = new LoadDetails { LoaderName = loader, ArchitectureName = archName, ArchitectureOptions = dlg.ArchitectureOptions, PlatformName = envName, LoadAddress = sAddr, EntryPoint = entry, }; OpenBinary(dlg.FileName.Text, (f) => pageInitial.OpenBinaryAs(f, details), f => false); } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the binary file {0}.", dlg.FileName.Text)); } return(true); }
public bool OpenBinaryAs() { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.Services = sc; if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(true); } var rawFileOption = (ListOption)dlg.RawFileTypes.SelectedValue; string archName = null; string envName = null; string sAddr = null; string loader = null; EntryPointElement entry = null; if (rawFileOption != null && rawFileOption.Value != null) { RawFileElement raw = null; raw = (RawFileElement)rawFileOption.Value; loader = raw.Loader; archName = raw.Architecture; envName = raw.Environment; sAddr = raw.BaseAddress; entry = raw.EntryPoint; } archName = archName ?? (string)((ListOption)dlg.Architectures.SelectedValue).Value; var envOption = (OperatingEnvironment)((ListOption)dlg.Platforms.SelectedValue).Value; envName = envName ?? (envOption != null? envOption.Name : null); sAddr = sAddr ?? dlg.AddressTextBox.Text.Trim(); arch = config.GetArchitecture(archName); if (arch == null) { throw new InvalidOperationException(string.Format("Unable to load {0} architecture.", archName)); } Address addrBase; if (!arch.TryParseAddress(sAddr, out addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", sAddr)); } var details = new LoadDetails { LoaderName = loader, ArchitectureName = archName, PlatformName = envName, LoadAddress = sAddr, EntryPoint = entry, }; OpenBinary(dlg.FileName.Text, (f) => pageInitial.OpenBinaryAs( f, details)); } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the binary file {0}.", dlg.FileName.Text)); } return(true); }
private void Given_Dialog() { dlg = mr.DynamicMock<IOpenAsDialog>(); var btnBrowse = mr.Stub<IButton>(); var btnOk = mr.Stub<IButton>(); var txtAddress = mr.Stub<ITextBox>(); var fileName = mr.Stub<ITextBox>(); dlg.Stub(d => d.AddressTextBox).Return(txtAddress); dlg.Stub(d => d.Services).Return(sc); dlg.Stub(d => d.FileName).Return(fileName); dlg.Stub(d => d.BrowseButton).Return(btnBrowse); dlg.Stub(d => d.OkButton).Return(btnOk); }