Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WatchList.WPF - Create project and add first button. #91

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions WatchList.WPF/App.xaml
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>
78 changes: 78 additions & 0 deletions WatchList.WPF/App.xaml.cs
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();
}
}
}
10 changes: 10 additions & 0 deletions WatchList.WPF/AssemblyInfo.cs
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)
)]
31 changes: 31 additions & 0 deletions WatchList.WPF/CinemaWindow.xaml
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>
22 changes: 22 additions & 0 deletions WatchList.WPF/CinemaWindow.xaml.cs
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)
{
}
}
}
27 changes: 27 additions & 0 deletions WatchList.WPF/WatchList.WPF.csproj
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>
11 changes: 11 additions & 0 deletions WatchList.WPF/WindowBox/MessageBoxPage.xaml
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>
47 changes: 47 additions & 0 deletions WatchList.WPF/WindowBox/MessageBoxPage.xaml.cs
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();
}
}
}
8 changes: 7 additions & 1 deletion WatchList.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchList.Migrations.SQLite
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchList.MudBlazors", "WatchList.MudBlazors\WatchList.MudBlazors.csproj", "{F1C2F716-B695-48AF-AAAA-C05D77D2868B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchList.ASP.Net.Controllers", "WatchList.ASP.Net.Controllers\WatchList.ASP.Net.Controllers.csproj", "{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchList.ASP.Net.Controllers", "WatchList.ASP.Net.Controllers\WatchList.ASP.Net.Controllers.csproj", "{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchList.WPF", "WatchList.WPF\WatchList.WPF.csproj", "{FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -48,6 +50,10 @@ Global
{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}.Release|Any CPU.Build.0 = Release|Any CPU
{FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading