Added main structure

This commit is contained in:
Laurent
2026-02-16 22:44:44 +01:00
parent 663302c5b1
commit be6de65f85
10 changed files with 176 additions and 37 deletions

View File

@@ -1,8 +1,7 @@
<Application x:Class="GifResizer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GifResizer"
StartupUri="MainWindow.xaml">
xmlns:local="clr-namespace:GifResizer">
<Application.Resources>
</Application.Resources>

View File

@@ -1,6 +1,8 @@
using System.Configuration;
using System.Data;
using System.Windows;
using GifResizer.ViewModels;
using GifResizer.Views;
namespace GifResizer;
@@ -9,4 +11,13 @@ namespace GifResizer;
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var viewModel = new MainViewModel();
var mainWindow = new MainWindow(viewModel);
mainWindow.Show();
}
}

View File

@@ -8,4 +8,6 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

View File

@@ -1,12 +0,0 @@
<Window x:Class="GifResizer.MainWindow"
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:GifResizer"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>

View File

@@ -1,23 +0,0 @@
using System.Text;
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.Navigation;
using System.Windows.Shapes;
namespace GifResizer;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}

6
GifResizer/Models/Gif.cs Normal file
View File

@@ -0,0 +1,6 @@
namespace GifResizer.Models;
public class Gif
{
}

View File

@@ -0,0 +1,6 @@
namespace GifResizer.Service;
public class ResizeService
{
}

View File

@@ -0,0 +1,37 @@
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
namespace GifResizer.ViewModels;
public class MainViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
public MainViewModel()
{
FilePath = Directory.GetCurrentDirectory();
}
public string FilePath
{
get;
set => SetField(ref field, value);
}
private bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

View File

@@ -0,0 +1,73 @@
<Window x:Class="GifResizer.Views.MainWindow"
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"
mc:Ignorable="d"
Title="Gif resizer" Height="480" Width="640"
ResizeMode="NoResize">
<Border BorderBrush="Gray"
BorderThickness="1"
CornerRadius="5"
Padding="5"
Margin="20">
<StackPanel Orientation="Vertical" Margin="20">
<Border BorderBrush="Gray"
BorderThickness="1"
CornerRadius="5"
Padding="5"
Margin="20">
<StackPanel Orientation="Vertical">
<TextBlock
Margin="0,0,0,5"
Text="{
Binding FilePath,
TargetNullValue=No file selected,
FallbackValue=Gif filepath...
}"
Width="Auto"
Height="Auto"
HorizontalAlignment="Left"
VerticalAlignment="Center"
/>
<Button
Content="Browse..."
Padding="5"
Width="Auto"
Height="Auto"
Click="BrowseButton_Click"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</StackPanel>
</Border>
<Button
Content="Resize"
Padding="5"
Width="Auto"
Height="Auto"
Click="ResizeButton_Click"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<!--
<TextBlock Grid.Row="3" Text="Options:" Margin="0,0,0,5"/>
<CheckBox Grid.Row="4"
Content="Optimize file size"
Margin="0,0,0,15"/>
<Button Grid.Row="5"
Content="Resize GIF"
Width="120"
Height="35"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
-->
</StackPanel>
</Border>
</Window>

View File

@@ -0,0 +1,40 @@
using System.Windows;
using GifResizer.ViewModels;
using Microsoft.Win32;
namespace GifResizer.Views;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private readonly MainViewModel _mainViewModel;
public MainWindow(MainViewModel viewModel)
{
InitializeComponent();
_mainViewModel = viewModel;
DataContext = _mainViewModel;
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog
{
Filter = "GIF files (*.gif)|*.gif|All files (*.*)|*.*",
Title = "Select a GIF file"
};
if (fileDialog.ShowDialog() == true)
{
_mainViewModel.FilePath = fileDialog.FileName;
}
}
private void ResizeButton_Click(object sender, RoutedEventArgs e)
{
}
}