feat: 그래프 설정 값 가져오기

hhsung_work
HyungJune Kim 10 months ago
parent 0edb2c9864
commit 630570e506

@ -9,8 +9,24 @@
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Generic.xaml"/> <ResourceDictionary Source="/Resources/Generic.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign2.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Badged.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Card.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Chip.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Clock.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Flipper.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.FlipperClassic.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ColorPicker.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RatingBar.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TimePicker.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.SmartHint.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Snackbar.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.AutoSuggestBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.SplitButton.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type vm:MonitoringViewModel}"> <DataTemplate DataType="{x:Type vm:MonitoringViewModel}">

@ -49,6 +49,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OxyPlot.Wpf" Version="2.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-rc.1.efcore.9.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-rc.1.efcore.9.0.0" />
</ItemGroup> </ItemGroup>

@ -159,7 +159,12 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Margin="20" <Border Margin="20"
Background="#384659" BorderBrush="#404F63" BorderThickness="1" CornerRadius="10"> Background="#384659" BorderBrush="#404F63" BorderThickness="1" CornerRadius="10">
<StackPanel> <Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackPanel DockPanel.Dock="Top">
<Grid Margin="15"> <Grid Margin="15">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/> <ColumnDefinition Width="80"/>
@ -231,20 +236,25 @@
<TextBlock Text="Y축 (복수 선택)" VerticalAlignment="Center" <TextBlock Text="Y축 (복수 선택)" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/> FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<!-- SelectedItems 바인딩을 위한 간단 Behavior는 아래 3) 참고 --> <!-- SelectedItems 바인딩을 위한 간단 Behavior는 아래 3) 참고 -->
<Border Grid.Row="1" CornerRadius="10" Background="White">
<ListBox ItemsSource="{Binding YFieldCandidates}" <ListBox ItemsSource="{Binding YFieldCandidates}"
DisplayMemberPath="Display" DisplayMemberPath="Display"
SelectionMode="Extended" SelectionMode="Extended"
helper:MultiSelectBehavior.SelectedItems="{Binding SelectedYFields, Mode=OneWay}" helper:MultiSelectBehavior.SelectedItems="{Binding SelectedYFields, Mode=OneWay}"
Height="150" Grid.Row="1" Height="Auto" Background="White"
FontSize="16" FontWeight="Bold"/> FontSize="16" FontWeight="Bold"
Style="{StaticResource MaterialDesignFilterChipListBox}"/>
</Border>
<!-- 옵션 --> <!-- 옵션 -->
<StackPanel Orientation="Horizontal" Margin="0 15 0 0" Grid.Row="2"> <StackPanel Orientation="Horizontal" Margin="0 15 0 0" Grid.Row="2">
<CheckBox Content="마커 표시" IsChecked="{Binding ShowMarkers}" Margin="0 0 15 0" <CheckBox Content="마커 표시" IsChecked="{Binding ShowMarkers}" Margin="0 0 15 0"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White" FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
VerticalContentAlignment="Center"/> VerticalContentAlignment="Center"
Style="{StaticResource MaterialDesignUserForegroundCheckBox}"/>
<CheckBox Content="스무딩" IsChecked="{Binding UseSmoothing}" <CheckBox Content="스무딩" IsChecked="{Binding UseSmoothing}"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White" FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
VerticalContentAlignment="Center"/> VerticalContentAlignment="Center"
Style="{StaticResource MaterialDesignUserForegroundCheckBox}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -278,7 +288,8 @@
<CheckBox Content="회귀선" IsChecked="{Binding ShowRegression}" <CheckBox Content="회귀선" IsChecked="{Binding ShowRegression}"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White" FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
Margin="0" Grid.Row="1" Grid.Column="3" Margin="0" Grid.Row="1" Grid.Column="3"
VerticalContentAlignment="Center"/> VerticalContentAlignment="Center"
Style="{StaticResource MaterialDesignUserForegroundCheckBox}"/>
</Grid> </Grid>
<!-- BOX: 값 필드 + 그룹 필드 + 옵션 --> <!-- BOX: 값 필드 + 그룹 필드 + 옵션 -->
@ -326,6 +337,12 @@
</Grid> </Grid>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="15 0" Grid.Row="1" HorizontalAlignment="Right">
<Button Content="그래프 생성" Style="{StaticResource MaterialDesignFlatLightBgButton}"
FontWeight="Bold" Command="{Binding DrawGraphCommand}"/>
</StackPanel>
</Grid>
</Border> </Border>
<Border Grid.Column="1" Margin="0 20 20 20" <Border Grid.Column="1" Margin="0 20 20 20"

@ -26,6 +26,7 @@ namespace SmartAquaViewer.ViewModel
public class MonitoringViewModel : INotifyPropertyChanged public class MonitoringViewModel : INotifyPropertyChanged
{ {
#region Properties
public ObservableCollection<GraphType> GraphTypes { get; } public ObservableCollection<GraphType> GraphTypes { get; }
public List<WaterQualityVO> WaterQualityList { get; } public List<WaterQualityVO> WaterQualityList { get; }
@ -82,6 +83,7 @@ namespace SmartAquaViewer.ViewModel
{ {
_selectedGraphType = value; _selectedGraphType = value;
OnPropertyChanged(); OnPropertyChanged();
OnPropertyChanged(nameof(ShowXSelector));
RebuildFieldCandidates(); RebuildFieldCandidates();
var idx = GraphTypes.IndexOf(value); var idx = GraphTypes.IndexOf(value);
@ -139,6 +141,8 @@ namespace SmartAquaViewer.ViewModel
} }
} }
public bool ShowXSelector => SelectedGraphType == GraphType.SCATTER;
// [필드 후보 목록] 탭/시스템에 따라 달라짐 // [필드 후보 목록] 탭/시스템에 따라 달라짐
public ObservableCollection<FieldItem> AvailableFields { get; } = new(); public ObservableCollection<FieldItem> AvailableFields { get; } = new();
@ -189,8 +193,10 @@ namespace SmartAquaViewer.ViewModel
private double _boxWidth = 0.3; // Box private double _boxWidth = 0.3; // Box
public double BoxWidth { get => _boxWidth; set { _boxWidth = value; OnPropertyChanged(); } } public double BoxWidth { get => _boxWidth; set { _boxWidth = value; OnPropertyChanged(); } }
#endregion
public ICommand ChangeDrawerStatusCommand { get; } public ICommand ChangeDrawerStatusCommand { get; }
public ICommand DrawGraphCommand { get; }
public delegate void SystemChangedEventHandler(MonitorTab selectedTab); public delegate void SystemChangedEventHandler(MonitorTab selectedTab);
public event SystemChangedEventHandler OnSystemChanged; public event SystemChangedEventHandler OnSystemChanged;
@ -219,11 +225,39 @@ namespace SmartAquaViewer.ViewModel
SetGraphType(); SetGraphType();
ChangeDrawerStatusCommand = new RelayCommand(_ => IsOpenMode = !IsOpenMode); ChangeDrawerStatusCommand = new RelayCommand(_ => IsOpenMode = !IsOpenMode);
DrawGraphCommand = new RelayCommand(DrawGraph);
RebuildAvailableFields(); RebuildAvailableFields();
RebuildFieldCandidates(); RebuildFieldCandidates();
} }
private void DrawGraph(object obj)
{
switch (SelectedGraphType)
{
case GraphType.LINE:
var xFieldLine = SelectedXField?.Name == "RecordedTime" ? SelectedXField : null;
var yFields = SelectedYFields.Count > 0 ? SelectedYFields : new ObservableCollection<FieldItem> { SelectedYField };
var isMarker = ShowMarkers;
var isSmoothing = UseSmoothing;
break;
case GraphType.BOX:
var xFieldBox = SelectedXField;
var dataFieldBox = SelectedYField;
var boxGroup = SelectedGroupField;
var boxWidth = BoxWidth;
break;
case GraphType.SCATTER:
var xFieldScatter = SelectedXField?.Name == "RecordedTime" ? SelectedXField : null;
var yFiledScatter = SelectedYField;
var markerSIze = ScatterMarkerSize;
var showRegression = ShowRegression;
break;
default:
break;
}
}
private void SetGraphType() private void SetGraphType()
{ {
GraphTypes.Clear(); GraphTypes.Clear();
@ -293,7 +327,11 @@ namespace SmartAquaViewer.ViewModel
GroupFieldCandidates.Clear(); GroupFieldCandidates.Clear();
// X축: 시간 우선 // X축: 시간 우선
foreach (var f in AvailableFields) XFieldCandidates.Add(f); foreach (var f in AvailableFields)
{
XFieldCandidates.Add(f);
if (SelectedGraphType == GraphType.LINE || SelectedGraphType == GraphType.STEP) break;
}
SelectedXField = AvailableFields.FirstOrDefault(f => f.DataType == typeof(DateTime)) SelectedXField = AvailableFields.FirstOrDefault(f => f.DataType == typeof(DateTime))
?? AvailableFields.FirstOrDefault(); ?? AvailableFields.FirstOrDefault();

Loading…
Cancel
Save