This commit is contained in:
ZouJin 2024-05-19 02:20:16 +08:00
commit dfc799663c
11 changed files with 498 additions and 24 deletions

View File

@ -159,7 +159,7 @@
</Setter>
</Style>
<Style x:Key="StndardToggleButtonStyle" BasedOn="{StaticResource {x:Type ToggleButton}}"
<Style x:Key="ThemedToggleButtonStyle" BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ToggleButtonHelper.CheckedBackground" Value="{DynamicResource DARKPrimaryDarker}" />

View File

@ -26,7 +26,7 @@
<PackageReference Include="LinePutScript" Version="1.11.6" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.7" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.2" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.3" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">

View File

@ -66,7 +66,7 @@
<Setter Property="BorderBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="Padding" Value="7,0,15,0" />
<Setter Property="pu:ComboBoxHelper.CornerRadius" Value="5" />
<Setter Property="pu:ComboBoxHelper.WatermarkForeground" Value="#DCDCDC" />
<Setter Property="pu:ComboBoxHelper.WatermarkForeground" Value="#BABABA" />
<Setter Property="pu:ComboBoxHelper.ItemsSelectedBackground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ComboBoxHelper.ItemsSelectedForeground" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:ComboBoxHelper.ItemsHoverBackground" Value="{DynamicResource DARKPrimaryTrans4}" />

View File

@ -19,6 +19,6 @@
<PackageReference Include="LinePutScript" Version="1.11.6" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.7" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.2" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.3" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

View File

@ -87,6 +87,8 @@
<None Remove="Res\img\rank6.png" />
<None Remove="Res\img\rbgb.png" />
<None Remove="Res\img\rbgt.png" />
<None Remove="Res\img\r_agency_job.png" />
<None Remove="Res\img\r_agency_training.png" />
<None Remove="Res\img\r_autobuy_1.png" />
<None Remove="Res\img\r_autobuy_2.png" />
<None Remove="Res\img\r_autobuy_3.png" />
@ -137,6 +139,8 @@
<Resource Include="Res\img\rank1.png" />
<Resource Include="Res\img\rank3.png" />
<Resource Include="Res\img\rbgb.png" />
<Resource Include="Res\img\r_agency_job.png" />
<Resource Include="Res\img\r_agency_training.png" />
<Resource Include="Res\img\r_mostfood_Food.png" />
<Resource Include="Res\remixicon.ttf" />
<Resource Include="vpeticon.ico">
@ -227,7 +231,7 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.2" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VPet-Simulator.Core\VPet-Simulator.Core.csproj" />

View File

@ -988,17 +988,17 @@
FontSize="20" FontWeight="Bold" Text="{ll:Str 制作组名单}" />
<TextBlock Grid.Column="1" Margin="0,130,0,0" VerticalAlignment="Top"
TextWrapping="WrapWithOverflow">
<Run Text="{ll:Str '杨远洛里斯'}" />
,<Run Text="{ll:Str '吉娜'}" />
,<Hyperlink Click="Mod_Click" Foreground="{DynamicResource PrimaryText}">
<Run Text="{ll:Str '杨远洛里斯'}" />,
<Run Text="{ll:Str '吉娜'}" />,
<Hyperlink Click="Mod_Click" Foreground="{DynamicResource PrimaryText}">
<Run Text="{ll:Str 广大MOD作者}" />
</Hyperlink><LineBreak />
<Run Text="{ll:Str '洛里斯杨远'}" />
, トニーちゃん<Hyperlink Click="Git_Click">
<Run Text="{ll:Str '洛里斯杨远'}" />,
末城via <Hyperlink Click="Git_Click">
<Run Text="{ll:Str Git贡献名单}" />
</Hyperlink><LineBreak />
<Run Text="{ll:Str '叶书天'}" />
,<Hyperlink Click="Mod_Click" Foreground="{DynamicResource PrimaryText}">
<Run Text="{ll:Str '叶书天'}" />,
<Hyperlink Click="Mod_Click" Foreground="{DynamicResource PrimaryText}">
<Run Text="{ll:Str 广大MOD作者}" />
</Hyperlink>
<LineBreak />

View File

@ -7,6 +7,17 @@
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" Title="{ll:Str 工作面板}" Height="375"
Style="{DynamicResource BaseWindowXStyle}" Background="{DynamicResource PrimaryLighter}" Width="650"
ResizeMode="CanMinimize" Closed="Window_Closed">
<pu:WindowX.Resources>
<Style x:Key="IconButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Static pu:StyleKeys.ButtonStyle}}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#BABABA" />
<Setter Property="FontFamily" Value="{StaticResource RemixIcon}" />
<Setter Property="pu:ButtonHelper.HoverForeground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ButtonHelper.HoverBackground" Value="{x:Null}" />
<Setter Property="pu:ButtonHelper.ClickBackground" Value="{x:Null}" />
</Style>
<local:ScheduleItemTemplateSelector x:Key="ScheduleItemTemplateSelector" />
</pu:WindowX.Resources>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
@ -43,15 +54,9 @@
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{ll:Str 工作内容}"
FontSize="{Binding FontSize, Converter={x:Static pu:Converters.DoubleMinusConverter}, ConverterParameter=2, Source={x:Static pu:GlobalSettings.Setting}}" />
<Grid Grid.Row="1" Margin="0,3,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ComboBox x:Name="detailTypes" Style="{DynamicResource StandardComboBoxStyle}"
SelectionChanged="detailTypes_SelectionChanged" />
</Grid>
FontSize="{Binding FontSize, Source={x:Static pu:GlobalSettings.Setting}}" />
<ComboBox x:Name="detailTypes" Grid.Row="1" Margin="0,3,0,0" Style="{DynamicResource StandardComboBoxStyle}"
SelectionChanged="detailTypes_SelectionChanged" />
<Image x:Name="WorkViewImage" RenderOptions.BitmapScalingMode="HighQuality" Grid.Row="2"
Margin="-20,0" Stretch="Uniform" Source="/Res/img/r_singlemoney_1.png" />
<Border Grid.Row="2" VerticalAlignment="Bottom" Background="{DynamicResource SecondaryTrans}"
@ -135,6 +140,227 @@
Click="btnStart_Click" FontSize="16" FontWeight="Bold" />
</Grid>
</Grid>
<Grid x:Name="gdSchedule">
<TabControl pu:TabControlHelper.ItemsCornerRadius="4" pu:TabControlHelper.ItemsHeight="NaN"
pu:TabControlHelper.ItemsHoverBackground="{DynamicResource PrimaryLight}"
pu:TabControlHelper.ItemsPadding="10,7"
pu:TabControlHelper.ItemsSelectedBackground="{DynamicResource PrimaryDark}"
pu:TabControlHelper.ItemsSelectedForeground="{DynamicResource DARKPrimaryText}" Background="Transparent"
BorderThickness="0" Foreground="{DynamicResource PrimaryText}" SelectedIndex="0">
<TabItem Header="机构签署">
<Grid Margin="7">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="15" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<UniformGrid Columns="2">
<UniformGrid.Resources>
<Style TargetType="ToggleButton" BasedOn="{StaticResource {x:Static pu:StyleKeys.ToggleButtonStyle}}">
<Setter Property="Padding" Value="0,3" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryText}" />
<Setter Property="BorderBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="BorderThickness" Value="1.5" />
<Setter Property="pu:ToggleButtonHelper.CheckedBackground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ToggleButtonHelper.CheckedForeground" Value="{DynamicResource DARKPrimaryText}" />
</Style>
</UniformGrid.Resources>
<ToggleButton x:Name="tbtnAgencyJob" pu:ToggleButtonHelper.CornerRadius="4,0,0,4" Content="工作中介" IsChecked="True"
Checked="tbtn_Agency_CheckChanged" PreviewMouseLeftButtonDown="tbtnAgency_PreviewMouseLeftButtonDown"/>
<ToggleButton x:Name="tbtnAgencyTraning" pu:ToggleButtonHelper.CornerRadius="0,4,4,0" Content="培训机构"
Checked="tbtn_Agency_CheckChanged" PreviewMouseLeftButtonDown="tbtnAgency_PreviewMouseLeftButtonDown"/>
</UniformGrid>
<Image x:Name="imgAgency" RenderOptions.BitmapScalingMode="HighQuality" Grid.Row="2"
Margin="-20,0" Stretch="Uniform" Source="/Res/img/r_agency_job.png" />
</Grid>
<Border Grid.Column="2" Background="White" CornerRadius="4" />
<Grid Grid.Column="2" Margin="15">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ComboBox Margin="0,3,0,0" Style="{DynamicResource StandardComboBoxStyle}"
pu:ComboBoxHelper.Watermark="--请选择套餐--" SelectionChanged="detailTypes_SelectionChanged" />
<TextBlock Grid.Row="1" Margin="0,7,0,0" VerticalAlignment="Bottom" Text="{ll:Str 选择等级}"/>
<TextBlock Grid.Row="1" Margin="0,7,0,0" FontSize="16" HorizontalAlignment="Right" Foreground="{DynamicResource DARKPrimary}" >
<Run Text="Lv."/>
<Run Text="50"/>
</TextBlock>
<Slider Grid.Row="2" pu:SliderHelper.ThumbWidth="10"
pu:SliderHelper.ThumbCornerRadius="2" pu:SliderHelper.ThumbHeight="16"
pu:SliderHelper.ThumbBorderThickness="2" SmallChange="1" Value="1" Minimum="1"
TickFrequency="1" IsSnapToTickEnabled="True" ValueChanged="wDouble_ValueChanged"
LargeChange="1" Style="{DynamicResource StandardSliderStyle}" TickPlacement="Both"></Slider>
<TextBlock Grid.Row="3" Margin="0,7,0,0">
<Run>抽成</Run>
<Run Foreground="{DynamicResource DARKPrimary}" Text="40%" />
<Run>学费</Run>
<Run Foreground="{DynamicResource DARKPrimary}" Text="20%" />
</TextBlock>
<Grid Grid.Row="4" Margin="0,3,0,0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="15" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock>办理费用</TextBlock>
<TextBlock Grid.Column="2" HorizontalAlignment="Right" Foreground="{DynamicResource DARKPrimary}" Text="50000" />
<TextBlock Grid.Row="1">等级需求</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Foreground="{DynamicResource DARKPrimary}" Text="100" />
<TextBlock Grid.Row="2">合同持续时间</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" Foreground="{DynamicResource DARKPrimary}" Text="1周" />
</Grid>
<Button x:Name="btnSignAgency" Grid.Row="6" Height="30" Content="{ll:Str 签署}"
Style="{DynamicResource ThemedButtonStyle}" Background="{DynamicResource PrimaryDarker}"
Click="btnSignAgency_Click" FontSize="16" FontWeight="Bold" />
</Grid>
</Grid>
</TabItem>
<TabItem Header="日程表">
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="140"/>
</Grid.ColumnDefinitions>
<Grid Margin="0,0,15,0">
<Border Background="White"
CornerRadius="4" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Margin="7,7,0,0" Text="日程安排" />
<ScrollViewer Grid.Row="1">
<StackPanel Margin="20,7,7,7">
<ItemsControl x:Name="icSchedule"
ItemTemplateSelector="{StaticResource ScheduleItemTemplateSelector}">
<ItemsControl.Resources>
<DataTemplate x:Key="WorkScheduleTemplate">
<StackPanel>
<Button Margin="-20,-5,0,-5" HorizontalAlignment="Left" Visibility="{Binding IsPreviousIsRest, Converter={x:Static pu:Converters.TrueToCollapseConverter}}"
Style="{DynamicResource IconButtonStyle}" ToolTip="{ll:Str 添加休息}" Click="btn_addRest_Click">&#xea11;</Button>
<Border Height="90" CornerRadius="5" Background="{DynamicResource DARKPrimaryTrans4}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Margin="-15,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center">
<Button Margin="0,0,0,0" Padding="0"
Style="{DynamicResource IconButtonStyle}" ToolTip="{ll:Str 上移}" Click="btn_scheduleUp_Click">&#xea76;</Button>
<Button Margin="0,0,0,0" Padding="0"
Style="{DynamicResource IconButtonStyle}" ToolTip="{ll:Str 下移}" Click="btn_scheduleDown_Click">&#xea4c;</Button>
</StackPanel>
<Image Stretch="Uniform" Source="/Res/img/r_autobuy_3.png" />
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock>工作内容</TextBlock>
<TextBlock FontSize="16" Foreground="{DynamicResource DARKPrimary}" Text="{Binding WorkName}"/>
<TextBlock>持续时间</TextBlock>
<TextBlock FontSize="16" Foreground="{DynamicResource DARKPrimary}">
<Run Text="{Binding WorkTime}"/>
<Run>分钟</Run>
</TextBlock>
</StackPanel>
<Button Grid.Column="2" HorizontalAlignment="Right"
Background="Transparent" Foreground="{DynamicResource DangerBrush}" FontFamily="{StaticResource RemixIcon}" Click="btn_removeSchedule_Click">&#xeb97;</Button>
</Grid>
</Border>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="RestScheduleTemplate">
<Border Margin="0,7,0,7" Height="30" CornerRadius="5" Padding="0,3" Background="#F1F2F3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal"
Margin="7,0">
<TextBlock VerticalAlignment="Center">休息</TextBlock>
<pu:NumberInput Minimum="0" Interval="1" IsSnapToIntervalEnabled="True"
Background="Transparent" BorderThickness="0" Foreground="{DynamicResource DARKPrimary}"
FontSize="16" Padding="0" Value="{Binding RestTime, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" ValueChanged="NumberInput_ValueChanged">
<pu:NumberInput.UpDownButtonStyle>
<Style TargetType="RepeatButton" BasedOn="{StaticResource {x:Static pu:NumberInput.UpDownButtonStyleKey}}">
<Setter Property="FontSize" Value="10" />
</Style>
</pu:NumberInput.UpDownButtonStyle>
</pu:NumberInput>
<TextBlock VerticalAlignment="Center" Foreground="{DynamicResource DARKPrimary}"
FontSize="16">分钟</TextBlock>
</StackPanel>
<Button Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center"
Background="Transparent" Foreground="{DynamicResource DangerBrush}"
FontFamily="{StaticResource RemixIcon}" Content="&#xeb97;" Click="btn_removeSchedule_Click"/>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
<Button Margin="-20,-5,0,-5" HorizontalAlignment="Left"
Style="{DynamicResource IconButtonStyle}" Content="&#xea11;" ToolTip="{ll:Str 添加休息}" Click="btn_addRest_Click"/>
</StackPanel>
</ScrollViewer>
</Grid>
</Grid>
<Grid Grid.Column="1"
Margin="0,7,7,7">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="合计"/>
<Grid Grid.Row="1" Margin="0,7,0,0">
<pu:RingProgressBar x:Name="rpgbSchedule" Height="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"
IsPercentVisible="False" FontSize="20"
Foreground="{DynamicResource DARKPrimary}" BorderBrush="{DynamicResource DARKPrimaryTrans4}" BorderThickness="2"
Minimum="0" Maximum="100" Value="0" />
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel>
<TextBlock Opacity="0.5">工作时间</TextBlock>
<TextBlock Foreground="{DynamicResource DARKPrimary}" HorizontalAlignment="Right">
<Run x:Name="runScheduleWork" FontSize="22">0</Run>
<Run>分钟</Run>
</TextBlock>
<TextBlock Opacity="0.5">休息时间</TextBlock>
<TextBlock Foreground="{DynamicResource DARKPrimary}" HorizontalAlignment="Right">
<Run x:Name="runScheduleRest" FontSize="22">0</Run>
<Run>分钟</Run>
</TextBlock>
</StackPanel>
</Grid>
</Grid>
<ToggleButton x:Name="btnStartSchedule" Grid.Row="3"
Style="{DynamicResource ThemedToggleButtonStyle}" Height="30" Content="{ll:Str 开始日程}"
Background="{DynamicResource PrimaryDarker}" FontSize="16" FontWeight="Bold"
Click="btnStartSchedule_Click" />
</Grid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Grid>
</Grid>
</Grid>

View File

@ -1,10 +1,15 @@
using LinePutScript.Localization.WPF;
using Panuon.WPF;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using VPet_Simulator.Windows.Interface;
using static VPet_Simulator.Core.GraphHelper;
@ -24,13 +29,16 @@ public partial class winWorkMenu : WindowX
private readonly ObservableCollection<string> _studyDetails = new ObservableCollection<string>();
private readonly ObservableCollection<string> _playDetails = new ObservableCollection<string>();
private readonly ObservableCollection<string> _starDetails = new ObservableCollection<string>();
private readonly ObservableCollection<ScheduleItemBase> _schedules = new ObservableCollection<ScheduleItemBase>();
public void ShowImageDefault(Work.WorkType type)
{
Dispatcher.BeginInvoke(() =>
{
WorkViewImage.Source = mw.ImageSources.FindImage("work_" + mw.Set.PetGraph + "_t_" + type.ToString(), "work_" + type.ToString());
}, DispatcherPriority.Loaded);
_schedules.CollectionChanged += Schedules_CollectionChanged;
icSchedule.ItemsSource = _schedules;
}
public winWorkMenu(MainWindow mw, Work.WorkType type)
@ -66,6 +74,18 @@ public partial class winWorkMenu : WindowX
LsbCategory.SelectedIndex = (int)type;
ShowImageDefault(type);
AllowChange = true;
_schedules.Add(new WorkScheduleItem(
mw.ImageSources.FindImage("work_" + mw.Set.PetGraph + "_t_" + type.ToString(), "work_" + type.ToString()),
"学习",
60
));
_schedules.Add(new RestScheduleItem(10));
_schedules.Add(new WorkScheduleItem(
mw.ImageSources.FindImage("work_" + mw.Set.PetGraph + "_t_" + type.ToString(), "work_" + type.ToString()),
"学习",
70
));
}
public bool IsWorkStar(Work work) => mw.Set["work_star"].GetBool(work.Name);
public void SetWorkStar(Work work, bool setvalue) => mw.Set["work_star"].SetBool(work.Name, setvalue);
@ -147,6 +167,8 @@ public partial class winWorkMenu : WindowX
var lastIndex = detailTypes.SelectedIndex;
if (LsbCategory.SelectedIndex < 3)
ShowImageDefault((Work.WorkType)LsbCategory.SelectedIndex);
gdWork.Visibility = Visibility.Visible;
gdSchedule.Visibility = Visibility.Collapsed;
switch (LsbCategory.SelectedIndex)
{
case 0:
@ -167,9 +189,9 @@ public partial class winWorkMenu : WindowX
break;
case 4:
gdWork.Visibility = Visibility.Collapsed;
gdSchedule.Visibility = Visibility.Visible;
return;
}
gdWork.Visibility = Visibility.Visible;
detailTypes.IsDropDownOpen = true;
detailTypes_SelectionChanged(null, null);
}, DispatcherPriority.Loaded);
@ -228,6 +250,11 @@ public partial class winWorkMenu : WindowX
mw.winWorkMenu = null;
}
private void Schedules_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
CalculateSceduleTime();
}
private void btnStart_Click(object sender, RoutedEventArgs e)
{
if (nowworkdisplay != null)
@ -262,4 +289,221 @@ public partial class winWorkMenu : WindowX
}
AllowChange = true;
}
private void btnStartSchedule_Click(object sender, RoutedEventArgs e)
{
}
private void NumberInput_ValueChanged(object sender, SelectedValueChangedRoutedEventArgs<double?> e)
{
CalculateSceduleTime();
}
private void CalculateSceduleTime()
{
int workTime = 0;
int restTime = 0;
for (int i = 0; i < _schedules.Count; i++)
{
var item = _schedules[i];
var lastItem = i == 0 ? null : _schedules[i - 1];
if (item is WorkScheduleItem workItem)
{
workItem.IsPreviousIsRest = lastItem is RestScheduleItem;
workTime += workItem.WorkTime;
}
else if (item is RestScheduleItem restItem)
{
restTime += restItem.RestTime;
}
}
rpgbSchedule.Maximum = workTime + restTime;
rpgbSchedule.Value = workTime;
runScheduleWork.Text = workTime.ToString();
runScheduleRest.Text = restTime.ToString();
}
private void tbtn_Agency_CheckChanged(object sender, RoutedEventArgs e)
{
if (imgAgency == null)
{
return;
}
if (sender == tbtnAgencyJob)
{
imgAgency.Source = new BitmapImage(new Uri($"pack://application:,,,/Res/img/r_agency_job.png"));
tbtnAgencyTraning.IsChecked = false;
}
else if (sender == tbtnAgencyTraning)
{
imgAgency.Source = new BitmapImage(new Uri($"pack://application:,,,/Res/img/r_agency_training.png"));
tbtnAgencyJob.IsChecked = false;
}
}
private void tbtnAgency_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
var toggleButton = sender as ToggleButton;
if (toggleButton.IsChecked == true)
{
e.Handled = true;
}
}
private void btnSignAgency_Click(object sender, RoutedEventArgs e)
{
}
private void btn_addRest_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var scheduleItem = button.DataContext as ScheduleItemBase;
if (scheduleItem == null)
{
if(_schedules.LastOrDefault() is RestScheduleItem lastRest)
{
lastRest.RestTime += 30;
}
else
{
_schedules.Add(new RestScheduleItem(30));
}
}
else
{
var index = _schedules.IndexOf(scheduleItem);
_schedules.Insert(index, new RestScheduleItem(30));
}
}
private void btn_removeSchedule_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var scheduleItem = button.DataContext as ScheduleItemBase;
var index = _schedules.IndexOf(scheduleItem);
var previousItem = index == 0 ? null : _schedules[index - 1];
var nextItem = index == _schedules.Count - 1 ? null : _schedules[index + 1];
if (previousItem is RestScheduleItem previousRest
&& nextItem is RestScheduleItem nextRest)
{
previousRest.RestTime += nextRest.RestTime;
_schedules.Remove(nextRest);
}
_schedules.Remove(scheduleItem);
}
private void btn_scheduleUp_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var scheduleItem = button.DataContext as ScheduleItemBase;
var index = _schedules.IndexOf(scheduleItem);
if(index == 0)
{
return;
}
var previousItem = index == 0 ? null : _schedules[index - 1];
var nextItem = index == _schedules.Count - 1 ? null : _schedules[index + 1];
if (previousItem is RestScheduleItem previousRest
&& nextItem is RestScheduleItem nextRest)
{
previousRest.RestTime += nextRest.RestTime;
_schedules.Remove(nextRest);
}
_schedules.Remove(scheduleItem);
_schedules.Insert(Math.Max(index - 1, 0), scheduleItem);
}
private void btn_scheduleDown_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var scheduleItem = button.DataContext as ScheduleItemBase;
var index = _schedules.IndexOf(scheduleItem);
if (index == _schedules.Count - 1)
{
return;
}
var previousItem = index == 0 ? null : _schedules[index - 1];
var nextItem = index == _schedules.Count - 1 ? null : _schedules[index + 1];
if (previousItem is RestScheduleItem previousRest
&& nextItem is RestScheduleItem nextRest)
{
previousRest.RestTime += nextRest.RestTime;
_schedules.Remove(nextRest);
}
_schedules.Remove(scheduleItem);
_schedules.Insert(Math.Min(index + 1, _schedules.Count), scheduleItem);
}
}
public abstract class ScheduleItemBase
: NotifyPropertyChangedBase
{
}
public class WorkScheduleItem
: ScheduleItemBase
{
public WorkScheduleItem()
{
}
public WorkScheduleItem(ImageSource image,
string workName,
int workTime)
{
Image = image;
WorkName = workName;
WorkTime = workTime;
}
public ImageSource Image { get; set; }
public string WorkName { get; set; }
public int WorkTime { get; set; }
public bool IsPreviousIsRest { get => _isPreviousIsRest; set => Set(ref _isPreviousIsRest, value); }
private bool _isPreviousIsRest;
}
public class RestScheduleItem
: ScheduleItemBase
{
public RestScheduleItem()
{
}
public RestScheduleItem(int restTime)
{
RestTime = restTime;
}
public int RestTime { get => _restTime; set => Set(ref _restTime, value); }
private int _restTime;
}
internal class ScheduleItemTemplateSelector
: DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
var element = container as FrameworkElement;
if(item is WorkScheduleItem workItem)
{
return element.FindResource("WorkScheduleTemplate") as DataTemplate;
}
else if(item is RestScheduleItem restItem)
{
return element.FindResource("RestScheduleTemplate") as DataTemplate;
}
throw new NotImplementedException();
}
}

View File

@ -23,7 +23,7 @@
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.7" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.2" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.3" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>