|
| 1 | +<ci:MyWindow x:Class="MetadataEditor.Views.MetadataEditorWindow" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 5 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 6 | + xmlns:local="clr-namespace:MetadataEditor.Views" |
| 7 | + xmlns:ci="http://classisland.tech/schemas/xaml/core" |
| 8 | + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" |
| 9 | + xmlns:converters="clr-namespace:MetadataEditor.Converters" |
| 10 | + xmlns:announcement="clr-namespace:ClassIsland.Core.Models.Metadata.Announcement;assembly=ClassIsland.Core" |
| 11 | + mc:Ignorable="d" |
| 12 | + Title="MetadataEditorWindow" Height="750" Width="1400" |
| 13 | + TextElement.Foreground="{DynamicResource MaterialDesignBody}" |
| 14 | + Background="{DynamicResource MaterialDesignPaper}" |
| 15 | + FontFamily="{StaticResource HarmonyOsSans}" |
| 16 | + TextElement.FontWeight="Regular" |
| 17 | + TextElement.FontSize="14" |
| 18 | + TextOptions.TextFormattingMode="Ideal" |
| 19 | + TextOptions.TextRenderingMode="Auto" |
| 20 | + Closing="MetadataEditorWindow_OnClosing" |
| 21 | + DataContext="{Binding RelativeSource={RelativeSource Self}}"> |
| 22 | + <ci:MyWindow.Resources> |
| 23 | + <converters:SeverityToIntConverter x:Key="SeverityToIntConverter" /> |
| 24 | + |
| 25 | + <converters:StorageScopeToIntConverter x:Key="StorageScopeToIntConverter" /> |
| 26 | + <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> |
| 27 | + <DataTemplate DataType="{x:Type announcement:Announcement}"> |
| 28 | + <ScrollViewer> |
| 29 | + <StackPanel Margin="6"> |
| 30 | + <TextBox Text="{Binding Summary}" |
| 31 | + TextWrapping="Wrap" |
| 32 | + AcceptsReturn="True" |
| 33 | + Style="{StaticResource MaterialDesignOutlinedTextBox}" |
| 34 | + materialDesign:HintAssist.Hint="摘要" |
| 35 | + materialDesign:TextFieldAssist.CharacterCounterVisibility="Visible" |
| 36 | + Margin="0 0 0 6"/> |
| 37 | + <Grid> |
| 38 | + <Grid.ColumnDefinitions> |
| 39 | + <ColumnDefinition/> |
| 40 | + <ColumnDefinition Width="Auto"/> |
| 41 | + <ColumnDefinition/> |
| 42 | + </Grid.ColumnDefinitions> |
| 43 | + <DatePicker Grid.Column="0" |
| 44 | + SelectedDate="{Binding StartTime}" |
| 45 | + Style="{StaticResource MaterialDesignFloatingHintDatePicker}" |
| 46 | + materialDesign:HintAssist.Hint="开始时间"/> |
| 47 | + <materialDesign:PackIcon Kind="ArrowRight" Margin= "6 0" |
| 48 | + Grid.Column="1" VerticalAlignment="Center"/> |
| 49 | + <DatePicker Grid.Column="2" |
| 50 | + SelectedDate="{Binding EndTime}" |
| 51 | + Style="{StaticResource MaterialDesignFloatingHintDatePicker}" |
| 52 | + materialDesign:HintAssist.Hint="结束时间"/> |
| 53 | + </Grid> |
| 54 | + <ComboBox Style="{StaticResource MaterialDesignFloatingHintComboBox}" |
| 55 | + materialDesign:HintAssist.Hint="严重程度" |
| 56 | + Margin="0 0 0 6" |
| 57 | + SelectedIndex="{Binding Severity, Converter={StaticResource SeverityToIntConverter}}"> |
| 58 | + <ComboBoxItem>公告</ComboBoxItem> |
| 59 | + <ComboBoxItem>信息</ComboBoxItem> |
| 60 | + <ComboBoxItem>重要</ComboBoxItem> |
| 61 | + <ComboBoxItem>警告</ComboBoxItem> |
| 62 | + <ComboBoxItem>严重</ComboBoxItem> |
| 63 | + </ComboBox> |
| 64 | + <ComboBox Style="{StaticResource MaterialDesignFloatingHintComboBox}" |
| 65 | + materialDesign:HintAssist.Hint="已读状态保存范围" |
| 66 | + Margin="0 0 0 6" |
| 67 | + SelectedIndex="{Binding ReadStateStorageScope, Converter={StaticResource StorageScopeToIntConverter}}"> |
| 68 | + <ComboBoxItem>本地配置</ComboBoxItem> |
| 69 | + <ComboBoxItem>机器</ComboBoxItem> |
| 70 | + </ComboBox> |
| 71 | + |
| 72 | + <CheckBox IsChecked="{Binding HasDetails}" |
| 73 | + Content="有【了解更多】链接" |
| 74 | + Margin="0 0 0 6"/> |
| 75 | + <TextBox Text="{Binding DetailsUri}" |
| 76 | + Visibility="{Binding HasDetails, Converter={StaticResource BooleanToVisibilityConverter}}" |
| 77 | + Style="{StaticResource MaterialDesignFloatingHintTextBox}" |
| 78 | + materialDesign:HintAssist.Hint="了解更多链接" |
| 79 | + Margin="0 0 0 6"/> |
| 80 | + </StackPanel> |
| 81 | + </ScrollViewer> |
| 82 | + </DataTemplate> |
| 83 | + </ci:MyWindow.Resources> |
| 84 | + <ci:MyWindow.InputBindings> |
| 85 | + <KeyBinding Key="S" Modifiers="Control" Command="{Binding SaveMetadataCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=local:MetadataEditorWindow}}"/> |
| 86 | + </ci:MyWindow.InputBindings> |
| 87 | + <Grid> |
| 88 | + <Grid.RowDefinitions> |
| 89 | + <RowDefinition Height="Auto"/> |
| 90 | + <RowDefinition/> |
| 91 | + </Grid.RowDefinitions> |
| 92 | + <Menu Grid.Row="0" FontFamily="{StaticResource HarmonyOsSans}" materialDesign:MenuAssist.TopLevelMenuItemHeight="24"> |
| 93 | + <MenuItem Header="文件"> |
| 94 | + <MenuItem Header="保存" Icon="{materialDesign:PackIcon ContentSaveOutline}" InputGestureText="Ctrl+S" |
| 95 | + Command="{Binding SaveMetadataCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=local:MetadataEditorWindow}}"/> |
| 96 | + </MenuItem> |
| 97 | + </Menu> |
| 98 | + |
| 99 | + <TabControl Grid.Row="1" TabStripPlacement="Left"> |
| 100 | + <TabItem Header="公告"> |
| 101 | + <Grid> |
| 102 | + <Grid.RowDefinitions> |
| 103 | + <RowDefinition Height="Auto"/> |
| 104 | + <RowDefinition/> |
| 105 | + </Grid.RowDefinitions> |
| 106 | + <Grid.ColumnDefinitions> |
| 107 | + <ColumnDefinition Width="*"/> |
| 108 | + <ColumnDefinition Width="5"/> |
| 109 | + <ColumnDefinition Width="*"/> |
| 110 | + </Grid.ColumnDefinitions> |
| 111 | + |
| 112 | + <ToolBar Grid.Row="0" Grid.ColumnSpan="3" Grid.Column="0" |
| 113 | + ToolBarTray.IsLocked="True"> |
| 114 | + <Button Click="ButtonAddAnnouncement_OnClick"> |
| 115 | + <ci:IconText Kind="Add" Text="添加"/> |
| 116 | + </Button> |
| 117 | + </ToolBar> |
| 118 | + |
| 119 | + <DataGrid Grid.Row="1" Grid.Column="0" ItemsSource="{Binding ViewModel.Announcements}" |
| 120 | + AutoGenerateColumns="False" |
| 121 | + CanUserAddRows="False" |
| 122 | + CanUserSortColumns="False" |
| 123 | + SelectedItem="{Binding ViewModel.SelectedAnnouncement}"> |
| 124 | + |
| 125 | + <DataGrid.Columns> |
| 126 | + <DataGridTextColumn Width="*" Header="摘要" Binding="{Binding Summary}"/> |
| 127 | + <DataGridTemplateColumn Width="80" Header="严重度"> |
| 128 | + <DataGridTemplateColumn.CellEditingTemplate> |
| 129 | + <DataTemplate> |
| 130 | + <ComboBox Margin="0 -8" SelectedIndex="{Binding Severity, Converter={StaticResource SeverityToIntConverter}}"> |
| 131 | + <ComboBoxItem>公告</ComboBoxItem> |
| 132 | + <ComboBoxItem>信息</ComboBoxItem> |
| 133 | + <ComboBoxItem>重要</ComboBoxItem> |
| 134 | + <ComboBoxItem>警告</ComboBoxItem> |
| 135 | + <ComboBoxItem>严重</ComboBoxItem> |
| 136 | + </ComboBox> |
| 137 | + </DataTemplate> |
| 138 | + </DataGridTemplateColumn.CellEditingTemplate> |
| 139 | + <DataGridTemplateColumn.CellTemplate> |
| 140 | + <DataTemplate> |
| 141 | + <ComboBox Margin="0 -8" SelectedIndex="{Binding Severity, Converter={StaticResource SeverityToIntConverter}}"> |
| 142 | + <ComboBoxItem>公告</ComboBoxItem> |
| 143 | + <ComboBoxItem>信息</ComboBoxItem> |
| 144 | + <ComboBoxItem>重要</ComboBoxItem> |
| 145 | + <ComboBoxItem>警告</ComboBoxItem> |
| 146 | + <ComboBoxItem>严重</ComboBoxItem> |
| 147 | + </ComboBox> |
| 148 | + </DataTemplate> |
| 149 | + </DataGridTemplateColumn.CellTemplate> |
| 150 | + </DataGridTemplateColumn> |
| 151 | + <DataGridTemplateColumn Width="120" Header="开始时间"> |
| 152 | + <DataGridTemplateColumn.CellEditingTemplate> |
| 153 | + <DataTemplate> |
| 154 | + <DatePicker SelectedDate="{Binding StartTime}" Margin="0 -8"/> |
| 155 | + </DataTemplate> |
| 156 | + </DataGridTemplateColumn.CellEditingTemplate> |
| 157 | + <DataGridTemplateColumn.CellTemplate> |
| 158 | + <DataTemplate> |
| 159 | + <TextBlock Text="{Binding StartTime, StringFormat={}{0:yyyy/M/d}}"/> |
| 160 | + </DataTemplate> |
| 161 | + </DataGridTemplateColumn.CellTemplate> |
| 162 | + </DataGridTemplateColumn> |
| 163 | + <DataGridTemplateColumn Width="120" Header="结束时间"> |
| 164 | + <DataGridTemplateColumn.CellEditingTemplate> |
| 165 | + <DataTemplate> |
| 166 | + <DatePicker SelectedDate="{Binding EndTime}" Margin="0 -8"/> |
| 167 | + </DataTemplate> |
| 168 | + </DataGridTemplateColumn.CellEditingTemplate> |
| 169 | + <DataGridTemplateColumn.CellTemplate> |
| 170 | + <DataTemplate> |
| 171 | + <TextBlock Text="{Binding EndTime, StringFormat={}{0:yyyy/M/d}}"/> |
| 172 | + </DataTemplate> |
| 173 | + </DataGridTemplateColumn.CellTemplate> |
| 174 | + </DataGridTemplateColumn> |
| 175 | + </DataGrid.Columns> |
| 176 | + </DataGrid> |
| 177 | + |
| 178 | + <GridSplitter Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" Width="5" |
| 179 | + ResizeBehavior="PreviousAndNext"/> |
| 180 | + |
| 181 | + <ContentPresenter Grid.Column="2" Grid.Row="1" |
| 182 | + Content="{Binding ViewModel.SelectedAnnouncement}"/> |
| 183 | + </Grid> |
| 184 | + </TabItem> |
| 185 | + </TabControl> |
| 186 | + </Grid> |
| 187 | +</ci:MyWindow> |
0 commit comments