public static string GetName(long date) { Java.Util.Calendar cal = Java.Util.Calendar.GetInstance(Java.Util.Locale.English); cal.Time = new Java.Util.Date(date); int dayofmonth = cal.Get(Java.Util.CalendarField.DayOfMonth); int dayofweek = cal.Get(Java.Util.CalendarField.DayOfWeek); switch (dayofweek) { case 1: return("Sun " + dayofmonth); case 2: return("Mon " + dayofmonth); case 3: return("Tue " + dayofmonth); case 4: return("Wed " + dayofmonth); case 5: return("Thu " + dayofmonth); case 6: return("Fri " + dayofmonth); case 7: return("Sat " + dayofmonth); default: return(""); } }
public int getWeekStartFrom() { var temp = Java.Util.Calendar.Instance; temp.Set(_calendar.Get(CalendarField.Year), _calendar.Get(CalendarField.Month), 1); var weekstartfrom = temp.Get(CalendarField.DayOfWeek); return(weekstartfrom); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { Java.Util.Calendar c = Java.Util.Calendar.Instance; int year = c.Get(Java.Util.CalendarField.Year); int month = c.Get(Java.Util.CalendarField.Month); int day = c.Get(Java.Util.CalendarField.DayOfMonth); return(new DatePickerDialog(Activity, this, year, month, day)); }
public string InterpretDate(Java.Util.Calendar date) { int year = date.Get(CalendarField.Year); int month = date.Get(CalendarField.Month); int day = date.Get(CalendarField.DayOfMonth); SimpleDateFormat weekdayNameFormat = new SimpleDateFormat("EEE", Locale.Default); String weekday = weekdayNameFormat.Format(date.Time); SimpleDateFormat format = new SimpleDateFormat(" M/d", Locale.Default); String test = ""; //switch (weekday.ToLower()) //{ // case "sat": // //test = "شنبه"; // break; // case "sun": // //test = "یکشنبه"; // break; // case "mon": // //test = "دوشنبه"; // break; // case "tue": // // test = "سه شنبه"; // break; // case "wed": // // test = "چهارشنبه"; // break; // case "thu": // //test = "پنجشنبه"; // break; // case "fri": // //test = "جمعه"; // break; //} PersianCalendar persianCalendar = new PersianCalendar(year, month, day); // All android api level do not have a standard way of getting the first letter of // the week day name. Hence we get the first char programmatically. // Details: http://stackoverflow.com/questions/16959502/get-one-letter-abbreviation-of-week-day-of-a-date-in-java#answer-16959657 if (mShortDate) { weekday = Convert.ToString(weekday[0]); return(persianCalendar.getIranianDate()); } else { return(test.ToUpper() + " " + persianCalendar.getIranianDate()); } }
public List <String[]> getEvents(int calendarid = 1) { var eventsUri = CalendarContract.Events.ContentUri; Console.WriteLine("whatever"); string[] eventsProjection = { CalendarContract.Events.InterfaceConsts.Id, CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart, CalendarContract.Events.InterfaceConsts.Dtend, CalendarContract.Events.InterfaceConsts.Description, CalendarContract.Events.InterfaceConsts.EventLocation, CalendarContract.Events.InterfaceConsts.EventTimezone }; //Date d = new Date (); Java.Util.Calendar c = Java.Util.Calendar.GetInstance(Java.Util.TimeZone.GetTimeZone("Australia/Brisbane")); c.Add(CalendarField.Month, -1); Console.WriteLine("Date: " + c.Get(CalendarField.DayOfMonth) + "/" + c.Get(CalendarField.Month) + "/" + c.Get(CalendarField.Year) + " ::: " + c.TimeInMillis); String ww = "calendar_id=" + calendarid + " AND dtstart > " + c.TimeInMillis; ICursor cursor = Forms.Context.ApplicationContext.ContentResolver.Query(eventsUri, eventsProjection, ww, null, "dtstart ASC"); //do date not datetime, write to system calendar List <String[]> things = new List <String[]> (); if (cursor.MoveToFirst()) { do { String calid = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Id)); String title = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Title)); String Dstart = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtstart)); String Dend = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtend)); String desc = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Description)); String loc = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.EventLocation)); Console.WriteLine(cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.EventTimezone))); things.Add(new String[] { calid, title, Dstart, Dend, desc, loc }); //Console.WriteLine("ID: " + calid); }while(cursor.MoveToNext()); } cursor.Close(); cursor.Dispose(); return(things); }
public void Apply(Java.Lang.Object p0) { CalendarCell calendarCell = p0.JavaCast <CalendarCell>(); if (calendarCell.CellType != CalendarCellType.Date) { return; } calendar.TimeInMillis = calendarCell.Date; if (calendar.Get(Java.Util.CalendarField.DayOfMonth) == 21 && calendar.Get(Java.Util.CalendarField.Month) == Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Month)) { calendarCell.SetBackgroundColor( Android.Graphics.Color.ParseColor("#FF00A1"), Android.Graphics.Color.ParseColor("#F988CF")); } }
public Java.Lang.Object Apply(Java.Lang.Object timeInMillis) { calendar.TimeInMillis = (long)timeInMillis; if (calendar.Get(CalendarField.DayOfWeek) == Calendar.Sunday) { return(Color.Red.ToArgb()); } return(null); }
public GregorianCalendar(Context context) { _calendar = Java.Util.Calendar.Instance; _monthNames = new[] { context.Resources.GetString(Resource.String.January), context.Resources.GetString(Resource.String.February), context.Resources.GetString(Resource.String.March), context.Resources.GetString(Resource.String.April), context.Resources.GetString(Resource.String.May), context.Resources.GetString(Resource.String.June), context.Resources.GetString(Resource.String.July), context.Resources.GetString(Resource.String.August), context.Resources.GetString(Resource.String.September), context.Resources.GetString(Resource.String.October), context.Resources.GetString(Resource.String.November), context.Resources.GetString(Resource.String.December) }; _countMonth = _calendar.Get(CalendarField.Month); _countYear = _calendar.Get(CalendarField.Year); _currentMonth = _countMonth; _currentYear = _countYear; }
public void Apply(Java.Lang.Object p0) { if (p0 is CalendarDayCell calendarCell && calendarCell.CellType == CalendarCellType.Date) { // p0 is enabled color, p1 is disabled color // calendarCell.SetBackgroundColor(p0, p1) calendarCell.SetBackgroundColor(ParseColor("#F8F8F8"), ParseColor("#E0E0E0")); calendarCell.SetTextColor(ParseColor("#000000"), ParseColor("#FFFFFF")); calendar.TimeInMillis = calendarCell.Date; var weekDay = calendar.Get(CalendarField.DayOfWeek); if (weekDay == 1 || weekDay == 7) { calendarCell.SetBackgroundColor(ParseColor("#EEEEEE"), ParseColor("#E0E0E0")); calendarCell.SetTextColor(ParseColor("#999999"), ParseColor("#AAAAAA")); } var boldTypeface = Typeface.Create(calendarCell.TextPaint.Typeface, TypefaceStyle.Bold); if (calendar.Get(CalendarField.Date) == Instance.Get(CalendarField.Date) && calendar.Get(CalendarField.Month) == Instance.Get(CalendarField.Month) && calendar.Get(CalendarField.Year) == Instance.Get(CalendarField.Year)) { calendarCell.BorderColor = ParseColor("#00FF44"); calendarCell.BorderWidth = Forms.Context.ToPixels(2); calendarCell.Typeface = boldTypeface; } if (calendarCell.Selected) { calendarCell.Typeface = boldTypeface; } } }
internal string When() { try { if (statusbarnotification.Notification.Extras.GetBoolean(Notification.ExtraShowWhen) == true) { Java.Util.Calendar calendar = Java.Util.Calendar.Instance; calendar.TimeInMillis = statusbarnotification.Notification.When; return(string.Format("{0:D2}:{1:D2} {2}", calendar.Get(CalendarField.Hour), calendar.Get(CalendarField.Minute), calendar.GetDisplayName((int)CalendarField.AmPm, (int)CalendarStyle.Short, Locale.Default))); } return(string.Empty); } catch { return(string.Empty); } }
private String getEventTitle(Java.Util.Calendar time) { return(String.Format("Event of {0}:{1} {2}/{3}", time.Get(CalendarField.HourOfDay), time.Get(CalendarField.Minute), time.Get(CalendarField.Month) + 1, time.Get(Calendar.DayOfMonth))); }
protected override void OnCreate(Bundle bundle) { this.RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait; _fragment1.SetActivity(this); _fragment2.SetActivity(this); _fragment3.SetActivity(this); _settingsWindow.SetActivity(this); base.OnCreate(bundle); //dialogwindow.SetActivity( SetContentView(Resource.Layout.Main); mGeneratorImage = new ImageGenerator(this); //mDisplayGeneratedImage = FindViewById<ImageView>(Resource.Id.imageGen); mCurrentDate = Java.Util.Calendar.Instance; mGeneratorImage.SetIconSize(50, 50); mGeneratorImage.SetDateSize(30); mGeneratorImage.SetMonthSize(10); mGeneratorImage.SetDatePosition(42); mGeneratorImage.SetMonthPosition(14); mGeneratorImage.SetDateColor(Color.ParseColor("#3c6eaf")); mGeneratorImage.SetMonthColor(Color.White); mGeneratorImage.SetStorageToSDCard(true); //Первичная отрисовка иконки календаря int primaryYear = mCurrentDate.Get(CalendarField.Year); int primaryMonth = mCurrentDate.Get(CalendarField.Month); int primaryDay = mCurrentDate.Get(CalendarField.DayOfMonth); //REPAIR PLEASE mCurrentDate.Set(primaryYear, primaryMonth, primaryDay); mGenerateDateIcon = mGeneratorImage.GenerateDateImage(mCurrentDate, Resource.Drawable.EmptyCalendar); //mDisplayGeneratedImage.SetImageBitmap(mGenerateDateIcon); //var drawCalendar = mDisplayGeneratedImage.Background; FloatingActionButton btnCalendar = FindViewById <FloatingActionButton>(Resource.Id.btnCalendar); //btnCalendar.SetBackgroundDrawable(drawCalendar); //Кнопка для сортировки задач по дате btnCalendar.Click += delegate { //mCurrentDate = Java.Util.Calendar.Instance; int mYear = mCurrentDate.Get(CalendarField.Year); int mMonth = mCurrentDate.Get(CalendarField.Month); int mDay = mCurrentDate.Get(CalendarField.DayOfMonth); DatePickerDialog datePickerDialog = new DatePickerDialog(this, Android.App.AlertDialog.ThemeDeviceDefaultDark, this, mYear, mMonth, mDay); datePickerDialog.Show(); }; mScrollView = FindViewById <SlidingTabScrollView>(Resource.Id.sliding_tabs); mViewPager = FindViewById <ViewPager>(Resource.Id.viewPager); mViewPager.Adapter = new SamplePagerAdapter(this, SupportFragmentManager); mScrollView.ViewPager = mViewPager; //Получаем экземпляр бд DataBase.db = DataBase.getDataBase(); DataBase.db.createDataBase(); DataBase.db.createDataBaseExp(); DataBase.db.createDataBaseSettings(); //Первичные настройки приложения if (DataBase.db.getSettings().Count == 0) { DataBase.db.insertStartSettings(); } string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); Log.Info("DB_PATH", folder); //var imgBtn = new ImageButton //var imgBtn = FindViewById<ImageButton>(Resource.Id.imgBtn); FloatingActionButton settingsBtn = FindViewById <FloatingActionButton>(Resource.Id.settingsBtn); settingsBtn.Click += delegate { //Создаем окно для добавления новой задачи Android.App.FragmentTransaction ft = FragmentManager.BeginTransaction(); Android.App.Fragment prev = FragmentManager.FindFragmentByTag("dialog"); //Передаем id новой заметки для корректной записи в бд Bundle frag_bundle = new Bundle(); //frag_bundle.PutLong("Id", task.Id); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); _settingsWindow = SettingsWindow.NewInstance(frag_bundle); var act = _settingsWindow.Activity; //Показываем окно _settingsWindow.SetActivity(this); _settingsWindow.Show(ft, "dialog"); }; }
public static int GetDay(long date) { Java.Util.Calendar cal = Java.Util.Calendar.GetInstance(Java.Util.Locale.English); cal.Time = new Java.Util.Date(date); return(cal.Get(Java.Util.CalendarField.DayOfMonth)); }
private void Calendar_DaySlotLoading(object sender, CalendarDaySlotLoadingEventArgs e) { // get day Java.Util.Date date = e.Date; Java.Util.Calendar cal = Java.Util.Calendar.GetInstance(Java.Util.Locale.English); cal.Time = date; int day = cal.Get(Java.Util.CalendarField.DayOfMonth); // create day slot layout container CalendarDaySlotBase layout = new CalendarDaySlotBase(ApplicationContext); layout.SetGravity(GravityFlags.Top); layout.SetVerticalGravity(GravityFlags.Top); layout.Orientation = Orientation.Vertical; layout.SetBackgroundColor(Android.Graphics.Color.White); layout.SetPadding(5, 5, 5, 5); LinearLayout.LayoutParams linearLayoutParams1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent); layout.LayoutParameters = linearLayoutParams1; // create text element TextView tv = new TextView(ApplicationContext); LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); tv.LayoutParameters = linearLayoutParams; tv.Gravity = GravityFlags.Center; //текст цифр tv.Text = day.ToString(); tv.SetTextColor(Android.Graphics.Color.Black); if (e.AdjacentDay) { // format adjacent day text tv.SetTextColor(Android.Graphics.Color.Gray); //цвет неактивных дней } // add text element to layout layout.AddView(tv); String Year = e.Date.ToString().Split(' ')[5]; String Month = e.Date.ToString().Split(' ')[1]; string intMonth = "0"; // add weather image for certain days for (int i = 0; i < records.Count; i++) { if (records[i].Year == Year) { switch (Month) { case "Jan": intMonth = "1"; break; case "Feb": intMonth = "2"; break; case "Mar": intMonth = "3"; break; case "Apr": intMonth = "4"; break; case "May": intMonth = "5"; break; case "Jun": intMonth = "6"; break; case "Jul": intMonth = "7"; break; case "Aug": intMonth = "8"; break; case "Sep": intMonth = "9"; break; case "Okt": intMonth = "10"; break; case "Now": intMonth = "11"; break; case "Dec": intMonth = "12"; break; default: break; } if (records[i].Month == intMonth && day.ToString() == records[i].Day) { layout.SetBackgroundColor(Android.Graphics.Color.LightBlue); } } } // finally, set layout to day slot e.DaySlot = layout; }