瀏覽代碼

Almost complite task 2

Gorbachev 1 月之前
父節點
當前提交
9b32b9a109
共有 2 個文件被更改,包括 80 次插入9 次删除
  1. 16 5
      Task1/MainWindow.axaml
  2. 64 4
      Task1/MainWindow.axaml.cs

+ 16 - 5
Task1/MainWindow.axaml

@@ -10,12 +10,10 @@
 		<StackPanel>
 			<DatePicker Name="DatePick" Classes = "DatePick"></DatePicker>
 		</StackPanel>
-
-		<StackPanel Classes="StackPanel.TestStack">
-			<Button Click="ShowUsersClick">Кнопка что бы узнать всё</Button>		
+		<StackPanel Name="ButtonShow" Classes="StackPanel.TestStack">
+			<Button Click="ShowUsersClick" Margin="50, 10">Кнопка что бы узнать всё</Button>		
 		</StackPanel>
 		<StackPanel Name="ShowPanelDate" Classes="HiddenDate">
-			<TextBox Name="Info"></TextBox>
 			<TextBox Name="InfoYear"></TextBox>
 			<TextBox Name="InfoMonth">Или</TextBox>
 			<TextBox Name="InfoDay"></TextBox>
@@ -23,7 +21,20 @@
 				<TextBox Name="WeekDay"></TextBox>
 			</StackPanel>
 		</StackPanel>
-			
+			<StackPanel Classes="HiddenDate" Name="Calendars">
+				<StackPanel Name="Calendars_Buttons">
+				<Button Click="Button_Click_CalendarEastern">Кто я по восточному гороскопу</Button>
+				<Button Click="Button_Click_CalendarZodiac">Кто я по знаку зодиака</Button>
+				</StackPanel>
+				<StackPanel Name="EasternGoro" Classes="HiddenDate"></StackPanel>
+				<StackPanel Name="Zodiac" Classes="HiddenDate">
+					<TextBox Name="ZodiacSign"></TextBox>
+				</StackPanel>
+				
+			</StackPanel>
+			<StackPanel Classes="HiddenDate" Name="Backbutton">
+				<Button   Click="Button_Click_Back">Назад</Button>
+			</StackPanel>
 	</StackPanel>
 	</Grid>
 </Window>

+ 64 - 4
Task1/MainWindow.axaml.cs

@@ -3,6 +3,8 @@ using Avalonia.Interactivity;
 using Avalonia.Media;
 using Avalonia.Styling;
 using System;
+using System.Collections.Generic;
+using static System.Runtime.InteropServices.JavaScript.JSType;
 
 namespace Task1
 {
@@ -33,7 +35,7 @@ namespace Task1
                 InfoYear.Text = Convert.ToString(separateYear) + " ëåò " + Convert.ToString(separateMonth) + " ìåñÿöåâ " + Convert.ToString(separateDay) + " äíåé.";
                 InfoDay.Text = Convert.ToString((today - dateUsed).TotalDays) + " äíåé ";
 
-                WeekDay.Text = Convert.ToString(dateUsed.DayOfWeek);
+                WeekDay.Text = "Äåíü íåäåëè: " + Convert.ToString(dateUsed.DayOfWeek);
                 DateTime buffer = dateUsed;
                 while (buffer <= today)
                 {
@@ -48,16 +50,74 @@ namespace Task1
                         BirthDates.Children.Add(BDate);
                     }
                 }
-
+                ShowPanelDate.IsVisible = true;
+                Calendars.IsVisible = true;
             }
             catch(Exception ex) {
-                Info.Text = ex.Message;
             }
 
-            ShowPanelDate.IsVisible = true;
+            
+
+            
+        }
+
+        private void Button_Click_CalendarEastern(object sender, RoutedEventArgs e)
+        {
+            ShowPanelDate.IsVisible = false;
+            Calendars.IsVisible = false;
+            Backbutton.IsVisible = true;
+            EasternGoro.IsVisible = true;
+            ButtonShow.IsVisible = false;
+        }
+        private void Button_Click_CalendarZodiac(object sender, RoutedEventArgs e)
+        {
+            Backbutton.IsVisible = true;
+            EasternGoro.IsVisible= false;
+            ShowPanelDate.IsVisible = false;
+            Calendars_Buttons.IsVisible = false;
+
+            List<string> Signs = new List<string>() { "Âîäîëåé", "Ðûáû", "Îâåí", "Òåëåö", "Áëèçíåöû", "Ðàê", "Ëåâ", "Äåâà", "Âåñû", "Ñêîðïèîí", "Ñòðåëåö", "Êîçåðîã" };
+            
 
+            string date = DatePick.SelectedDate.ToString();
+            DateTime dateUsed = Convert.ToDateTime(date);
+            switch (dateUsed.Month)
+            {
+                case 1: { if (dateUsed.Day >= 20) { ZodiacSign.Text = Signs[0]; } else { ZodiacSign.Text = Signs[11]; } break; }
+                case 2: { if (dateUsed.Day >= 20) { ZodiacSign.Text = Signs[1]; } else { ZodiacSign.Text = Signs[0]; } break; }
+                case 3: { if (dateUsed.Day >= 21) { ZodiacSign.Text = Signs[2]; } else { ZodiacSign.Text = Signs[1]; } break; }
+                case 4: { if (dateUsed.Day >= 20) { ZodiacSign.Text = Signs[3]; } else { ZodiacSign.Text = Signs[2]; } break; }
+                case 5: { if (dateUsed.Day >= 21) { ZodiacSign.Text = Signs[4]; } else { ZodiacSign.Text = Signs[3]; } break; }
+                case 6: { if (dateUsed.Day >= 21) { ZodiacSign.Text = Signs[5]; } else { ZodiacSign.Text = Signs[4]; } break; }
+                case 7: { if (dateUsed.Day >= 23) { ZodiacSign.Text = Signs[6]; } else { ZodiacSign.Text = Signs[5]; } break; }
+                case 8: { if (dateUsed.Day >= 23) { ZodiacSign.Text = Signs[7]; } else { ZodiacSign.Text = Signs[6]; } break; }
+                case 9: { if (dateUsed.Day >= 23) { ZodiacSign.Text = Signs[8]; } else { ZodiacSign.Text = Signs[7]; } break; }
+                case 10: { if (dateUsed.Day >= 24) { ZodiacSign.Text = Signs[9]; } else {  ZodiacSign.Text = Signs[8]; } break; }
+                case 11: { if (dateUsed.Day >= 23) { ZodiacSign.Text = Signs[10]; } else { ZodiacSign.Text = Signs[9]; } break; }
+                case 12: { if (dateUsed.Day >= 21) { ZodiacSign.Text = Signs[11]; } else { ZodiacSign.Text = Signs[10]; } break; }
+            }
+            ButtonShow.IsVisible = false;
+            ZodiacSign.IsVisible = true;
+            Zodiac.IsVisible = true;
+            
             
         }
+
+        private void Button_Click_Back(object sender, RoutedEventArgs e)
+        {
+
+            Calendars_Buttons.IsVisible = true;
+            ShowPanelDate.IsVisible = true;
+            Calendars.IsVisible = true;
+            Backbutton.IsVisible = false;
+            EasternGoro.IsVisible = false;
+            Zodiac.IsVisible = false;
+            ButtonShow.IsVisible = true;
+
+
+        }
+
+            
     }