Esempio n. 1
0
        public bool Save(IEnumerable <object> docs)
        {
            var objsAry = Distinct(docs).ToArray();

            if (objsAry.Length == 0)
            {
                return(true);
            }

            if (objsAry.Length == 1)
            {
                SaveOptionsVM options;

                if (objsAry[0] is IDsDocument document)
                {
                    var optsData = new SaveModuleOptionsVM(document);
                    var optsWin  = new SaveModuleOptionsDlg();
                    optsWin.Owner       = appWindow.MainWindow;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                    {
                        return(false);
                    }
                    options = optsData;
                }
                else
                {
                    var buffer = objsAry[0] as HexBuffer;
                    Debug.Assert(!(buffer is null));
                    var optsData = new SaveHexOptionsVM(buffer);
                    var optsWin  = new SaveHexOptionsDlg();
                    optsWin.Owner       = appWindow.MainWindow;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                    {
                        return(false);
                    }
                    options = optsData;
                }

                var data = new SaveMultiModuleVM(mmapDisabler.Value, Dispatcher.CurrentDispatcher, options);
                var win  = new SaveSingleModuleDlg();
                win.Owner       = appWindow.MainWindow;
                win.DataContext = data;
                data.Save();
                win.ShowDialog();
                return(MarkAsSaved(data, objsAry));
            }
            else
            {
                var data = new SaveMultiModuleVM(mmapDisabler.Value, Dispatcher.CurrentDispatcher, objsAry);
                var win  = new SaveMultiModuleDlg();
                win.Owner       = appWindow.MainWindow;
                win.DataContext = data;
                win.ShowDialog();
                return(MarkAsSaved(data, objsAry));
            }
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        /// <summary>
        /// Saves all asms/hex docs and returns true if all of them were saved to disk
        /// </summary>
        /// <param name="objs">All objects to save</param>
        /// <returns></returns>
        public static bool SaveAssemblies(IEnumerable <IUndoObject> objs)
        {
            var objsAry = objs.ToArray();

            if (objsAry.Length == 0)
            {
                return(true);
            }

            if (objsAry.Length == 1)
            {
                SaveOptionsVM options;

                var asm = objsAry[0] as LoadedAssembly;
                if (asm != null)
                {
                    var optsData = new SaveModuleOptionsVM(asm);
                    var optsWin  = new SaveModuleOptionsDlg();
                    optsWin.Owner       = MainWindow.Instance;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                    {
                        return(false);
                    }
                    options = optsData;
                }
                else
                {
                    var doc      = (AsmEdHexDocument)objsAry[0];
                    var optsData = new SaveHexOptionsVM(doc);
                    var optsWin  = new SaveHexOptionsDlg();
                    optsWin.Owner       = MainWindow.Instance;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                    {
                        return(false);
                    }
                    options = optsData;
                }

                var data = new SaveMultiModuleVM(MainWindow.Instance.Dispatcher, options);
                var win  = new SaveSingleModuleDlg();
                win.Owner       = MainWindow.Instance;
                win.DataContext = data;
                data.Save();
                win.ShowDialog();
                return(MarkAsSaved(data, objsAry));
            }
            else
            {
                var data = new SaveMultiModuleVM(MainWindow.Instance.Dispatcher, objsAry);
                var win  = new SaveMultiModuleDlg();
                win.Owner       = MainWindow.Instance;
                win.DataContext = data;
                win.ShowDialog();
                return(MarkAsSaved(data, objsAry));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Saves all asms/hex docs and returns true if all of them were saved to disk
        /// </summary>
        /// <param name="objs">All objects to save</param>
        /// <returns></returns>
        public static bool SaveAssemblies(IEnumerable<IUndoObject> objs)
        {
            var objsAry = objs.ToArray();
            if (objsAry.Length == 0)
                return true;

            if (objsAry.Length == 1) {
                SaveOptionsVM options;

                var asm = objsAry[0] as LoadedAssembly;
                if (asm != null) {
                    var optsData = new SaveModuleOptionsVM(asm);
                    var optsWin = new SaveModuleOptionsDlg();
                    optsWin.Owner = MainWindow.Instance;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                        return false;
                    options = optsData;
                }
                else {
                    var doc = (AsmEdHexDocument)objsAry[0];
                    var optsData = new SaveHexOptionsVM(doc);
                    var optsWin = new SaveHexOptionsDlg();
                    optsWin.Owner = MainWindow.Instance;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                        return false;
                    options = optsData;
                }

                var data = new SaveMultiModuleVM(options);
                var win = new SaveSingleModuleDlg();
                win.Owner = MainWindow.Instance;
                win.DataContext = data;
                data.Save();
                win.ShowDialog();
                return MarkAsSaved(data, objsAry);
            }
            else {
                var data = new SaveMultiModuleVM(objsAry);
                var win = new SaveMultiModuleDlg();
                win.Owner = MainWindow.Instance;
                win.DataContext = data;
                win.ShowDialog();
                return MarkAsSaved(data, objsAry);
            }
        }
Esempio n. 5
0
		public bool Save(IEnumerable<object> docs) {
			var objsAry = Distinct(docs).ToArray();
			if (objsAry.Length == 0)
				return true;

			if (objsAry.Length == 1) {
				SaveOptionsVM options;

				var document = objsAry[0] as IDsDocument;
				if (document != null) {
					var optsData = new SaveModuleOptionsVM(document);
					var optsWin = new SaveModuleOptionsDlg();
					optsWin.Owner = appWindow.MainWindow;
					optsWin.DataContext = optsData;
					var res = optsWin.ShowDialog();
					if (res != true)
						return false;
					options = optsData;
				}
				else {
					var buffer = objsAry[0] as HexBuffer;
					Debug.Assert(buffer != null);
					var optsData = new SaveHexOptionsVM(buffer);
					var optsWin = new SaveHexOptionsDlg();
					optsWin.Owner = appWindow.MainWindow;
					optsWin.DataContext = optsData;
					var res = optsWin.ShowDialog();
					if (res != true)
						return false;
					options = optsData;
				}

				var data = new SaveMultiModuleVM(mmapDisabler.Value, Dispatcher.CurrentDispatcher, options);
				var win = new SaveSingleModuleDlg();
				win.Owner = appWindow.MainWindow;
				win.DataContext = data;
				data.Save();
				win.ShowDialog();
				return MarkAsSaved(data, objsAry);
			}
			else {
				var data = new SaveMultiModuleVM(mmapDisabler.Value, Dispatcher.CurrentDispatcher, objsAry);
				var win = new SaveMultiModuleDlg();
				win.Owner = appWindow.MainWindow;
				win.DataContext = data;
				win.ShowDialog();
				return MarkAsSaved(data, objsAry);
			}
		}
Esempio n. 6
0
		/// <summary>
		/// Saves all asms/hex docs and returns true if all of them were saved to disk
		/// </summary>
		/// <param name="objs">All objects to save</param>
		/// <returns></returns>
		public static bool SaveAssemblies(IEnumerable<IUndoObject> objs) {
			var objsAry = objs.ToArray();
			if (objsAry.Length == 0)
				return true;

			if (objsAry.Length == 1) {
				SaveOptionsVM options;

				var file = UndoCommandManager.Instance.TryGetDnSpyFile(objsAry[0]);
				if (file != null) {
					var optsData = new SaveModuleOptionsVM(file);
					var optsWin = new SaveModuleOptionsDlg();
					optsWin.Owner = MainWindow.Instance;
					optsWin.DataContext = optsData;
					var res = optsWin.ShowDialog();
					if (res != true)
						return false;
					options = optsData;
				}
				else {
					var doc = UndoCommandManager.Instance.TryGetAsmEdHexDocument(objsAry[0]);
					Debug.Assert(doc != null);
					var optsData = new SaveHexOptionsVM(doc);
					var optsWin = new SaveHexOptionsDlg();
					optsWin.Owner = MainWindow.Instance;
					optsWin.DataContext = optsData;
					var res = optsWin.ShowDialog();
					if (res != true)
						return false;
					options = optsData;
				}

				var data = new SaveMultiModuleVM(MainWindow.Instance.Dispatcher, options);
				var win = new SaveSingleModuleDlg();
				win.Owner = MainWindow.Instance;
				win.DataContext = data;
				data.Save();
				win.ShowDialog();
				return MarkAsSaved(data, objsAry);
			}
			else {
				var data = new SaveMultiModuleVM(MainWindow.Instance.Dispatcher, objsAry);
				var win = new SaveMultiModuleDlg();
				win.Owner = MainWindow.Instance;
				win.DataContext = data;
				win.ShowDialog();
				return MarkAsSaved(data, objsAry);
			}
		}
Esempio n. 7
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();
        }
Esempio n. 8
0
        /// <summary>
        /// Saves all asms/hex docs and returns true if all of them were saved to disk
        /// </summary>
        /// <param name="objs">All objects to save</param>
        /// <returns></returns>
        public static bool SaveAssemblies(IEnumerable <IUndoObject> objs)
        {
            var objsAry = objs.ToArray();

            if (objsAry.Length == 0)
            {
                return(true);
            }

            if (objsAry.Length == 1)
            {
                SaveOptionsVM options;

                var file = UndoCommandManager.Instance.TryGetDnSpyFile(objsAry[0]);
                if (file != null)
                {
                    var optsData = new SaveModuleOptionsVM(file);
                    var optsWin  = new SaveModuleOptionsDlg();
                    optsWin.Owner       = MainWindow.Instance;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                    {
                        return(false);
                    }
                    options = optsData;
                }
                else
                {
                    var doc = UndoCommandManager.Instance.TryGetAsmEdHexDocument(objsAry[0]);
                    Debug.Assert(doc != null);
                    var optsData = new SaveHexOptionsVM(doc);
                    var optsWin  = new SaveHexOptionsDlg();
                    optsWin.Owner       = MainWindow.Instance;
                    optsWin.DataContext = optsData;
                    var res = optsWin.ShowDialog();
                    if (res != true)
                    {
                        return(false);
                    }
                    options = optsData;
                }

                var data = new SaveMultiModuleVM(MainWindow.Instance.Dispatcher, options);
                var win  = new SaveSingleModuleDlg();
                win.Owner       = MainWindow.Instance;
                win.DataContext = data;
                data.Save();
                win.ShowDialog();
                return(MarkAsSaved(data, objsAry));
            }
            else
            {
                var data = new SaveMultiModuleVM(MainWindow.Instance.Dispatcher, objsAry);
                var win  = new SaveMultiModuleDlg();
                win.Owner       = MainWindow.Instance;
                win.DataContext = data;
                win.ShowDialog();
                return(MarkAsSaved(data, objsAry));
            }
        }