private void Grid_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { string BaseName = System.Text.RegularExpressions.Regex.Replace((sender as System.Windows.Controls.Grid).Name, @"Grid", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Windows.Shapes.Rectangle EnteredRectangle = FindName("Rectangle" + BaseName) as System.Windows.Shapes.Rectangle; int Index = Rectangles.IndexOf(EnteredRectangle); if (Rectangles.ElementAt(Index).Style == FindResource("RectangleStyleEventedDay")) { previousIndex = Index; } System.Windows.Controls.TextBlock EnteredTextBlock = TextBlocks.ElementAt(Index); if ((EnteredRectangle.Style == FindResource("RectangleStyleNone") && EnteredTextBlock.Style == FindResource("TextBlockStyleForOtherMonths")) || EnteredRectangle.Style == FindResource("RectangleStyleToday")) { return; } EnteredRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleMouseEntered"); }
private void ChangeProperties(int which, string persianDate, string rectangleResourceName, string persianTextBlockResourceName) { Rectangles.ElementAt(which) .Style = (System.Windows.Style)FindResource(rectangleResourceName); TextBlocks.ElementAt(which) .Text = persianDate; TextBlocks.ElementAt(which) .Style = (System.Windows.Style)FindResource(persianTextBlockResourceName); }
// Checks for ball-rectangles collision and removes dead rectangles. private void CheckRectangleCollision(Ball ball) { for (int i = Rectangles.Count - 1; i >= 0; --i) { if (ball.CheckCollision(Rectangles.ElementAt(i))) { if (Rectangles.ElementAt(i).HitsRemaining <= 0) { Rectangles.RemoveAt(i); } break; } } }
public void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { int todayIndex; foreach (System.Windows.Shapes.Rectangle item in Rectangles) { item.Style = (System.Windows.Style)FindResource("RectangleStyleNone"); if (item.Style == (System.Windows.Style)FindResource("RectangleStyleToday")) { todayIndex = Rectangles.IndexOf(item); } } SelectedRectangleBaseName = System.Text.RegularExpressions.Regex.Replace((sender as System.Windows.Controls.Grid).Name, @"Grid", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Windows.Shapes.Rectangle SelectedRectangle = FindName("Rectangle" + SelectedRectangleBaseName) as System.Windows.Shapes.Rectangle; int Index = Rectangles.IndexOf(SelectedRectangle); System.Windows.Controls.TextBlock SelectedTextBlock = TextBlocks.ElementAt(Index); if ((SelectedRectangle.Style == FindResource("RectangleStyleNone") && SelectedTextBlock.Style == FindResource("TextBlockStyleForOtherMonths"))) { return; } foreach (int index in IntEventedIndex) { (Rectangles.ElementAt(index)).Style = (System.Windows.Style)FindResource("RectangleStyleEventedDay"); } SelectedRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleToday"); PreviousRectangle = SelectedRectangle; ////بدست آوردن اطلاعات امروز this.yearPersian = this.yearForNavigating; this.monthPersian = this.monthForNavigating; this.dayPersian = (FindName("TextBlock" + SelectedRectangleBaseName) as System.Windows.Controls.TextBlock).Text.ConvertToInteger(); SelectedDateTime = new FarsiLibrary.Utils.PersianDate(yearPersian, monthPersian, dayPersian); SelectedDateTimeChanged?.Invoke(this, System.EventArgs.Empty); }