// PointSense Calendar Widgets for Point Sense Suite // // Design by BlueOcean, community.pointui.com // // Any distribute please notify me //All using class included in ClockWidgets, no need add duplication using PushButton; class CalendarWidget : Widget { //settings String skinPath; int firstday; int appointmentDays, checkBusy; String style; Control *c; RegistryNotification timeNotify; DateTime dtDay; #region widget must have void WriteAttribute(XmlNode root) { root.SetChildValue("name", "calendar"); root.SetChildValue("id", ID); root.SetChildValue("skin", skinPath); root.SetChildValue("firstday", firstday); root.SetChildValue("appointmentdays", appointmentDays); root.SetChildValue("checkbusy", checkBusy); } void NewWidget(XmlNode attr, String newid, String fn, int x, int y) { attr.SetChildValue("name", "calendar"); attr.SetChildValue("id", newid); attr.SetChildValue("skin", fn); attr.SetChildValue("firstday", 0); attr.SetChildValue("appointmentdays", 1); attr.SetChildValue("checkbusy", 0); //If no first setting OnChanged(); FlowStack.ReturnToStart(); } #endregion void Load() { //call inherited Widget_Load(); Attribute.GetChildValue("skin", skinPath); Attribute.GetChildValue("firstday", firstday); Attribute.GetChildValue("appointmentdays", appointmentDays); Attribute.GetChildValue("checkbusy", checkBusy); LoadCalendarSetting(); if (style == "ramappointment") { dtDay.Now(); c.LoadBirthdays(); timeNotify.OnNotify = timeNotify_OnNotify; } } void LoadCalendarSetting() { XmlNode root, Setting; root.LoadFromFile(homePath + "Calendar\\" + skinPath + "\\setting.xml"); //lblDebug.SetText(skinPath); root.FindNode("theme", Setting); Setting.GetChildValue("style", style); if (style == "month") { MonthControl monthCalendar; monthCalendar.path = homePath + "Calendar\\" + skinPath + "\\"; monthCalendar.firstday = firstday; monthCalendar.widget_OnClickHold = widget_OnClickHold; Controls.Add(monthCalendar); c = monthCalendar; } else if (style == "appointment") { AppointmentControl apptCalendar; apptCalendar.path = homePath + "Calendar\\" + skinPath + "\\"; apptCalendar.appDays = appointmentDays; apptCalendar.widget_OnClickHold = widget_OnClickHold; Controls.Add(apptCalendar); c = apptCalendar; } else if (style == "ramappointment") { RamAppointmentControl apptCalendar; apptCalendar.path = homePath + "Calendar\\" + skinPath + "\\"; apptCalendar.appDays = appointmentDays; apptCalendar.widget_OnClickHold = widget_OnClickHold; Controls.Add(apptCalendar); c = apptCalendar; } } void Layout() { Widget_Layout(); SetWidthHeight(c.GetWidth(), c.GetHeight()); width = c.GetWidth(); height = c.GetHeight(); c.SetBounds(0, 0); } #region events void Activated() { if (style == "month") { if (checkBusy == 1) { c.CheckAppointment(); } c.CheckToday(); } else if (style == "appointment") { c.Activated(); } else if (style == "ramappointment") { c.Activated(); timeNotify.Start("HKLM\\System\\State\\DateTime", "Time"); } } void Deactivated() { if (style == "ramappointment") { timeNotify.Stop(); } } void timeNotify_OnNotify() { if (style == "ramappointment") { DateTime dt; dt.Now(); if (!dt.IsSameDay(dtDay)) { c.LoadBirthdays(); c.Activated(); dtDay = dt; } else if ((c.dtAppt != c.dtEmpty) && (dt >= c.dtAppt)) { c.LoadInfos(); } } } void widget_OnClickHold() { OnClickHold(this); } void ShowSetting() { if (style == "month") { MonthSettingScreen s; s.currentFirstDay = firstday; s.checkBusy = checkBusy; s.OnCheckBusyChanged = SettingScreen_OnCheckBusyChanged; s.OnFirstDayChanged = SettingScreen_OnFirstDayChanged; FlowStack.Branch(s); }else if (style == "appointment") { AppointmentSettingScreen s; s.OnDaysChanged = SettingScreen_OnDaysChanged; String a = appointmentDays; s.SetSelectedItemID(a); FlowStack.Branch(s); }else if (style == "ramappointment") { RamAppointmentSettingScreen s; s.OnDaysChanged = SettingScreen_OnDaysChanged; String a = appointmentDays; s.SetSelectedItemID(a); FlowStack.Branch(s); } } void SettingScreen_OnFirstDayChanged() { if (firstday == 0) { firstday = 1; } else { firstday = 0; } if (style == "month") { c.firstday = firstday; c.ReloadCalendar(); } OnChanged(); } void SettingScreen_OnDaysChanged(ListItem li) { appointmentDays = li.Attributes.Item("ID"); if (style == "appointment") { c.appDays = appointmentDays; c.Activated(); } else if (style == "ramappointment") { c.appDays = appointmentDays; c.LoadBirthdays(); c.Activated(); } OnChanged(); } void SettingScreen_OnCheckBusyChanged() { if (checkBusy == 0) { checkBusy = 1; } else { checkBusy = 0; } OnChanged(); } #endregion } #region MonthCalendar class MonthControl : GestureControl { //Include daynameBar and Cell, not include TopBG and Bottom BG. int firstday; //0: Mon, 1: Sun String path; Image imgTopBG, imgBottomBG, imgDayNameBG; Surface surCellSelectedBG, surCellBG, surTodayBG; int Month, Year; Control calendarCells; DateTime CurrentDate, StartDate, EndDate; Label lblMonth; PushButton butPrevious, butNext; int x, y, w, h; int todayIndex; Event OnCellClick; Event OnCellClickHold; Event widget_OnClickHold; //Label lblDebug; void Load() { SetTabStop(true); surTodayBG.LoadFromFile(path + "Calendar.Today.Cell.Background.jif"); surCellBG.LoadFromFile(path + "Calendar.Cell.Background.jif"); surCellSelectedBG.LoadFromFile(path + "Calendar.Cell.Selected.Background.jif"); x = 0 + 3; y = 0; imgTopBG.Surface.LoadFromFile(path + "Calendar.Top.Background.jif"); imgTopBG.SetTabStop(true); imgTopBG.OnClick=imgTopBG_OnClick; imgTopBG.OnClickHold = imgTopBG_OnClickHold; Controls.Add(imgTopBG); imgTopBG.SetBounds(x, y); y += imgTopBG.GetHeight(); imgDayNameBG.Surface.LoadFromFile(path + "Calendar.Day.Name.Background.jif"); Controls.Add(imgDayNameBG); imgDayNameBG.SetBounds(x, y); w = imgDayNameBG.GetWidth() / 7; h = imgDayNameBG.GetHeight(); for (int i = 0; i < 7; i++) { Label lblDayName; lblDayName.SetFont("Font.Small"); lblDayName.SetAlign("Center", "Center"); imgDayNameBG.Controls.Add(lblDayName); lblDayName.SetBounds(x + (i * w), 0, w, h); } Controls.Add(calendarCells); w = surCellBG.GetWidth(); h = surCellBG.GetHeight(); for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { CalendarCell cell; cell.OnClick = Cell_OnClick; cell.OnClickHold = Cell_OnClickHold; cell.path = path; cell.Image = surCellBG; cell.ImageSelected = surCellSelectedBG; calendarCells.Controls.Add(cell); cell.SetBounds((j * w),(i * h)); } } w = 7 * surCellBG.GetWidth(); h = 6 * surCellBG.GetHeight(); calendarCells.SetWidthHeight(w, h); y += imgDayNameBG.GetHeight(); calendarCells.SetBounds(x, y); imgBottomBG.Surface.LoadFromFile(path + "Calendar.Bottom.Background.jif"); Controls.Add(imgBottomBG); y += calendarCells.GetHeight(); imgBottomBG.SetBounds(x, y); w = imgTopBG.GetWidth(); h = imgTopBG.GetHeight() + imgDayNameBG.GetHeight() + calendarCells.GetHeight() + imgBottomBG.GetHeight(); SetWidthHeight(w + 6, h); lblMonth.SetAlign("Left", "Center"); lblMonth.SetFont("Font.Title"); imgTopBG.Controls.Add(lblMonth); x = Device.AutoScaleValue(40); lblMonth.SetBounds(x,0,imgTopBG.GetWidth(), imgTopBG.GetHeight()); butPrevious.Image.LoadFromFile(path + "Button.Previous.jif"); butPrevious.ImageSelected.LoadFromFile(path + "Button.Previous.jif"); butPrevious.ImagePushed.LoadFromFile(path + "Button.Previous.Selected.jif"); butPrevious.OnClick = butPrevious_OnClick; imgTopBG.Controls.Add(butPrevious); butNext.Image.LoadFromFile(path + "Button.Next.jif"); butNext.ImageSelected.LoadFromFile(path + "Button.Next.jif"); butNext.ImagePushed.LoadFromFile(path + "Button.Next.Selected.jif"); butNext.OnClick = butNext_OnClick; imgTopBG.Controls.Add(butNext); x = imgTopBG.GetWidth() - (butNext.GetWidth() + Device.AutoScaleValue(5)); y = (imgTopBG.GetHeight() - butNext.GetHeight()) / 2; y += Device.AutoScaleValue(3); butNext.SetBounds(x, y); x -= butNext.GetWidth(); butPrevious.SetBounds(x, y); CurrentDate.Now(); ReloadCalendar(); } void ShowMonth() { String s; s = CurrentDate.ToString("MMMM yyyy"); lblMonth.SetText(s); } void CheckToday() { CalendarCell* cellPtr; DateTime dt; dt.Now(); cellPtr = calendarCells.Controls.Item(todayIndex); if (dt.IsSameDay(cellPtr.day)) { return; } cellPtr.IsToday = false; cellPtr.Image = surCellBG; for (int k = 0; k < 42; k++) { cellPtr = calendarCells.Controls.Item(k); if (dt.IsSameDay(cellPtr.day)) { if (!cellPtr.IsToday) { cellPtr.IsToday = true; cellPtr.Image = surTodayBG; todayIndex = k; return; } } } } #region event void MouseMoveUp() { int d; d = CurrentDate.GetDaysInMonth(CurrentDate.GetYear(), CurrentDate.GetMonth()); d = 0 - d; CurrentDate.AddDays(d); ReloadCalendar(); } void MouseMoveDown() { int d; d = CurrentDate.GetDaysInMonth(CurrentDate.GetYear(), CurrentDate.GetMonth()); CurrentDate.AddDays(d); ReloadCalendar(); } void Cell_OnClick(CalendarCell* cellPtr) { AppointmentScreen s; s.CurrentDate = cellPtr.day; //s.OnDone = AppointmentScreen_OnDone; FlowStack.Branch(s); } void Cell_OnClickHold(CalendarCell* cellPtr) { widget_OnClickHold(); } void imgTopBG_OnClickHold() { widget_OnClickHold(); } void butPrevious_OnClick(Control sender, int x, int y) { int d; d = CurrentDate.GetDaysInMonth(CurrentDate.GetYear(), CurrentDate.GetMonth()); d = 0 - d; CurrentDate.AddDays(d); ReloadCalendar(); } void butNext_OnClick(Control sender, int x, int y) { int d; d = CurrentDate.GetDaysInMonth(CurrentDate.GetYear(), CurrentDate.GetMonth()); CurrentDate.AddDays(d); ReloadCalendar(); } void imgTopBG_OnClick(Control sender, int x, int y) { CurrentDate.Now(); ReloadCalendar(); } #endregion void ReloadCalendar() { int i, k, day; String s; DateTime dt; DateTime dtnow; ShowMonth(); dtnow.Now(); dt = CurrentDate; i = dt.GetDay(); i -= 1; i = 0 - i; dt.AddDays(i); i = dt.GetDayOfWeek(); i = 0 - i; if (firstday==1) { i -= 1; } dt.AddDays(i); StartDate = dt; Label* lblDayName; CalendarCell* cellPtr; for (int k = 0; k < 42; k++) { cellPtr = calendarCells.Controls.Item(k); cellPtr.SetDate(dt); if (dt.GetMonth() != CurrentDate.GetMonth()) { cellPtr.SetActive(false); } else { cellPtr.SetActive(true); } if (dt.IsSameDay(dtnow)) { if (!cellPtr.IsToday) { cellPtr.IsToday = true; cellPtr.Image = surTodayBG; todayIndex = k; } } else { if (cellPtr.IsToday) { cellPtr.IsToday = false; cellPtr.Image = surCellBG; } } if (k < 7) { s = dt.ToString("dddd"); s = s.SubString(0, 3); lblDayName = imgDayNameBG.Controls.Item(k); lblDayName.SetText(s); } dt.AddDays(1); } //dt.AddDays(-1); EndDate = dt; StartDate.SetStartOfDay(); CheckAppointment(); } void CheckAppointment() { DataTable tbl; DateTime dt, dtStart, dtEnd; int i, k; CalendarCell* cellPtr; i = 0; while (i < 42) { cellPtr = calendarCells.Controls.Item(i); cellPtr.SetBusy(false); i++; } dt = CurrentDate; Appointments.GetAppointments(tbl); //tbl.SetMaxItems(42); tbl.SetSort("Start"); String filter; filter = "[End] >= <{Now} AND [Start] < <{End}"; String tmp; float f; f = StartDate.ToVariantTime(); tmp = f.ToString("%.5f"); filter.Replace("{Now}", tmp); //dt.AddDays(1); f = EndDate.ToVariantTime(); f.Trunc(); tmp = f.ToString("%.0f"); filter.Replace("{End}", tmp); k = 0; tbl.SetRestriction(filter); while (tbl.MoveNext() && k < 42) { tbl.GetValue("End", dtEnd); tbl.GetValue("Start", dtStart); dtEnd.AddDays(1); dtEnd.SetStartOfDay(); dtStart.SetStartOfDay(); i = k; cellPtr = calendarCells.Controls.Item(i); //if (dtStart >= cellPtr.day) //{ while (i < 42) { cellPtr = calendarCells.Controls.Item(i); if (dtEnd >= cellPtr.day) { if ((cellPtr.day >= dtStart) && (dtEnd >= cellPtr.day)) { cellPtr.SetBusy(true); k = i + 1; } } else { break; } i++; } //while i<42 } //while tbl } } #endregion #region CalendarDayCell class CalendarCell : Button { DateTime day; Label lblDay; bool IsToday; bool IsBusy; bool IsActive; Image imgIndicatorIcon; String path; void Load() { lblDay.SetFont("Font.Normal"); lblDay.SetAlign("Center", "Center"); imgIndicatorIcon.Surface.LoadFromFile(path + "Calendar.Indicator.jif"); Controls.Add(imgIndicatorIcon); Controls.Add(lblDay); int x, y, w, h; w = Image.GetWidth(); h = Image.GetHeight(); lblDay.SetBounds(0, 0, w, h); x = w - imgIndicatorIcon.GetWidth(); y = 0; imgIndicatorIcon.SetBounds(x, y); } void SetDate(DateTime dt) { String s; day = dt; s = day.GetDay(); lblDay.SetText(s); } void SetBusy(bool a) { IsBusy = a; imgIndicatorIcon.SetVisible(IsBusy); } ////////////////////////////////// /* void SetActive(bool a) { IsActive = a; if (IsActive) { if (day.GetDayOfWeek() < 5) { lblDay.SetColor("White"); } else if(day.Get { lblDay.SetColor("LightGray"); } } else { lblDay.SetColor("Gray"); } } */ ////////////////////////////////// void SetActive(bool a) { IsActive = a; int tmp_day; if (IsActive) { tmp_day = day.GetDayOfWeek(); if (tmp_day < 5) { lblDay.SetColor("White"); } else if(tmp_day ==5) { lblDay.SetColor("Blue"); } else { lblDay.SetColor("Red"); } } else { lblDay.SetColor("Gray"); } } ////////////////////////////////// /* void Layout() { w = GetWidth(); h = GetHeight(); lblDay.SetBounds(0, 0, w, h); if (IsBusy) { imgIndicatorIcon.Surface = imgIndicator; imgIndicatorIcon.AutoSize(); x = w - imgIndicatorIcon.GetWidth(); y = 0; imgIndicatorIcon.SetBounds(x, y); } }*/ } #endregion DayCell #region appointmentCalendar class AppointmentControl : Control { Image imgLeftBG, imgRightBG, imgIndicator, imgDDay; // Edited CustomBitmapLabel lblDate; Label lblMonth, lblApptDate, lblApptTime, lblApptSubject; String path; int x, y, w, h, padding; int ObjectID; int appDays; RegistryNotification DDay_Day, DDay_Text, DDay_From; // Add Label lblDDay_Day, lblDDay_Text, lblDDay_From; // Add Event widget_OnClickHold; void Load() { // 디데이 위젯 사용시 DDay_Start.mscr 실행 Process.Start("{ProgramFiles}\\MortScript\\MortScript.exe", "\"\\Storage Card\\Program Files\\Home2\\PointSense\\Widgets\\Calendar\\Appointment\\DDay_Start.mscr\""); imgLeftBG.Surface.LoadFromFile(path + "Calendar.Left.Background.jif"); imgLeftBG.SetTabStop(true); imgLeftBG.OnClickHold = imgLeftBG_OnClickHold; imgLeftBG.OnClick = imgLeftBG_OnClick; Controls.Add(imgLeftBG); imgRightBG.Surface.LoadFromFile(path + "Calendar.Right.Background.jif"); imgRightBG.SetTabStop(true); imgRightBG.OnClick = imgRightBG_OnClick; imgRightBG.OnClickHold = imgLeftBG_OnClickHold; Controls.Add(imgRightBG); imgIndicator.Surface.LoadFromFile(path + "Calendar.Indicator.Normal.jif"); imgRightBG.Controls.Add(imgIndicator); imgDDay.Surface.LoadFromFile(path + "DDay.Background.jif"); imgDDay.SetTabStop(true); imgDDay.OnClick = imgDDay_OnClick; imgDDay.OnClickHold = imgLeftBG_OnClickHold; Controls.Add(imgDDay); imgLeftBG.SetBounds(0, 0); y = imgLeftBG.GetHeight(); imgDDay.SetBounds(0, y + 1); x = imgLeftBG.GetWidth(); imgRightBG.SetBounds(x, 0); y = (imgRightBG.GetHeight() - imgIndicator.GetHeight()) / 2; imgIndicator.SetBounds(0, y); lblDate.FilePrefix="{Application}\\PointSense\\Theme\\b"; lblDate.SetText("31"); imgLeftBG.Controls.Add(lblDate); // Add x = Device.AutoScaleValue(17); y = Device.AutoScaleValue(24); ////////////////////////////// lblDate.SetBounds(x, y, imgLeftBG.GetWidth(), imgLeftBG.GetHeight()); lblMonth.SetAlign("Center","Top"); lblMonth.SetFont("Font.Small"); y = Device.AutoScaleValue(8); imgLeftBG.Controls.Add(lblMonth); lblMonth.SetBounds(0, y, imgLeftBG.GetWidth(), lblMonth.GetFontHeight()); w = imgRightBG.GetWidth() - (2 * padding); padding = Device.AutoScaleValue(4); // Edited y=padding; x = padding + imgIndicator.GetWidth(); lblApptDate.SetFont("Font.Medium"); // Edited imgRightBG.Controls.Add(lblApptDate); lblApptDate.SetBounds(x, y, w, lblApptDate.GetFontHeight()); lblApptTime.SetFont("Font.Normal"); // Edited imgRightBG.Controls.Add(lblApptTime); y += lblApptDate.GetFontHeight(); lblApptTime.SetBounds(x, y, w, lblApptTime.GetFontHeight()); lblApptSubject.SetFont("Font.Medium"); // Edited imgRightBG.Controls.Add(lblApptSubject); y += lblApptTime.GetFontHeight(); lblApptSubject.SetBounds(x, y, w, lblApptSubject.GetFontHeight()); w = imgLeftBG.GetWidth() + imgRightBG.GetWidth(); h = imgLeftBG.GetHeight() + imgDDay.GetHeight() + 1; SetWidthHeight(w,h); DDay_Day.OnNotify = DDay_Day_OnNotify; DDay_Text.OnNotify = DDay_Text_OnNotify; DDay_From.OnNotify = DDay_From_OnNotify; lblDDay_Day.SetAlign("Center", "Center"); lblDDay_Day.SetFont("Font.Medium"); imgDDay.Controls.Add(lblDDay_Day); lblDDay_Text.SetAlign("Left", "Center"); lblDDay_Text.SetFont("Font.Medium"); imgDDay.Controls.Add(lblDDay_Text); lblDDay_From.SetAlign("Right", "Center"); lblDDay_From.SetFont("Font.Small"); imgDDay.Controls.Add(lblDDay_From); h = imgDDay.GetHeight(); x = 5; lblDDay_Day.SetBounds(x,0,95,h); x = x + 95 + 5; lblDDay_Text.SetBounds(x,0,160,h); x = x + 160; lblDDay_From.SetBounds(x,0,160,h); StartUpdates(); } void Activated() { DateTime dt; dt.Now(); String s; s = dt.GetDay(); // Edited if(s.GetLength() == 1){ s = "0" + s; } lblDate.SetText(s); /*if (s.GetLength() >= 2) { x = Device.AutoScaleValue(15); } else { x = Device.AutoScaleValue(22); } y = Device.AutoScaleValue(22); lblDate.SetBounds(x, y, imgLeftBG.GetWidth(), imgLeftBG.GetHeight()); */ s = dt.ToString("MMM"); lblMonth.SetText(s); LoadAppointment(); } void LoadAppointment() { DataTable tbl; DateTime dt; dt.Now(); Appointments.GetAppointments(tbl); tbl.SetMaxItems(1); tbl.SetSort("Start"); String filter; filter = "[End] >= <{Now} AND [Start] < <{End}"; String tmp; float f; f = dt.ToVariantTime(); tmp = f.ToString("%.5f"); filter.Replace("{Now}", tmp); dt.AddDays(appDays); f = dt.ToVariantTime(); f.Trunc(); tmp = f.ToString("%.0f"); filter.Replace("{End}", tmp); tbl.SetRestriction(filter); dt.Now(); if (tbl.MoveNext()) { String s, s1; // Edited DateTime dtStart, dtEnd; bool isAllDay; tbl.GetValue("ObjectID", ObjectID); tbl.GetValue("Start", dtStart); tbl.GetValue("AllDayEvent", isAllDay); tbl.GetValue("End", dtEnd); tbl.GetValue("Location", s1); // Add imgIndicator.SetVisible(true); if ((dt >= dtStart) && (dt <= dtEnd)) { imgIndicator.Surface.LoadFromFile(path + "Calendar.Indicator.Expired.jif"); } else { imgIndicator.Surface.LoadFromFile(path + "Calendar.Indicator.Normal.jif"); } if (dtStart.IsSameDay(dt)||(dtStart= 2) { x = Device.AutoScaleValue(15); } y = Device.AutoScaleValue(22); lblDate.SetBounds(x, y, imgCalendar.GetWidth(), imgCalendar.GetHeight()); */ s = dt.ToString("MMM"); lblMonth.SetText(s); } void DisplayValue(int val, Label* lbl, bool bg, Image* img) { if ((val < 20) || (val >= 100)) { lbl.SetFont("Font.Normal"); } else { lbl.SetFont("Font.Small"); } if (val >= 100) { lbl.SetText("*"); } else { lbl.SetText(val); } if (bg) { if (val > 0) { img.SetVisible(true); } else { img.SetVisible(false); } } } void InsertInfo(Info info) { int i = 0; bool insert = false; while ((insert == false) && (i < colInfos.GetCount()) && (i < 4)) { Info *iterInfo = colInfos.Item(i); if (info.dt < iterInfo.dt) { insert = true; } else if ((info.dt == iterInfo.dt) && (info.type < iterInfo.type)) { insert = true; } else { i++; } } if (i < 4) { InsertInfoIndex(info, i); } } void InsertInfoIndex(Info info, int index) { if (index < 4) { int i = 0; Collection colTmp; Info* iterInfo; while ((i < index) && (i < colInfos.GetCount())) { iterInfo = colInfos.Item(i); Info newInfo; newInfo.Copy(iterInfo); colTmp.Add(newInfo); i++; } colTmp.Add(info); i++; while ((i < 4) && (i < colInfos.GetCount() + 1)) { iterInfo = colInfos.Item(i - 1); Info newInfo; newInfo.Copy(iterInfo); colTmp.Add(newInfo); i++; } colInfos.Clear(); i = 0; while (i < colTmp.GetCount()) { iterInfo = colTmp.Item(i); Info newInfo; newInfo.Copy(iterInfo); colInfos.Add(newInfo); i++; } } } void DisplayInfos() { int i = 0; while ((i < colInfos.GetCount()) && (i < 4)) { Info *info = colInfos.Item(i); Image *imgIndicator = colImgIndicator.Item(i); imgIndicator.SetVisible(true); imgIndicator.Surface.LoadFromFile(path + info.pathInd); Label *lblApptDate = colLblApptDate.Item(i); lblApptDate.SetText(info.date); Label *lblApptSubject = colLblApptSubject.Item(i); lblApptSubject.SetText(info.subject); i++; } while (i < 4) { Image *imgIndicator = colImgIndicator.Item(i); imgIndicator.SetVisible(false); Label *lblApptDate = colLblApptDate.Item(i); lblApptDate.SetText(""); Label *lblApptSubject = colLblApptSubject.Item(i); lblApptSubject.SetText(""); i++; } } void LoadAppointments() { DataTable tbl; DateTime dt; dt.Now(); Appointments.GetAppointments(tbl); String filter; filter = "[End] >= <{Now} AND [Start] < <{End}"; String tmp; float f; f = dt.ToVariantTime(); tmp = f.ToString("%f"); filter.Replace("{Now}", tmp); dt.AddDays(appDays); f = dt.ToVariantTime(); tmp = f.ToString("%f"); filter.Replace("{End}", tmp); tbl.SetRestriction(filter); tbl.SetSort("Start"); int nbApptDay = 0; int nbApptTot = 0; dt.Now(); while (tbl.MoveNext()) { DateTime dtStart, dtEnd; bool isAllDay; tbl.GetValue("Start", dtStart); tbl.GetValue("End", dtEnd); tbl.GetValue("AllDayEvent", isAllDay); if (isAllDay || (dt < dtEnd)) { String subject; tbl.GetValue("Subject", subject); DateTime dayStart, dayEnd; dayStart = dtStart; dayStart.SetStartOfDay(); dayEnd = dtEnd; dayEnd.SetStartOfDay(); dayEnd.AddDays(1); if ((dt >= dayStart) && (dt < dtEnd)) { nbApptDay++; } nbApptTot++; Info info; info.type = 0; info.dt = dtStart; if ((dt >= dtStart) && (dt < dtEnd)) { info.pathInd = "RamCalendar.Indicator.Actif.jif"; } else { info.pathInd = "RamCalendar.Indicator.Normal.jif"; } String s = dtStart.ToRegionalDateString("dddd"); s = s.SubString(0, 1); //s += " " + dtStart.ToRegionalDateString("dd/MM"); s = dtStart.ToRegionalDateString("M월 dd일 (") + s + ")"; if (!isAllDay) { s += " " + dtStart.ToRegionalTimeString("NoSeconds"); } else { DateTime dt2 = dtEnd; dt2.AddDays(-1); if (!dtStart.IsSameDay(dt2)) { String s2 = dt2.ToRegionalDateString("dddd"); s2 = s2.SubString(0, 1); //s += " - " + s2 + " " + dt2.ToRegionalDateString("dd/MM"); s += " - " + dt2.ToRegionalDateString("M월 dd일 (") + s2 + ")"; } } info.date = s; info.subject = subject; InsertInfo(info); if ((dtStart > dt) && ((dtAppt == dtEmpty) || (dtStart < dtAppt))) { dtAppt = dtStart; } else if ((dtEnd > dt) && ((dtAppt == dtEmpty) || (dtEnd < dtAppt))) { dtAppt = dtEnd; } } } DisplayValue(nbApptDay, lblApptDay, true, imgBGApptDay); DisplayValue(nbApptTot, lblApptTot, false, 0); } void LoadTasks() { DataTable tbl; Tasks.GetTasks(tbl); String filter; filter = "[DueDate] < <{End} AND [Complete] = False"; DateTime dt; dt.Now(); dt.AddDays(appDays); float f; f = dt.ToVariantTime(); String tmp; tmp = f.ToString("%f"); filter.Replace("{End}", tmp); tbl.SetRestriction(filter); tbl.SetSort("DueDate"); int nbTaskDay = 0; int nbTaskTot = 0; dt.Now(); while (tbl.MoveNext()) { DateTime taskStart, taskDue; bool complete; String subject; tbl.GetValue("StartDate", taskStart); tbl.GetValue("DueDate", taskDue); tbl.GetValue("Subject", subject); if (taskDue <= dt) { nbTaskDay++; } nbTaskTot++; Info info; info.type = 1; info.dt = taskDue; info.dt.AddDays(1); if (taskDue <= dt) { info.pathInd = "RamCalendar.Task.Due.jif"; } else { info.pathInd = "RamCalendar.Task.Normal.jif"; } String s = taskDue.ToRegionalDateString("dddd"); s = s.SubString(0, 1); info.date = taskDue.ToRegionalDateString("M월 dd일 (") + s + ")"; info.subject = subject; InsertInfo(info); } DisplayValue(nbTaskDay, lblTaskDay, true, imgBGTaskDay); DisplayValue(nbTaskTot, lblTaskTot, false, 0); } void LoadBirthdays() { colContacts.Clear(); DataTable tbl; Contacts.GetContacts(tbl); DateTime dt; dt.Now(); dt.SetStartOfDay(); DateTime dtMax = dt; dtMax.AddDays(appDays); while (tbl.MoveNext()) { int objectId; DateTime birthday; tbl.GetValue("ObjectID", objectId); tbl.GetValue("Birthday", birthday); if (birthday != dtEmpty) { String s = birthday.GetMonth(); s += "/"; s += birthday.GetDay(); s += "/"; s += dt.GetYear(); DateTime dtBirthYear = s; Contact contact; if ((dtBirthYear >= dt) && (dtBirthYear <= dtMax)) { contact.Set(objectId); colContacts.Add(contact); } else if (birthday.GetMonth() == 1) { // case of january -> year + 1 s = birthday.GetMonth(); s += "/"; s += birthday.GetDay(); s += "/"; s += dt.GetYear() + 1; DateTime dtBirthYear = s; if ((dtBirthYear >= dt) && (dtBirthYear <= dtMax)) { contact.Set(objectId); colContacts.Add(contact); } } } } } void DisplayBirthdays() { int nbBirthDay = 0; int nbBirthTot = 0; DateTime dt; dt.now(); dt.SetStartOfDay(); int i = 0; while (i < colContacts.GetCount()) { Contact *contact = colContacts.Item(i); DateTime birthday; String firstName, lastName; contact.GetValue("Birthday", birthday); contact.GetValue("FirstName", firstName); contact.GetValue("LastName", lastName); String s = birthday.GetMonth(); s += "/"; s += birthday.GetDay(); s += "/"; if ((birthday.GetMonth() == 1) && (dt.GetMonth() == 12)) { s += dt.GetYear() + 1; } else { s += dt.GetYear(); } DateTime dtBirthYear = s; if (dtBirthYear == dt) { nbBirthDay++; } nbBirthTot++; Info info; info.type = 2; info.dt = dtBirthYear; info.dt.AddDays(1); info.pathInd = "RamCalendar.Birthday.jif"; String s = dtBirthYear.ToRegionalDateString("dddd"); s = s.SubString(0, 1); info.date = dtBirthYear.ToRegionalDateString("M월 dd일 (") + s + ")"; info.subject = firstName + " " + lastName; int nbY = dt.GetYear() - birthday.GetYear(); if (nbY > 0) { info.subject += " ("; info.subject += nbY; info.subject += ")"; } InsertInfo(info); i++; } DisplayValue(nbBirthDay, lblBirthDay, true, imgBGBirthDay); DisplayValue(nbBirthTot, lblBirthTot, false, 0); } void LoadAlarms() { bool active; active = false; int flag0, flag1, flag2; ByteArray binFlag0, binFlag1, binFlag2; RegistryKey reg; reg.Open("HKLM\\Software\\Microsoft\\Clock\\0"); reg.GetValue("AlarmFlags", binFlag0); flag0 = binFlag0.GetByte(0); if (flag0 == 1) { active = true; } reg.Open("HKLM\\Software\\Microsoft\\Clock\\1"); reg.GetValue("AlarmFlags", binFlag1); flag1 = binFlag1.GetByte(0); if (flag1 == 1) { active = true; } reg.Open("HKLM\\Software\\Microsoft\\Clock\\2"); reg.GetValue("AlarmFlags", binFlag2); flag2 = binFlag2.GetByte(0); if (flag2 == 1) { active = true; } if (active) { imgClock.Surface.LoadFromFile(path + "RamCalendar.Alarm.On.jif"); lblClockTime.SetColor("White"); //lblClockTime.SetText(nextAlarm); lblClockTime.SetText(Terms.Get("On")); lblClockDate.SetText(""); } else { imgClock.Surface.LoadFromFile(path + "RamCalendar.Alarm.Off.jif"); lblClockTime.SetColor("LightGray"); lblClockTime.SetText(Terms.Get("Off")); lblClockDate.SetText(""); } } void imgBG_OnClickHold(Control sender, int x, int y) { widget_OnClickHold(); } void imgCalendar_OnClick(Control sender, int x, int y) { DateTime dt; dt.Now(); Appointments.DisplayApp(dt); RegistryKey k; k.Open("HKLM\\Software\\Pointui\\Home 2"); String val; k.GetValue("ThumbCal", val); if (val == "On") { Process.Start("{ProgramFiles}\\ThumbCal\\ThumbCal.exe"); } else { Process.Start("poutlook.exe", "calendar -vm"); } } void ctrCLock_OnClick(Control sender, int x, int y) { Process.StartControlPanelApplet("cplmain.cpl", 16); } void imgBG_OnClick(Control sender, int x, int y) { RegistryKey k; k.Open("HKLM\\Software\\Pointui\\Home 2"); String val; k.GetValue("ThumbCal", val); if (val == "On") { Process.Start("{ProgramFiles}\\ThumbCal\\ThumbCal.exe", "calendar -va"); } else { Appointments.Display(ObjectID); } } } #endregion #region Month Setting Screen class MonthSettingScreen : ListScreen { Label lblTitle; int currentFirstDay; int checkBusy; Event OnFirstDayChanged; Event OnCheckBusyChanged; void Load() { Controls.Add(lblTitle); SetTitlePosition(lblTitle); lblTitle.SetText(Terms.Get("Calendar Settings")); String s; if (currentFirstDay == 0) { s = Terms.Get("Sunday"); } else { s = Terms.Get("Monday"); } s = Terms.Get("Firstday") + ": " + s; AddItem("FirstDay", s); if (checkBusy == 0) { s = Terms.Get("Check Busy"); } else { s = Terms.Get("No Check Busy"); } AddItem("CheckBusy", s); OnListItemClick = OnListItemClick_Handler; } void OnListItemClick_Handler(ListItem li, int x, int y) { String id; id = li.Attributes.Item("ID"); if (id == "FirstDay") { OnFirstDayChanged(); FlowStack.Return(); } else if (id == "CheckBusy") { OnCheckBusyChanged(); FlowStack.Return(); } } } class AppointmentSettingScreen : ListScreen { Label lblTitle; Event OnDaysChanged; void Load() { Controls.Add(lblTitle); SetTitlePosition(lblTitle); lblTitle.SetText(Terms.Get("Appointment Settings")); AddItem("1", Terms.Get("1 day")); AddItem("2", Terms.Get("2 days")); AddItem("3", Terms.Get("3 days")); AddItem("4", Terms.Get("4 days")); AddItem("5", Terms.Get("5 days")); AddItem("6", Terms.Get("6 days")); AddItem("7", Terms.Get("7 days")); AddItem("14", Terms.Get("14 days")); OnListItemClick = OnListItemClick_Handler; } void OnListItemClick_Handler(ListItem li, int x, int y) { OnDaysChanged(li); FlowStack.Return(); } } class RamAppointmentSettingScreen : ListScreen { Label lblTitle; Event OnDaysChanged; void Load() { Controls.Add(lblTitle); SetTitlePosition(lblTitle); lblTitle.SetText(Terms.Get("Appointment Settings")); AddItem("1", Terms.Get("1 day")); AddItem("2", Terms.Get("2 days")); AddItem("3", Terms.Get("3 days")); AddItem("4", Terms.Get("4 days")); AddItem("5", Terms.Get("5 days")); AddItem("6", Terms.Get("6 days")); AddItem("7", Terms.Get("7 days")); AddItem("14", Terms.Get("14 days")); OnListItemClick = OnListItemClick_Handler; } void OnListItemClick_Handler(ListItem li, int x, int y) { OnDaysChanged(li); FlowStack.Return(); } } #endregion Setting #region Appointment Screen class AppointmentScreen : ListScreen { DateTime CurrentDate; DataTable tbl; Surface icon; Label lblTitle; Event OnDone; void Load() { String s; Controls.Add(lblTitle); SetTitlePosition(lblTitle); s = CurrentDate.ToString("dddd"); s = s + " " + CurrentDate.ToString("dd MMMM"); lblTitle.SetText(s); icon.LoadFromFile("{Application}\\PointSense\\Theme\\Calendar.Icon.jif"); Refresh(); SetSoftKeys("Done", Terms.Get("Back"), "Add", Terms.Get("Add")); OnListItemClick = OnListItemClick_Handler; } //void Activate() //{ //} void AppGotFocus() { Refresh(); } void Refresh() { Clear(); DateTime dt; dt = CurrentDate; dt.SetStartOfDay(); Appointments.GetAppointments(tbl); //tbl.SetMaxItems(1); tbl.SetSort("Start"); String filter; filter = "[End] >= <{Now} AND [Start] < <{End}"; String tmp; float f; f = dt.ToVariantTime(); tmp = f.ToString("%.0f"); filter.Replace("{Now}", tmp); dt.AddDays(1); f = dt.ToVariantTime(); f.Trunc(); tmp = f.ToString("%.0f"); filter.Replace("{End}", tmp); tbl.SetRestriction(filter); while (tbl.MoveNext()) { int ObjectID; String text; DateTime dtEnd, dtStart; bool isAllDayEvent; tbl.GetValue("ObjectID", ObjectID); tbl.GetValue("Subject", text); tbl.GetValue("End", dtEnd); tbl.GetValue("Start", dtStart); tbl.GetValue("AllDayEvent", isAllDayEvent); String s; if (isAllDayEvent) { s = Terms.Get("Allday"); } else { s = dtStart.ToString("h:mm tt"); if (dtStart.IsSameDay(dtEnd)) { s += " - " + dtEnd.ToString("h:mm tt"); } else { s += " - " + Terms.Get("Multiday"); } } s.ToUpper(); ListItem* li; AddItem("TwoLine", li); li.Attributes.Add("ID", ObjectID); li.Attributes.Add("Text", s); li.Attributes.Add("Text2ndLine", text); li.Attributes.Add("Icon", icon); li.Refresh(); } } void OnListItemClick_Handler(ListItem selectedItem, int x, int y) { //show the task int ObjectID; ObjectID = selectedItem.Attributes.Item("ID"); RegistryKey k; k.Open("HKLM\\Software\\Pointui\\Home 2"); String val; k.GetValue("ThumbCal", val); if (val == "On") { Process.Start("{ProgramFiles}\\ThumbCal\\ThumbCal.exe", "oid "+ObjectID); } else { Appointments.Display(ObjectID); } } bool SoftKeyButtonClick(String buttonID) { if (buttonID == "Add") { RegistryKey k; k.Open("HKLM\\Software\\Pointui\\Home 2"); String val; k.GetValue("ThumbCal", val); if (val == "On") { Process.Start("{ProgramFiles}\\ThumbCal\\ThumbCal.exe", "calendar -new"); } else { Process.Start("poutlook.exe", "calendar -new"); } } } bool Done(ListItem selectedItem) { OnDone(); } } #endregion