feat: view swap 기능 추가

hhsung_work
HyungJune Kim 11 months ago
parent 7daa875b05
commit 99eb505d72

@ -2,13 +2,29 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SmartAquaViewer"
xmlns:view="clr-namespace:SmartAquaViewer.View"
xmlns:vm="clr-namespace:SmartAquaViewer.ViewModel"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Reources/Generic.xaml"/>
<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>
<DataTemplate DataType="{x:Type vm:MonitoringViewModel}">
<view:MonitoringView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:EnergyViewModel}">
<view:EnegyView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:GreenHouseGasViewModel}">
<view:GreenHouseView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:CCTVViewModel}">
<view:CCTVView/>
</DataTemplate>
</ResourceDictionary>
</Application.Resources>
</Application>

@ -6,25 +6,48 @@
xmlns:local="clr-namespace:SmartAquaViewer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:view="clr-namespace:SmartAquaViewer.View"
xmlns:vm="clr-namespace:SmartAquaViewer.ViewModel"
mc:Ignorable="d"
Title="MainWindow" Height="1080" Width="1920" WindowStartupLocation="CenterScreen">
<Window.DataContext>
<vm:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="270"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="150"/>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.RowSpan="2"> <!--파일 리스트-->
<view:FileListView x:Name="fileListView"/>
</Grid>
<Grid Grid.Column="1"> <!--탭-->
<Grid Grid.Column="1" Background="#00498D"> <!--탭-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<RadioButton x:Name="rdbtnMonitoing" GroupName="contentSwap" Content="모니터링" Tag="monitoring"
Style="{StaticResource RadioButtonStyle}" Margin="60 0" IsChecked="True"
Command="{Binding SwapViewCommand}"
CommandParameter="{Binding Tag, RelativeSource={RelativeSource Self}}"/>
<RadioButton x:Name="rdbtnEnergy" GroupName="contentSwap" Content="에너지" Tag="energy"
Style="{StaticResource RadioButtonStyle}"
Command="{Binding SwapViewCommand}"
CommandParameter="{Binding Tag, RelativeSource={RelativeSource Self}}"/>
<RadioButton x:Name="rdBtnGreenHouseGas" GroupName="contentSwap" Content="온실가스" Tag="greenHouseGas"
Style="{StaticResource RadioButtonStyle}" Margin="60 0 0 0"
Command="{Binding SwapViewCommand}"
CommandParameter="{Binding Tag, RelativeSource={RelativeSource Self}}"/>
<RadioButton x:Name="rdbtnCCTV" GroupName="contentSwap" Content="CCTV" Tag="cctv"
Style="{StaticResource RadioButtonStyle}" Margin="60 0"
Command="{Binding SwapViewCommand}"
CommandParameter="{Binding Tag, RelativeSource={RelativeSource Self}}"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1"> <!--기능 화면-->
<ContentControl x:Name="contentControl"/>
<ContentControl x:Name="contentControl" Content="{Binding SelectedViewModel}"/>
</Grid>
</Grid>
</Window>

@ -0,0 +1,30 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="RadioButtonStyle" TargetType="RadioButton">
<Setter Property="Background" Value="#2F2F44"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="32"/>
<Setter Property="Width" Value="300"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border Background="{TemplateBinding Background}" CornerRadius="10"
BorderThickness="1" BorderBrush="Black">
<TextBlock Text="{TemplateBinding Content}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="32" Foreground="{TemplateBinding Foreground}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#C2C2E6"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -9,9 +9,17 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<None Remove="Reources\Images\ListImage.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MaterialDesignColors" Version="5.2.1" />
<PackageReference Include="MaterialDesignThemes" Version="5.2.1" />
</ItemGroup>
<ItemGroup>
<Resource Include="Reources\Images\ListImage.png" />
</ItemGroup>
</Project>

@ -0,0 +1,16 @@
<UserControl x:Class="SmartAquaViewer.View.CCTVView"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="CCTV View"
FontSize="24" FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Black"/>
</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>
/// CCTVView.xaml에 대한 상호 작용 논리
/// </summary>
public partial class CCTVView : UserControl
{
public CCTVView()
{
InitializeComponent();
}
}
}

@ -0,0 +1,16 @@
<UserControl x:Class="SmartAquaViewer.View.EnegyView"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="Energy View"
FontSize="24" FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Black"/>
</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>
/// EnegyView.xaml에 대한 상호 작용 논리
/// </summary>
public partial class EnegyView : UserControl
{
public EnegyView()
{
InitializeComponent();
}
}
}

@ -7,32 +7,48 @@
xmlns:vm="clr-namespace:SmartAquaViewer.ViewModel"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="300">
d:DesignHeight="1040" d:DesignWidth="270">
<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>
<Border Background="#1E2241">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<!-- Header Row -->
<RowDefinition Height="*"/>
<!-- File List Row -->
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Image Source="/Reources/Images/ListImage.png"
Width="35" Margin="20 0"/>
<TextBlock Text="파일 목록"
FontSize="20" FontWeight="Bold" Foreground="White"
VerticalAlignment="Center"/>
<Button Width="35" Height="35" Margin="50 0"
Background="#ffd663"
Command="{Binding OpenFileDialogCommand}">
<materialDesign:PackIcon Kind="FolderAdd"/>
</Button>
</StackPanel>
<ListView Grid.Row="1"
Margin="10"
ItemsSource="{Binding FileList}"
SelectedItem="{Binding SelectedFile}"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
BorderThickness="0" Background="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="{Binding Name}" Margin="5"
FontSize="16" FontWeight="Medium" Foreground="White"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Border>
</UserControl>

@ -0,0 +1,16 @@
<UserControl x:Class="SmartAquaViewer.View.GreenHouseView"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="Green House View"
FontSize="24" FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Black"/>
</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>
/// GreenHouseView.xaml에 대한 상호 작용 논리
/// </summary>
public partial class GreenHouseView : UserControl
{
public GreenHouseView()
{
InitializeComponent();
}
}
}

@ -0,0 +1,16 @@
<UserControl x:Class="SmartAquaViewer.View.MonitoringView"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="Monitoring View"
FontSize="24" FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Black"/>
</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>
/// MonitoringView.xaml에 대한 상호 작용 논리
/// </summary>
public partial class MonitoringView : UserControl
{
public MonitoringView()
{
InitializeComponent();
}
}
}

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace SmartAquaViewer.ViewModel
{
public class CCTVViewModel : INotifyPropertyChanged
{
public CCTVViewModel()
{
}
public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace SmartAquaViewer.ViewModel
{
public class EnergyViewModel : INotifyPropertyChanged
{
public EnergyViewModel() { }
public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace SmartAquaViewer.ViewModel
{
public class GreenHouseGasViewModel : INotifyPropertyChanged
{
public GreenHouseGasViewModel()
{
// Initialization logic for GreenHouseGasViewModel can go here
}
public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using SmartAquaViewer.Controls;
namespace SmartAquaViewer.ViewModel
{
public class MainViewModel : INotifyPropertyChanged
{
private object? _selectedViewModel;
public object? SelectedViewModel
{
get => _selectedViewModel;
set
{
if (_selectedViewModel != value)
{
_selectedViewModel = value;
OnPropertyChanged(nameof(SelectedViewModel));
}
}
}
public ICommand SwapViewCommand { get; }
public MainViewModel()
{
SwapViewCommand = new RelayCommand(SwapView);
SelectedViewModel = new MonitoringViewModel(); // Default view
}
private void SwapView(object obj)
{
var tag = (string)obj;
switch (tag)
{
case "monitoring":
SelectedViewModel = new MonitoringViewModel();
break;
case "energy":
SelectedViewModel = new EnergyViewModel();
break;
case "greenHouseGas":
SelectedViewModel = new GreenHouseGasViewModel();
break;
case "cctv":
SelectedViewModel = new CCTVViewModel();
break;
default:
throw new ArgumentException("Unknown view tag", nameof(obj));
}
}
public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace SmartAquaViewer.ViewModel
{
public class MonitoringViewModel : INotifyPropertyChanged
{
public MonitoringViewModel()
{
// Initialization logic for MonitoringViewModel can go here
}
public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
Loading…
Cancel
Save