feat: 파일 목록 시각화

hhsung_work
HyungJune Kim 11 months ago
parent d10b77d5a7
commit 7daa875b05

@ -1,20 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35931.197 d17.13
VisualStudioVersion = 17.13.35931.197
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartAquaViewer", "SmartAquaViewer\SmartAquaViewer.csproj", "{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Debug|x64.ActiveCfg = Debug|x64
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Debug|x64.Build.0 = Debug|x64
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Release|Any CPU.Build.0 = Release|Any CPU
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Release|x64.ActiveCfg = Release|x64
{B1AF5CCA-731E-42E1-8ECD-9B8FC7237A95}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -4,6 +4,11 @@
xmlns:local="clr-namespace:SmartAquaViewer"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace SmartAquaViewer.Controls
{
public class RelayCommand : ICommand
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
}
public bool CanExecute(object parameter) => _canExecute?.Invoke(parameter) ?? true;
public void Execute(object parameter) => _execute(parameter);
public event EventHandler? CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
}
public class RelayCommand<T> : ICommand
{
private readonly Action<T> _execute;
private readonly Func<T, bool>? _canExecute;
public RelayCommand(Action<T> execute, Func<T, bool>? canExecute = null)
{
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
}
public bool CanExecute(object? parameter)
{
return _canExecute?.Invoke((T)parameter!) ?? true;
}
public void Execute(object? parameter)
{
_execute((T)parameter!);
}
public event EventHandler? CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
}
}

@ -4,9 +4,27 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SmartAquaViewer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:view="clr-namespace:SmartAquaViewer.View"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="MainWindow" Height="1080" Width="1920" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="150"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.RowSpan="2"> <!--파일 리스트-->
<view:FileListView x:Name="fileListView"/>
</Grid>
<Grid Grid.Column="1"> <!--탭-->
</Grid>
<Grid Grid.Row="1" Grid.Column="1"> <!--기능 화면-->
<ContentControl x:Name="contentControl"/>
</Grid>
</Grid>
</Window>

@ -19,6 +19,7 @@ namespace SmartAquaViewer
public MainWindow()
{
InitializeComponent();
}
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartAquaViewer.Model
{
public class FileModel
{
public string Name { get; set; }
}
}

@ -6,6 +6,12 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MaterialDesignColors" Version="5.2.1" />
<PackageReference Include="MaterialDesignThemes" Version="5.2.1" />
</ItemGroup>
</Project>

@ -0,0 +1,38 @@
<UserControl x:Class="SmartAquaViewer.View.FileListView"
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:SmartAquaViewer.View"
xmlns:vm="clr-namespace:SmartAquaViewer.ViewModel"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="300">
<UserControl.DataContext>
<vm:FileListViewModel/>
</UserControl.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!-- Header Row -->
<RowDefinition Height="*"/> <!-- File List Row -->
</Grid.RowDefinitions>
<Button Width="30" Height="30"
Command="{Binding OpenFileDialogCommand}">
<materialDesign:PackIcon Kind="Folder"/>
</Button>
<ListView Grid.Row="1"
Margin="10"
ItemsSource="{Binding FileList}"
SelectedItem="{Binding SelectedFile}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Margin="5"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</UserControl>

@ -0,0 +1,28 @@
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.Navigation;
using System.Windows.Shapes;
namespace SmartAquaViewer.View
{
/// <summary>
/// FileListView.xaml에 대한 상호 작용 논리
/// </summary>
public partial class FileListView : UserControl
{
public FileListView()
{
InitializeComponent();
}
}
}

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Win32;
using SmartAquaViewer.Controls;
using SmartAquaViewer.Model;
namespace SmartAquaViewer.ViewModel
{
public class FileListViewModel : INotifyPropertyChanged
{
public ObservableCollection<FileModel> FileList { get; set; }
private FileModel? _selectedFile;
public FileModel SelectedFile
{
get => _selectedFile;
set
{
if (_selectedFile != value)
{
_selectedFile = value;
OnPropertyChanged();
}
}
}
public ICommand OpenFileDialogCommand { get; }
public FileListViewModel()
{
FileList = new ObservableCollection<FileModel>();
OpenFileDialogCommand = new RelayCommand(OpenFileList);
}
private void OpenFileList(object obj)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Multiselect = true,
Filter = "Json Files (*.json)|*.json|All Files (*.*)|*.*"
};
if (openFileDialog.ShowDialog() == true)
{
FileList.Clear();
foreach (var filePath in openFileDialog.FileNames)
{
var fileName = System.IO.Path.GetFileName(filePath);
var fileModel = new FileModel { Name = fileName };
if (!FileList.Any(f => f.Name == fileModel.Name))
{
FileList.Add(fileModel);
}
}
}
}
public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
Loading…
Cancel
Save