internal void ShowOptions(SaveOptionsVM data) { if (data == null) return; var mvm = data as SaveModuleOptionsVM; if (mvm != null) { var win = new SaveModuleOptionsDlg(); win.Owner = this; var clone = mvm.Clone(); win.DataContext = clone; var res = win.ShowDialog(); if (res == true) { clone.CopyTo(mvm); ((SaveMultiModuleVM)DataContext).OnModuleSettingsSaved(); } return; } var hvm = data as SaveHexOptionsVM; if (hvm != null) { var win = new SaveHexOptionsDlg(); win.Owner = this; var clone = hvm.Clone(); win.DataContext = clone; var res = win.ShowDialog(); if (res == true) { clone.CopyTo(hvm); ((SaveMultiModuleVM)DataContext).OnModuleSettingsSaved(); } return; } throw new InvalidOperationException(); }
static double GetSize(SaveOptionsVM vm) { switch (vm.Type) { case SaveOptionsType.Module: return(((SaveModuleOptionsVM)vm).Module.Types.Count); case SaveOptionsType.Hex: var hex = (SaveHexOptionsVM)vm; ulong size = GetSize(hex.Buffer.Span.Start, hex.Buffer.Span.End); const double m = 1.0; const double sizediv = 10 * 1024 * 1024; return(m * (size / sizediv)); default: throw new InvalidOperationException(); } }
internal void ShowOptions(SaveOptionsVM data) { if (data == null) { return; } var mvm = data as SaveModuleOptionsVM; if (mvm != null) { var win = new SaveModuleOptionsDlg(); win.Owner = this; var clone = mvm.Clone(); win.DataContext = clone; var res = win.ShowDialog(); if (res == true) { clone.CopyTo(mvm); ((SaveMultiModuleVM)DataContext).OnModuleSettingsSaved(); } return; } var hvm = data as SaveHexOptionsVM; if (hvm != null) { var win = new SaveHexOptionsDlg(); win.Owner = this; var clone = hvm.Clone(); win.DataContext = clone; var res = win.ShowDialog(); if (res == true) { clone.CopyTo(hvm); ((SaveMultiModuleVM)DataContext).OnModuleSettingsSaved(); } return; } throw new InvalidOperationException(); }
void SaveAsync(SaveOptionsVM[] mods) { AppCulture.InitializeCulture(); try { moduleSaver = new ModuleSaver(mods); moduleSaver.OnProgressUpdated += moduleSaver_OnProgressUpdated; moduleSaver.OnLogMessage += moduleSaver_OnLogMessage; moduleSaver.OnWritingFile += moduleSaver_OnWritingFile; moduleSaver.SaveAll(); AsyncAddMessage(dnSpy_AsmEditor_Resources.SaveModules_Log_AllFilesWritten, false, false); } catch (TaskCanceledException) { AsyncAddMessage(dnSpy_AsmEditor_Resources.SaveModules_Log_SaveWasCanceled, true, false); } catch (UnauthorizedAccessException ex) { AsyncAddMessage(string.Format(dnSpy_AsmEditor_Resources.SaveModules_Log_AccessError, ex.Message), true, false); } catch (IOException ex) { AsyncAddMessage(string.Format(dnSpy_AsmEditor_Resources.SaveModules_Log_FileError, ex.Message), true, false); } catch (Exception ex) { AsyncAddMessage(string.Format(dnSpy_AsmEditor_Resources.SaveModules_Log_Exception, ex), true, false); } moduleSaver = null; ExecInOldThread(() => { CurrentFileName = string.Empty; State = SaveState.Saved; }); }
public SaveMultiModuleVM(IMmapDisabler mmapDisabler, Dispatcher dispatcher, SaveOptionsVM options) { this.mmapDisabler = mmapDisabler; this.dispatcher = dispatcher; this.modules.Add(options); }
public SaveMultiModuleVM(Dispatcher dispatcher, SaveOptionsVM options) { this.dispatcher = dispatcher; this.modules.Add(options); }
void SaveAsync(SaveOptionsVM[] mods) { try { moduleSaver = new ModuleSaver(mods); moduleSaver.OnProgressUpdated += moduleSaver_OnProgressUpdated; moduleSaver.OnLogMessage += moduleSaver_OnLogMessage; moduleSaver.OnWritingFile += moduleSaver_OnWritingFile; moduleSaver.SaveAll(); AsyncAddMessage("All files written to disk.", false, false); } catch (TaskCanceledException) { AsyncAddMessage("Save was canceled by user.", true, false); } catch (UnauthorizedAccessException ex) { AsyncAddMessage(string.Format("Access error: {0}", ex.Message), true, false); } catch (IOException ex) { AsyncAddMessage(string.Format("File error: {0}", ex.Message), true, false); } catch (Exception ex) { AsyncAddMessage(string.Format("An exception occurred\n\n{0}", ex), true, false); } moduleSaver = null; ExecInOldThread(() => { CurrentFileName = string.Empty; State = SaveState.Saved; }); }
public SaveMultiModuleVM(SaveOptionsVM options) { this.modules.Add(options); }
public SaveState(SaveOptionsVM vm) { this.File = vm; }
public ModuleSaverWriteEventArgs(SaveOptionsVM vm, bool starting) { this.File = vm; this.Starting = starting; }
static double GetSize(SaveOptionsVM vm) { switch (vm.Type) { case SaveOptionsType.Module: return ((SaveModuleOptionsVM)vm).Module.Types.Count; case SaveOptionsType.Hex: var hex = (SaveHexOptionsVM)vm; ulong size = GetSize(hex.Document.StartOffset, hex.Document.EndOffset); const double m = 1.0; const double sizediv = 10 * 1024 * 1024; return m * (size / sizediv); default: throw new InvalidOperationException(); } }
public ModuleSaverWriteEventArgs(SaveOptionsVM vm, bool starting) { File = vm; Starting = starting; }
public SaveState(SaveOptionsVM vm) => File = vm;