-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WatchList.WPF - Create project and add first button. (#91)
* WatchList.WPF - Create project and add first button. * WatchList.WPF - Fixed Linter.
- Loading branch information
1 parent
69b8086
commit 569b18d
Showing
9 changed files
with
239 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Application x:Class="WatchList.WPF.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
Startup="Application_Startup"> | ||
<Application.Resources></Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.IO; | ||
using System.Windows; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Serilog; | ||
using Serilog.Core; | ||
using WatchList.Core.Extension; | ||
using WatchList.Core.Repository; | ||
using WatchList.Core.Service; | ||
using WatchList.Core.Service.Component; | ||
using WatchList.Core.Service.DataLoading; | ||
using WatchList.Migrations.SQLite; | ||
using WatchList.WPF.WindowBox; | ||
|
||
namespace WatchList.WPF | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : System.Windows.Application | ||
{ | ||
private void Application_Startup(object sender, StartupEventArgs e) | ||
{ | ||
Log.Logger = CreateLogger(); | ||
|
||
try | ||
{ | ||
Log.Information("Starting WinForms applications"); | ||
var serviceCollection = AppServiceDI(); | ||
serviceCollection.AddSerilog(); | ||
|
||
using var contain = serviceCollection.BuildServiceProvider( | ||
new ServiceProviderOptions | ||
{ | ||
ValidateOnBuild = true, | ||
ValidateScopes = true, | ||
}); | ||
|
||
using var scope = contain.CreateScope(); | ||
var serviceProvider = scope.ServiceProvider; | ||
|
||
// Create the startup window | ||
CinemaWindow cinemaWindow = new CinemaWindow(serviceProvider); | ||
// Show the window | ||
cinemaWindow.Show(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Fatal(ex, "Application terminated unexpectedly"); | ||
} | ||
finally | ||
{ | ||
Log.CloseAndFlush(); | ||
} | ||
} | ||
|
||
private static IServiceCollection AppServiceDI() | ||
=> new ServiceCollection().AddSingleton(new DbContextFactoryMigrator("app.db")) | ||
.AddScoped(e => e.GetRequiredService<DbContextFactoryMigrator>().Create()) | ||
.AddScoped<WatchItemRepository>() | ||
.AddScoped<IMessageBox, MessageBoxPage>() | ||
.AddScoped<WatchItemService>() | ||
.AddScoped<DownloadDataService>() | ||
.AddLogging(); | ||
|
||
private static Logger CreateLogger(string logDirectory = "log") | ||
{ | ||
try | ||
{ | ||
Directory.CreateDirectory(logDirectory); | ||
} | ||
catch | ||
{ | ||
} | ||
|
||
return logDirectory.CreateLogger(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Window | ||
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:WatchList.WPF" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" x:Class="WatchList.WPF.CinemaWindow" | ||
mc:Ignorable="d" | ||
Title="CinemaWindow" Height="450" Width="800"> | ||
<Grid Background="#FFBAFDC1"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="40"/> | ||
<RowDefinition/> | ||
<RowDefinition Height="50"/> | ||
<RowDefinition Height="40"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
</Grid.ColumnDefinitions> | ||
<ui:Button Grid.Column="6" Content="Add Data" HorizontalAlignment="Stretch" | ||
Grid.Row="3" VerticalAlignment="Stretch" Margin="5 5 5 5" | ||
FontSize="14" RenderTransformOrigin="10,10" AutomationProperties.Name="Btn_Add_Data" | ||
Background="#FFECFBC7" Appearance="Dark" Click="Button_Click"/> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Windows; | ||
|
||
namespace WatchList.WPF | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class CinemaWindow : Window | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
|
||
public CinemaWindow(IServiceProvider serviceProvider) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
InitializeComponent(); | ||
} | ||
|
||
private void Button_Click(object sender, RoutedEventArgs e) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net7.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UseWPF>true</UseWPF> | ||
<UseWindowsForms>True</UseWindowsForms> | ||
<EnableWindowsTargeting>true</EnableWindowsTargeting> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="WPF-UI" Version="3.0.5" /> | ||
<PackageReference Include="WPF-UI.Tray" Version="3.0.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WatchList.Core\WatchList.Core.csproj" /> | ||
<ProjectReference Include="..\WatchList.Migrations.SQLite\WatchList.Migrations.SQLite.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Extension\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Page x:Class="WatchList.WPF.WindowBox.MessageBoxPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:WatchList.WPF.WindowBox" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800" | ||
Title="MessageBoxPage"> | ||
<Grid></Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Windows.Controls; | ||
using WatchList.Core.Model.QuestionResult; | ||
using WatchList.Core.Service.Component; | ||
|
||
namespace WatchList.WPF.WindowBox | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MessageBoxPage.xaml | ||
/// </summary> | ||
public partial class MessageBoxPage : Page, IMessageBox | ||
{ | ||
public MessageBoxPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Task<DialogReplaceItemQuestion> ShowDataReplaceQuestion(string titleItem) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task ShowError(string message) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task ShowInfo(string message) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> ShowQuestion(string message) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> ShowQuestionSaveItem(string message) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task ShowWarning(string message) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters