Пример #1
0
        async void OnScheduleDelButtonClicked(object sender, EventArgs args)
        {
            Button button = sender as Button;

            long id = Convert.ToInt32(button.CommandParameter.ToString());

            SQLLiteDB.DelItem(id);

            List <ScheduleViewItem> saveList = new List <ScheduleViewItem>();

            foreach (var data in scheduleView)
            {
                if (data.Id == id)
                {
                    continue;
                }

                saveList.Add((ScheduleViewItem)data);
            }

            ScheduleView.Clear();

            foreach (var data in saveList)
            {
                scheduleView.Add((ScheduleViewItem)data);
            }

            SchedueListView.ItemsSource = scheduleView;
        }
Пример #2
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (isStarted)
            {
                foreach (var data in SQLLiteDB.ReadUserScheduleData())
                {
                    if (data.IsNotify == false && data.Time < DateTime.Now.AddMinutes(15))
                    {
                        //   CrossLocalNotifications.Current.Show(data.Message, DateTime.Now.ToString(), data.Id, DateTime.Now);

                        var manager = (NotificationManager)GetSystemService(NotificationService);

                        if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
                        {
                            var notification = new Notification.Builder(this, "DE")
                                               .SetContentTitle(DateTime.Now.ToString() + "알림!")
                                               .SetContentText(data.Message)
                                               .SetSmallIcon(Resource.Drawable.xamagonBlue)
                                               .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.xamagonBlue))
                                               .SetSmallIcon(Resource.Drawable.xamagonBlue)
                                               .Build();

                            manager.Notify(data.Id, notification);
                        }
                        else
                        {
                            var notification = new Notification.Builder(this)
                                               .SetContentTitle(DateTime.Now.ToString() + "알림!")
                                               .SetContentText(data.Message)
                                               .SetSmallIcon(Resource.Drawable.xamagonBlue)
                                               .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.xamagonBlue))
                                               .SetSmallIcon(Resource.Drawable.xamagonBlue)
                                               .Build();

                            manager.Notify(data.Id, notification);
                        }

                        //Notify update
                        data.IsNotify = true;
                        SQLLiteDB.Upsert(data, false);
                    }
                }
            }
            else
            {
                RegisterForegroundService();
                isStarted = true;
            }

            SQLLiteDB.InsertScheduleLog(DateTime.Now);

            AlarmReceiver.AddAlarmEvent(10);

            return(StartCommandResult.Sticky);
        }
Пример #3
0
        public void RefreshData()
        {
            int idInc = 0;

            if (LoadInfo.Count == 0)
            {
                foreach (var data in BibleInfo.ListOldTestament)
                {
                    BibleTableInfo info = new BibleTableInfo();

                    info.Id             = idInc++;
                    info.Name           = data;
                    info.MaxChapterSize = BibleInfo.GetChapterSize(data);

                    LoadInfo.Add(info);
                }

                foreach (var data in BibleInfo.ListNewTestament)
                {
                    BibleTableInfo info = new BibleTableInfo();

                    info.Id             = idInc++;
                    info.Name           = data;
                    info.MaxChapterSize = BibleInfo.GetChapterSize(data);

                    LoadInfo.Add(info);
                }
            }

            listView.ItemsSource = LoadInfo;

            listView.ItemSelected += OnItemSelected;

            var plan = SQLLiteDB.ReadBibleReadPlan();

            if (plan != null)
            {
                ReadChapterCount.Text = plan.Count.ToString();

                var search = LoadInfo.Find(e => e.Name == plan.BibleName);
                if (search != null)
                {
                    listView.SelectedItem = search;
                    listView.TabIndex     = search.Id;
                }

                StartTime.Date = plan.StartTime;


                ShowInfomation(StartTime.Date, plan.Count);
            }
        }
Пример #4
0
        async void OnLogSearchButtonClicked(object sender, EventArgs args)
        {
            ClearCalendarButtonColor(Color.White);
            ScheduleView.Clear();
            foreach (var schedule in SQLLiteDB.ReadScheduleLog())
            {
                scheduleView.Add(new ScheduleViewItem {
                    Display = schedule.Time.ToString()
                });
            }

            SchedueListView.ItemsSource = scheduleView;
        }
Пример #5
0
        private void AddMarkWord()
        {
            try
            {
                Helper.RemoveRowGrid(main_grid, UnderliningPos);

                var list = SQLLiteDB.ReadUnderlining();
                if (list != null)
                {
                    int startpos = UnderliningPos;
                    foreach (var data in list)
                    {
#if GLOBAL
                        var contexttext = BibleInfo.GetContextText(BibleType.KJV, data.BibleName, data.Chapter, data.Verse);
#else
                        var contexttext = BibleInfo.GetContextText(BibleType.KRV, data.BibleName, data.Chapter, data.Verse);
#endif


                        int    __verse;
                        string line;
                        Helper.SpliteVerseText(contexttext, out __verse, out line);

#if GLOBAL
                        var text = data.BibleName + " " + data.Chapter + " Chapter" + " " + data.Verse + "Verse \n" + line;
#else
                        var text = data.BibleName + " " + data.Chapter + " 장" + " " + data.Verse + "절 \n" + line;
#endif
                        var labelText = new Label {
                            Text = text, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0)
                        };

                        var stackLayout = new StackLayout();

                        stackLayout.Children.Add(labelText);
                        var frame = new Frame {
                            BorderColor = Color.Black, Padding = new Thickness(3, 3, 3, 3)
                        };
                        frame.Content = stackLayout;

                        main_grid.Children.Add(frame, 0, startpos++);
                        Grid.SetColumnSpan(frame, 2);
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Пример #6
0
        async void OnScheduleSaveButtonClicked(object sender, EventArgs args)
        {
            //하나씩 저장
            if (FocusButton != null)
            {
                DateTime saveDateTime = new DateTime(ViewModel.CurrentDateTime.Year, ViewModel.CurrentDateTime.Month, Convert.ToInt32(FocusButton.Text), timePicker1.Time.Hours, timePicker1.Time.Minutes, timePicker1.Time.Seconds);

                UserScheduleData saveShedulData = new UserScheduleData();
                saveShedulData.Time    = saveDateTime;
                saveShedulData.Message = ScheduleEdit.Text;
                SQLLiteDB.Upsert(saveShedulData);

                scheduleView.Add(new ScheduleViewItem {
                    Id = saveShedulData.Id, Display = Helper.DateTimeToShortTime(saveDateTime) + " " + ScheduleEdit.Text
                });

                FocusButton.BackgroundColor = Color.White;
                FocusButton       = null;
                ScheduleEdit.Text = string.Empty;
                timePicker1.Time  = new TimeSpan(12, 0, 0);
            }
            else //범위로 저장
            {
                DateTime current = RangeFrom.Date;
                while (true)
                {
                    DateTime saveDateTime = new DateTime(current.Year, current.Month, current.Day, timePicker1.Time.Hours, timePicker1.Time.Minutes, timePicker1.Time.Seconds);

                    UserScheduleData saveShedulData = new UserScheduleData();
                    saveShedulData.Time    = saveDateTime;
                    saveShedulData.Message = ScheduleEdit.Text;
                    SQLLiteDB.Upsert(saveShedulData);

                    current = current.AddDays(1);

                    if (current > RangeUntil.Date)
                    {
                        break;
                    }
                }

                ClearCalendarButtonColor(Color.White);

                RangeStackLayout.IsVisible = false;
                ScheduleGrid.IsVisible     = false;
            }
        }
Пример #7
0
        public Setting()
        {
            InitializeComponent();

            TextSizeSlider.Value = User.CacheData.FontSize;

            TextSizeSlider.ValueChanged += (sender, args) =>
            {
                var newStep = Math.Round(args.NewValue / StepValue);

                Slider SliderMain = sender as Slider;

                SliderMain.Value = newStep * StepValue;

                User.CacheData.FontSize = (int)args.NewValue;

                TextSizeLabel.FontSize = (int)args.NewValue;

                SQLLiteDB.Upsert(User.CacheData);
            };


            KJVOption.IsToggled = User.CacheData.EnalbeKJV;

            MessagingCenter.Subscribe <Setting, CompletePacket>(this, "setting", (s, e) =>
            {
                LOGIN_RES res = new LOGIN_RES();
                res           = LOGIN_RES.Parser.ParseFrom(e.Data);

                messageLabel.Text = res.VarCode.ToString();
            });

            usernameEntry.Focus();

            //이미 로그인 중이면 메세지 표시를 변경
            if (NetProcess.IsSuccessAuth == true)
            {
                messageLabel.Text     = "접속중";
                usernameEntry.Text    = NetProcess.UserId;
                loginbutton.IsVisible = false;
            }
        }
Пример #8
0
        async void OnButtonClicked(object sender, EventArgs args)
        {
            if (SelBibleName == "")
            {
                await App.Current.MainPage.DisplayAlert("", "You must choose a testament.", "OK");
            }
            else
            {
                var CountText = ReadChapterCount.Text;

                if (CountText == null)
                {
                    CountText = "3";
                }

                if (Helper.IsNumber(CountText) == false)
                {
                    await App.Current.MainPage.DisplayAlert("", "Please write number ", "OK");

                    return;
                }

                int Count = Convert.ToInt16(CountText);

                if (Count > 100 || 0 >= Count)
                {
                    await App.Current.MainPage.DisplayAlert("", "Please write number.", "OK");

                    return;
                }

                bool answer = await App.Current.MainPage.DisplayAlert("info", SelBibleName + " from " + "each day " + CountText, "yes", "no");

                if (answer == true)
                {
                    SQLLiteDB.InsertBibleReadPlan(StartTime.Date, SelBibleName, Count);

                    ShowInfomation(StartTime.Date, Count);
                }
            }
        }
Пример #9
0
        async void OnButtonClicked(object sender, EventArgs args)
        {
            if (SelBibleName == "")
            {
                await DisplayAlert("", "시작할 권을 먼저 선택해야 합니다.", "OK");
            }
            else
            {
                var CountText = ReadChapterCount.Text;

                if (CountText == null)
                {
                    CountText = "3";
                }

                if (Helper.IsNumber(CountText) == false)
                {
                    await DisplayAlert("", "장수는 숫자로만 입력하세요 ", "OK");

                    return;
                }

                int Count = Convert.ToInt16(CountText);

                if (Count > 100 || 0 >= Count)
                {
                    await DisplayAlert("", "권장 장수가 아닙니다.", "OK");

                    return;
                }

                bool answer = await DisplayAlert("안내", SelBibleName + "부터 " + "하루 " + CountText + "장씩 시작 하시겠 습니까?", "예", "아니요");

                if (answer == true)
                {
                    SQLLiteDB.InsertBibleReadPlan(StartTime.Date, SelBibleName, Count);

                    ShowInfomation(StartTime.Date, Count);
                }
            }
        }
Пример #10
0
        private void LoadCacheUserData()
        {
            try
            {
                SQLLiteDB.LoadCacheData();

                //성경 읽기계획이 없는 경우 디폴트로 분당에서 하는 것으로 설정한다.
                var plan = SQLLiteDB.ReadBibleReadPlan();
                if (plan == null)
                {
                    DateTime StartTime = new DateTime(2020, 1, 13);
                    SQLLiteDB.InsertBibleReadPlan(StartTime.Date, "마태복음", 1);
                }
            }
            catch (Exception e)
            {
#if DEBUG
                CrossLocalNotifications.Current.Show("SQLLiteDB.LoadCacheData Failded", DateTime.Now.ToString(), 0, DateTime.Now);
#endif
            }
        }
Пример #11
0
        private MyPosToBibleRead CalculateTodayBibleChapter(int addDay = 0)
        {
            MyPosToBibleRead readpos = new MyPosToBibleRead();

            var data = SQLLiteDB.ReadBibleReadPlan();

            if (data == null)
            {
                return(null);
            }

            DateTime BeginTime = data.StartTime;

            DateTime MondayTime = WeekDateTime(DateTime.Now, DayOfWeek.Monday);

            MondayTime = MondayTime.AddDays(addDay);

            if (data.StartTime > MondayTime)
            {
                return(null);
            }

            int DiffDay = (MondayTime - BeginTime).Days;

            var search = BibleInfo.List.Find(e => e.Name == data.BibleName);

            if (search == null)
            {
                return(null);
            }

            int accChapterSize = 0;

            foreach (var bible in BibleInfo.List)
            {
                if (search.Id > bible.Id)
                {
                    continue;
                }


                int chapter = BibleInfo.GetChapterSize(bible.Name);

                int currChapter = DiffDay * data.Count;
                accChapterSize += chapter;


                if (currChapter + 1 <= accChapterSize)
                {
                    readpos.begin_bibleName = bible.Name;
                    readpos.begin_chapter   = Math.Abs((accChapterSize - currChapter) - chapter) + 1;

                    string outbible   = "";
                    int    outchapter = 1;

                    string inbible   = readpos.begin_bibleName;
                    int    inchapter = readpos.begin_chapter;

                    for (int i = 0; i < data.Count - 1; i++)
                    {
                        GetNextPos(inbible, inchapter, out outbible, out outchapter);

                        inbible   = outbible;
                        inchapter = outchapter;
                    }

                    readpos.end_bibleName = outbible;
                    readpos.end_chapter   = outchapter;
                    break;
                }
            }

            return(readpos);
        }
Пример #12
0
 void OnToggledKJV(object sender, ToggledEventArgs e)
 {
     User.CacheData.EnalbeKJV = e.Value;
     SQLLiteDB.Upsert(User.CacheData);
 }
Пример #13
0
        public SettingView()
        {
            InitializeComponent();

            vm.BtnMessage = "Login";
            vm.Version    = "Newest version";

            {
                var currentVersion = VersionTracking.CurrentVersion;

                double myversion = 0;
                double.TryParse(currentVersion, out myversion);
                const Double Eps = 0.000000000000001;

                if (Math.Abs(User.Version - myversion) > Eps)
                {
                    vm.Version = "Updatable";
                }
            }

            TextSizeSlider.Value = User.CacheData.FontSize;

            TextSizeSlider.ValueChanged += (sender, args) =>
            {
                var newStep = Math.Round(args.NewValue / StepValue);

                Slider SliderMain = sender as Slider;

                SliderMain.Value = newStep * StepValue;

                User.CacheData.FontSize = (int)args.NewValue;

                TextSizeLabel.FontSize = (int)args.NewValue;

                SQLLiteDB.Upsert(User.CacheData);

                Device.BeginInvokeOnMainThread(() =>
                {
                    User.OnceVersionNotify = true;
                    DependencyService.Get <Toast>().Notification("New Version Updated");
                });
            };

            KJVOption.IsToggled = User.CacheData.EnalbeKJV;

            usernameEntry.Focus();

            //이미 로그인 중이면 메세지 표시를 변경
            if (User.LoginSuccess == true)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    messageLabel.Text  = "Conncted";
                    usernameEntry.Text = User.CacheData.UserName;
                    passwordEntry.Text = "****";

                    vm.BtnMessage = "Conncted";
                });
            }

            BindingContext = vm;
        }
Пример #14
0
        private void UpdateCalendar(DateTime dateTime)
        {
            if (dateTime.Day != 1)
            {
                throw new ArgumentException($"{nameof(dateTime)}.Day is {dateTime.Day} but should be 1!");
            }

            // Remove days
            CalendarGrid.Children.Clear();

            // Update month and year label
            MonthLabel.Text = dateTime.ToString("MMMM");
            YearLabel.Text  = dateTime.Year.ToString();

            // Add days
            var dayOfWeek = (int)dateTime.DayOfWeek - 1; // -1 to let the week start on Monday instead of Sunday

            if (dayOfWeek < 0)
            {
                dayOfWeek = 6;
            }

            var daysInMonth = DateTime.DaysInMonth(dateTime.Year, dateTime.Month) + 1;
            var row         = 0;

            for (var day = 1; day < daysInMonth; day++)
            {
                var currentDay = dateTime.AddDays(day - 1);
                var isInRange  = currentDay >= RangeFrom.Date && currentDay <= RangeUntil.Date;

                var dayButton = new Button
                {
                    Text = day.ToString(),
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    BackgroundColor   = Color.White,
                };

                //오늘 버튼 표시
                if (DateTime.Now.Year == currentDay.Year && DateTime.Now.Month == currentDay.Month && DateTime.Now.Day == currentDay.Day)
                {
                    FocusButton = dayButton;
                    FocusButton.BackgroundColor = Color.Red;
                }

                dayButton.Clicked += delegate {
                    if (FocusButton != null)
                    {
                        FocusButton.BackgroundColor = Color.White;
                    }

                    FocusButton = dayButton;
                    FocusButton.BackgroundColor = Color.Red;

                    ScheduleGrid.IsVisible = true;

                    ScheduleView.Clear();
                    SchedueListView.ItemsSource = scheduleView;

                    foreach (var data in SQLLiteDB.ReadUserScheduleData())
                    {
                        if (dateTime.Year == data.Time.Year && dateTime.Month == data.Time.Month && Convert.ToInt16(dayButton.Text) == data.Time.Day)
                        {
                            scheduleView.Add(new ScheduleViewItem {
                                Display = Helper.DateTimeToShortTime(data.Time) + " " + data.Message, Id = data.Id
                            });
                        }
                    }
                };

                if (_shouldShowRange && isInRange)
                {
                    dayButton.BackgroundColor = Color.Red;
                }

                CalendarGrid.Children.Add(dayButton, dayOfWeek, row);

                dayOfWeek += 1;

                // Begin new row
                if (dayOfWeek > 6)
                {
                    dayOfWeek = 0;
                    row++;
                }
            }
        }