예제 #1
0
파일: util.Droid.cs 프로젝트: thejibb/Core
        /// <summary>
        /// Converts a java datetime to system.datetime
        /// </summary>
        /// <returns>The date to date time.</returns>
        /// <param name="date">Date.</param>
        public static DateTime NativeDateToDateTime(Java.Util.Date date)
        {
            long javaDateAsMilliseconds = date.Time;
            var  dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Add(TimeSpan.FromMilliseconds(javaDateAsMilliseconds));

            return(dateTime);
        }
예제 #2
0
        /************************
        **DrawMonthCell Method**
        ************************/
        private void Calendar_DrawMonthCell(object sender, DrawMonthCellEventArgs e)
        {
            SimpleDateFormat compareString = new SimpleDateFormat("dd/MM/yyyy");
            String           temp          = new SimpleDateFormat("dd/MM/yyyy").Format(e.MonthCell.Date.Time);

            Java.Util.Date date      = compareString.Parse(temp);
            string         dayString = new SimpleDateFormat("EEEE").Format(date);

            if (dayString.ToLower().Equals("sunday") || dayString.ToLower().Equals("saturday"))
            {
                e.MonthCell.TextColor     = Color.ParseColor("#0990e9");
                e.MonthCell.FontAttribute = Typeface.Create(" ", TypefaceStyle.Bold);
            }
            else
            {
                e.MonthCell.TextColor     = Color.ParseColor("#7F7F7F");
                e.MonthCell.FontAttribute = Typeface.Create(" ", TypefaceStyle.Italic);
            }
        }
예제 #3
0
        public void SetAlarm(int hour, int minute, string title, string message)
        {
            //AppContext.StartService(new Intent(AppContext, typeof(AppStickyService)));
            Intent myintent = new Intent(Android.App.Application.Context, typeof(AppStickyService));

            myintent.PutExtra("message", message);
            myintent.PutExtra("title", title);
            //PendingIntent pendingintent = PendingIntent.GetBroadcast(Android.App.Application.Context, 0, myintent, PendingIntentFlags.UpdateCurrent);
            PendingIntent pintent = PendingIntent.GetService(this, 0, new Intent(this, typeof(AppStickyService)), 0);

            Java.Util.Date     date = new Java.Util.Date();
            Java.Util.Calendar cal  = Java.Util.Calendar.Instance;
            cal.TimeInMillis = Java.Lang.JavaSystem.CurrentTimeMillis();
            cal.Set(Java.Util.CalendarField.HourOfDay, hour);
            cal.Set(Java.Util.CalendarField.Minute, minute);
            cal.Set(Java.Util.CalendarField.Second, 0);
            AlarmManager alarmManager = Android.App.Application.Context.GetSystemService(Android.Content.Context.AlarmService) as AlarmManager;

            alarmManager.Set(AlarmType.RtcWakeup, cal.TimeInMillis, pintent);
            Toast.MakeText(this, "Service started ", ToastLength.Long).Show();
        }
예제 #4
0
파일: util.Droid.cs 프로젝트: thejibb/Core
        /// <summary>
        /// Converts a date between time zones
        /// </summary>
        /// <returns>The date in the converted timezone.</returns>
        /// <param name="date">Date to convert</param>
        /// <param name="fromTZ">from Time Zone</param>
        /// <param name="toTZ">To Time Zone</param>
        public static Java.Util.Date ConvertTimeZone(Java.Util.Date date, Java.Util.TimeZone fromTZ, Java.Util.TimeZone toTZ)
        {
            long fromTZDst = 0;

            if (fromTZ.InDaylightTime(date))
            {
                fromTZDst = fromTZ.DSTSavings;
            }

            long fromTZOffset = fromTZ.RawOffset + fromTZDst;

            long toTZDst = 0;

            if (toTZ.InDaylightTime(date))
            {
                toTZDst = toTZ.DSTSavings;
            }

            long toTZOffset = toTZ.RawOffset + toTZDst;

            return(new Java.Util.Date(date.Time + (toTZOffset - fromTZOffset)));
        }
예제 #5
0
        private void AddEventToHistoryFile(string type)
        {
            double secondsFromEpoch = new Java.Util.Date().Time / 1000.0;

            navigation.AddHistoryEvent(type, secondsFromEpoch.ToString());
        }
예제 #6
0
        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;
        }