bool RunDialog (OpenFileDialogData data)
		{			
			Application.EnableVisualStyles ();
			
			FileDialog fileDlg = null;
			if (data.Action == Gtk.FileChooserAction.Open)
				fileDlg = new OpenFileDialog ();
			else
				fileDlg = new SaveFileDialog ();
			
			var dlg = new CustomOpenFileDialog (fileDlg, data);
				
			SelectFileDialogHandler.SetCommonFormProperties (data, dlg.FileDialog);
			
			using (dlg) {
				rootForm = new WinFormsRoot ();
				if (dlg.ShowDialog (rootForm) == DialogResult.Cancel) {
					return false;
				}
	
				FilePath[] paths = new FilePath [fileDlg.FileNames.Length];
				for (int n = 0; n < fileDlg.FileNames.Length; n++)	
					paths [n] = fileDlg.FileNames [n];
				data.SelectedFiles = paths;
				
				if (dlg.SelectedEncodingId != null)
					data.Encoding = dlg.SelectedEncodingId > 0 ? Encoding.GetEncoding (dlg.SelectedEncodingId) : null;
				if (dlg.SelectedViewer != null)
					data.SelectedViewer = dlg.SelectedViewer;
				
				data.CloseCurrentWorkspace = dlg.CloseCurrentWorkspace;
			}
			
			return true;
		}
Exemple #2
0
        bool RunDialog(OpenFileDialogData data)
        {
            Application.EnableVisualStyles();

            FileDialog fileDlg = null;

            if (data.Action == Gtk.FileChooserAction.Open)
            {
                fileDlg = new OpenFileDialog();
            }
            else
            {
                fileDlg = new SaveFileDialog();
            }

            var dlg = new CustomOpenFileDialog(fileDlg, data);

            SelectFileDialogHandler.SetCommonFormProperties(data, dlg.FileDialog);

            using (dlg)
            {
                rootForm = new WinFormsRoot();
                if (dlg.ShowDialog(rootForm) == DialogResult.Cancel)
                {
                    return(false);
                }

                FilePath[] paths = new FilePath [fileDlg.FileNames.Length];
                for (int n = 0; n < fileDlg.FileNames.Length; n++)
                {
                    paths [n] = fileDlg.FileNames [n];
                }
                data.SelectedFiles = paths;

                if (dlg.SelectedEncodingId != null)
                {
                    data.Encoding = dlg.SelectedEncodingId > 0 ? Encoding.GetEncoding(dlg.SelectedEncodingId) : null;
                }
                if (dlg.SelectedViewer != null)
                {
                    data.SelectedViewer = dlg.SelectedViewer;
                }

                data.CloseCurrentWorkspace = dlg.CloseCurrentWorkspace;
            }

            return(true);
        }
		public bool Run (OpenFileDialogData data)
		{			
			Application.EnableVisualStyles ();
			
			var parentWindow = data.TransientFor ?? MessageService.RootWindow;
			FileDialog fileDlg = null;
			if (data.Action == Gtk.FileChooserAction.Open)
				fileDlg = new OpenFileDialog ();
			else
				fileDlg = new SaveFileDialog ();
			
			var dlg = new CustomOpenFileDialog (fileDlg, data);
				
			SelectFileDialogHandler.SetCommonFormProperties (data, dlg.FileDialog);
			
			using (dlg) {
                if (dlg.ShowDialog () == DialogResult.Cancel) {
					parentWindow.Present ();
                    return false;
				}
	
				FilePath[] paths = new FilePath [fileDlg.FileNames.Length];
				for (int n = 0; n < fileDlg.FileNames.Length; n++)	
					paths [n] = fileDlg.FileNames [n];
				data.SelectedFiles = paths;
				
				if (dlg.SelectedEncodingId != null)
					data.Encoding = dlg.SelectedEncodingId;
				if (dlg.SelectedViewer != null)
					data.SelectedViewer = dlg.SelectedViewer;
				
				data.CloseCurrentWorkspace = dlg.CloseCurrentWorkspace;
			}
			
			parentWindow.Present ();
			return true;
		}