private void Grid_MouseLeave(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 LeavedRectangle = FindName("Rectangle" + BaseName) as System.Windows.Shapes.Rectangle; int Index = Rectangles.IndexOf(LeavedRectangle); if (LeavedRectangle.Style != FindResource("RectangleStyleToday")) { if (previousIndex == Index) { LeavedRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleEventedDay"); previousIndex = -1; return; } } System.Windows.Controls.TextBlock LeavedTextBlock = TextBlocks.ElementAt(Index); if ((LeavedRectangle.Style == FindResource("RectangleStyleNone") && LeavedTextBlock.Style == FindResource("TextBlockStyleForOtherMonths")) || LeavedRectangle.Style == FindResource("RectangleStyleToday") || LeavedRectangle.Style == FindResource("RectangleStyleEventedDay")) { return; } LeavedRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleNone"); }
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); }
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; } 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 AAk.Utils.PersianDate(yearPersian, monthPersian, dayPersian); RaiseSelectedDateTimeChangedEvent(); if (e.ClickCount == 2) { RaiseMouseDoubleClickEvent(); } }