/// <summary> /// Generates an array of days in a month /// </summary> /// <param name="month">The month to get the days for </param> /// <param name="year">The year to get the days for </param> /// <param name="maxDate">The max date to generate enabled cells</param> /// <param name="minDate">The min date to generate enabled cells</param> /// <param name="isCurrentMonth">flag to indicate if this is the current month</param> /// <returns>Returns an int array full of days in a month</returns> public DayCell[] GetDaysOfMonth(int month, int year, DateTime minDate, DateTime maxDate, bool isCurrentMonth) { KeyValuePair <int, int> key = new KeyValuePair <int, int>(month, year); int daysCount = DateTime.DaysInMonth(year, month); DayCell[] days = null; if (daysArrays.ContainsKey(key)) { days = daysArrays[key]; foreach (DayCell item in days) { item.IsEnabled = IsDateWithinRange(minDate, maxDate, item); item.IsInCurrentMonth = isCurrentMonth; } } else { days = new DayCell[daysCount]; for (int i = 0; i < days.Length; i++) { DayCell item = new DayCell(i + 1, month, year); item.IsEnabled = IsDateWithinRange(minDate, maxDate, item); item.IsInCurrentMonth = isCurrentMonth; days[i] = item; } daysArrays[key] = days;//cache the array } return(days); }
private void MouseClickManagement(MouseEventArgs e) { //reinit values List <string> ClickedValues = new List <string>(); m_clickedItemsList = new List <string>(); string ClickedValuesString = ""; m_clickedItemsCSV = ""; //get the Cell DataGridView.HitTestInfo hit = this.HitTest(e.X, e.Y); if (hit.Type == DataGridViewHitTestType.Cell) { clickedCell = this.Rows[hit.RowIndex].Cells[hit.ColumnIndex]; } //hour cell? try { HalfHourCell hhc = (HalfHourCell)clickedCell; for (int i = 0; i < hhc.CalendarItems.Count; i++) { ClickedValues.Add(hhc.CalendarItems[i].Key); ClickedValuesString += hhc.CalendarItems[i].Key + ","; } } catch { } //day cell? try { DayCell hhc = (DayCell)clickedCell; for (int i = 0; i < hhc.CalendarItems.Count; i++) { ClickedValues.Add(hhc.CalendarItems[i].Key); ClickedValuesString += hhc.CalendarItems[i].Key + ","; } } catch { } if (ClickedValues.Count > 0) { m_clickedItemsList = ClickedValues; //less the last , m_clickedItemsCSV = Microsoft.VisualBasic.Strings.Left(ClickedValuesString, Microsoft.VisualBasic.Strings.Len(ClickedValuesString) - 1); //raise event Change List this.ListChanged(m_clickedItemsCSV); } else { this.ListChanged(""); } }
public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) { DayCell cell = tableView.DequeueReusableCell(cellId) as DayCell; if (cell == null) { cell = new DayCell(days[indexPath.Row].ToString("dddd"), days[indexPath.Row], cellId); } else { cell.UpdateCell(days[indexPath.Row].ToString("dddd"), days[indexPath.Row]); } cell.Accessory = UITableViewCellAccessory.DisclosureIndicator; return(cell); }
/// <summary> /// In this method we change the DayCell styles are changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// void daycellstylechange() { // For DayCell Custom Style s = new Style(); DayCell fx = new DayCell(); s.TargetType = fx.GetType(); Setter sett = new Setter(DayCell.BackgroundProperty, dcBackgroundBackup); Setter sett1 = new Setter(DayCell.BorderBrushProperty, dcBorderBackup); Setter sett2 = new Setter(DayCell.BorderThicknessProperty, new Thickness(dcBorThickValue)); Setter sett3 = new Setter(Border.CornerRadiusProperty, new CornerRadius(dcCornerValue)); s.Setters.Add(sett); s.Setters.Add(sett1); s.Setters.Add(sett2); s.Setters.Add(sett3); firstCalendarEdit.DayCellsStyle = s; }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { //// request a recycled cell to save memory //UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); //// if there are no cells to reuse, create a new one //if (cell == null) // cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier); //cell.TextLabel.Text = tableItems[indexPath.Row]; //return cell; DayCell cell = tableView.DequeueReusableCell(cellId) as DayCell; if (cell == null) cell = new DayCell(sessions[indexPath.Row].Name, sessions[indexPath.Row].Name, cellId); else cell.UpdateCell(sessions[indexPath.Row].Name, sessions[indexPath.Row].Name); cell.Accessory = UITableViewCellAccessory.DisclosureIndicator; return cell; }
private void CreateSquares() { double rowHeight = Height / 8; double cellSize = rowHeight; double currentY = TopLeftLocation.Y; //Month title MonthNameCell title = new MonthNameCell(month, TopLeftLocation, rowHeight, Width); cells.Add(title); //Day titles currentY = currentY - rowHeight; CreateDayTitles(currentY, cellSize); foreach (Week week in month.GetWeeksInOrder()) { currentY = currentY - rowHeight; //Week number WeekNumberCell ws = new WeekNumberCell( week, new Coordinate(TopLeftLocation.X, currentY, 0), cellSize); cells.Add(ws); //Day number foreach (KeyValuePair <int, Day> kvp in week.Days) { if (kvp.Value.Date.Month == month.Number) { Coordinate loc = new Coordinate( TopLeftLocation.X + kvp.Key * cellSize, currentY, 0); DayCell ds = new DayCell(kvp.Value, loc, cellSize); cells.Add(ds); } } } Cells = new ReadOnlyCollection <ICalendarCell>(cells); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { //// request a recycled cell to save memory //UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); //// if there are no cells to reuse, create a new one //if (cell == null) // cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier); //cell.TextLabel.Text = tableItems[indexPath.Row]; //return cell; DayCell cell = tableView.DequeueReusableCell(cellId) as DayCell; if (cell == null) { cell = new DayCell(sessions[indexPath.Row].Name, sessions[indexPath.Row].Name, cellId); } else { cell.UpdateCell(sessions[indexPath.Row].Name, sessions[indexPath.Row].Name); } cell.Accessory = UITableViewCellAccessory.DisclosureIndicator; return(cell); }
/// <summary> /// Checks if the specified date is greater than /// </summary> /// <param name="minDate">The min date</param> /// <param name="maxDate">The max date</param> /// <param name="cell">The cell to check</param> /// <returns>Returns true if the cell is greater</returns> public static bool IsDateWithinRange(DateTime minDate, DateTime maxDate, DayCell cell) { long ticks = new DateTime(cell.YearNumber, cell.MonthNumber, cell.DayNumber).Ticks; return(ticks >= minDate.Ticks && ticks <= maxDate.Ticks); }