public void onDayButton(DayButton selectedButton) { DateTime selectedButtonTime = selectedButton.getAssignedDateTime(); bool outOfMonth = selectedButtonTime.Month != dateViewSelection.Month; if (outOfMonth) { int yearDif = selectedButtonTime.Year - dateViewSelection.Year; int monthDif = selectedButtonTime.Month - dateViewSelection.Month; if (yearDif != 0) { monthDif += 12 * yearDif; } dateViewSelection = dateViewSelection.AddMonths(monthDif); layoutDateView(); } else { selectedTime = new DateTime(selectedButtonTime.Year, selectedButtonTime.Month, selectedButtonTime.Day, selectedTime.Hour, selectedTime.Minute, CONSTANT_DATETIME_SECONDS); switchToTimeView(); } }
internal void RefreshDay(int day) { DayButton db = DayButtons.Find(d => d.IsMainMonth && d.Text == "" + day); if (db == null) { return; } db.Refresh(); }
public void Init() { for (int index = 0; index < 42; index++) { int i = index % 7; int j = index / 7; DayButton db = new DayButton(Width / 7 * i, Height / 6 * j, form, Width / 7 - 5, Height / 6 - 5); DayButtons.Add(db); Controls.Add(db); } }
private void Awake() { xMin = -6.9f; xMax = 6.9f; yMin = -4.6f; yMax = 4.6f; new_dayButton = GetComponent <DayButton>(); rb2D = GetComponent <Rigidbody2D>(); bx = GetComponent <BoxCollider2D>(); rectGO = GetComponent <RectTransform>(); anchoredPositionInitial = rectGO.anchoredPosition; }
async void OnDayButtonClicked(object sender, System.EventArgs e) { DayButton dayButton = (DayButton)sender; await Navigation.PushAsync(new ReminderListPage(dayButton.Date)); todayDate = DateTime.Now; if ((todayDate.Day == dayButton.Date.Day) && (todayDate.Month == dayButton.Date.Month) && (todayDate.Year == dayButton.Date.Year)) { dayButton.BackgroundColor = Color.Orange; //dayButton.FontAttributes = FontAttributes.Bold; } }
private void applyDayButtonConstants(DayButton button) { button.dayButtonTransform.SetParent(daySelectionPanelTransform); button.dayButtonTransform.localScale = Vector3.one; button.setDateTimePickerParent(this); Vector3 pos = button.dayButtonTransform.localPosition; pos.z = 0.0f; button.dayButtonTransform.localPosition = pos; dayButtonToggleGroup.RegisterToggle(button.dayButton); button.dayButton.group = dayButtonToggleGroup; }
void Calender(int y, int m) { calenderStack.Children.Clear(); DateTime dt = new DateTime(y, m, 1); int week = (int)dt.DayOfWeek; //うるう年設定 int[] md = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (DateTime.IsLeapYear(y)) { md[1] = 29; } //曜日あわせ int cnt = 0; while (cnt < week) { cnt++; } int day = 1; int line; for (line = 0; line <= (md[m - 1] / 7) + 1; line++) { //カレンダー用stackLayout StackLayout dayStack = new StackLayout() { HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Spacing = 0 }; /*/予定確認用stackLayout * StackLayout dayPlanStack = new StackLayout() * { * HorizontalOptions = LayoutOptions.EndAndExpand, * VerticalOptions = LayoutOptions.FillAndExpand, * Orientation = StackOrientation.Horizontal, * Spacing = 0 * };*/ //最後左づめ if (line >= md[m - 1] / 7) { dayStack.HorizontalOptions = LayoutOptions.StartAndExpand; //dayPlanStack.HorizontalOptions = LayoutOptions.StartAndExpand; } while (cnt < 7 && day <= md[m - 1]) { //日にちを表示 DayButton dayButton = new DayButton() { Text = day.ToString(), BackgroundColor = Color.Transparent, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Button)), WidthRequest = 42, HeightRequest = 42, Date = new DateTime(year, month, day) }; dayButton.Clicked += OnDayButtonClicked; todayDate = DateTime.Now; if ((todayDate.Day == dayButton.Date.Day) && (todayDate.Month == dayButton.Date.Month) && (todayDate.Year == dayButton.Date.Year)) { dayButton.BackgroundColor = Color.Orange; //dayButton.FontAttributes = FontAttributes.Bold; } //曜日による色変更 DateTime dateTime = new DateTime(y, m, day); int w = (int)dateTime.DayOfWeek; if (w == 0) { dayButton.TextColor = Color.Red; } else if (w == 6) { dayButton.TextColor = Color.Blue; } else { dayButton.TextColor = Color.Black; } dayStack.Children.Add(dayButton); /*/予定の有無 * DayLabel dayLabel = new DayLabel() * { * Text = " ■", * TextColor = Color.Aqua, * dtPlan = new DateTime(year, month, day), * WidthRequest = 42, * HeightRequest = 9 * }; * dayPlanStack.Children.Add(dayLabel); */ //IOSの文字変更 if (Device.RuntimePlatform == Device.iOS) { dayButton.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)); //dayLabel.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); //dayLabel.Text = " ■"; //dayLabel.HeightRequest = 2; } day++; cnt++; } cnt = 0; calenderStack.Children.Add(dayStack); //calenderStack.Children.Add(dayPlanStack); } }