Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlaricGilbert committed Feb 3, 2019
2 parents de9e8f6 + c5eee8c commit a1b080c
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 14 deletions.
7 changes: 7 additions & 0 deletions BiliCommenter/BiliCommenter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="WelcomeWindow.xaml.cs">
<DependentUpon>WelcomeWindow.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -103,6 +106,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="WelcomeWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down
60 changes: 50 additions & 10 deletions BiliCommenter/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,36 @@
namespace BiliCommenter
{
/// <summary>
/// MainWindow.xaml Logic
/// Interactive logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow
{
/// <summary>
/// List of the current tasks.
/// </summary>
public List<CommentTask> TaskList = new List<CommentTask>();
/// <summary>
/// A map from the task's name to the task object instance.
/// </summary>
public Dictionary<string, CommentTask> TaskPair = new Dictionary<string, CommentTask>();
/// <summary>
/// List of the on-updating bangumis.
/// </summary>
private List<BangumiInfo> Bangumis { get; set; }
/// <summary>
/// Instance of the welcome window.
/// </summary>
private WelcomeWindow WelcomeWindow { get; } = new WelcomeWindow();
/// <summary>
/// A variable which marks the selected index number was changed by another,
/// preventing the infinite loop call between TaskListBox and BangumiListBox.
/// </summary>
private bool ListBoxChangedByAnother = false;
/// <summary>
/// Create an BitmapImage uses the specified url.
/// </summary>
/// <param name="url">Image source</param>
/// <returns>The created image.</returns>
public BitmapImage CreateBI(string url)
{
BitmapImage bi = new BitmapImage();
Expand All @@ -49,6 +71,10 @@ public async Task FreshUserInfo()
}
public void Initialize()
{
// Show the welcome window and hide the main window.
WelcomeWindow.Show();
this.Visibility = Visibility.Hidden;

//Inherit tasks.
if (Settings.Default.IsInheritTasks)
ReadTasks();
Expand All @@ -67,7 +93,7 @@ public void Initialize()
this.Invoke(() => LoginFlyout.IsOpen = true);
});
if (Settings.Default.IsSaveAccessKey)
freshThread.Start();
freshThread.Start(); //Starts the thread only when Settings.Default.IsSaveAccessKey is set to True.
#endregion

#region Get bangumi informations.
Expand All @@ -76,9 +102,7 @@ public void Initialize()
Bangumis = await Bangumi.GetBangumiInfosAsync();
List<string> titles = new List<string>();
for (int i = 0; i < Bangumis.Count; i++)
{
titles.Add(Bangumis[i].Title);
}
this.Invoke(() => BangumiListBox.ItemsSource = titles);
});
bangumiThread.Start();
Expand All @@ -87,12 +111,13 @@ public void Initialize()
#region Get bilibili emojis.
Thread emojiThread = new Thread(async () =>
{

// Get the list of the emojis.
var allEmojis = await Common.GetEmojisAsync();

for (int i = 0; i < allEmojis.Data.Count; i++)
{
var emojiPack = allEmojis.Data[i];
// These part of code is a piece of s**t, but works :).
this.Invoke(() =>
{
var item = new TabItem();
Expand Down Expand Up @@ -135,6 +160,11 @@ public void Initialize()
EmojiTabControl.Items.Add(item);
});
}
this.Invoke(() =>
{
this.Visibility = Visibility.Visible;
WelcomeWindow.Close();
});
});
#if !DEBUG
emojiThread.Start(); // do not load the emojis in the debug mode.
Expand Down Expand Up @@ -341,11 +371,21 @@ private void ReadTasks()
TaskList = new List<CommentTask>();
foreach (var task in TaskList)
{
task.TaskId = TaskListBox.Items.Count;
TaskListBox.Items.Add(task.BangumiInfo.Title);
TaskPair.Add(task.BangumiInfo.Title, task);
task.Callback = TaskCallback;
task.Start();
try
{
task.TaskId = TaskListBox.Items.Count;
task.Start();
TaskListBox.Items.Add(task.BangumiInfo.Title);
TaskPair.Add(task.BangumiInfo.Title, task);
task.Callback = TaskCallback;
}
catch (ArgumentOutOfRangeException) // when target time is before the current time, Noticer throws.
{
// remove it from
TaskList.Remove(task);
// there should be a logger system..
task.Dispose();
}
}
}
private void UpdateSettings(object sender, RoutedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions BiliCommenter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.1.0")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyVersion("0.2.2.0")]
[assembly: AssemblyFileVersion("0.2.2.0")]
12 changes: 12 additions & 0 deletions BiliCommenter/WelcomeWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window x:Class="BiliCommenter.WelcomeWindow"
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:local="clr-namespace:BiliCommenter"
mc:Ignorable="d"
Title="WelcomeWindow" Height="512" Width="512" WindowStyle="None" AllowsTransparency="True" Background="#00FFFFFF">
<Grid>
<Image Source="logo.ico"/>
</Grid>
</Window>
27 changes: 27 additions & 0 deletions BiliCommenter/WelcomeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace BiliCommenter
{
/// <summary>
/// WelcomeWindow.xaml 的交互逻辑
/// </summary>
public partial class WelcomeWindow : Window
{
public WelcomeWindow()
{
InitializeComponent();
}
}
}
2 changes: 1 addition & 1 deletion BiliCore/BiliCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>0.2.0.0</AssemblyVersion>
<AssemblyVersion>0.2.2.0</AssemblyVersion>
<FileVersion>0.2.0.0</FileVersion>
<Version>0.2.0</Version>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion BiliCore/Core/Noticer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void PreciousTimer_Elapsed(object sender, ElapsedEventArgs e)
public void Start(NoticerElapsedCallback callback)
{
if (Delta < 0)
throw new Exception();
throw new ArgumentOutOfRangeException("Target time should be after the current time.");
Callback = callback;
MainTimer = new Timer(1000);
MainTimer.Elapsed += CheckTime;
Expand Down
10 changes: 10 additions & 0 deletions What's new.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## 0.2.x - currently mainly supporting version

### 0.2.2.0

New features:

```
Welcome window.
```

Fixed the task loading bug in 0.2.1.0.

### 0.2.1.0

Changes:
Expand Down

0 comments on commit a1b080c

Please sign in to comment.