Ejemplo 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));
            }
        }
Ejemplo n.º 2
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));
            }
        }
Ejemplo 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(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);
            }
        }
Ejemplo n.º 4
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);
			}
		}
Ejemplo n.º 5
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);
			}
		}
Ejemplo 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));
            }
        }