Example #1
0
		public static void Save(IResourceNode[] nodes, bool useSubDirs, ResourceDataType resourceDataType) {
			if (nodes == null)
				return;

			var files = GetFiles(GetResourceData(nodes, resourceDataType), useSubDirs).ToArray();
			if (files.Length == 0)
				return;

			var data = new ProgressVM(MainWindow.Instance.Dispatcher, new ResourceSaver(files));
			var win = new ProgressDlg();
			win.DataContext = data;
			win.Owner = MainWindow.Instance;
			win.Title = files.Length == 1 ? "Save Resource" : "Save Resources";
			var res = win.ShowDialog();
			if (res != true)
				return;
			if (!data.WasError)
				return;
			MainWindow.Instance.ShowMessageBox(string.Format("An error occurred:\n\n{0}", data.ErrorMessage));
		}
Example #2
0
		internal static void Execute2(DnHexBox dnHexBox) {
			var doc = dnHexBox.Document;
			if (doc == null)
				return;
			var sel = dnHexBox.Selection;
			if (sel == null)
				return;

			var dialog = new WF.SaveFileDialog() {
				Filter = PickFilenameConstants.AnyFilenameFilter,
				RestoreDirectory = true,
				ValidateNames = true,
			};

			if (dialog.ShowDialog() != WF.DialogResult.OK)
				return;

			var data = new ProgressVM(MainWindow.Instance.Dispatcher, new HexDocumentDataSaver(doc, sel.Value.StartOffset, sel.Value.EndOffset, dialog.FileName));
			var win = new ProgressDlg();
			win.DataContext = data;
			win.Owner = MainWindow.Instance;
			win.Title = string.Format("Save Selection 0x{0:X}-0x{1:X}", sel.Value.StartOffset, sel.Value.EndOffset);
			var res = win.ShowDialog();
			if (res != true)
				return;
			if (!data.WasError)
				return;
			MainWindow.Instance.ShowMessageBox(string.Format("An error occurred:\n\n{0}", data.ErrorMessage));
		}