Example #1
0
        public static void NextRemind(Ddl ddl, bool recalculate)
        {
            DateTime now = DateTime.Now;

            if (recalculate)
            {
                ddl.RemindTime = now.Date.AddDays(-1) + ddl.RemindTime.TimeOfDay;
            }

            if (ddl.IsRemind == 0)
            {
                DateTime rt = ddl.RemindTime;
                string[] remindIntervalString = ddl.RemindInterval.Split('/');
                int[]    remindInterval       = { int.Parse(remindIntervalString[0]), int.Parse(remindIntervalString[1]), int.Parse(remindIntervalString[2]) };

                while (rt <= now)
                {
                    rt = AddTime(rt, remindInterval[0], remindInterval[1], remindInterval[2], 0, 0, 0, ddl.IsChineseCalender);
                }
                ddl.RemindTime = rt;
                DatabaseOperation.Update(ddl.Id, "RemindTime", rt);
            }
            else
            {
                DateTime rt = ddl.RemindTime;

                while (rt <= now || ddl.RemindInterval[Convert.ToInt16(rt.DayOfWeek)] != '1')
                {
                    rt = rt.AddDays(1);
                }
                ddl.RemindTime = rt;
                DatabaseOperation.Update(ddl.Id, "RemindTime", rt);
            }
        }
Example #2
0
        private void DeleteDdlBtn_Click(object sender, RoutedEventArgs e)
        {
            if (isDeleteComfirmed)
            {
                FlowWindow dfw = FlowWindowOperation.flowWindows.Find(d => d.ddl.Id == ddl.Id);
                if (dfw != null)
                {
                    dfw.Close();
                    FlowWindowOperation.flowWindows.Remove(dfw);
                }

                DatabaseOperation.Delete(ddl.Id);
                DdlOperation.RefreshDdls();
                DdlPage.self.ReloadDdlStackPanel();
                DdlPage.self.ShowSnackbar("删除成功");
            }
            else
            {
                isDeleteComfirmed = true;
                PackIcon icon = new PackIcon();
                icon.Kind            = PackIconKind.CheckBold;
                icon.Height          = 24;
                icon.Width           = 24;
                DeleteDdlBtn.Content = icon;
            }
        }
Example #3
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            path = AppDomain.CurrentDomain.BaseDirectory;

            _ = new DatabaseOperation();
            _ = new DdlOperation();
            _ = new SettingOperation();
            _ = new FlowWindowOperation();

            RemoveIcon();
            AddIcon();

            this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(AppDispatcherUnhandledException);

            dt.Interval = new TimeSpan(0, 0, 1);
            dt.Start();

            FlowWindowOperation.ShowAllFlowWindowEvent(sender, e);

            if (SettingOperation.firstTime)
            {
                OpenInfoPage();
            }
            else
            {
                OpenDdlPage();
            }
        }
Example #4
0
 public static void RefreshDdls()
 {
     ddls = DatabaseOperation.Select();
     leftTimesDict.Clear();
     foreach (Ddl ddl in ddls)
     {
         leftTimesDict.Add(ddl.Id, CalcLeftTime(ddl.EndTime));
     }
 }
Example #5
0
        public DdlOperation()
        {
            player = new MediaPlayer();

            ddls = DatabaseOperation.Select();
            foreach (Ddl ddl in ddls)
            {
                leftTimesDict.Add(ddl.Id, CalcLeftTime(ddl.EndTime));
            }

            App.dt.Tick += CalcLeftTimesEvent;
            App.dt.Tick += RemindTimesEvent;
        }
Example #6
0
        private static void NextLoop(Ddl ddl)
        {
            string[] str = ddl.LoopInterval.Split('/');
            DateTime startTime = ddl.StartTime, endTime = ddl.EndTime;

            int[] loopInterval = new int[6];
            for (int i = 0; i < 6; i++)
            {
                loopInterval[i] = int.Parse(str[i]);
            }

            startTime = endTime;
            endTime   = AddTime(endTime, loopInterval[0], loopInterval[1], loopInterval[2], loopInterval[3], loopInterval[4], loopInterval[5], ddl.IsChineseCalender);

            while (endTime <= DateTime.Now)
            {
                startTime = AddTime(startTime, loopInterval[0], loopInterval[1], loopInterval[2], loopInterval[3], loopInterval[4], loopInterval[5], ddl.IsChineseCalender);
                endTime   = AddTime(endTime, loopInterval[0], loopInterval[1], loopInterval[2], loopInterval[3], loopInterval[4], loopInterval[5], ddl.IsChineseCalender);
            }
            ddl.StartTime = startTime;
            ddl.EndTime   = endTime;

            DatabaseOperation.Update(ddl);
        }
Example #7
0
        private void YesBtn_Click(object sender, RoutedEventArgs e)
        {
            //set name
            if (DdlNameTextBox.Text.Length == 0)
            {
                ShowSnakebar(HintAssist.GetHint(DdlNameTextBox) + NullError.Text);
                return;
            }
            ddl.Name = DdlNameTextBox.Text;

            //set priority
            ddl.Priority = DdlPriority.Value;

            //set start time
            if (!GetStartTime(out DateTime startTime))
            {
                return;
            }
            ddl.StartTime = startTime;

            //set end time
            if (!GetEndTime(out DateTime endTime))
            {
                return;
            }
            ddl.EndTime           = endTime;
            ddl.IsChineseCalender = (bool)ChineseCheckbox.IsChecked;

            //check start time < end time
            if (endTime.CompareTo(startTime) <= 0)
            {
                ShowSnakebar(StartEndTimeError.Text);
                return;
            }

            //set loop
            String loopInterval = "";

            if ((bool)LoopCheckbox.IsChecked && !GetLoopInterval(out loopInterval))
            {
                return;
            }
            ddl.IsLoop = (bool)LoopCheckbox.IsChecked;
            if (ddl.IsLoop)
            {
                ddl.LoopInterval = loopInterval;
            }

            //set inform
            ddl.Inform = ((bool)NoticeCheckbox.IsChecked ? "1" : "0") +
                         ((bool)WindowCheckbox.IsChecked ? "1" : "0") +
                         ((bool)SoundCheckbox.IsChecked ? "1" : "0");

            //set remind
            string remindInterval = "";

            if ((bool)RemindCheckbox.IsChecked && !GetRemindInterval(out remindInterval))
            {
                return;
            }
            ddl.IsRemind = (bool)RemindCheckbox.IsChecked ? 0 : -1;
            if (ddl.IsRemind != -1)
            {
                ddl.RemindInterval = remindInterval;
                DateTime?st = RemindTimePicker.SelectedTime;
                if (!st.HasValue)
                {
                    ShowSnakebar(HintAssist.GetHint(RemindTimePicker) + NullError.Text);
                    return;
                }
                ddl.RemindTime = ddl.StartTime.Date + ((DateTime)st).TimeOfDay;

                if (RemindTimeGrid.SelectedIndex == 1)
                {
                    ddl.IsRemind = 1;
                }
                DdlOperation.NextRemind(ddl, true);
            }

            if (id == -1)
            {
                DatabaseOperation.Insert(ddl);
            }
            else
            {
                DatabaseOperation.Update(ddl);
            }

            DdlOperation.RefreshDdls();

            DialogResult = true;
            CloseWindow(sender, e);
        }