Skip to content

Commit b4e2696

Browse files
committed
将所有的文件对话框设置了父窗口,避免弹出的对话框在其他窗口之上的BUG
1 parent 448f68a commit b4e2696

File tree

12 files changed

+51
-18
lines changed

12 files changed

+51
-18
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.cs]
2+
3+
# CS0168: 声明了变量,但从未使用过
4+
dotnet_diagnostic.CS0168.severity = none

MapBoard.Core/Mapping/Model/LayerInfo/WfsMapLayerInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public WfsMapLayerInfo(string name, string url, string layerName, bool autoPopul
3939
Fields = null;
4040
}
4141

42+
#pragma warning disable CS1998 // 异步方法缺少 "await" 运算符,将以同步方式运行
4243
public async override Task ChangeNameAsync(string newName, Esri.ArcGISRuntime.Mapping.LayerCollection layers)
44+
#pragma warning restore CS1998 // 异步方法缺少 "await" 运算符,将以同步方式运行
4345
{
4446
Name = newName;
4547
}

MapBoard.UI/MapBoard.UI.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<Install>false</Install>
8181
</BootstrapperPackage>
8282
</ItemGroup>
83+
<ItemGroup>
84+
<None Include="..\.editorconfig" Link=".editorconfig" />
85+
</ItemGroup>
8386
<ItemGroup>
8487
<Resource Include="icon.png">
8588
<CopyToOutputDirectory>Never</CopyToOutputDirectory>

MapBoard.UI/UI/Bar/SelectionBar.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ private async Task ExportBase(FileFilterCollection filter, Func<string, Task> ta
480480
{
481481
string path = filter.CreateSaveFileDialog()
482482
.SetDefault(MapView.Selection.SelectedFeatures.Count + "个图形")
483+
.SetParent(Window.GetWindow(this))
483484
.GetFilePath();
484485
if (path != null)
485486
{

MapBoard.UI/UI/Dialog/SettingDialog.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ private void AddFileButtonClick(object sender, RoutedEventArgs e)
218218
.Add("TilePackage切片包", "tpk")
219219
.AddUnion()
220220
.CreateOpenFileDialog()
221+
.SetParent(this)
221222
.GetFilePath();
222223
if (path == null)
223224
{
@@ -245,6 +246,7 @@ private void ExportButton_Click(object sender, RoutedEventArgs e)
245246
string path = new FileFilterCollection().Add("MapBoard配置文件", "mbconfig")
246247
.CreateSaveFileDialog()
247248
.SetDefault("地图画板配置", null, "mbconfig")
249+
.SetParent(this)
248250
.GetFilePath();
249251
if (path != null)
250252
{
@@ -254,7 +256,11 @@ private void ExportButton_Click(object sender, RoutedEventArgs e)
254256

255257
private async void ImportButton_Click(object sender, RoutedEventArgs e)
256258
{
257-
string path = new FileFilterCollection().Add("MapBoard配置文件", "mbconfig").CreateOpenFileDialog().GetFilePath();
259+
string path = new FileFilterCollection()
260+
.Add("MapBoard配置文件", "mbconfig")
261+
.CreateOpenFileDialog()
262+
.SetParent(this)
263+
.GetFilePath();
258264
if (path != null)
259265
{
260266
try

MapBoard.UI/UI/GpxToolbox/GpxWindow.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,12 @@ private async void SpeedButtonClick(object sender, RoutedEventArgs e)
401401

402402
private async void SaveFileButtonClick(object sender, RoutedEventArgs e)
403403
{
404-
string path = new FileFilterCollection().Add("GPX轨迹文件", "gpx").CreateSaveFileDialog().SetDefault(Gpx.Name + ".gpx").GetFilePath();
404+
string path = new FileFilterCollection()
405+
.Add("GPX轨迹文件", "gpx")
406+
.CreateSaveFileDialog()
407+
.SetDefault(Gpx.Name + ".gpx")
408+
.SetParent(this)
409+
.GetFilePath();
405410
if (path != null)
406411
{
407412
try
@@ -612,6 +617,7 @@ private async void LinkTrackMenuClick(object sender, RoutedEventArgs e)
612617
new FileFilterCollection().Add("GPX轨迹文件", "gpx")
613618
.CreateSaveFileDialog()
614619
.SetDefault(tracks[0].FileName + " - 连接.gpx")
620+
.SetParent(this)
615621
.GetFilePath();
616622

617623
if (filePath != null)
@@ -761,6 +767,7 @@ private async void CaptureScreenButtonClick(object sender, RoutedEventArgs e)
761767
string path = new FileFilterCollection().Add("PNG图片", "png")
762768
.CreateSaveFileDialog()
763769
.SetDefault(Gpx.Name + ".png")
770+
.SetParent(this)
764771
.GetFilePath();
765772
if (path != null)
766773
{

MapBoard.UI/UI/IOUtility.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ public static FileFilterCollection AddIf(this FileFilterCollection filter, bool
4141
return filter;
4242
}
4343

44-
public static string GetImportFeaturePath(ImportLayerType type)
44+
public static string GetImportFeaturePath(ImportLayerType type,Window parentWindow)
4545
{
4646
return new FileFilterCollection()
4747
.AddIf(type == ImportLayerType.Gpx, "GPS轨迹文件", "gpx")
4848
.AddIf(type == ImportLayerType.Csv, "CSV表格", "csv")
4949
.CreateOpenFileDialog()
50+
.SetParent(parentWindow)
5051
.GetFilePath();
5152
}
5253

@@ -87,7 +88,7 @@ public async static Task ImportFeatureAsync(Window owner, string path, IEditable
8788
}
8889
}
8990

90-
public static string GetExportLayerPath(ILayerInfo layer, ExportLayerType type)
91+
public static string GetExportLayerPath(ILayerInfo layer, ExportLayerType type,Window parentWindow)
9192
{
9293
return new FileFilterCollection()
9394
.AddIf(type == ExportLayerType.LayerPackge, "地图画板图层包", "mblpkg")
@@ -97,6 +98,7 @@ public static string GetExportLayerPath(ILayerInfo layer, ExportLayerType type)
9798
.AddIf(type == ExportLayerType.GeoJSON, "GeoJSON文件", "geojson")
9899
.CreateSaveFileDialog()
99100
.SetDefault(layer.Name)
101+
.SetParent(parentWindow)
100102
.GetFilePath();
101103
}
102104

@@ -145,7 +147,7 @@ public async static Task ExportLayerAsync(Window owner, string path, IMapLayerIn
145147
}
146148
}
147149

148-
public static string GetImportMapPath(ImportMapType type)
150+
public static string GetImportMapPath(ImportMapType type, Window parentWindow)
149151
{
150152
return new FileFilterCollection()
151153
.AddIf(type == ImportMapType.MapPackageOverwrite, "地图画板地图包", "mbmpkg")
@@ -155,6 +157,7 @@ public static string GetImportMapPath(ImportMapType type)
155157
.AddIf(type == ImportMapType.Shapefile, "Shapefile", "shp")
156158
.AddIf(type == ImportMapType.CSV, "CSV表格", "csv")
157159
.CreateOpenFileDialog()
160+
.SetParent(parentWindow)
158161
.GetFilePath();
159162
}
160163

@@ -216,7 +219,7 @@ public async static Task ImportMapAsync(Window owner, string path, MapLayerColle
216219
}
217220
}
218221

219-
public static string GetExportMapPath(ExportMapType type)
222+
public static string GetExportMapPath(ExportMapType type, Window parentWindow)
220223
{
221224
return new FileFilterCollection()
222225
.AddIf(type == ExportMapType.MapPackage, "地图画板地图包", "mbmpkg")
@@ -226,6 +229,7 @@ public static string GetExportMapPath(ExportMapType type)
226229
.AddIf(type == ExportMapType.Screenshot, "截图", "png")
227230
.CreateSaveFileDialog()
228231
.SetDefault("地图画板 - " + DateTime.Now.ToString("yyyyMMdd-HHmmss"))
232+
.SetParent(parentWindow)
229233
.GetFilePath();
230234
}
231235

MapBoard.UI/UI/LayerListPanelHelper.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,43 +102,43 @@ public void ShowContextMenu()
102102
|| layer.GeometryType == GeometryType.Multipoint)
103103
{
104104
AddToMenu(menuImport, "GPX轨迹文件",
105-
() => IOUtility.GetImportFeaturePath(ImportLayerType.Gpx),
105+
() => IOUtility.GetImportFeaturePath(ImportLayerType.Gpx,MainWindow),
106106
p => IOUtility.ImportFeatureAsync(MainWindow, p, e, MapView, ImportLayerType.Gpx),
107107
"正在导入GPX轨迹文件");
108108
}
109109

110110
AddToMenu(menuImport, "CSV文件",
111-
() => IOUtility.GetImportFeaturePath(ImportLayerType.Csv),
111+
() => IOUtility.GetImportFeaturePath(ImportLayerType.Csv, MainWindow),
112112
p => IOUtility.ImportFeatureAsync(MainWindow, p, e, MapView, ImportLayerType.Csv),
113113
"正在导入CSV文件");
114114
}
115115
var menuExport = new MenuItem() { Header = "导出" };
116116
menu.Items.Add(menuExport);
117117

118118
AddToMenu(menuExport, "图层包",
119-
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.LayerPackge),
119+
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.LayerPackge,MainWindow),
120120
p => IOUtility.ExportLayerAsync(MainWindow, p, layer, MapView.Layers, ExportLayerType.LayerPackge),
121121
"正在导出图层包");
122122
if (Config.Instance.CopyShpFileWhenExport)
123123
{
124124
AddToMenu(menuExport, "图层包(重建)",
125-
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.LayerPackgeRebuild),
125+
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.LayerPackgeRebuild, MainWindow),
126126
p => IOUtility.ExportLayerAsync(MainWindow, p, layer, MapView.Layers, ExportLayerType.LayerPackgeRebuild),
127127
"正在导出图层包");
128128
}
129129
if (layer is ShapefileMapLayerInfo)
130130
{
131131
AddToMenu(menuExport, "GPS工具箱图层包",
132-
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.GISToolBoxZip),
132+
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.GISToolBoxZip, MainWindow),
133133
p => IOUtility.ExportLayerAsync(MainWindow, p, layer, MapView.Layers, ExportLayerType.GISToolBoxZip),
134134
"正在导出GPS工具箱图层包");
135135
}
136136
AddToMenu(menuExport, "KML打包文件",
137-
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.KML),
137+
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.KML, MainWindow),
138138
p => IOUtility.ExportLayerAsync(MainWindow, p, layer, MapView.Layers, ExportLayerType.KML),
139139
"正在导出KML打包文件");
140140
AddToMenu(menuExport, "GeoJSON文件",
141-
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.GeoJSON),
141+
() => IOUtility.GetExportLayerPath(layer, ExportLayerType.GeoJSON, MainWindow),
142142
p => IOUtility.ExportLayerAsync(MainWindow, p, layer, MapView.Layers, ExportLayerType.GeoJSON),
143143
"正在导出GeoJSON文件");
144144
}

MapBoard.UI/UI/MainWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ private async void ExportMenu_Click(object sender, RoutedEventArgs e)
470470
return;
471471
}
472472
canClosing = false; ExportMapType type = (ExportMapType)int.Parse((sender as FrameworkElement).Tag as string);
473-
string path = IOUtility.GetExportMapPath(type);
473+
string path = IOUtility.GetExportMapPath(type,this);
474474
if (path != null)
475475
{
476476
await DoAsync(async () =>
@@ -499,7 +499,7 @@ private void ExportButton_Click(object sender, SplitButtonClickEventArgs e)
499499
private async void ImportMenu_Click(object sender, RoutedEventArgs e)
500500
{
501501
var type = (ImportMapType)int.Parse((sender as FrameworkElement).Tag as string);
502-
string path = IOUtility.GetImportMapPath(type);
502+
string path = IOUtility.GetImportMapPath(type,this);
503503
if (path != null)
504504
{
505505
await DoAsync(async p =>

MapBoard.UI/UI/TileDownloader/TileDownloaderWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ private async void SaveButtonClick(object sender, RoutedEventArgs e)
516516
.Add(Config.Tile_FormatExtension + "图片", Config.Tile_FormatExtension)
517517
.CreateSaveFileDialog()
518518
.SetDefault("地图." + Config.Tile_FormatExtension)
519+
.SetParent(this)
519520
.GetFilePath();
520521
if (file != null)
521522
{

地图画板.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.28803.452
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31919.166
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapBoard.UI", "MapBoard.UI\MapBoard.UI.csproj", "{F45A258E-E3BE-4870-A1FB-F725EF30A852}"
77
EndProject
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案文件", "解
1010
.gitignore = .gitignore
1111
README.md = README.md
1212
日志.md = 日志.md
13+
.editorconfig = .editorconfig
1314
EndProjectSection
1415
EndProject
1516
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{416B6C02-20D7-406F-AB79-7701722B4848}"

日志.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,4 +1648,8 @@ Url DataGrid修改为ListBox+文本框,方便修改
16481648

16491649
修复了配置文件所在目录为程序目录时,关闭程序时出错的BUG
16501650

1651-
【地图画板】紧凑列表选项移动到视图选择同一行,减小占用面积
1651+
【地图画板】紧凑列表选项移动到视图选择同一行,减小占用面积
1652+
1653+
## 20211219
1654+
1655+
将所有的文件对话框设置了父窗口,避免弹出的对话框在其他窗口之上的BUG

0 commit comments

Comments
 (0)