<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ProWindow and Modal Dialog not working with Progressor in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/prowindow-and-modal-dialog-not-working-with/m-p/1359596#M10844</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a pro window that is modal - it lists the maps in the project. You select a map and press ok.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_0-1702379750178.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88747i57631EF6D4E9E1EE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_0-1702379750178.png" alt="Vidar_0-1702379750178.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile there is QueuedTask that opens up the map, this can take some time so I use a progress dialog just so the user knows Pro is doing things.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_1-1702380552252.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88748iB10472984D53159B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_1-1702380552252.png" alt="Vidar_1-1702380552252.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However if I don't put a message box after it has opened the map, code execution continues and won't allow the user to select a file to save the json and just says "JSON file not saved".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I want to get rid of this!" style="width: 399px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88749i78BC501FAA78DD2B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_2-1702380651920.png" alt="I want to get rid of this!" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;I want to get rid of this!&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is really strange because the save file dialog is modal but its almost like the computer has automatically cancelled the dialog and continued execution on it's own accord. I though execution had to halt on a modal dialog.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If anyone can help me get rid of the unnecessary message box that would be great. Also an explanation to what stupid thing I'm doing wrong would be great. I have tried many things but I can't seem to solve it.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The code below should be able to be copy pasted behind a ribbon button in pro. However you may need some rudimentary XAML for the pro window. Just an ok button would do I guess.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; protected async override void OnClick()
 {
    var proWindowModal = new MapPaneChooserWindow
    {
        DataContext = new MapPaneChooserWindowVM(),
        Owner = FrameworkApplication.Current.MainWindow
    };

    var dialogResult = proWindowModal.ShowDialog();
    if (dialogResult == true)
    {
        ProgressorSource ps = new ProgressorSource("Opening map...");
		
		//This can take some time - so we use a progress dialog.
		chosenMap = await QueuedTask.Run(() =&amp;gt;
		{
			return Module1.MapPaneChooserWindowVM.SelectedMap.GetMap();
		}, ps.Progressor);
        
		//!!!! Forced to put a message box here or it will run automatically to "Layer collection not saved" section below !!!!
		//If you take this message box out of hte code - you will see the effect
        MessageBox.Show("Finished opening map.", "Map", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);

        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.Filter = "JSON files (*.json)|*.json";
        saveFileDialog.Title = "Save JSON File";

        var result = saveFileDialog.ShowDialog();

        if (result == true)
        {
            //do stuff about saving a json file here...
        }
        else
        {
            MessageBox.Show("JSON file not saved", "Save JSON file", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
        }
	}
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2023 11:32:21 GMT</pubDate>
    <dc:creator>Vidar</dc:creator>
    <dc:date>2023-12-12T11:32:21Z</dc:date>
    <item>
      <title>ProWindow and Modal Dialog not working with Progressor</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/prowindow-and-modal-dialog-not-working-with/m-p/1359596#M10844</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a pro window that is modal - it lists the maps in the project. You select a map and press ok.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_0-1702379750178.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88747i57631EF6D4E9E1EE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_0-1702379750178.png" alt="Vidar_0-1702379750178.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile there is QueuedTask that opens up the map, this can take some time so I use a progress dialog just so the user knows Pro is doing things.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_1-1702380552252.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88748iB10472984D53159B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_1-1702380552252.png" alt="Vidar_1-1702380552252.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However if I don't put a message box after it has opened the map, code execution continues and won't allow the user to select a file to save the json and just says "JSON file not saved".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I want to get rid of this!" style="width: 399px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88749i78BC501FAA78DD2B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_2-1702380651920.png" alt="I want to get rid of this!" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;I want to get rid of this!&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is really strange because the save file dialog is modal but its almost like the computer has automatically cancelled the dialog and continued execution on it's own accord. I though execution had to halt on a modal dialog.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If anyone can help me get rid of the unnecessary message box that would be great. Also an explanation to what stupid thing I'm doing wrong would be great. I have tried many things but I can't seem to solve it.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The code below should be able to be copy pasted behind a ribbon button in pro. However you may need some rudimentary XAML for the pro window. Just an ok button would do I guess.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; protected async override void OnClick()
 {
    var proWindowModal = new MapPaneChooserWindow
    {
        DataContext = new MapPaneChooserWindowVM(),
        Owner = FrameworkApplication.Current.MainWindow
    };

    var dialogResult = proWindowModal.ShowDialog();
    if (dialogResult == true)
    {
        ProgressorSource ps = new ProgressorSource("Opening map...");
		
		//This can take some time - so we use a progress dialog.
		chosenMap = await QueuedTask.Run(() =&amp;gt;
		{
			return Module1.MapPaneChooserWindowVM.SelectedMap.GetMap();
		}, ps.Progressor);
        
		//!!!! Forced to put a message box here or it will run automatically to "Layer collection not saved" section below !!!!
		//If you take this message box out of hte code - you will see the effect
        MessageBox.Show("Finished opening map.", "Map", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);

        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.Filter = "JSON files (*.json)|*.json";
        saveFileDialog.Title = "Save JSON File";

        var result = saveFileDialog.ShowDialog();

        if (result == true)
        {
            //do stuff about saving a json file here...
        }
        else
        {
            MessageBox.Show("JSON file not saved", "Save JSON file", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
        }
	}
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 11:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/prowindow-and-modal-dialog-not-working-with/m-p/1359596#M10844</guid>
      <dc:creator>Vidar</dc:creator>
      <dc:date>2023-12-12T11:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: ProWindow and Modal Dialog not working with Progressor</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/prowindow-and-modal-dialog-not-working-with/m-p/1359786#M10848</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would suggest you do not use Windows Forms SaveFileDialog in ArcGIS Pro. Use ArcGIS Pro SaveItemDialog:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;                var dlg = new SaveItemDialog();
                dlg.Title = "Save JSON File";
                dlg.OverwritePrompt = true;
                dlg.DefaultExt = "json";
                dlg.InitialLocation = @"C:\Temp";

                var fileFilter = BrowseProjectFilter.GetFilter("esri_browseDialogFilters_browseFiles");
                fileFilter.FileExtension = "json";//restrict to specific extensions as needed
                fileFilter.BrowsingFilesMode = false;

                //Specify a name to show in the filter dropdown combo box - otherwise the name
                //will show as "Default"
                fileFilter.Name = "(*.json)";
                dlg.BrowseFilter = fileFilter;

                bool? result = dlg.ShowDialog();&lt;/LI-CODE&gt;&lt;P&gt;With SaveItemDialog it works as you expected.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 17:10:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/prowindow-and-modal-dialog-not-working-with/m-p/1359786#M10848</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-12-12T17:10:43Z</dc:date>
    </item>
  </channel>
</rss>

