Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
		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;
			});
		}
Beispiel #5
0
		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);
 }
Beispiel #7
0
		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;
			});
		}
Beispiel #8
0
		public SaveMultiModuleVM(Dispatcher dispatcher, SaveOptionsVM options) {
			this.dispatcher = dispatcher;
			this.modules.Add(options);
		}
Beispiel #9
0
 public SaveMultiModuleVM(SaveOptionsVM options)
 {
     this.modules.Add(options);
 }
Beispiel #10
0
			public SaveState(SaveOptionsVM vm) {
				this.File = vm;
			}
Beispiel #11
0
		public ModuleSaverWriteEventArgs(SaveOptionsVM vm, bool starting) {
			this.File = vm;
			this.Starting = starting;
		}
Beispiel #12
0
		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();
			}
		}
Beispiel #13
0
 public SaveState(SaveOptionsVM vm)
 {
     this.File = vm;
 }
Beispiel #14
0
 public SaveMultiModuleVM(IMmapDisabler mmapDisabler, Dispatcher dispatcher, SaveOptionsVM options)
 {
     this.mmapDisabler = mmapDisabler;
     this.dispatcher   = dispatcher;
     this.modules.Add(options);
 }
Beispiel #15
0
 public ModuleSaverWriteEventArgs(SaveOptionsVM vm, bool starting)
 {
     File     = vm;
     Starting = starting;
 }
Beispiel #16
0
 public SaveState(SaveOptionsVM vm) => File = vm;
Beispiel #17
0
 public SaveMultiModuleVM(SaveOptionsVM options)
 {
     this.modules.Add(options);
 }