Пример #1
0
		/// <summary>
		/// Saves the nodes
		/// </summary>
		/// <param name="nodes">Nodes</param>
		/// <param name="useSubDirs">true to create sub directories, false to dump everything in the same folder</param>
		/// <param name="resourceDataType">Type of data to save</param>
		/// <param name="ownerWindow">Owner window</param>
		public static void Save(IResourceDataProvider[] nodes, bool useSubDirs, ResourceDataType resourceDataType, Window ownerWindow = null) {
			if (nodes == null)
				return;

			Tuple<ResourceData, string>[] files;
			try {
				files = GetFiles(GetResourceData(nodes, resourceDataType), useSubDirs).ToArray();
			}
			catch (Exception ex) {
				MsgBox.Instance.Show(ex);
				return;
			}
			if (files.Length == 0)
				return;

			var data = new ProgressVM(Dispatcher.CurrentDispatcher, new ResourceSaver(files));
			var win = new ProgressDlg();
			win.DataContext = data;
			win.Owner = ownerWindow ?? Application.Current.MainWindow;
			win.Title = files.Length == 1 ? dnSpy_Contracts_DnSpy_Resources.SaveResource : dnSpy_Contracts_DnSpy_Resources.SaveResources;
			var res = win.ShowDialog();
			if (res != true)
				return;
			if (!data.WasError)
				return;
			MsgBox.Instance.Show(string.Format(dnSpy_Contracts_DnSpy_Resources.AnErrorOccurred, data.ErrorMessage));
		}
Пример #2
0
		/// <summary>
		/// Shows a progress dialog box
		/// </summary>
		/// <param name="task">Task</param>
		/// <param name="title">Title</param>
		/// <param name="ownerWindow">Owner window</param>
		public static void Show(IProgressTask task, string title, Window ownerWindow) {
			var win = new ProgressDlg();
			var vm = new ProgressVM(System.Windows.Threading.Dispatcher.CurrentDispatcher, task);
			win.Owner = ownerWindow;
			win.DataContext = vm;
			win.Title = title;
			win.ShowDialog();
		}
Пример #3
0
        /// <summary>
        /// Shows a progress dialog box
        /// </summary>
        /// <param name="task">Task</param>
        /// <param name="title">Title</param>
        /// <param name="ownerWindow">Owner window</param>
        public static void Show(IProgressTask task, string title, Window ownerWindow)
        {
            var win = new ProgressDlg();
            var vm  = new ProgressVM(System.Windows.Threading.Dispatcher.CurrentDispatcher, task);

            win.Owner       = ownerWindow;
            win.DataContext = vm;
            win.Title       = title;
            win.ShowDialog();
        }
Пример #4
0
		public override void SaveSelection() {
			if (HexView.Selection.IsEmpty)
				return;

			var dialog = new WF.SaveFileDialog() {
				Filter = PickFilenameConstants.AnyFilenameFilter,
				RestoreDirectory = true,
				ValidateNames = true,
			};
			if (dialog.ShowDialog() != WF.DialogResult.OK)
				return;

			var selectionSpan = HexView.Selection.StreamSelectionSpan;
			var data = new ProgressVM(CurrentDispatcher, new HexBufferDataSaver(HexView.Buffer, selectionSpan, dialog.FileName));
			var win = new ProgressDlg();
			win.DataContext = data;
			win.Owner = OwnerWindow;
			var info = SelectionToUserValue(selectionSpan.Start, selectionSpan.End);
			win.Title = string.Format(dnSpy_Resources.HexEditorSaveSelection_Title, info.Anchor.ToUInt64(), info.Active.ToUInt64());
			var res = win.ShowDialog();
			if (res != true)
				return;
			if (!data.WasError)
				return;
			messageBoxService.Show(string.Format(dnSpy_Resources.AnErrorOccurred, data.ErrorMessage));
		}