Skip to content

Commit 448f68a

Browse files
committed
日志将写到配置所在文件夹(通过CONFIG_HERE或者CONFIG_UP来指定),而非固定在程序目录下;修复了配置文件所在目录为程序目录时,关闭程序时出错的BUG;【地图画板】紧凑列表选项移动到视图选择同一行,减小占用面积
1 parent 1ac6938 commit 448f68a

File tree

6 files changed

+79
-40
lines changed

6 files changed

+79
-40
lines changed

MapBoard.Core/Parameters.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static Parameters()
2020
TileDownloadPath = "Download";
2121
BackupPath = "Backup";
2222
RecordsPath = "Record";
23+
LogsPath = "Logs";
2324
}
2425
else if (File.Exists(Path.Combine(appPath, ConfigUp)))
2526
{
@@ -29,6 +30,7 @@ static Parameters()
2930
TileDownloadPath = "../Download";
3031
BackupPath = "../Backup";
3132
RecordsPath = "../Record";
33+
LogsPath = "../Logs";
3234
}
3335
else
3436
{
@@ -39,6 +41,7 @@ static Parameters()
3941
TileDownloadPath = Path.Combine(folder, AppName, "Download");
4042
BackupPath = Path.Combine(folder, AppName, "Backup");
4143
RecordsPath = Path.Combine(folder, AppName, "Record");
44+
LogsPath = Path.Combine(folder, AppName, "Logs");
4245
}
4346
}
4447

@@ -58,6 +61,7 @@ static Parameters()
5861
public static readonly string TileDownloadPath;
5962
public static readonly string BackupPath;
6063
public static readonly string RecordsPath;
64+
public static readonly string LogsPath;
6165

6266
public static TimeSpan AnimationDuration { get; set; } = TimeSpan.FromSeconds(0.5);
6367
public static TimeSpan LoadTimeout { get; set; } = TimeSpan.FromSeconds(5);

MapBoard.UI/App.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Windows.Media;
1717
using MapBoard.UI.GpxToolbox;
1818
using MapBoard.UI.TileDownloader;
19+
using log4net.Appender;
1920

2021
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
2122

@@ -42,6 +43,18 @@ public App()
4243
private async void Application_Startup(object sender, StartupEventArgs e)
4344
{
4445
Log = LogManager.GetLogger(GetType());
46+
var h = (log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository();
47+
foreach (IAppender a in h.Root.Appenders)
48+
{
49+
if (a is FileAppender)
50+
{
51+
FileAppender fa = (FileAppender)a;
52+
fa.File = System.IO.Path.Combine(Parameters.LogsPath, "MapBoard.log");
53+
fa.ActivateOptions();
54+
break;
55+
}
56+
}
57+
4558
Log.Info("程序启动");
4659

4760
#if (DEBUG)

MapBoard.UI/Config.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,8 @@ public bool UseCompactLayerList
397397

398398
public void Save()
399399
{
400-
if (!Directory.Exists(Path.GetDirectoryName(path)))
400+
string dir = Path.GetDirectoryName(path);
401+
if (!string.IsNullOrWhiteSpace(dir)&& !Directory.Exists(dir))
401402
{
402403
Directory.CreateDirectory(Path.GetDirectoryName(path));
403404
}

MapBoard.UI/UI/LayerListPanel.xaml

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@
5151
</DataTemplate>
5252
</ItemsControl.ItemTemplate>
5353
</ItemsControl>
54-
<ui:ToggleSwitch
55-
IsOn="{Binding Source={x:Static m:Config.Instance}, Path=UseCompactLayerList}"
56-
OffContent="使用普通图层列表视图"
57-
OnContent="使用简略图层列表视图" />
54+
5855
</ui:SimpleStackPanel>
5956
</Border>
6057

@@ -216,17 +213,6 @@
216213
<RowDefinition Height="*" />
217214
</Grid.RowDefinitions>
218215
<ContentControl x:Name="groupContent" />
219-
<Button
220-
x:Name="btnGroups"
221-
Grid.Row="2"
222-
Margin="0,0,8,0"
223-
HorizontalAlignment="Right"
224-
Background="Transparent">
225-
<ui:FontIcon Glyph="&#xF168;" />
226-
<ui:FlyoutService.Flyout>
227-
<ui:Flyout x:Name="flyoutGroups" />
228-
</ui:FlyoutService.Flyout>
229-
</Button>
230216
<ListView
231217
x:Name="dataGrid"
232218
Grid.Row="4"
@@ -239,28 +225,55 @@
239225
ScrollViewer.CanContentScroll="False"
240226
SelectionChanged="SelectedLayerChanged"
241227
SelectionMode="Extended" />
242-
<ListView
243-
x:Name="lvwViewTypes"
228+
<Grid
244229
Grid.Row="2"
245-
HorizontalAlignment="Center"
246-
SelectedIndex="{Binding ViewType}">
247-
<ListView.ItemsPanel>
248-
<ItemsPanelTemplate>
249-
<WrapPanel
250-
VerticalAlignment="Top"
251-
Orientation="Horizontal" />
252-
</ItemsPanelTemplate>
253-
</ListView.ItemsPanel>
254-
<ListView.ItemContainerStyle>
255-
<Style
256-
BasedOn="{StaticResource DefaultListViewItemStyle}"
257-
TargetType="{x:Type ListViewItem}">
258-
<Setter Property="MinWidth" Value="10" />
259-
</Style>
260-
</ListView.ItemContainerStyle>
261-
<sys:String>顺序</sys:String>
262-
<sys:String>组别</sys:String>
263-
<sys:String>类型</sys:String>
264-
</ListView>
230+
Margin="4,0,0,0">
231+
<Grid.ColumnDefinitions>
232+
<ColumnDefinition Width="Auto" />
233+
<ColumnDefinition Width="*" />
234+
<ColumnDefinition Width="Auto" />
235+
<ColumnDefinition Width="8" />
236+
<ColumnDefinition Width="Auto" />
237+
</Grid.ColumnDefinitions>
238+
<ListView
239+
x:Name="lvwViewTypes"
240+
HorizontalAlignment="Left"
241+
SelectedIndex="{Binding ViewType}">
242+
<ListView.ItemsPanel>
243+
<ItemsPanelTemplate>
244+
<WrapPanel
245+
VerticalAlignment="Top"
246+
Orientation="Horizontal" />
247+
</ItemsPanelTemplate>
248+
</ListView.ItemsPanel>
249+
<ListView.ItemContainerStyle>
250+
<Style
251+
BasedOn="{StaticResource DefaultListViewItemStyle}"
252+
TargetType="{x:Type ListViewItem}">
253+
<Setter Property="MinWidth" Value="10" />
254+
</Style>
255+
</ListView.ItemContainerStyle>
256+
<sys:String>顺序</sys:String>
257+
<sys:String>组别</sys:String>
258+
<sys:String>类型</sys:String>
259+
</ListView>
260+
<CheckBox
261+
Grid.Column="2"
262+
Margin="0,0,-48,0"
263+
HorizontalAlignment="Right"
264+
Content="紧凑"
265+
FocusVisualStyle="{x:Null}"
266+
IsChecked="{Binding Source={x:Static m:Config.Instance}, Path=UseCompactLayerList}" />
267+
<Button
268+
x:Name="btnGroups"
269+
Grid.Column="4"
270+
Background="Transparent">
271+
<ui:FontIcon Glyph="&#xF168;" />
272+
<ui:FlyoutService.Flyout>
273+
<ui:Flyout x:Name="flyoutGroups" />
274+
</ui:FlyoutService.Flyout>
275+
</Button>
276+
277+
</Grid>
265278
</Grid>
266279
</local:UserControlBase>

MapBoard.UI/UI/LayerListPanel.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void SetListDataTemplate()
6666
private void UpdateLayout(double height)
6767
{
6868
var r = FindResource("bdGroups") as Border;
69-
if (height < 1050)
69+
if (height < 800)
7070
{
7171
lvwViewTypes.HorizontalAlignment = HorizontalAlignment.Left;
7272
btnGroups.Visibility = Visibility.Visible;

日志.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,4 +1640,12 @@ Url DataGrid修改为ListBox+文本框,方便修改
16401640

16411641
【地图画板】使用了更精确的缓冲区建立方式
16421642

1643-
【地图画板】支持对选中的图形新建缓冲区
1643+
【地图画板】支持对选中的图形新建缓冲区
1644+
1645+
## 20211214
1646+
1647+
日志将写到配置所在文件夹(通过CONFIG_HERE或者CONFIG_UP来指定),而非固定在程序目录下
1648+
1649+
修复了配置文件所在目录为程序目录时,关闭程序时出错的BUG
1650+
1651+
【地图画板】紧凑列表选项移动到视图选择同一行,减小占用面积

0 commit comments

Comments
 (0)