From 7daa875b05a1e376ef7d29920e85c552080e4003 Mon Sep 17 00:00:00 2001 From: hj615 Date: Tue, 22 Jul 2025 14:17:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8C=8C=EC=9D=BC=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SmartAquaViewer.sln | 8 ++- SmartAquaViewer/App.xaml | 7 +- SmartAquaViewer/Controls/RelayCommand.cs | 57 +++++++++++++++ SmartAquaViewer/MainWindow.xaml | 22 +++++- SmartAquaViewer/MainWindow.xaml.cs | 1 + SmartAquaViewer/Model/FileModel.cs | 13 ++++ SmartAquaViewer/SmartAquaViewer.csproj | 6 ++ SmartAquaViewer/View/FileListView.xaml | 38 ++++++++++ SmartAquaViewer/View/FileListView.xaml.cs | 28 ++++++++ .../ViewModel/FileListViewModel.cs | 72 +++++++++++++++++++ 10 files changed, 248 insertions(+), 4 deletions(-) create mode 100644 SmartAquaViewer/Controls/RelayCommand.cs create mode 100644 SmartAquaViewer/Model/FileModel.cs create mode 100644 SmartAquaViewer/View/FileListView.xaml create mode 100644 SmartAquaViewer/View/FileListView.xaml.cs create mode 100644 SmartAquaViewer/ViewModel/FileListViewModel.cs diff --git a/SmartAquaViewer.sln b/SmartAquaViewer.sln index 6109ea0..44473df 100644 --- a/SmartAquaViewer.sln +++ b/SmartAquaViewer.sln @@ -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 diff --git a/SmartAquaViewer/App.xaml b/SmartAquaViewer/App.xaml index 9bf51fc..af590e0 100644 --- a/SmartAquaViewer/App.xaml +++ b/SmartAquaViewer/App.xaml @@ -4,6 +4,11 @@ xmlns:local="clr-namespace:SmartAquaViewer" StartupUri="MainWindow.xaml"> - + + + + + + diff --git a/SmartAquaViewer/Controls/RelayCommand.cs b/SmartAquaViewer/Controls/RelayCommand.cs new file mode 100644 index 0000000..e0e491a --- /dev/null +++ b/SmartAquaViewer/Controls/RelayCommand.cs @@ -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 _execute; + private readonly Func _canExecute; + public RelayCommand(Action execute, Func 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 : ICommand + { + private readonly Action _execute; + private readonly Func? _canExecute; + + public RelayCommand(Action execute, Func? 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; + } + } +} diff --git a/SmartAquaViewer/MainWindow.xaml b/SmartAquaViewer/MainWindow.xaml index 25e73a3..ed8fa39 100644 --- a/SmartAquaViewer/MainWindow.xaml +++ b/SmartAquaViewer/MainWindow.xaml @@ -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"> - + + + + + + + + + + + + + + + + + diff --git a/SmartAquaViewer/MainWindow.xaml.cs b/SmartAquaViewer/MainWindow.xaml.cs index ca382bc..e8ec01d 100644 --- a/SmartAquaViewer/MainWindow.xaml.cs +++ b/SmartAquaViewer/MainWindow.xaml.cs @@ -19,6 +19,7 @@ namespace SmartAquaViewer public MainWindow() { InitializeComponent(); + } } } \ No newline at end of file diff --git a/SmartAquaViewer/Model/FileModel.cs b/SmartAquaViewer/Model/FileModel.cs new file mode 100644 index 0000000..12bdd70 --- /dev/null +++ b/SmartAquaViewer/Model/FileModel.cs @@ -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; } + } +} diff --git a/SmartAquaViewer/SmartAquaViewer.csproj b/SmartAquaViewer/SmartAquaViewer.csproj index e3e33e3..fc386e0 100644 --- a/SmartAquaViewer/SmartAquaViewer.csproj +++ b/SmartAquaViewer/SmartAquaViewer.csproj @@ -6,6 +6,12 @@ enable enable true + AnyCPU;x64 + + + + + diff --git a/SmartAquaViewer/View/FileListView.xaml b/SmartAquaViewer/View/FileListView.xaml new file mode 100644 index 0000000..0cb149c --- /dev/null +++ b/SmartAquaViewer/View/FileListView.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SmartAquaViewer/View/FileListView.xaml.cs b/SmartAquaViewer/View/FileListView.xaml.cs new file mode 100644 index 0000000..519f567 --- /dev/null +++ b/SmartAquaViewer/View/FileListView.xaml.cs @@ -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 +{ + /// + /// FileListView.xaml에 대한 상호 작용 논리 + /// + public partial class FileListView : UserControl + { + public FileListView() + { + InitializeComponent(); + } + } +} diff --git a/SmartAquaViewer/ViewModel/FileListViewModel.cs b/SmartAquaViewer/ViewModel/FileListViewModel.cs new file mode 100644 index 0000000..e22ec56 --- /dev/null +++ b/SmartAquaViewer/ViewModel/FileListViewModel.cs @@ -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 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(); + 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)); + } +}