Gorbachev 2 miesięcy temu
rodzic
commit
01734bddcd
2 zmienionych plików z 37 dodań i 3 usunięć
  1. 7 0
      Task1/MainWindow.axaml
  2. 30 3
      Task1/MainWindow.axaml.cs

+ 7 - 0
Task1/MainWindow.axaml

@@ -16,7 +16,14 @@
 		</StackPanel>
 		<StackPanel Name="ShowPanelDate" Classes="HiddenDate">
 			<TextBox Name="Info"></TextBox>
+			<TextBox Name="InfoYear"></TextBox>
+			<TextBox Name="InfoMonth">Или</TextBox>
+			<TextBox Name="InfoDay"></TextBox>
+			<StackPanel Name="BirthDates">
+				<TextBox Name="WeekDay"></TextBox>
+			</StackPanel>
 		</StackPanel>
+			
 	</StackPanel>
 	</Grid>
 </Window>

+ 30 - 3
Task1/MainWindow.axaml.cs

@@ -22,14 +22,41 @@ namespace Task1
                 DateTime today = DateTime.Today;
                 string date = DatePick.SelectedDate.ToString();
                 DateTime dateUsed = Convert.ToDateTime(date);
-                var dateModified = today - dateUsed;
+                var separateYear = today.Year - dateUsed.Year;
+                var separateMonth = today.Month - dateUsed.Month;
+                var separateDay = today.Day - dateUsed.Day;
+                if (separateDay < 0)
+                {
+                    separateMonth--;
+                    separateDay =  DateTime.DaysInMonth(dateUsed.Year, dateUsed.Month)+ (today.Day - dateUsed.Day);
+                }
+                InfoYear.Text = Convert.ToString(separateYear) + " ëåò " + Convert.ToString(separateMonth) + " ìåñÿöåâ " + Convert.ToString(separateDay) + " äíåé.";
+                InfoDay.Text = Convert.ToString((today - dateUsed).TotalDays) + " äíåé ";
+
+                WeekDay.Text = Convert.ToString(dateUsed.DayOfWeek);
+                DateTime buffer = dateUsed;
+                while (buffer <= today)
+                {
+                    buffer = buffer.AddYears(1);
+                    if (buffer.DayOfWeek == dateUsed.DayOfWeek)
+                    {
+                        TextBlock BDate = new TextBlock();
+                        {
+                            BDate.Text = buffer.ToString();
+                        }
+
+                        BirthDates.Children.Add(BDate);
+                    }
+                }
+
             }
             catch(Exception ex) {
-
+                Info.Text = ex.Message;
             }
-            ShowPanelDate.IsVisible = true;
 
+            ShowPanelDate.IsVisible = true;
 
+            
         }
     }