Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void LoadWorkingCalendarByEmployee()
        {
            monthCalendar1.Dates.Clear();
            int DeparmentID = (int)departmentTreeView.SelectedNode.Tag;

            dsEmployee = employeeDO.GetEmployeeByDepartment(DeparmentID);
            int employeeID = (int)dsEmployee.Tables[0].Rows[selectedRowIndex]["EmployeeID"];

            workingTimeDO = new RegWorkingTimeDO();
            dsWorkingTime = workingTimeDO.GetOverTimeByMonth(employeeID, CurrentMonth, CurrentYear);
            shiftDO       = new ShiftDO();
            DataSet dsShiftOver = new DataSet();

            if (dsWorkingTime.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsWorkingTime.Tables[0].Rows)
                {
                    DateTime Day         = DateTime.Parse(dr["WorkingDay"].ToString());
                    int      ShiftOverID = int.Parse(dr["ShiftOverID"].ToString());
                    dsShiftOver = shiftDO.GetShiftOverByID(ShiftOverID);

                    DateItem dateItem = new DateItem();
                    dateItem.DateColor = lblOverTimeLegend.ForeColor;
                    dateItem.BackColor = lblOverTimeLegend.BackColor;
                    dateItem.Date      = Day;
                    if (dsShiftOver != null)
                    {
                        dateItem.Text = dsShiftOver.Tables[0].Rows[0]["ShiftName"].ToString();
                    }
                    monthCalendar1.AddDateInfo(dateItem);
                }
            }
            monthCalendar1.Refresh();
            monthCalendar1.ClearSelection();
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <DateItem> > PostDateItems(DateItem item)
        {
            _context.DateItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetDateItem), new { id = item.DateItemId }, item));
        }
Ejemplo n.º 3
0
        public async Task <DateItem> deleteItem(int userId, int itemId)
        {
            using (NpgsqlConnection connection = new NpgsqlConnection(config.GetConnectionString("postgres")))
            {
                string sql = "SELECT user_id FROM \"date_item\" WHERE id = @id";
                IEnumerable <DateItem> result = await connection.QueryAsync <DateItem>(sql, new { id = itemId });

                List <DateItem> resultItems = result.ToList();
                if (!resultItems.Any())
                {
                    throw new InvalidOperationException("No such date item");
                }
                if (resultItems[0].user_id != userId)
                {
                    throw new UnauthorizedAccessException("Resource does not belong to you");
                }
                sql = "DELETE FROM \"date_item\" WHERE id = @id RETURNING *";
                DateItem deleteResult = await connection.QueryFirstOrDefaultAsync <DateItem>(sql, new { id = itemId });

                if (deleteResult == null)
                {
                    throw new InvalidOperationException("No rows were deleted");
                }
                return(deleteResult);
            }
        }
        private static bool CompareDates(DateTime date1, DateTime date2, DateItem parameter)
        {
            switch (parameter)
            {
            case DateItem.Year:
                return(date1.Year == date2.Year);

            case DateItem.Month:
                return(date1.Year == date2.Year && date1.Month == date2.Month);

            case DateItem.Day:
                return(date1.Year == date2.Year && date1.Month == date2.Month &&
                       date1.Day == date2.Day);

            case DateItem.Hour:
                return(date1.Year == date2.Year && date1.Month == date2.Month &&
                       date1.Day == date2.Day && date1.Hour == date2.Hour);

            case DateItem.Minute:
                return(date1.Year == date2.Year && date1.Month == date2.Month &&
                       date1.Day == date2.Day && date1.Hour == date2.Hour &&
                       date1.Minute == date2.Minute);

            case DateItem.Second:
                return(date1.Year == date2.Year && date1.Month == date2.Month &&
                       date1.Day == date2.Day && date1.Hour == date2.Hour &&
                       date1.Minute == date2.Minute && date1.Second == date2.Second);

            case DateItem.Millisecond:
                return(date1 == date2);

            default: throw new WrongAccuracyUsageException("Wrong DateItem.");
            }
        }
Ejemplo n.º 5
0
        public void RefreshNewAddedRows(ChatMessageViewModel chatModel, ChatMessage savedMessages)
        {
            DateItem dateItem = new DateItem();

            dateItem.setDate(chatModel.MessageTime.ToShortDateString());
            var  listofDates = consolidatedList.Where(a => a.getType() == 0).ToList();
            bool dateExist   = false;

            for (int i = 0; i < listofDates.Count; i++)
            {
                ListItem msg      = listofDates[i];
                DateItem DateItem = (DateItem)msg;
                if (DateItem.getDate() == dateItem.getDate())
                {
                    dateExist = true;
                }
            }
            if (!dateExist)
            {
                consolidatedList.Add(dateItem);
            }

            GeneralItem generalItem = new GeneralItem();

            generalItem.setChatMessagearray(savedMessages);
            consolidatedList.Add(generalItem);
            tblChatList.ReloadData();
            ScrollToBottom(true);
            filePath      = "";
            thumbFilePath = "";
        }
Ejemplo n.º 6
0
        //=之後要分到別的SCRIPT去===================
        public void AddActivity(Activity a)
        {
            //新增活動(不是UI)
            _schedule.addNewActivity(a);
            //傳輸
            List <string> tmp = _schedule.saveData(_myAccount.Account);

            for (int i = 0; i < tmp.Count; i++)
            {
                sentData(tmp[i]);
            }

            //確認是否已經標記過(如果沒有標記過,就標記在日曆物件)
            if (monthCalendar.Dates.IndexOf(new DateTime(a.Date.Year, a.Date.Month, a.Date.Day)) < 0)
            {
                //標示到日曆物件上
                DateItem di = new DateItem();
                di.Date       = new DateTime(a.Date.Year, a.Date.Month, a.Date.Day);
                di.BackColor1 = Color.Yellow;
                monthCalendar.AddDateInfo(di);
            }

            //提醒使用者創建成功
            notifyIcon.ShowBalloonTip(1000, "新增活動", a.Date.Year.ToString() + "/" +
                                      a.Date.Month.ToString() + "/" +
                                      a.Date.Day.ToString() + "-" +
                                      a.Date.Hour + ":" +
                                      a.Date.Minute, ToolTipIcon.Info);

            ShowSelectedDateActivities(selectedDate);
        }
Ejemplo n.º 7
0
        private void InitDateItems()
        {
            mListDateItems.Clear();
            var pageParent = PageParent;

            if (pageParent == null)
            {
                return;
            }
            var issueItems = pageParent.ListIssueItems;

            if (issueItems == null)
            {
                return;
            }
            var dateGroups = issueItems.GroupBy(g => g.Date);

            foreach (var dateGroup in dateGroups)
            {
                int      date = dateGroup.Key;
                DateItem item = new DateItem();
                item.Date = date;
                mListDateItems.Add(item);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// sets the colour for the month based on the amount of people assigned
        /// </summary>
        /// <param name="activeMonth"></param>
        /// <returns></returns>
        public DateItem[] SetDaysForMonth(ActiveMonth activeMonth)
        {
            int days = DateTime.DaysInMonth(activeMonth.Year, activeMonth.Month);

            dateItems = new DateItem[days];

            for (int i = 0; i < days; i++)
            {
                Color    color = Color.Red;
                DateTime date  = new DateTime(activeMonth.Year, activeMonth.Month, (i + 1));

                dateItems[i]      = new DateItem();
                dateItems[i].Date = new DateTime(activeMonth.Year, activeMonth.Month, (i + 1));

                foreach (Day day in this.days)
                {
                    DateTime test = day.Date();
                    if (test == date)
                    {
                        //check how many people are assigned to each shift
                        color = day.SetDayColor();
                    }
                }
                dateItems[i].BackColor1 = color;
            }

            return(dateItems);
        }
        public async Task <ActionResult <DateItemResponse> > Delete(int id)
        {
            try{
                string   bearerToken = Request.Headers["Authorization"].ToString().Split(" ").Last();
                int      userId      = int.Parse(jwtService.getUserId(bearerToken));
                DateItem result      = await datetimeService.deleteItem(userId, id);

                return(Ok(new DateItemResponse {
                    isSuccess = true, payload = new DateItemResponseData {
                        item = result
                    }
                }));
            }catch (UnauthorizedAccessException ex) {
                return(Unauthorized(new DateItemResponse {
                    isSuccess = false, error = new ApiError {
                        msg = ex.Message
                    }
                }));
            }catch (Exception ex) {
                return(BadRequest(new DateItemResponse {
                    isSuccess = false, error = new ApiError {
                        msg = ex.Message
                    }
                }));
            }
        }
Ejemplo n.º 10
0
        private DateItem BoldDate(DateTime date, string file)
        {
            DateItem ret = new DateItem();

            ret.Date       = date;
            ret.BackColor1 = Color.Green;
            //ret.Text = file;
            return(ret);
        }
Ejemplo n.º 11
0
        public void TestInitialize()
        {
            DateItem dateItem = new DateItem();

            Assert.IsNull(dateItem.date);
            Assert.AreEqual(string.Empty, dateItem.information);
            Assert.AreEqual(0, dateItem.id);
            Assert.AreEqual(0, dateItem.memberID);
        }
Ejemplo n.º 12
0
        private void AddSelectedDate(DateTime selectedDate)
        {
            var dateItem = new DateItem();

            dateItem.Date       = selectedDate;
            dateItem.BackColor1 = Color.Blue;
            _selectedDates.Add(dateItem);
            UpdateSelectedDates();
        }
Ejemplo n.º 13
0
        private void AddDateItem(DateItem dateItem)
        {
            switch (dateItem.Date.Month.ToString())
            {
            case "1":
                this.monthCalendar1.Dates.Add(dateItem);
                break;

            case "2":
                this.monthCalendar2.Dates.Add(dateItem);
                break;

            case "3":
                this.monthCalendar3.Dates.Add(dateItem);
                break;

            case "4":
                this.monthCalendar4.Dates.Add(dateItem);
                break;

            case "5":
                this.monthCalendar5.Dates.Add(dateItem);
                break;

            case "6":
                this.monthCalendar6.Dates.Add(dateItem);
                break;

            case "7":
                this.monthCalendar7.Dates.Add(dateItem);
                break;

            case "8":
                this.monthCalendar8.Dates.Add(dateItem);
                break;

            case "9":
                this.monthCalendar9.Dates.Add(dateItem);
                break;

            case "10":
                this.monthCalendar10.Dates.Add(dateItem);
                break;

            case "11":
                this.monthCalendar11.Dates.Add(dateItem);
                break;

            case "12":
                this.monthCalendar12.Dates.Add(dateItem);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 14
0
        private void btnAddDate_Click(object sender, EventArgs e)
        {
            DateItem item = new DateItem();

            SelectedTicket.Items.Insert(0, item);
            UpdateTicketLayout();
            SelectedItem = item;
            isChanged    = true;
            UpdateSaveButton();
        }
Ejemplo n.º 15
0
        public async Task <DateItem> getCoverItem(int userId)
        {
            using (NpgsqlConnection connection = new NpgsqlConnection(config.GetConnectionString("postgres")))
            {
                string   sql       = "SELECT * FROM \"date_item\" WHERE id = (SELECT date_item_id FROM \"cover_item\" WHERE user_id = @userId)";
                DateItem coverItem = await connection.QueryFirstOrDefaultAsync <DateItem>(sql, new { userId = userId });

                return(coverItem);
            }
        }
Ejemplo n.º 16
0
        private void RefreshTendencyPosItem(IssueItem issueItem)
        {
            DateItem dateItem = ComboDate.SelectedItem as DateItem;

            if (dateItem == null)
            {
                return;
            }
            int date = dateItem.Date;

            if (date != issueItem.Date)
            {
                return;
            }
            for (int i = 0; i < mListPositionItems.Count; i++)
            {
                var    posItem    = mListPositionItems[i];
                int    pos        = posItem.Pos;
                string serial     = issueItem.Serial;
                var    numberItem = mListNumberItems.FirstOrDefault(n => n.Serial == serial);
                if (numberItem != null)
                {
                    posItem.NumberItems.Add(numberItem);
                }
                var dataItem = mListTendencyData.FirstOrDefault(t => t.Serial == serial && t.Pos == pos);
                if (dataItem == null)
                {
                    continue;
                }
                TendencyDetailItem item = new TendencyDetailItem();
                item.Serial = serial;
                item.Number = dataItem.Number;
                item.Date   = date;
                item.Pos    = pos;
                if (dataItem.Repeat)
                {
                    item.Category = 1;
                }
                if (dataItem.Osillation)
                {
                    item.Category = 2;
                }
                if (dataItem.Increase)
                {
                    item.Category = 3;
                }
                if (dataItem.Other)
                {
                    item.Category = 4;
                }
                item.Times = dataItem.Times;
                item.Range = dataItem.Range;
                posItem.Items.Add(item);
            }
        }
Ejemplo n.º 17
0
        private void RefreshTendencyNumberItem(IssueItem issueItem)
        {
            DateItem dateItem = ComboDate.SelectedItem as DateItem;

            if (dateItem == null)
            {
                return;
            }
            int date = dateItem.Date;

            if (date != issueItem.Date)
            {
                return;
            }
            string serial = issueItem.Serial;
            var    data   = mListTendencyData.Where(t => t.Serial == serial).ToList();

            if (data.Count <= 0)
            {
                return;
            }
            TendencyNumberItem item = new TendencyNumberItem();

            item.Serial = serial;
            item.Date   = date;
            for (int i = 0; i < data.Count; i++)
            {
                var dataItem = data[i];
                item.Number = dataItem.Number;
                int pos = dataItem.Pos;
                if (pos == 1)
                {
                    item.D1Range = dataItem.Range;
                }
                if (pos == 2)
                {
                    item.D2Range = dataItem.Range;
                }
                if (pos == 3)
                {
                    item.D3Range = dataItem.Range;
                }
                if (pos == 4)
                {
                    item.D4Range = dataItem.Range;
                }
                if (pos == 5)
                {
                    item.D5Range = dataItem.Range;
                }
            }
            mListNumberItems.Add(item);
        }
        private void AddSelectedDate(DateTime selectedDate)
        {
            var dateItem = new DateItem();

            dateItem.Date       = selectedDate;
            dateItem.BackColor1 = Color.Blue;
            if (!_selectedDates.Select(x => x.Date).Contains(selectedDate))
            {
                _selectedDates.Add(dateItem);
            }
            UpdateSelectedDates();
        }
Ejemplo n.º 19
0
        private void DiasNoLaborables()
        {
            DateTime dt = new DateTime(2020, 01, 01);

            for (int i = 0; i <= 365; i++)
            {
                var di = new DateItem();
                di.Date      = dt.AddDays(i);
                di.Enabled   = false;
                dateItems[i] = di;
            }
        }
Ejemplo n.º 20
0
        public async Task <ActionResult <DateItem> > PutDateItem(int id, DateItem item)
        {
            if (id != item.DateItemId)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 21
0
        private void RemoverCALendarioFormato()
        {
            DateTime dt = new DateTime(2020, 01, 01);

            for (int i = 0; i <= 365; i++)
            {
                var di = new DateItem();
                di.Date      = dt.AddDays(i);
                di.Enabled   = false;
                dateItems[i] = di;
            }
        }
Ejemplo n.º 22
0
        private void TagHasTaskDay()
        {
            List <Activity> allTask = _schedule.getList();

            foreach (Activity task in allTask)
            {
                DateItem di = new DateItem();
                di.Date       = task.Date;
                di.BackColor1 = Color.Yellow;
                monthCalendar.AddDateInfo(di);
            }
        }
Ejemplo n.º 23
0
        public void deleteSeminar(object dateItem)
        {
            DateItem dateItemClicked = dateItem as DateItem;

            if (this.seminarListP.Count > 1)
            {
                this.seminarListP.Remove(dateItemClicked);
            }
            else
            {
                this.seminarListP[0] = new DateItem();
            }
        }
Ejemplo n.º 24
0
        private void deleteExam(object dateItem)
        {
            DateItem dateItemClicked = dateItem as DateItem;

            if (this.examListP.Count > 1)
            {
                this.examListP.Remove(dateItemClicked);
            }
            else
            {
                this.examListP[0] = new DateItem();
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Thiết lập những ngày được chọn là ngày làm việc
        /// </summary>
        //private void SetWorkingDay()
        //{
        //    foreach (string selectedDate in selectedDates)
        //    {
        //        // Thiết lập ngày làm việc
        //        DateItem dateItem = new DateItem();
        //        dateItem.Date = DateTime.Parse(selectedDate);
        //        dateItem.BackColor = lblWorkingDayLegend.BackColor;
        //        dateItem.DateColor = lblWorkingDayLegend.ForeColor;

        //        dateItem.Text = cboShift.Text;
        //        monthCalendar1.AddDateInfo(dateItem);
        //    }
        //}

        ///// <summary>
        ///// Thiết lập những ngày được chọn là ngày nghỉ
        ///// </summary>
        //private void SetNonWorkingDay()
        //{
        //    foreach (string selectedDate in selectedDates)
        //    {
        //        // Thiết lập ngày nghỉ
        //        DateItem dateItem = new DateItem();
        //        dateItem.Date = DateTime.Parse(selectedDate);
        //        dateItem.BackColor = lblNonWorkingDayLegend.BackColor;
        //        dateItem.DateColor = lblNonWorkingDayLegend.ForeColor;
        //        dateItem.Text = "";
        //        monthCalendar1.AddDateInfo(dateItem);

        //    }
        //}

        ///// <summary>
        ///// Thiết lập những ngày được chọn là ngày nghỉ
        ///// </summary>
        //private void SetHoliday()
        //{
        //    foreach (string selectedDate in selectedDates)
        //    {
        //        // Thiết lập ngày lễ
        //        DateItem dateItem = new DateItem();
        //        dateItem.Date = DateTime.Parse(selectedDate);
        //        dateItem.BackColor = lblHolidayLegend.BackColor;
        //        dateItem.DateColor = lblHolidayLegend.ForeColor;
        //        dateItem.Text = "";
        //        monthCalendar1.AddDateInfo(dateItem);

        //    }
        //}

        /// <summary>
        /// Thiết lập những ngày được chọn là ngày làm thêm hệ số 1
        /// </summary>
        private void SetOverTime()
        {
            foreach (string selectedDate in selectedDates)
            {
                // Thiết lập ngày lễ
                DateItem dateItem = new DateItem();
                dateItem.Date      = DateTime.Parse(selectedDate);
                dateItem.BackColor = lblOverTimeLegend.BackColor;
                dateItem.DateColor = lblOverTimeLegend.ForeColor;
                dateItem.Text      = cboShift.Text;
                monthCalendar1.AddDateInfo(dateItem);
            }
        }
Ejemplo n.º 26
0
        private void InitTendencyPosItems()
        {
            DateItem dateItem = ComboDate.SelectedItem as DateItem;

            if (dateItem == null)
            {
                return;
            }
            int date = dateItem.Date;

            for (int i = 0; i < mListPositionItems.Count; i++)
            {
                var posItem = mListPositionItems[i];
                int pos     = posItem.Pos;
                posItem.NumberItems.Clear();
                posItem.Items.Clear();
                for (int j = 0; j < mListNumberItems.Count; j++)
                {
                    posItem.NumberItems.Add(mListNumberItems[j]);
                }
                var data = mListTendencyData.Where(t => t.Date == date && t.Pos == pos).OrderBy(t => t.Number).ToList();
                for (int j = 0; j < data.Count; j++)
                {
                    var dataItem            = data[j];
                    TendencyDetailItem item = new TendencyDetailItem();
                    item.Serial = dataItem.Serial;
                    item.Number = dataItem.Number;
                    item.Date   = dataItem.Date;
                    item.Pos    = pos;
                    if (dataItem.Repeat)
                    {
                        item.Category = 1;
                    }
                    if (dataItem.Osillation)
                    {
                        item.Category = 2;
                    }
                    if (dataItem.Increase)
                    {
                        item.Category = 3;
                    }
                    if (dataItem.Other)
                    {
                        item.Category = 4;
                    }
                    item.Times = dataItem.Times;
                    item.Range = dataItem.Range;
                    posItem.Items.Add(item);
                }
            }
        }
Ejemplo n.º 27
0
        private void ChargeCalendarYear()
        {
            this.metroLabel1.Text = this.Year.ToString() + "年";
            this.monthCalendar1.ActiveMonth.Year  = Year;
            this.monthCalendar2.ActiveMonth.Year  = Year;
            this.monthCalendar3.ActiveMonth.Year  = Year;
            this.monthCalendar4.ActiveMonth.Year  = Year;
            this.monthCalendar5.ActiveMonth.Year  = Year;
            this.monthCalendar6.ActiveMonth.Year  = Year;
            this.monthCalendar7.ActiveMonth.Year  = Year;
            this.monthCalendar8.ActiveMonth.Year  = Year;
            this.monthCalendar9.ActiveMonth.Year  = Year;
            this.monthCalendar10.ActiveMonth.Year = Year;
            this.monthCalendar11.ActiveMonth.Year = Year;
            this.monthCalendar12.ActiveMonth.Year = Year;
            this.monthCalendar1.Dates.Clear();
            this.monthCalendar2.Dates.Clear();
            this.monthCalendar3.Dates.Clear();
            this.monthCalendar4.Dates.Clear();
            this.monthCalendar5.Dates.Clear();
            this.monthCalendar6.Dates.Clear();
            this.monthCalendar7.Dates.Clear();
            this.monthCalendar8.Dates.Clear();
            this.monthCalendar9.Dates.Clear();
            this.monthCalendar10.Dates.Clear();
            this.monthCalendar11.Dates.Clear();
            this.monthCalendar12.Dates.Clear();

            List <KeyValueData> lstKeyValueDatas = null;
            short shRet = KeyValueDataAccess.Instance.GetHolidays(this.Year.ToString(), ref lstKeyValueDatas);

            if (lstKeyValueDatas == null)
            {
                return;
            }
            foreach (KeyValueData item in lstKeyValueDatas)
            {
                DateTime time;
                if (!DateTime.TryParse(item.DATA_VALUE, out time))
                {
                    continue;
                }
                DateItem dateItem = new DateItem();
                dateItem.Date           = time;
                dateItem.Tag            = item;
                dateItem.DateColor      = Color.Black;
                dateItem.ImageListIndex = 0;
                AddDateItem(dateItem);
            }
            this.Update();
        }
Ejemplo n.º 28
0
        public async Task <DateItem> createItem(DateItemInput _input, int userId)
        {
            using (NpgsqlConnection connection = new NpgsqlConnection(config.GetConnectionString("postgres")))
            {
                string   sql    = "INSERT INTO \"date_item\" (user_id,title,date) VALUES( @userId, @title, @date) RETURNING*";
                DateItem result = await connection.QueryFirstOrDefaultAsync <DateItem>(sql, new { userId = userId, title = _input.title, date = _input.date });

                if (result == null)
                {
                    throw new InvalidOperationException("Sql returned num of rows affected as 0");
                }
                return(result);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Converts poemdate FB2 element
        /// </summary>
        /// <param name="poemDateItem">item to convert </param>
        /// <returns>XHTML representation</returns>
        public IHTMLItem Convert(DateItem poemDateItem)
        {
            if (poemDateItem == null)
            {
                throw new ArgumentNullException("poemDateItem");
            }
            var date = new Paragraph(HTMLElementType.XHTML11);

            date.Add(new SimpleHTML5Text(HTMLElementType.XHTML11)
            {
                Text = poemDateItem.Text
            });
            SetClassType(date, ElementStylesV2.PoemDate);
            return(date);
        }
Ejemplo n.º 30
0
        private void InitTendencyNumberItems()
        {
            mListNumberItems.Clear();
            DateItem dateItem = ComboDate.SelectedItem as DateItem;

            if (dateItem == null)
            {
                return;
            }
            int date       = dateItem.Date;
            var data       = mListTendencyData.Where(t => t.Date == date);
            var dataGroups = data.GroupBy(t => t.Number);

            foreach (var dataGroup in dataGroups)
            {
                int number = dataGroup.Key;
                TendencyNumberItem item = new TendencyNumberItem();
                item.Date   = date;
                item.Number = number;
                foreach (var dataItem in dataGroup)
                {
                    string serial = dataItem.Serial;
                    item.Serial = serial;
                    int pos = dataItem.Pos;
                    if (pos == 1)
                    {
                        item.D1Range = dataItem.Range;
                    }
                    if (pos == 2)
                    {
                        item.D2Range = dataItem.Range;
                    }
                    if (pos == 3)
                    {
                        item.D3Range = dataItem.Range;
                    }
                    if (pos == 4)
                    {
                        item.D4Range = dataItem.Range;
                    }
                    if (pos == 5)
                    {
                        item.D5Range = dataItem.Range;
                    }
                }
                mListNumberItems.Add(item);
            }
        }
Ejemplo n.º 31
0
        internal void Load(XElement xPoem)
        {
            if (xPoem == null)
            {
                throw new ArgumentNullException("xPoem");
            }

            if (xPoem.Name.LocalName != Fb2PoemElementName)
            {
                throw new ArgumentException("Element of wrong type passed", "xPoem");
            }

            Title = null;
            Date = null;
            epigraphs.Clear();
            content.Clear();
            authors.Clear();

            IEnumerable<XElement> xElements = xPoem.Elements();
            foreach (var xElement in xElements)
            {
                if (xElement.Name == (XName)(xPoem.Name.Namespace + StanzaItem.Fb2StanzaElementName))
                {
                    StanzaItem stanza = new StanzaItem();
                    try
                    {
                        stanza.Load(xElement);
                        content.Add(stanza);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + SubTitleItem.Fb2SubtitleElementName))
                {
                    SubTitleItem subtitle = new SubTitleItem();
                    try
                    {
                        subtitle.Load(xElement);
                        content.Add(subtitle);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + TitleItem.Fb2TitleElementName) && Title == null) // only one title
                {
                        Title = new TitleItem();
                        Title.Load(xElement);
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + EpigraphItem.Fb2EpigraphElementName))
                {
                    EpigraphItem epigraphItem = new EpigraphItem();
                    try
                    {
                        epigraphItem.Load(xElement);
                        epigraphs.Add(epigraphItem);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + TextAuthorItem.Fb2TextAuthorElementName))
                {
                    TextAuthorItem author = new TextAuthorItem();
                    try
                    {
                        author.Load(xElement);
                        authors.Add(author);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + DateItem.Fb2DateElementName) && Date == null) // only one date
                {
                    Date = new DateItem();
                    try
                    {
                        Date.Load(xElement);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }

            XAttribute xID = xPoem.Attribute("id");
            if ((xID != null) && (xID.Value != null))
            {
                ID = xID.Value;
            }

            Lang = null;
            XAttribute xLang = xPoem.Attribute(XNamespace.Xml + "lang");
            if ((xLang != null) && (xLang.Value != null))
            {
                Lang = xLang.Value;
            }
        }
Ejemplo n.º 32
0
        public void SaveSetting()
        {
            if (radioButton_none.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecEndMode", "0", SettingPath.TimerSrvIniPath);
            }
            if (radioButton_standby.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecEndMode", "1", SettingPath.TimerSrvIniPath);
            }
            if (radioButton_suspend.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecEndMode", "2", SettingPath.TimerSrvIniPath);
            }
            if (radioButton_shutdown.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecEndMode", "3", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_reboot.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "Reboot", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "Reboot", "0", SettingPath.TimerSrvIniPath);
            }

            IniFileHandler.WritePrivateProfileString("SET", "WakeTime", textBox_pcWakeTime.Text, SettingPath.TimerSrvIniPath);
            IniFileHandler.WritePrivateProfileString("SET", "BatMargin", textBox_batWait.Text, SettingPath.TimerSrvIniPath);
            IniFileHandler.WritePrivateProfileString("SET", "StartMargin", textBox_megine_start.Text, SettingPath.TimerSrvIniPath);
            IniFileHandler.WritePrivateProfileString("SET", "EndMargin", textBox_margine_end.Text, SettingPath.TimerSrvIniPath);
            IniFileHandler.WritePrivateProfileString("SET", "RecAppWakeTime", textBox_appWakeTime.Text, SettingPath.TimerSrvIniPath);

            if (checkBox_appMin.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecMinWake", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecMinWake", "0", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_appView.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecView", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecView", "0", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_appDrop.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "DropLog", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "DropLog", "0", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_addPgInfo.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "PgInfoLog", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "PgInfoLog", "0", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_appNW.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecNW", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecNW", "0", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_appOverWrite.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecOverWrite", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecOverWrite", "0", SettingPath.TimerSrvIniPath);
            }

            IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "Count", ngProcessList.Count.ToString(), SettingPath.TimerSrvIniPath);
            for (int i = 0; i < ngProcessList.Count; i++)
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", i.ToString(), ngProcessList[i], SettingPath.TimerSrvIniPath);
            }

            IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoStandbyTime", ngMin, SettingPath.TimerSrvIniPath);
            if (ngUsePC == true)
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoUsePC", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoUsePC", "0", SettingPath.TimerSrvIniPath);
            }
            IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoUsePCTime", ngUsePCMin, SettingPath.TimerSrvIniPath);
            if (ngFileStreaming == true)
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoFileStreaming", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoFileStreaming", "0", SettingPath.TimerSrvIniPath);
            }
            if (ngShareFile == true)
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoShareFile", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("NO_SUSPEND", "NoShareFile", "0", SettingPath.TimerSrvIniPath);
            }

            IniFileHandler.WritePrivateProfileString("SET", "ProcessPriority", comboBox_process.SelectedIndex.ToString(), SettingPath.TimerSrvIniPath);

            if (checkBox_back_priority.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "BackPriority", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "BackPriority", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_sameChPriority.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "SameChPriority", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "SameChPriority", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_enable_relay.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "EventRelay", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "EventRelay", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_chgTitle.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "ResAutoChgTitle", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "ResAutoChgTitle", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_chk_TimeOnly.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "ResAutoChkTime", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "ResAutoChkTime", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_autoDel.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "AutoDel", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "AutoDel", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_recname.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecNamePlugIn", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecNamePlugIn", "0", SettingPath.TimerSrvIniPath);
            }
            if (comboBox_recname.SelectedItem != null)
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecNamePlugInFile", (string)comboBox_recname.SelectedItem, SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "RecNamePlugInFile", "", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_autoDelRecInfo.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "AutoDelRecInfo", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "AutoDelRecInfo", "0", SettingPath.TimerSrvIniPath);
            }
            IniFileHandler.WritePrivateProfileString("SET", "AutoDelRecInfoNum", textBox_autoDelRecInfo.Text.ToString(), SettingPath.TimerSrvIniPath);

            if (checkBox_timeSync.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "TimeSync", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "TimeSync", "0", SettingPath.TimerSrvIniPath);
            }

            if (checkBox_useSrvCoop.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "UseSrvCoop", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "UseSrvCoop", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_useResSrvCoop.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "UseResSrvCoop", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "UseResSrvCoop", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_useEpgSrvCoop.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "UseEpgSrvCoop", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "UseEpgSrvCoop", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_ngResCoop.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "NgAddResSrvCoop", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "NgAddResSrvCoop", "0", SettingPath.TimerSrvIniPath);
            }
            if (checkBox_ngEpgCoop.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "NgEpgFileSrvCoop", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "NgEpgFileSrvCoop", "0", SettingPath.TimerSrvIniPath);
            }
            IniFileHandler.WritePrivateProfileString("COOP_SRV", "Num", listBox_coopSrv.Items.Count.ToString(), SettingPath.TimerSrvIniPath);
            for (int i = 0; i < listBox_coopSrv.Items.Count; i++)
            {
                CoopServerInfo info = listBox_coopSrv.Items[i] as CoopServerInfo;
                IniFileHandler.WritePrivateProfileString("COOP_SRV", "ADD" + i.ToString(), info.ServerAddress, SettingPath.TimerSrvIniPath);
                IniFileHandler.WritePrivateProfileString("COOP_SRV", "PORT" + i.ToString(), info.ServerPort.ToString(), SettingPath.TimerSrvIniPath);
            }

            Settings.Instance.CloseMin = (bool)checkBox_closeMin.IsChecked;
            Settings.Instance.WakeMin = (bool)checkBox_minWake.IsChecked;
            Settings.Instance.MinHide = (bool)checkBox_minHide.IsChecked;

            IniFileHandler.WritePrivateProfileString("DEL_EXT", "Count", extList.Count.ToString(), SettingPath.TimerSrvIniPath);
            for (int i = 0; i < extList.Count; i++)
            {
                IniFileHandler.WritePrivateProfileString("DEL_EXT", i.ToString(), extList[i], SettingPath.TimerSrvIniPath);
            }

            IniFileHandler.WritePrivateProfileString("DEL_CHK", "Count", delChkFolderList.Count.ToString(), SettingPath.TimerSrvIniPath);
            for (int i = 0; i < delChkFolderList.Count; i++)
            {
                IniFileHandler.WritePrivateProfileString("DEL_CHK", i.ToString(), delChkFolderList[i], SettingPath.TimerSrvIniPath);
            }

            if (checkBox_tcpServer.IsChecked == true)
            {
                IniFileHandler.WritePrivateProfileString("SET", "EnableTCPSrv", "1", SettingPath.TimerSrvIniPath);
            }
            else
            {
                IniFileHandler.WritePrivateProfileString("SET", "EnableTCPSrv", "0", SettingPath.TimerSrvIniPath);
            }
            IniFileHandler.WritePrivateProfileString("SET", "TCPPort", textBox_tcpPort.Text, SettingPath.TimerSrvIniPath);

            IniFileHandler.WritePrivateProfileString("SET", "Baloon", textBox_baloonclose.Text, SettingPath.TimerSrvIniPath);

            if (checkBox_noToolTips.IsChecked == true)
            {
                Settings.Instance.NoToolTip = true;
            }
            else
            {
                Settings.Instance.NoToolTip = false;
            }

            if (checkBox_noBallonTips.IsChecked == true)
            {
                Settings.Instance.NoBallonTips = true;
            }
            else
            {
                Settings.Instance.NoBallonTips = false;
            }
            if (checkBox_playDClick.IsChecked == true)
            {
                Settings.Instance.PlayDClick = true;
            }
            else
            {
                Settings.Instance.PlayDClick = false;
            }
            if (checkBox_fixSearchResult.IsChecked == true)
            {
                Settings.Instance.FixSearchResult = true;
            }
            else
            {
                Settings.Instance.FixSearchResult = false;
            }

            if (defSearchKey.regExpFlag == 0)
            {
                Settings.Instance.SearchKeyRegExp = false;
            }
            else
            {
                Settings.Instance.SearchKeyRegExp = true;
            }
            if (defSearchKey.aimaiFlag == 0)
            {
                Settings.Instance.SearchKeyAimaiFlag = false;
            }
            else
            {
                Settings.Instance.SearchKeyAimaiFlag = true;
            }
            if (defSearchKey.titleOnlyFlag == 0)
            {
                Settings.Instance.SearchKeyTitleOnly = false;
            }
            else
            {
                Settings.Instance.SearchKeyTitleOnly = true;
            }
            if (defSearchKey.titleOnlyFlag == 0)
            {
                Settings.Instance.SearchKeyTitleOnly = false;
            }
            else
            {
                Settings.Instance.SearchKeyTitleOnly = true;
            }
            Settings.Instance.SearchKeyContentList.Clear();
            foreach (EpgContentData info in defSearchKey.contentList)
            {
                ContentKindInfo item = new ContentKindInfo();
                item.Nibble1 = info.content_nibble_level_1;
                item.Nibble2 = info.content_nibble_level_2;
                Settings.Instance.SearchKeyContentList.Add(item);
            }
            Settings.Instance.SearchKeyDateItemList.Clear();
            foreach (EpgSearchDateInfo info in defSearchKey.dateList)
            {
                DateItem item = new DateItem();
                item.DateInfo = info;
                Settings.Instance.SearchKeyDateItemList.Add(item);
            }
            Settings.Instance.SearchKeyServiceList.Clear();
            foreach (Int64 info in defSearchKey.serviceList)
            {
                Settings.Instance.SearchKeyServiceList.Add(info);
            }

            if (defSearchKey.notContetFlag == 0)
            {
                Settings.Instance.SearchKeyNotContent = false;
            }
            else
            {
                Settings.Instance.SearchKeyNotContent = true;
            }
            if (defSearchKey.notDateFlag == 0)
            {
                Settings.Instance.SearchKeyNotDate = false;
            }
            else
            {
                Settings.Instance.SearchKeyNotDate = true;
            }
            Settings.Instance.SearchKeyFreeCA = defSearchKey.freeCAFlag;
            Settings.Instance.SearchKeyChkRecEnd = defSearchKey.chkRecEnd;
            Settings.Instance.SearchKeyChkRecDay = defSearchKey.chkRecDay;

            Settings.Instance.ViewButtonList.Clear();
            foreach (ViewMenuItem info in listBox_viewBtn.Items)
            {
                Settings.Instance.ViewButtonList.Add(info.MenuName);
            }

            Settings.Instance.TaskMenuList.Clear();
            foreach (ViewMenuItem info in listBox_viewTask.Items)
            {
                Settings.Instance.TaskMenuList.Add(info.MenuName);
            }

            Settings.Instance.Cust1BtnName = textBox_name1.Text;
            Settings.Instance.Cust1BtnCmd = textBox_exe1.Text;
            Settings.Instance.Cust1BtnCmdOpt = textBox_opt1.Text;

            Settings.Instance.Cust2BtnName = textBox_name2.Text;
            Settings.Instance.Cust2BtnCmd = textBox_exe2.Text;
            Settings.Instance.Cust2BtnCmdOpt = textBox_opt2.Text;

            Settings.Instance.IEpgStationList = stationList;
        }
 /// <summary>
 /// Invoked when the item currently displayed changes.
 /// </summary>
 /// <param name="sender">The FlipView instance for which the current item has changed.</param>
 /// <param name="e">Event data that describes how the current item was changed.</param>
 void FlipView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     // Enable the previous and next buttons as appropriate
     try
     {
         this.DefaultViewModel["CanFlipNext"] = this.flipView.Items != null && this.flipView.SelectedIndex < (this.flipView.Items.Count - 1);
         this.DefaultViewModel["CanFlipPrevious"] = this.flipView.SelectedIndex > 0;
         SampleDataItem item = this.flipView.Items[this.flipView.SelectedIndex] as SampleDataItem;
         this.pageTitle.Text = "Hindu Calendar - " + item.Title + " " + item.Year.ToString();
         this.cityTitle.Text = item.Group.city._Name;
         FlipViewItem selectedFlipViewItem = (FlipViewItem)this.flipView.ItemContainerGenerator.ContainerFromIndex(flipView.SelectedIndex);
         if (selectedFlipViewItem != null)
         {
             if (_currentHighlightedDateItem != null)
             {
                 _currentHighlightedDateItem.HighlightBorder(false);
             }
             _currentHighlightedDateItem = null;
             Grid monthView = (Grid)FindNamedElement(selectedFlipViewItem, "monthView");
             int month = ((flipView.SelectedIndex) % 12) + 1;
             BuildCalendar(monthView, month, item);
             Debug.Assert(_currentHighlightedDateItem != null);
             DayViewGridStoryboard.Begin();
         }
     }
     catch (ArgumentException exc)
     {
         Debug.WriteLine("Exception is " + exc.Message);
         Debug.Assert(false);
     }
 }
        private void Update_MetroForDate_DateTable()
        {
            Make();
            if (DateItems != null)
            {
                if (DateItems.Count > 0)
                {
                    DateTable.ListItemTxts = new List<object>();
                    DateTable.ListItemTips = new List<object>();
                    var today = new DateItem {Day = NowDay, Month = NowMonth, Week = NowWeek, Year = NowYear};

                    foreach (var dateItem in DateItems)
                    {
                        if (dateItem.IsToday)
                        {
                            DateTable.ListItemTxts.Add(dateItem.Day+",Select");
                            DateTable.ListItemTips.Add(dateItem);
                        }
                        else
                        {
                            DateTable.ListItemTxts.Add(dateItem.Day);
                            DateTable.ListItemTips.Add(dateItem);
                        }
                    }
                }
            }
            DateTable.UpdateListItem();
        }
        private void BuildCalendar(Grid monthView, int month, SampleDataItem item) 
        {
            int row, col;
            DateItem[,] dateItems;

            if (monthView.Tag == null)
            {
                dateItems = new DateItem[numRows, numCols];

                for (row = 0; row < numRows; row++)
                {
                    for (col = 0; col < numCols; col++)
                    {
                        DateItem dateItem = new DateItem();
                        dateItem.SetValue(Grid.RowProperty, row);
                        dateItem.SetValue(Grid.ColumnProperty, col);
                        monthView.Children.Add(dateItem);
                        dateItems[row, col] = dateItem;
                        if (row == 0)
                        {
                            DayOfWeek day = (DayOfWeek)col;
                            dateItem.SetDay(_dayStrings[(int)day]);
                        }
                        else
                        {
                            dateItem.SetDay(" ");
                            dateItem.PointerReleased += dateItem_PointerReleased;
                        }
                    }
                }
                monthView.Tag = dateItems;
            }

            // collapse them all to be opened later
            dateItems = (DateItem[,])monthView.Tag;
            for (row = 1; row < numRows; row++)
            {
                for (col = 0; col < numCols; col++)
                {
                    dateItems[row, col].Visibility = Visibility.Collapsed;
                }
            }

            String previousTamilMonth, tamilMonth;
            String previousSanskritMonth, sanskritMonth;
            String previousPaksha, paksha;
            bool fullMoonDayFound = false;
            bool newMoonDayFound = false;
            DateItem currentDateItem = null;

            row = 1;
            previousTamilMonth = null;
            previousSanskritMonth = null;

            previousPaksha = "";
            tamilMonthTitle.Text = "";
            sanskritMonthTitle.Text = "";
            for (int day = 1; day <= 31 ; day++)
            {
                DateTime dateTime;
                try
                {
                    dateTime = new DateTime(item.Year, month, day);
                    col = (int)dateTime.DayOfWeek;
                    
                    String festival, nakshatra;
                    bool isNewMoonDay, isFullMoonDay;
                    bool highlight;

                    item.GetDateData(month, day, out isNewMoonDay, out isFullMoonDay, out festival, out paksha, out nakshatra, out tamilMonth);
                    PanchangData pdata = item.GetPanchangData(month, day);
                    sanskritMonth = pdata._fieldValues[(int)FieldType.SanskritMonth];

                    if (isNewMoonDay)
                    {
                        newMoonDayFound = true;
                    }

                    if (isFullMoonDay)
                    {
                        fullMoonDayFound = true;
                    }

                    // Sometimes the tithi changes in the middle of the day and is not captured. Lets fix it here
                    if ((previousPaksha.Contains("Shukla") == true) && (paksha.Contains("Krishna") == true) && (fullMoonDayFound == false))
                    {
                        // Set the previous item to full moon day
                        currentDateItem.SetDay(currentDateItem.GetDay(), false, true, null, null, "KeepExisting");
                    }

                    // Sometimes the tithi changes in the middle of the day and is not captured. Lets fix it here
                    if ((previousPaksha.Contains("Krishna") == true) && (paksha.Contains("Shukla") == true) && (newMoonDayFound == false))
                    {
                        // Set the previous item to new moon day
                        currentDateItem.SetDay(currentDateItem.GetDay(), true, false, null, null, "KeepExisting");
                    }

                    previousPaksha = paksha;

                    currentDateItem = dateItems[row, col];
                    PrivateEvent evt = null;
                    if (_privateEvents != null)
                    {
                        evt = _privateEvents.GetFirstEventForDate(dateTime);
                    }

                    if (evt != null)
                    {
                        currentDateItem.SetDay(day,
                            isNewMoonDay, isFullMoonDay, evt._eventText, null, nakshatra);
                    }
                    else
                    {
                        currentDateItem.SetDay(day,
                            isNewMoonDay, isFullMoonDay, festival, null, nakshatra);
                    }
                        
                    currentDateItem.Visibility = Visibility.Visible;
                    if (String.Equals(previousTamilMonth, tamilMonth, StringComparison.OrdinalIgnoreCase) == false)
                    {
                        tamilMonthTitle.Text += (previousTamilMonth == null) ? tamilMonth : ("-" + tamilMonth);
                        previousTamilMonth = tamilMonth;
                    }

                    if (String.Equals(previousSanskritMonth, sanskritMonth, StringComparison.OrdinalIgnoreCase) == false)
                    {
                        sanskritMonthTitle.Text += ((previousSanskritMonth == null) ? sanskritMonth : ("-" + sanskritMonth.Trim()));
                        previousSanskritMonth = sanskritMonth;
                    }

                    highlight = false;
                    // If its the curent month then highlight the current day
                    if (month == DateTime.Today.Month) 
                    {
                        if (day == DateTime.Today.Day)
                        {
                            // Highlight today
                            highlight = true;
                        }
                    }
                    else if (day == 1)
                    {
                        // Highlight the first day of some other month
                            highlight = true;
                    }

                    if (highlight)
                    { 
                        currentDateItem.HighlightBorder(true);
                        ShowDetail(month, day, item);
                        _currentHighlightedDateItem = currentDateItem;
                    }

                    if (col == (numCols-1))
                    {
                        row++;
                        if (row == numRows)
                        {
                            row = 1; // Reset it back to the first row. Provides a foldable calender
                        }
                    }
                }
                catch (ArgumentOutOfRangeException)
                {
                }
            }
        }
        private void dateItem_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            DateItem dateItem = sender as DateItem;

            // If its a mouse click look for left mouse button click
            if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                Windows.UI.Input.PointerPoint currentPoint = e.GetCurrentPoint(dateItem);
                Windows.UI.Input.PointerUpdateKind kind = currentPoint.Properties.PointerUpdateKind;
                if (kind != Windows.UI.Input.PointerUpdateKind.LeftButtonReleased)
                {
                    return;
                }
            }

            // If the user clicks on the empty squares skip
            if (dateItem.GetDay() > 0)
            {
                try
                {
                    SampleDataItem item = this.flipView.Items[this.flipView.SelectedIndex] as SampleDataItem;
                    int month = ((flipView.SelectedIndex) % 12) + 1;
                    ShowDetail(month, dateItem.GetDay(), item);
                    dateItem.HighlightBorder(true);

                    DateItem oldItem = _currentHighlightedDateItem;
                    if (oldItem != null)
                    {
                        oldItem.HighlightBorder(false);
                    }

                    _currentHighlightedDateItem = dateItem;
                }
                catch (ArgumentOutOfRangeException err)
                {
                    Debug.WriteLine("Argument out of range" + err);
                }
            }
        }