Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            // If these are not used the ToString for DateTime throws an exception in some cultures
            // For more information: https://forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
            var c1  = new System.Globalization.ChineseLunisolarCalendar();
            var c2  = new System.Globalization.GregorianCalendar();
            var c3  = new System.Globalization.HebrewCalendar();
            var c4  = new System.Globalization.HijriCalendar();
            var c5  = new System.Globalization.JapaneseCalendar();
            var c6  = new System.Globalization.JapaneseLunisolarCalendar();
            var c7  = new System.Globalization.JulianCalendar();
            var c8  = new System.Globalization.KoreanCalendar();
            var c9  = new System.Globalization.KoreanLunisolarCalendar();
            var c10 = new System.Globalization.PersianCalendar();
            var c11 = new System.Globalization.TaiwanCalendar();
            var c12 = new System.Globalization.TaiwanLunisolarCalendar();
            var c13 = new System.Globalization.ThaiBuddhistCalendar();
            var c14 = new System.Globalization.UmAlQuraCalendar();

            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.SetVmPolicy(builder.Build());

            base.OnCreate(bundle);

            CrossCurrentActivity.Current.Init(this, bundle);
            PermissionsHelper.Activity = this;

            this.SetTheme(Resource.Style.Theme_Design_Light);

            //CachedImageRenderer.Init(false);
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init(false);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // If these are not used the ToString for DateTime throws an exception in some cultures
            // For more information: https://forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
            var c1  = new System.Globalization.ChineseLunisolarCalendar();
            var c2  = new System.Globalization.GregorianCalendar();
            var c3  = new System.Globalization.HebrewCalendar();
            var c4  = new System.Globalization.HijriCalendar();
            var c5  = new System.Globalization.JapaneseCalendar();
            var c6  = new System.Globalization.JapaneseLunisolarCalendar();
            var c7  = new System.Globalization.JulianCalendar();
            var c8  = new System.Globalization.KoreanCalendar();
            var c9  = new System.Globalization.KoreanLunisolarCalendar();
            var c10 = new System.Globalization.PersianCalendar();
            var c11 = new System.Globalization.TaiwanCalendar();
            var c12 = new System.Globalization.TaiwanLunisolarCalendar();
            var c13 = new System.Globalization.ThaiBuddhistCalendar();
            var c14 = new System.Globalization.UmAlQuraCalendar();

            AnalyticsHelper.Initialize(Xamarin.Forms.Device.iOS);

            global::Xamarin.Forms.Forms.Init();

            CachedImageRenderer.Init();

            LoadApplication(new App());

            UITextField.Appearance.TintColor = Xamarin.Forms.Color.FromHex("#2548D8").ToUIColor();
#if __TESTS__
            Xamarin.Calabash.Start();
#endif
            return(base.FinishedLaunching(app, options));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            DateTime dt = DateTime.Now.AddDays(1);

            System.Globalization.TaiwanLunisolarCalendar tlc = new System.Globalization.TaiwanLunisolarCalendar();
            var lDay = tlc.GetDayOfMonth(dt);

            //判斷農歷初一,十五
            if (lDay == 1 || lDay == 15)
            {
                const string token  = "改成要發送LineNotify的Token";
                var          client = new HttpClient {
                    BaseAddress = new Uri("https://notify-api.line.me/api/notify")
                };
                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");

                var kvDict = new Dictionary <string, string> {
                    { "message", "改成要發送的訊息內容" }
                };

                var content = new FormUrlEncodedContent(kvDict);

                var response = client.PostAsync("", content).Result;
                response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            }
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            //上網找農曆程式碼
            DateTime now = DateTime.Now;

            System.Globalization.TaiwanLunisolarCalendar tc = new System.Globalization.TaiwanLunisolarCalendar();
            DateTime d = DateTime.Today;

            //button2.Text = tc.GetYear(d).ToString(); // 農曆幾年
            //button2.Text = tc.GetMonth(d).ToString();  // 農曆幾月
            //button2.Text = tc.GetDayOfMonth(d).ToString(); // 農曆幾號
            // button2.Text = tc.GetDayOfWeek(d).ToString();  //星期幾
            //button2.Text = tc.GetYear(d).ToString() + "-" +tc.GetMonth(d).ToString() + "-" +tc.GetDayOfMonth(d).ToString() ;  //顯示今天農曆年月日

            // 另一寫法,顯示今天農曆年月日, 持續....
            // button2.Text = tc.ToDateTime("Int32 year","int32 month","int32 day","int32 hour","int32 minute","int32 second","int32 millisecond").ToString();
            //button2.Text = Convert.ToDateTime(tc).ToString();
            button2.Text = tc.Eras.ToString()
        }