Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8c3bbff
📝 Chore(.csproj): Updated dotnet to 7, references.
Dynesshely Sep 9, 2023
f36ad46
💾 Feat: Init data and models.
Dynesshely Sep 9, 2023
149fea6
📝 Chore(KitX): Removed struct json files, waiting new KitX SDK (Crequ…
Dynesshely Sep 9, 2023
268c22b
📝 Chore: Import `Common.BasicHelper`.
Dynesshely Sep 9, 2023
0f94c27
💾 Feat: Clean, including @StardustSeemsInk 's works on KitX connectio…
Dynesshely Sep 9, 2023
1af5353
💾 Feat: Organized.
Dynesshely Sep 9, 2023
02fc78e
💾 Feat: Optimized.
Dynesshely Sep 10, 2023
9bc1632
💾 Feat: Multi features, see details.
Dynesshely Sep 13, 2023
bc8d51d
💾 Feat: Better color calculating.
Dynesshely Sep 13, 2023
ab1b9ce
💾 Feat: Optimized.
Dynesshely Sep 14, 2023
558525f
💾 Feat: Merged.
Dynesshely Sep 14, 2023
5e83e39
🔧 Fix(SortStrategy): Fixed.
Dynesshely Sep 14, 2023
66eaf46
💾 Feat: Display class progress.
Dynesshely Sep 15, 2023
fdbae86
💾 Feat: Better color.
Dynesshely Sep 15, 2023
7dd4ef8
💾 Feat: You can change background image now.
Dynesshely Sep 15, 2023
bdeede8
💾 Feat: Optimized.
Dynesshely Sep 15, 2023
facc312
💾 Feat: Animation in class beginning.
Dynesshely Sep 16, 2023
3848c87
💾 Feat: Now you can view animation effect through debug menu, and you…
Dynesshely Sep 16, 2023
1614a5f
💾 Feat: Optimized.
Dynesshely Sep 16, 2023
eb9a9dd
💾 Feat: Converter for DayOfWeek
Dynesshely Sep 17, 2023
764d4a6
💾 Feat: Optimized.
Dynesshely Sep 17, 2023
38a66a2
💾 Feat: Added icon.
Dynesshely Sep 17, 2023
205eaa2
📄 Docs: Updated.
Dynesshely Sep 17, 2023
bbdec63
💾 Feat: Optimized.
Dynesshely Sep 17, 2023
0f459ef
💾 Feat: DateTime display at topmost window.
Dynesshely Sep 17, 2023
30e5b1c
💾 Feat: Draggable date time block.
Dynesshely Sep 18, 2023
f7a6ff4
💾 Feat: After dragging, snap date time block to top.
Dynesshely Sep 18, 2023
2e475d0
💾 Feat: Added drag margin.
Dynesshely Sep 18, 2023
eca4ce5
💾 Feat: Added inertial system.
Dynesshely Sep 18, 2023
661f5b0
🔧 Fix: Fixed negative time problem.
Dynesshely Sep 18, 2023
6fac85a
💾 Feat: Touch to shrink time block.
Dynesshely Sep 19, 2023
268c44d
💾 Feat: Display weather info.
Dynesshely Sep 21, 2023
5049337
💾 Feat: Weather data added temperature and wind direction.
Dynesshely Sep 21, 2023
26e1047
💾 Feat: Optimized.
Dynesshely Sep 21, 2023
09b0782
🔧 Fix: Fixed error shrink distance after date time font size changed.
Dynesshely Sep 21, 2023
12fd112
💾 Feat: Display sentence from web now.
Dynesshely Sep 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ClassScheduler.Runner/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;

Expand Down Expand Up @@ -30,6 +31,8 @@ private void Application_Startup(object sender, StartupEventArgs e)

try
{
AddDllResolveHandler(Path.GetFullPath("./"));

LoadPlugin("./ClassScheduler.WPF.dll");
}
catch (Exception o)
Expand All @@ -47,6 +50,23 @@ private void Application_Startup(object sender, StartupEventArgs e)
}
}

private static void AddDllResolveHandler(string appendPath)
{
var domain = AppDomain.CurrentDomain;

domain.AssemblyResolve += (sender, args) =>
{
var assemblyFolder = Path.GetFullPath(appendPath);
var assemblyPath = Path.Combine(assemblyFolder, new AssemblyName(args.Name).Name + ".dll");

if (!File.Exists(assemblyPath)) return null;

var assembly = Assembly.LoadFrom(assemblyPath);

return assembly;
};
}

private static void LoadPlugin(string path)
{
if (File.Exists(Path.GetFullPath(path)))
Expand Down
5 changes: 5 additions & 0 deletions ClassScheduler.Runner/ClassScheduler.Runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x64</Platforms>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ClassScheduler.WPF\ClassScheduler.WPF.csproj" />
</ItemGroup>
Expand Down
Binary file added ClassScheduler.Runner/icon.ico
Binary file not shown.
9 changes: 0 additions & 9 deletions ClassScheduler.WPF/Assets/ChartData.txt

This file was deleted.

Binary file modified ClassScheduler.WPF/Assets/icon.ico
Binary file not shown.
5 changes: 2 additions & 3 deletions ClassScheduler.WPF/ClassScheduler.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<ItemGroup>
<PackageReference Include="Common.BasicHelper" Version="1.3.584.228" />
<PackageReference Include="KitX.Contract.CSharp" Version="23.4.6559.497" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1938.49" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

Expand All @@ -26,9 +28,6 @@
</ItemGroup>

<ItemGroup>
<None Update="Assets\ChartData.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Assets\icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace ClassScheduler.WPF.Converters;

public class HorizontalAlignmentReverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var align = (HorizontalAlignment)value;
switch (align)
{
case HorizontalAlignment.Left:
return HorizontalAlignment.Right;
case HorizontalAlignment.Center:
return HorizontalAlignment.Stretch;
case HorizontalAlignment.Right:
return HorizontalAlignment.Left;
case HorizontalAlignment.Stretch:
return HorizontalAlignment.Center;
}

return align;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
27 changes: 27 additions & 0 deletions ClassScheduler.WPF/Converters/RectConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace ClassScheduler.WPF.Converters;

public class RectConverter : IMultiValueConverter
{
public object Convert(
object[] values,
Type targetType,
object parameter,
CultureInfo culture)
{
return new Rect(0, 0, (double)values[0], (double)values[1]);
}

public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
CultureInfo culture)
{
throw new NotImplementedException();
}
}
63 changes: 63 additions & 0 deletions ClassScheduler.WPF/Data/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using ClassScheduler.WPF.Utils;
using System;
using System.IO;
using System.Text.Json;

namespace ClassScheduler.WPF.Data;

public class AppConfig
{
public TopmostEffectsSettings TopmostEffectsSettings { get; set; } = new();

public WallPaperSettings WallPaperSettings { get; set; } = new();
}

public class TopmostEffectsSettings
{
public bool? IsDateTimeVisible { get; set; } = true;
}

public class WallPaperSettings
{
public string? WallPapersPath { get; set; }

public int CurrentWallPaperIndex { get; set; } = 0;

public bool? WallPapersEnabled { get; set; } = false;

public WallPaperStyle? WallPaperStyle { get; set; } = Utils.WallPaperStyle.Stretched;
}

public static class AppConfigExtensions
{
public static void Save(
this AppConfig config,
string path = "./Data/AppConfig.json",
Action<JsonSerializerOptions>? optionsProcessor = null)
{
var options = new JsonSerializerOptions()
{
IncludeFields = true,
WriteIndented = true,
};
optionsProcessor?.Invoke(options);

var json = JsonSerializer.Serialize(config, options);
File.WriteAllText(path, json);
}

public static AppConfig? LoadAsAppConfig(
this string path,
Action<JsonSerializerOptions>? optionsProcessor = null)
{
if (!Path.Exists(path)) return null;

var options = new JsonSerializerOptions();
optionsProcessor?.Invoke(options);

var json = File.ReadAllText(path);
var appConfig = JsonSerializer.Deserialize<AppConfig>(json, options);

return appConfig;
}
}
44 changes: 27 additions & 17 deletions ClassScheduler.WPF/Data/Classes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ public class Classes
{
public string? Name { get; set; }

public List<ClassModel> ClassesList { get; set; } = new();
public List<ClassModel> ClassesList { get; set; } = new()
{
new()
{
Name = "name",
BeginTime = DateTime.Now,
EndTime = DateTime.Now + new TimeSpan(1,0,0),
WeekDay = 1,
}
};

public Classes Sort()
{
ClassesList.Sort(
new Comparison<ClassModel>(
(x, y) =>
(x, y) =>
{
if (x.WeekDay == y.WeekDay)
{
if (x.WeekDay == y.WeekDay)
{
if (x.BeginTime == y.BeginTime)
return 0;
else
return x.BeginTime > y.BeginTime ? 1 : -1;
}
else
return x.WeekDay > y.WeekDay ? 1 : -1;
var x_begin = DateTime.Parse(x.BeginTime?.ToString("HH:mm")!);
var y_begin = DateTime.Parse(y.BeginTime?.ToString("HH:mm")!);
var x_end = DateTime.Parse(x.EndTime?.ToString("HH:mm")!);
var y_end = DateTime.Parse(y.EndTime?.ToString("HH:mm")!);

if (x_begin == y_begin && x_end == y_end)
return x.Name!.CompareTo(y.Name);
else return x_begin.CompareTo(y_end);
}
)
else return x.WeekDay > y.WeekDay ? 1 : -1;
}
);

return this;
Expand All @@ -39,7 +49,7 @@ public static class ClassesExtensions
{
public static void Save(
this Classes classes,
string path,
string path = "./Data/Classes.json",
Action<JsonSerializerOptions>? optionsProcessor = null)
{
var options = new JsonSerializerOptions()
Expand All @@ -49,11 +59,11 @@ public static void Save(
};
optionsProcessor?.Invoke(options);

var json = JsonSerializer.Serialize(classes);
var json = JsonSerializer.Serialize(classes, options);
File.WriteAllText(path, json);
}

public static Classes? Load(
public static Classes? LoadAsClasses(
this string path,
Action<JsonSerializerOptions>? optionsProcessor = null)
{
Expand All @@ -63,7 +73,7 @@ public static void Save(
optionsProcessor?.Invoke(options);

var json = File.ReadAllText(path);
var classes = JsonSerializer.Deserialize<Classes>(json);
var classes = JsonSerializer.Deserialize<Classes>(json, options);

return classes;
}
Expand Down
2 changes: 1 addition & 1 deletion ClassScheduler.WPF/Identity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using KitX.Contract.CSharp;
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace ClassScheduler.WPF;

Expand Down
16 changes: 14 additions & 2 deletions ClassScheduler.WPF/Instances.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,35 @@ internal static void Init()
if (!Directory.Exists(Path.GetFullPath("./Data/")))
Directory.CreateDirectory(Path.GetFullPath("./Data/"));

Classes = "./Data/Classes.json".Load();
AppConfig = "./Data/AppConfig.json".LoadAsAppConfig();
AppConfig ??= new();
AppConfig.Save();

Classes = "./Data/Classes.json".LoadAsClasses();
Classes ??= new();
Classes.Save("./Data/Classes.json");
Classes.Sort();
Classes.Save();

MainWindow = new();

ScheduleWindow = new();

TopmostEffectsWindow = new();
TopmostEffectsWindow.Show();

Controller = new();
}

internal static MainWindow? MainWindow { get; set; }

internal static ScheduleWindow? ScheduleWindow { get; set; }

internal static TopmostEffectsWindow? TopmostEffectsWindow { get; set; }

internal static Controller? Controller { get; set; }

internal static AppConfig? AppConfig { get; set; }

internal static Classes? Classes { get; set; }

internal static NotifyIcon? NotifyIcon { get; set; }
Expand Down
7 changes: 3 additions & 4 deletions ClassScheduler.WPF/Models/ClassModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using ClassScheduler.WPF.Models.Types;
using ClassScheduler.WPF.Models.Types;
using System;

namespace ClassScheduler.WPF.Models;

Expand Down Expand Up @@ -33,7 +32,7 @@ public int? DayOfWeek
{
var weekDay = (int)WeekDay!;
var dividedCount = 0;
while(weekDay != 1)
while (weekDay != 1)
{
weekDay /= 2;
++dividedCount;
Expand Down
29 changes: 29 additions & 0 deletions ClassScheduler.WPF/Utils/Converter/DayOfWeekToInt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;

namespace ClassScheduler.WPF.Utils.Converter;

public static class DayOfWeekToInt
{
public static int ToInt(this DayOfWeek day)
{
switch (day)
{
case DayOfWeek.Sunday:
return 7;
case DayOfWeek.Monday:
return 1;
case DayOfWeek.Tuesday:
return 2;
case DayOfWeek.Wednesday:
return 3;
case DayOfWeek.Thursday:
return 4;
case DayOfWeek.Friday:
return 5;
case DayOfWeek.Saturday:
return 6;
}

return -1;
}
}
Loading