-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml
203 lines (185 loc) · 13.5 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<Window x:Class="LeafyLove.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:LeafyLove.ViewModels"
xmlns:utilities ="clr-namespace:LeafyLove.Utilities"
Title="Виртуальное растение" Height="800" Width="1280">
<Window.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#FFD3E4F4" Offset="0"/>
<GradientStop Color="#FFA6BCD0" Offset="1"/>
</LinearGradientBrush>
</Window.Background>
<Window.Resources>
<SolidColorBrush x:Key="PanelBackgroundBrush" Color="#FFEFF7FC"/>
<SolidColorBrush x:Key="PanelBorderBrush" Color="#FFA2A2A2"/>
<SolidColorBrush x:Key="ButtonHoverBackground" Color="#FFD6EAF8"/>
<!-- Стиль для ProgressBar -->
<Style x:Key="ProgressBarStyle" TargetType="ProgressBar">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="Background" Value="#FFEFF7FC"/>
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Height" Value="15"/>
</Style>
<Style x:Key="ActionButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="5"/>
<Setter Property="Width" Value="80"/>
<Setter Property="Background" Value="LightGray"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource ButtonHoverBackground}"/>
</Trigger>
</Style.Triggers>
</Style>
<utilities:TimeOfDayToBackgroundConverter x:Key="TimeOfDayToBackgroundConverter"/>
<utilities:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
<utilities:BooleanToThicknessConverter x:Key="BooleanToThicknessConverter"/>
</Window.Resources>
<StackPanel>
<Menu VerticalAlignment="Top">
<MenuItem Header="_Файл">
<MenuItem Header="_Сбросить прогресс" Click="ResetProgress_Click"/>
</MenuItem>
</Menu>
<TabControl>
<TabControl.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#FFD3E4F4" Offset="0"/>
<GradientStop Color="#FFA6BCD0" Offset="1"/>
</LinearGradientBrush>
</TabControl.Background>
<!-- Вкладка с растениями -->
<TabItem x:Name="MainTab" Header="Главная">
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding MainUser.Plants}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{StaticResource PanelBorderBrush}"
BorderThickness="1"
Margin="8,4,0,0"
CornerRadius="5"
MaxHeight="600">
<!-- Фон для каждого растения -->
<Border.Background>
<ImageBrush ImageSource="{Binding DataContext.CurrentBackground, RelativeSource={RelativeSource AncestorType=Window}}"
Stretch="UniformToFill"
AlignmentX="Center"
AlignmentY="Top"/>
</Border.Background>
<Grid>
<StackPanel MinWidth="300" MinHeight="600" Orientation="Vertical" VerticalAlignment="Stretch" MouseEnter="StackPanel_MouseEnter" MouseLeave="StackPanel_MouseLeave">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#55FFFFFF" />
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<!-- Название растения -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontWeight="Bold" FontSize="16" Margin="5" HorizontalAlignment="Center"
IsReadOnly="{Binding Path=IsEditing, Converter={StaticResource InverseBooleanConverter}}"
BorderThickness="{Binding Path=IsEditing, Converter={StaticResource BooleanToThicknessConverter}}"
Background="Transparent" />
<Button Command="{Binding DataContext.BeginEditCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding}"
Content="✎"
Width="20" Height="20"
ToolTip="Переименовать"
Background="Transparent" />
</StackPanel>
<!-- Изображение растения -->
<Image x:Name="coinImage" Source="pack://application:,,,/LeafyLove;component/Resources/Images/coin.png" Opacity="0" Height="50" Width="50"/>
<Image Width="300" Height="180" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,180,0,0" Source="{Binding ImagePath}"/>
<!-- Индикаторы здоровья и уровня воды -->
<StackPanel Margin="3">
<TextBlock Text="Здоровье" FontSize="12" FontWeight="Bold"/>
<ProgressBar Value="{Binding Health}" Style="{StaticResource ProgressBarStyle}" Maximum="100"/>
<TextBlock Text="Уровень воды" FontSize="12" FontWeight="Bold"/>
<ProgressBar Value="{Binding WaterLevel}" Style="{StaticResource ProgressBarStyle}" Maximum="100"/>
</StackPanel>
<!-- Кнопки взаимодействия -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
<Button Content="Полить" Command="{Binding DataContext.WaterCommand, RelativeSource={RelativeSource AncestorType=Window}}" Style="{StaticResource ActionButtonStyle}"/>
<Button Content="Удобрить" Command="{Binding DataContext.FertilizeCommand, RelativeSource={RelativeSource AncestorType=Window}}" Style="{StaticResource ActionButtonStyle}"/>
<Button Content="Лечить" Command="{Binding DataContext.TreatCommand, RelativeSource={RelativeSource AncestorType=Window}}" Style="{StaticResource ActionButtonStyle}"/>
</StackPanel>
<Button Content="Продать" Command="{Binding DataContext.SellPlantCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" Style="{StaticResource ActionButtonStyle}" CommandParameter="{Binding}" />
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</TabItem>
<!-- Вкладка магазина -->
<TabItem x:Name="StoreTab" Header="Магазин">
<Grid>
<TextBlock Text="{Binding MainUser.Money, StringFormat='Баланс: {0}'}"
FontSize="16" FontWeight="Bold"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="2" />
<TabControl>
<!-- Вкладка с цветами -->
<TabItem Header="Цветы">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding FlowerItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="1" CornerRadius="5" Padding="10" Margin="5" MaxHeight="300" VerticalAlignment="Top">
<StackPanel>
<Image Source="{Binding ImagePath}" Height="100" Width="300" />
<TextBlock Text="{Binding Name}" FontWeight="Bold" FontSize="14" Margin="5"/>
<TextBlock Text="{Binding Price, StringFormat='Цена: {0}'}" FontSize="12" Margin="5"/>
<Button Content="Купить" Command="{Binding DataContext.PurchaseCommand, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" CommandParameter="{Binding}" Margin="5"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</TabItem>
<!-- Вкладка с инструментами -->
<TabItem Header="Инструменты">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding ToolItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="1" CornerRadius="5" Padding="10" Margin="5" MaxHeight="300" VerticalAlignment="Top">
<StackPanel>
<Image Source="{Binding ImagePath}" Height="100" Width="300" />
<TextBlock Text="{Binding Name}" FontWeight="Bold" FontSize="14" Margin="5"/>
<TextBlock Text="{Binding Price, StringFormat='Цена: {0}'}" FontSize="12" Margin="5"/>
<Button Content="Купить" Command="{Binding DataContext.PurchaseCommand, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" CommandParameter="{Binding}" Margin="5"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</TabItem>
</TabControl>
</Grid>
</TabItem>
</TabControl>
</StackPanel>
</Window>