Skip to content

Commit

Permalink
Merge pull request #1 from wuxianao/master
Browse files Browse the repository at this point in the history
Some easy change
  • Loading branch information
truebigsand authored Aug 16, 2022
2 parents de4bb18 + b09d466 commit c02df4c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 40 deletions.
78 changes: 42 additions & 36 deletions CustomTools/Kouyu100AutoFinishWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,46 @@
mc:Ignorable="d"
WindowStartupLocation="CenterOwner"
Title="Kouyu100" Height="450" Width="800">
<Grid>
<TextBlock HorizontalAlignment="Left" Margin="10,18,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="authToken(从网页Cookies中取得): "/>
<TextBox x:Name="AuthTokenTextBox" HorizontalAlignment="Left" Margin="208,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="358" Cursor="Arrow"/>
<Button x:Name="GetHomeworkListButton" Content="获取作业列表" Margin="664,10,5,0" VerticalAlignment="Top" Click="GetHomeworkListButton_Click" Background="#FF2196F3"/>
<ListBox x:Name="HomeworkListBox" Margin="10,47,10,10" HorizontalContentAlignment="Stretch">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Name}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding Status}" Foreground="{DynamicResource MaterialDesignLightForeground}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Background" Value="#FFA7FFA7"></Setter>
<Style.Triggers>
<Trigger Property="Text" Value="未完成">
<Setter Property="Background" Value="#FFFF2649"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<EventSetter Event="MouseDoubleClick" Handler="HomeworkListBoxItem_MouseDoubleClick"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Button x:Name="InnerWebbrowserLoginButton" Content="内置登录" HorizontalAlignment="Left" Margin="571,10,0,0" VerticalAlignment="Top" Click="InnerWebbrowserLoginButton_Click" Cursor="Hand"/>
</Grid>
<Grid>
<TextBlock HorizontalAlignment="Left" Margin="10,63,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="authToken(从网页Cookies中取得): " Height="20" Width="190" RenderTransformOrigin="0.5,-0.212"/>
<TextBox x:Name="AuthTokenTextBox" InputMethod.IsInputMethodEnabled="True" HorizontalAlignment="Left" Margin="203,59,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="330" Cursor="Arrow"/>
<Button x:Name="GetHomeworkListButton" IsEnabled="False" Opacity="0.5" Content="获取作业列表" Margin="650,50,10,0" VerticalAlignment="Top" Click="GetHomeworkListButton_Click" Background="#FF2196F3" Cursor="Hand"/>
<ListBox x:Name="HomeworkListBox" Margin="10,88,10,10" HorizontalContentAlignment="Stretch" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Name}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding Status}" Foreground="{DynamicResource MaterialDesignLightForeground}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Background" Value="#FFA7FFA7"></Setter>
<Style.Triggers>
<Trigger Property="Text" Value="未完成">
<Setter Property="Background" Value="#FFFF2649"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<EventSetter Event="MouseDoubleClick" Handler="HomeworkListBoxItem_MouseDoubleClick"/>
</Style>
</ListBox.ItemContainerStyle>
<Button Content="Button"/>
</ListBox>
<Button x:Name="InnerWebbrowserLoginButton" Content="内置登录" HorizontalAlignment="Left" Margin="551,51,0,0" VerticalAlignment="Top" Click="InnerWebbrowserLoginButton_Click" Cursor="Hand" Height="31" Width="94" RenderTransformOrigin="0.585,-0.75"/>
<Grid HorizontalAlignment="Center" Height="35" Margin="0,10,0,0" VerticalAlignment="Top" Width="780" Cursor="Hand">
<Label Content="口语100一键开摆" HorizontalAlignment="Left" Height="25" Margin="0,10,0,0" VerticalAlignment="Top" Width="210" Background="White" Foreground="#DD100000"/>

<Button x:Name="Clear_state" Content="清除" Margin="670,2,10,1" Background="#FF2196F3" Cursor="Hand" Click="Clear_state_Click"/>
</Grid>
</Grid>
</Window>
32 changes: 32 additions & 0 deletions CustomTools/Kouyu100AutoFinishWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public string Kouyu100HttpPost(string Url, string postDataStr)
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
#pragma warning disable CS8602 // 解引用可能出现空引用。
#pragma warning disable CS8604 // 引用类型参数可能为 null。
static bool isOver = true;
private void GetHomeworkListButton_Click(object sender, RoutedEventArgs e)
{
isOver = false;
Task.Run(delegate
{
GetHomeworkListButton.Dispatcher.BeginInvoke(new Action(delegate
Expand Down Expand Up @@ -153,7 +155,9 @@ private void GetHomeworkListButton_Click(object sender, RoutedEventArgs e)
{
GetHomeworkListButton.IsEnabled = true;
}));

});
isOver = true;
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
#pragma warning restore CS8602 // 解引用可能出现空引用。
#pragma warning restore CS8604 // 引用类型参数可能为 null。
Expand All @@ -176,6 +180,34 @@ private void InnerWebbrowserLoginButton_Click(object sender, RoutedEventArgs e)
MessageBox.Show("请在接下来弹出的窗口内登录, 登陆成功后关闭即可");
kouyu100AutoFinishInnerWindowLoginWebbrowserWindow.ShowDialog();
AuthTokenTextBox.Text = kouyu100AutoFinishInnerWindowLoginWebbrowserWindow.GetAuthToken();
if (AuthTokenTextBox.Text != "")
{
AuthTokenTextBox.IsEnabled = false;
GetHomeworkListButton.IsEnabled = true;
GetHomeworkListButton.Opacity = 1;
}
}

private void Clear_state_Click(object sender, RoutedEventArgs e)
{
if (isOver)
{
AuthTokenTextBox.IsEnabled = true;
GetHomeworkListButton.IsEnabled = false;
GetHomeworkListButton.Opacity = 0.5;
for (int index = 0; index < 10; index++)
{
for (int i = 0; i < HomeworkListBox.Items.Count; i++)
{
HomeworkListBox.Items.RemoveAt(i);
}
}

}
else
{
MessageBox.Show("正在读取中,无法关闭");
}
}
}
}
11 changes: 7 additions & 4 deletions CustomTools/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
TextElement.FontSize="14"
WindowStartupLocation="CenterScreen"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button x:Name="SchoolDataButton" Content="信息课数据" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Click="SchoolDataButtonClick"/>
<Button x:Name="Kouyu100Button" Content="口语100一键开摆" HorizontalAlignment="Left" Margin="130,10,0,0" VerticalAlignment="Top" Cursor="Hand" Click="Kouyu100Button_Click"/>
<Grid>
<Button x:Name="SchoolDataButton" Content="信息课数据" HorizontalAlignment="Left" Margin="10,75,0,0" VerticalAlignment="Top" Click="SchoolDataButtonClick"/>
<Button x:Name="Kouyu100Button" Content="口语100一键开摆" HorizontalAlignment="Left" Margin="134,75,0,0" VerticalAlignment="Top" Cursor="Hand" Click="Kouyu100Button_Click"/>
<Grid HorizontalAlignment="Left" Height="45" Margin="10,10,0,0" VerticalAlignment="Top" Width="770">
<Label Content="Custom Tools" HorizontalAlignment="Left" Height="30" Margin="10,0,0,0" VerticalAlignment="Center" Width="130" FontSize="16"/>
</Grid>

</Grid>
</Grid>
</Window>
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CustomTools
A tool can solve question about kouyu100 homework.
Students in jzhx can use tools to save time.

0 comments on commit c02df4c

Please sign in to comment.