public void Refresh() { First_.Items.Clear(); Second_.Items.Clear(); Third_.Items.Clear(); GridView[] dayTitles = { First_, Second_, Third_ }; GridView[] dayAgendas = { FirstDay, SecondDay, ThirdDay }; DayAgenda day = App.AgendasModel.GetDay(DateTime.Today); DateTime time = firstDate; for (int titleIndex = 0; titleIndex < dayTitles.Length; titleIndex++) { UILayout uiLayout = new UILayout(); uiLayout.SolidColorBrush = Colors.LightSeaGreen; //<<<<<<< HEAD // StackPanel stackPanel = uiLayout.GetMode_A_StackPanel(100, 100, 5, time.Month, time.Day); //======= StackPanel stackPanel = uiLayout.GetMode_A_StackPanel(100, 100, 5, time.Month, time.Day); stackPanel.Tag = time; stackPanel.Tapped += stackPanel_Tapped; //>>>>>>> 15e4197158387a14fb3e1114550e2ff780f71c62 dayTitles[titleIndex].Items.Add(stackPanel); dayAgendas[titleIndex].Items.Clear(); List <Agenda> agendaList = App.AgendasModel.GetAgendaList(time); for (int agendaIndex = 0; agendaIndex < agendaList.Count; agendaIndex++) { //DayAgenda day = App.AgendasModel.GetDayList(time).ElementAt(i); UILayout uiLayout2 = new UILayout(); int hour = agendaList[agendaIndex].StartDateTime.Value.Hour; int min = agendaList[agendaIndex].StartDateTime.Value.Minute; int hour2 = agendaList[agendaIndex].EndDateTime.Value.Hour; int min2 = agendaList[agendaIndex].EndDateTime.Value.Minute; StackPanel stackPanel2 = uiLayout2.GetMode_B_StackPanel(150, 100, 0, 0, hour * 60 + min, hour2 * 60 + min2, agendaList[agendaIndex].Title); stackPanel2.Tag = agendaList[agendaIndex]; stackPanel2.Tapped += stackPanel2_Tapped; GridView agenda = new GridView(); agenda.AllowDrop = true; agenda.DragEnter += myRectangle_DragEnter; agenda.Items.Add(stackPanel2); dayAgendas[titleIndex].Items.Add(agenda); uiLayout2 = null; } time = time.AddDays(1); } }
//Paint public void Paint(int year, int month, int day = -1) { int lastMonthWeek; int lastMonthDays; int nowMonthWeek; int nowMonthDays; int nextMonthWeek; int nextMonthDays; WeekAndDays(out lastMonthWeek, out lastMonthDays, year, month - 1); WeekAndDays(out nowMonthWeek, out nowMonthDays, year, month); WeekAndDays(out nextMonthWeek, out nextMonthDays, year, month + 1); _itemsConrol.Items.Clear(); int count = 0; for (int i = 0; i < 7; i++) { UILayout uiLayout = new UILayout(); if (i == 6) { uiLayout.SolidColorBrush = Colors.DarkGoldenrod; _itemsConrol.Items.Add(uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, 0, 0, 0, month.ToString()+"月")); } else if (i == 5) { uiLayout.SolidColorBrush = Colors.DarkGoldenrod; _itemsConrol.Items.Add(uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, 0, 0, 0, year.ToString())); } else { uiLayout.SolidColorBrush = Colors.Transparent; _itemsConrol.Items.Add(uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, 0, 0, 0, "")); } } for (int i = 0; i < 7; i++) { StackPanel stackPanel = CreateStackPanel(((DayOfWeek)i).ToString(), WeekColor(-1)); stackPanel.Tag = null; _itemsConrol.Items.Add(stackPanel); } for (int i = 1; i <= nowMonthWeek; i++) { StackPanel stackPanel = CreateStackPanel(month - 1 < 1 ? month - 1 + 12 : month - 1, lastMonthDays - nowMonthWeek + i, WeekColor(7)); stackPanel.Tag = new DateTime(year, month - 1 < 1 ? month - 1 + 12 : month - 1, lastMonthDays - nowMonthWeek + i); _itemsConrol.Items.Add(stackPanel); count = (count + 1) % 7; } for (int i = 1; i <= nowMonthDays; i++) { StackPanel stackPanel = CreateStackPanel(month, i, WeekColor(count)); stackPanel.Tag = new DateTime(year, month, i); _itemsConrol.Items.Add(stackPanel); count = (count + 1) % 7; } for (int i = 1; i <= 7 - nextMonthWeek; i++) { StackPanel stackPanel = CreateStackPanel(month + 1 > 12 ? month + 1 - 12 : month + 1, i, WeekColor(7)); stackPanel.Tag = new DateTime(year, month + 1 > 12 ? month + 1 - 12 : month + 1, i); _itemsConrol.Items.Add(stackPanel); count = (count + 1) % 7; } }
//CreateTextBlock private StackPanel CreateStackPanel(int month, int day, Color color) { UILayout uiLayout = new UILayout(); uiLayout.SolidColorBrush = color; StackPanel stackPanel = uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, BLOCK_THICKNESS, month, day); stackPanel.Tapped += OnPointerPressed; return stackPanel; }
//CreateTextBlock private StackPanel CreateStackPanel(string showText, Color color) { UILayout uiLayout = new UILayout(); uiLayout.SolidColorBrush = color; return uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, BLOCK_THICKNESS, 0, 0, showText); }
//Paint public void Paint(int year, int month, int day = -1) { int lastMonthWeek; int lastMonthDays; int nowMonthWeek; int nowMonthDays; int nextMonthWeek; int nextMonthDays; WeekAndDays(out lastMonthWeek, out lastMonthDays, year, month - 1); WeekAndDays(out nowMonthWeek, out nowMonthDays, year, month); WeekAndDays(out nextMonthWeek, out nextMonthDays, year, month + 1); _itemsConrol.Items.Clear(); int count = 0; for (int i = 0; i < 7; i++) { UILayout uiLayout = new UILayout(); if (i == 6) { uiLayout.SolidColorBrush = Colors.DarkGoldenrod; _itemsConrol.Items.Add(uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, 0, 0, 0, month.ToString() + "月")); } else if (i == 5) { uiLayout.SolidColorBrush = Colors.DarkGoldenrod; _itemsConrol.Items.Add(uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, 0, 0, 0, year.ToString())); } else { uiLayout.SolidColorBrush = Colors.Transparent; _itemsConrol.Items.Add(uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, 0, 0, 0, "")); } } for (int i = 0; i < 7; i++) { StackPanel stackPanel = CreateStackPanel(((DayOfWeek)i).ToString(), WeekColor(-1)); stackPanel.Tag = null; _itemsConrol.Items.Add(stackPanel); } for (int i = 1; i <= nowMonthWeek; i++) { StackPanel stackPanel = CreateStackPanel(month - 1 < 1 ? month - 1 + 12 : month - 1, lastMonthDays - nowMonthWeek + i, WeekColor(7)); stackPanel.Tag = new DateTime(year, month - 1 < 1 ? month - 1 + 12 : month - 1, lastMonthDays - nowMonthWeek + i); _itemsConrol.Items.Add(stackPanel); count = (count + 1) % 7; } for (int i = 1; i <= nowMonthDays; i++) { StackPanel stackPanel = CreateStackPanel(month, i, WeekColor(count)); stackPanel.Tag = new DateTime(year, month, i); _itemsConrol.Items.Add(stackPanel); count = (count + 1) % 7; } for (int i = 1; i <= 7 - nextMonthWeek; i++) { StackPanel stackPanel = CreateStackPanel(month + 1 > 12 ? month + 1 - 12 : month + 1, i, WeekColor(7)); stackPanel.Tag = new DateTime(year, month + 1 > 12 ? month + 1 - 12 : month + 1, i); _itemsConrol.Items.Add(stackPanel); count = (count + 1) % 7; } }
public void Refresh() { First_.Items.Clear(); Second_.Items.Clear(); Third_.Items.Clear(); GridView[] dayTitles = { First_, Second_, Third_ }; GridView[] dayAgendas = { FirstDay, SecondDay, ThirdDay }; DayAgenda day = App.AgendasModel.GetDay(DateTime.Today); DateTime time = firstDate; for (int titleIndex = 0; titleIndex < dayTitles.Length; titleIndex++) { UILayout uiLayout = new UILayout(); uiLayout.SolidColorBrush = Colors.LightSeaGreen; //<<<<<<< HEAD // StackPanel stackPanel = uiLayout.GetMode_A_StackPanel(100, 100, 5, time.Month, time.Day); //======= StackPanel stackPanel = uiLayout.GetMode_A_StackPanel(100, 100, 5,time.Month , time.Day); stackPanel.Tag = time; stackPanel.Tapped += stackPanel_Tapped; //>>>>>>> 15e4197158387a14fb3e1114550e2ff780f71c62 dayTitles[titleIndex].Items.Add(stackPanel); dayAgendas[titleIndex].Items.Clear(); List<Agenda> agendaList = App.AgendasModel.GetAgendaList(time); for (int agendaIndex = 0; agendaIndex < agendaList.Count; agendaIndex++) { //DayAgenda day = App.AgendasModel.GetDayList(time).ElementAt(i); UILayout uiLayout2 = new UILayout(); int hour = agendaList[agendaIndex].StartDateTime.Value.Hour; int min = agendaList[agendaIndex].StartDateTime.Value.Minute; int hour2 = agendaList[agendaIndex].EndDateTime.Value.Hour; int min2 = agendaList[agendaIndex].EndDateTime.Value.Minute; StackPanel stackPanel2 = uiLayout2.GetMode_B_StackPanel(150, 100, 0, 0, hour * 60 + min, hour2 * 60 + min2, agendaList[agendaIndex].Title); stackPanel2.Tag = agendaList[agendaIndex]; stackPanel2.Tapped += stackPanel2_Tapped; GridView agenda = new GridView(); agenda.AllowDrop = true; agenda.DragEnter += myRectangle_DragEnter; agenda.Items.Add(stackPanel2); dayAgendas[titleIndex].Items.Add(agenda); uiLayout2 = null; } time = time.AddDays(1); } }
//InitialAgendaGridViewList private List<StackPanel> InitialAgendaGridViewList(List<Agenda> agendaList) { List<StackPanel> gridViewList = new List<StackPanel>(); for (int i = 0; i < agendaList.Count; i++) { int collisionCount = 1; //GridView gridView = CreateGridView(Colors.DarkGreen); double startHourMin = GetHourMin(agendaList[i].StartDateTime); double endHourMin = GetHourMin(agendaList[i].EndDateTime); double width = (endHourMin - startHourMin) / 60.0 * HourWidth; double height; double left = startHourMin / 60.0 * HourWidth; double top = LINE_PADDING; for (int j = 0; j < i; j++) { StackPanel iGridView = gridViewList[j]; double iLeft = iGridView.Margin.Left; double iRight = iLeft + iGridView.Width; if (top == iGridView.Margin.Top && iLeft <= left && left <= iRight) { top += HOUR_HEIGHT + LINE_PADDING; collisionCount++; j = 0; } } if (_collisionCount < collisionCount) { _collisionCount = collisionCount; } UILayout uiLayout = new UILayout(); width = width >= HOUR_MIN_WIDTH ? width : HOUR_MIN_WIDTH; height = HOUR_HEIGHT; StackPanel stackPanel = uiLayout.GetMode_B_StackPanel(width, height, left, top, startHourMin, endHourMin, agendaList[i].Title); stackPanel.PointerPressed += OnPointerPressed; stackPanel.Tag = agendaList[i]; gridViewList.Add(stackPanel); } return gridViewList; }