BililiveRecorder/BililiveRecorder.WPF/MainWindow.xaml
2018-12-11 00:57:40 +08:00

219 lines
13 KiB
XML

<Window x:Class="BililiveRecorder.WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:BililiveRecorder.WPF"
mc:Ignorable="d"
MinHeight="400" MinWidth="650"
Title="录播姬" Height="450" Width="800"
Loaded="Window_Loaded" Closing="Window_Closing" StateChanged="Window_StateChanged">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<DataTemplate x:Key="LogTemplate" >
<TextBlock Text="{Binding}" TextWrapping="Wrap" Cursor="Hand" MouseRightButtonUp="TextBlock_MouseRightButtonUp"/>
</DataTemplate>
<local:RecordStatusConverter x:Key="RSC"/>
</ResourceDictionary>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--<local:UpdateBarUserControl Grid.Row="0" x:Name="UpdateBar"/>-->
<tb:TaskbarIcon x:Name="NotifyIcon" Visibility="Collapsed" IconSource="/ico.ico" TrayLeftMouseUp="Taskbar_Click">
<tb:TaskbarIcon.TrayToolTip>
<Border BorderBrush="Black" BorderThickness="1" Background="White" CornerRadius="1">
<StackPanel Margin="5">
<TextBlock FontSize="14" Text="{Binding Title}"/>
<TextBlock FontSize="13" Text="{Binding Recorder.Config.WorkDirectory,Mode=OneWay}" Margin="0,0,0,7"/>
<ItemsControl ItemsSource="{Binding Recorder}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource RSC}" Mode="OneWay">
<Binding Path="IsMonitoring" Mode="OneWay"/>
<Binding Path="IsRecording" Mode="OneWay"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Text="{Binding DownloadSpeedPersentage,StringFormat=0.##%,Mode=OneWay}" Margin="5,0,0,0"/>
<TextBlock Margin="5,0" Text="{Binding RealRoomid,Mode=OneWay}"/>
<TextBlock Text="{Binding StreamerName,Mode=OneWay}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</tb:TaskbarIcon.TrayToolTip>
<tb:TaskbarIcon.ContextMenu>
<ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<!--<MenuItem IsCheckable="True">不弹出提醒</MenuItem>-->
<MenuItem Header="退出">
<MenuItem Header="确认退出" Click="Taskbar_Quit_Click"/>
</MenuItem>
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="7*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="RoomList" ItemsSource="{Binding Recorder}"
SelectionMode="Extended" SelectionUnit="FullRow"
CanUserAddRows="False" CanUserDeleteRows="False"
AutoGenerateColumns="False" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTemplateColumn Header="回放剪辑按钮">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Click="Clip_Click">剪辑</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Roomid,Mode=OneWay}" Header="房间号"/>
<DataGridTextColumn Binding="{Binding RealRoomid,Mode=OneWay}" Header="原房间号"/>
<DataGridTextColumn Binding="{Binding StreamerName,Mode=OneWay}" Header="主播名字"/>
<DataGridTextColumn Header="当前状态">
<DataGridTextColumn.Binding>
<MultiBinding Converter="{StaticResource RSC}" Mode="OneWay">
<Binding Path="IsMonitoring" Mode="OneWay"/>
<Binding Path="IsRecording" Mode="OneWay"/>
</MultiBinding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding DownloadSpeedKiBps,StringFormat=0.## KiB/s,Mode=OneWay}" Header="下载速度"/>
<DataGridTextColumn Binding="{Binding DownloadSpeedPersentage,StringFormat=0.## %,Mode=OneWay}" Header="速度百分比"/>
<DataGridTextColumn Binding="{Binding Processor.Clips.Count,Mode=OneWay}" Header="剪辑数量"/>
<!-- TODO: Fix Binding Memory Leak -->
</DataGrid.Columns>
</DataGrid>
<ItemsControl Grid.Row="1" Grid.RowSpan="2" x:Name="Log" ItemsSource="{Binding Logs}" ItemTemplate="{StaticResource LogTemplate}" ToolTip="右键点击可以复制单行日志">
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer x:Name="LogScroll" CanContentScroll="True">
<ItemsPresenter/>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsItemsHost="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Grid Grid.Column="1" DataContext="{Binding ElementName=RoomList,Path=SelectedItem}" Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="25"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">房间号:</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding Roomid,Mode=OneWay}"/>
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">原房间号:</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding RealRoomid,Mode=OneWay}"/>
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">主播名字:</TextBlock>
<TextBlock Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding StreamerName,Mode=OneWay}"/>
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">录制状态:</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" >
<TextBlock.Text>
<MultiBinding Converter="{StaticResource RSC}" Mode="OneWay">
<Binding Path="IsMonitoring" Mode="OneWay"/>
<Binding Path="IsRecording" Mode="OneWay"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">剪辑数量:</TextBlock>
<TextBlock Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding Processor.Clips.Count,Mode=OneWay}"/>
<!-- TODO: Fix Binding Memory Leak -->
<TextBlock Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">下载速度:</TextBlock>
<TextBlock Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding DownloadSpeedKiBps,StringFormat=0.## KiB/s,Mode=OneWay}"/>
<TextBlock Grid.Row="7" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">速度百分比:</TextBlock>
<TextBlock Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding DownloadSpeedPersentage,StringFormat=0.## %,Mode=OneWay}"/>
<Grid Grid.Row="9" Grid.ColumnSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="5,0" Click="EnableAutoRec">启用自动录制</Button>
<Button Grid.Column="1" Margin="5,0" Click="DisableAutoRec">禁用自动录制</Button>
<Button Grid.Row="1" Grid.Column="0" Margin="5" Click="TriggerRec">手动触发开始录制</Button>
<Button Grid.Row="1" Grid.Column="1" Margin="5" Click="CutRec">切断当前录制</Button>
<Button Grid.Row="2" Grid.ColumnSpan="2" Margin="5,0" Click="RemoveRecRoom">删除这个直播间</Button>
</Grid>
</Grid>
<Grid Grid.Column="1" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Margin="5,2" Grid.Column="0">添加直播间:</TextBlock>
<TextBox VerticalAlignment="Center" Margin="0,2" Grid.Column="1" x:Name="AddRoomidTextBox"/>
<Button VerticalAlignment="Center" Margin="5,2" Padding="10,0" Grid.Column="2" x:Name="AddRoomidButton" Click="AddRoomidButton_Click">添加</Button>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="5,2" Click="EnableAllAutoRec">启用所有直播间</Button>
<Button Grid.Column="1" Margin="5,2" Click="DisableAllAutoRec">禁用所有直播间</Button>
</Grid>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="SettingsButton" Click="SettingsButton_Click" Width="50" Margin="5" Content="设置" Grid.Column="1"/>
</Grid>
</Grid>
</Grid>
</Grid>
</Window>