修改日志显示

This commit is contained in:
zxd 2018-09-07 10:36:30 +08:00
parent 5b194cb7bf
commit 80aa891a33
6 changed files with 62 additions and 14 deletions

View File

@ -28,8 +28,18 @@
<Setter Property="Margin" <Setter Property="Margin"
Value="0,10" /> Value="0,10" />
</Style> </Style>
<ContextMenu x:Key="LogMenu" >
<MenuItem Header="清除"
Command="{Binding ClearLogs}" Foreground="White"/>
</ContextMenu>
</c:MetroWindow.Resources> </c:MetroWindow.Resources>
<c:MetroWindow.RightWindowCommands> <c:MetroWindow.RightWindowCommands>
<c:WindowCommands> <c:WindowCommands>
<Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}" <Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}"
@ -49,7 +59,8 @@
Visibility="{Binding Source={x:Static local:AppEx.Current}, Path=AppMode, Converter={StaticResource AppModeToVisibilityConverter}, ConverterParameter=SwitchToControllingCoptersModeButton}" />--> Visibility="{Binding Source={x:Static local:AppEx.Current}, Path=AppMode, Converter={StaticResource AppModeToVisibilityConverter}, ConverterParameter=SwitchToControllingCoptersModeButton}" />-->
<Button Name="btnShowLog" <Button Name="btnShowLog"
Content="日志" Content="日志"
Click="btnShowLog_Click" /> Click="btnShowLog_Click"
Visibility="Collapsed"/>
<Button Name="btnGoHome" <Button Name="btnGoHome"
Content="回家" Content="回家"
Click="btnGoHome_Click" /> Click="btnGoHome_Click" />
@ -171,11 +182,21 @@
Background="{StaticResource HighlightBrush}"> Background="{StaticResource HighlightBrush}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Margin="4" <TextBlock Margin="4"
Text="{Binding Message}"/> Text="{Binding Message}" MouseUp="LogShowHide"/>
<TextBlock Margin="4" <TextBlock Margin="4"
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" /> Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
</StackPanel> </StackPanel>
</Border> </Border>
<TextBox Name="logTextBox" Height="700" Width="600" Background="#FF2D2D2D"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Visibility="Hidden"
Text="{Binding Logs}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TextChanged="LogTextChange"
IsReadOnly="True"
TextWrapping="Wrap"
ContextMenu="{StaticResource LogMenu}"/>
</Grid> </Grid>
</c:MetroWindow> </c:MetroWindow>

View File

@ -483,6 +483,17 @@ namespace Plane.FormationCreator
logWindows.Show(); logWindows.Show();
} }
private void LogShowHide(object sender, MouseButtonEventArgs e)
{
if (logTextBox.Visibility == Visibility.Visible)
logTextBox.Visibility = Visibility.Hidden;
else
logTextBox.Visibility = Visibility.Visible;
}
private void LogTextChange(object sender, TextChangedEventArgs e)
{
logTextBox.ScrollToEnd();
}
} }
} }

View File

@ -335,12 +335,6 @@
<ItemGroup> <ItemGroup>
<Resource Include="bg.jpg" /> <Resource Include="bg.jpg" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="tiane.bmp" />
</ItemGroup>
<ItemGroup>
<Resource Include="tiane.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -134,9 +134,9 @@ namespace Plane.FormationCreator.ViewModels
var center = _mapManager.Center; var center = _mapManager.Center;
string id; string id;
int colnum = 20; //自动生成列数=4 int colnum = 5; //自动生成列数=4
float coldis = 2.5f;//列相距5米 float coldis = 3.5f;//列相距5米
float rowdis = 5f;//行相距5米 float rowdis = 3f;//行相距5米
int currcol = 0; //当前列号 int currcol = 0; //当前列号
int currrow = 0; //当前行 int currrow = 0; //当前行
Tuple<double, double> colheadLatLng = new Tuple<double, double>(0, 0); Tuple<double, double> colheadLatLng = new Tuple<double, double>(0, 0);

View File

@ -59,16 +59,25 @@ namespace Plane.FormationCreator.ViewModels
set set
{ {
Set(nameof(Message), ref _Message, value); Set(nameof(Message), ref _Message, value);
_MessageList.Add(value); Logs += (Environment.NewLine + value);
} }
} }
private List<string> _MessageList = new List<string>(); private List<string> _MessageList = new List<string>();
public string Messages public string Messages
{ {
get { return string.Join("\r\n", _MessageList.ToArray()); } get { return string.Join("\r\n", _MessageList.ToArray()); }
} }
private string _Logs = "----------软件日志----------";
public string Logs
{
get { return _Logs; }
set { Set(nameof(Logs), ref _Logs, value); }
}
private ICommand _RestartListeningCommand; private ICommand _RestartListeningCommand;
public ICommand RestartListeningCommand public ICommand RestartListeningCommand
{ {
@ -211,6 +220,18 @@ namespace Plane.FormationCreator.ViewModels
} }
} }
private ICommand _ClearLogs;
public ICommand ClearLogs
{
get
{
return _ClearLogs ?? (_ClearLogs = new RelayCommand(() =>
{
Logs = "";
}));
}
}
private string GetSwitchVelocityModeButtonContent() private string GetSwitchVelocityModeButtonContent()
=> AppEx.Current.IsInFastMode ? "高速模式" : "低速模式"; => AppEx.Current.IsInFastMode ? "高速模式" : "低速模式";
} }

View File

@ -9,6 +9,7 @@
mc:Ignorable="d" mc:Ignorable="d"
Style="{StaticResource VSWindowStyleKey}" Style="{StaticResource VSWindowStyleKey}"
Title="日志" Height="776.219" Width="1195.283"> Title="日志" Height="776.219" Width="1195.283">
<Grid> <Grid>
<TabControl> <TabControl>
<TabItem Header="软件日志"> <TabItem Header="软件日志">