/// <summary> /// 存储提醒 /// </summary> /// <param name="elememt"></param> private void SaveData(Grid elememt) { try { if (TitleContent.Equals("添加提醒"))//添加提醒 { ReminderModel model = new ReminderModel(); GuiD = Guid.NewGuid().ToString().Replace("-", ""); model.GuiD = GuiD; if (_years != null) { ReminderTime = string.Format("{0:yyyy/M/d H:mm}", Convert.ToDateTime(_years.Currentitem + "/" + _months.Currentitem + "/" + _days.Currentitem + " " + _format.Currentitem + " " + _hours.Currentitem + ":" + _minutes.Currentitem)); } else { ReminderTime = string.Format("{0:yyyy/M/d H:mm}", Convert.ToDateTime(years + "/" + months + "/" + days + " " + format + " " + hours + ":" + minutes)); } model.ReminderTime = ReminderTime; model.Content = Content; model.Contact = Contact; model.Record = Record; model.RecordPath = RecordPath; model.Ring = Ring; DataManager.Instance.InsertTables(model); ReminderManager.Instance.Reminders.Add(model); BackToMainView("Cancel"); } else if (TitleContent.Equals("详细信息"))//修改提醒 { int index = ReminderManager.Instance.Reminders.IndexOf(ReminderManager.Instance.Reminders.Where(temp => temp.GuiD == _lastReminder.GuiD).First()); if (_years != null) { ReminderTime = string.Format("{0:yyyy/M/d H:mm}", Convert.ToDateTime(_years.Currentitem + "/" + _months.Currentitem + "/" + _days.Currentitem + " " + _format.Currentitem + " " + _hours.Currentitem + ":" + _minutes.Currentitem)); } else { ReminderTime = string.Format("{0:yyyy/M/d H:mm}", Convert.ToDateTime(years + "/" + months + "/" + days + " " + format + " " + hours + ":" + minutes)); } _lastReminder.ReminderTime = ReminderTime; _lastReminder.Content = Content; _lastReminder.Contact = Contact; _lastReminder.Record = Record; _lastReminder.RecordPath = RecordPath; _lastReminder.Ring = Ring; DataManager.Instance.UpdateTables(_lastReminder); ReminderManager.Instance.Reminders[index] = _lastReminder; BackToMainView("Cancel"); } } catch (Exception e) { LogWriter.Instance.Error(e); } }
/// <summary> /// 加载初始功能类型 /// </summary> /// <param name="element"></param> private void LoadedDeleteButton(Border element) { if (TitleContent.Equals("添加闹钟")) { element.Visibility = Visibility.Hidden; } else if (TitleContent.Equals("编辑闹钟")) { element.Visibility = Visibility.Visible; } }
private void LoadedTitleContent(Image element) { if (string.IsNullOrEmpty(TitleContent)) { element.Visibility = Visibility.Visible; } else { element.Visibility = Visibility.Hidden; if (TitleContent.Equals("备忘提醒")) { } else if (TitleContent.Equals("远程提醒")) { } } }
/// <summary> /// 存储闹钟 /// </summary> /// <param name="elememt"></param> private void SaveData(Grid elememt) { try { if (TitleContent.Equals("添加闹钟")) { AlarmClockModel model = new AlarmClockModel(); GuiD = Guid.NewGuid().ToString().Replace("-", ""); model.GuiD = GuiD; Hours = _hours.Currentitem; Minutes = _minutes.Currentitem; Format = format.Currentitem; Time = string.Format("{0:H:mm}", Convert.ToDateTime(Format + " " + Hours + ":" + Minutes)); model.AlarmTime = Time; model.AlarmDate = Days == "永不" ? "" : Days; model.Label = Label; model.IsRepetition = IsRepetition == "True" ? "1" : "0"; model.IsOpen = "1"; model.Ring = Ring; DataManager.Instance.InsertTables(model); MainAlarmClockManager.Instance.AlarmClocks.Add(model); BackToMainView("Cancel"); } else if (TitleContent.Equals("编辑闹钟")) { int index = MainAlarmClockManager.Instance.AlarmClocks.IndexOf(MainAlarmClockManager.Instance.AlarmClocks.Where(temp => temp.GuiD == _lastAlarmClock.GuiD).First()); Hours = _hours.Currentitem; Minutes = _minutes.Currentitem; Format = format.Currentitem; Time = string.Format("{0:H:mm}", Convert.ToDateTime(Format + " " + Hours + ":" + Minutes)); _lastAlarmClock.AlarmTime = Time; _lastAlarmClock.AlarmDate = Days == "永不" ? "" : Days; _lastAlarmClock.Label = Label; _lastAlarmClock.IsOpen = "1"; _lastAlarmClock.IsRepetition = IsRepetition == "True" ? "1" : "0"; _lastAlarmClock.Ring = Ring; DataManager.Instance.UpdateTables(_lastAlarmClock); MainAlarmClockManager.Instance.AlarmClocks[index] = _lastAlarmClock; BackToMainView("Cancel"); } } catch (Exception e) { LogWriter.Instance.Error(e); } }
/// <summary> /// 获取初始数据 /// </summary> /// <param name="element"></param> private void FetchData(ListBox element) { try { if (ListBoxItems.Count == 0) { if (TitleContent.Equals("备忘提醒")) { foreach (var item in ReminderManager.Instance.Reminders.ToArray()) { if (string.IsNullOrEmpty(item.Contact)) { AddNewReminder(element, item); } } } else if (TitleContent.Equals("远程提醒")) { foreach (var item in ReminderManager.Instance.Reminders.ToArray()) { if (!string.IsNullOrEmpty(item.Contact)) { AddNewReminder(element, item); } } } else { foreach (var item in ReminderManager.Instance.Reminders.ToArray()) { if (string.IsNullOrEmpty(item.Contact)) { AddNewReminder(element, item); } } } } } catch (Exception e) { LogWriter.Instance.Error(e); } }
/// <summary> /// 返回提醒主页面回调 /// </summary> /// <param name="target"></param> private void BackToMainView(string target) { try { ListBoxItems.Clear(); if (_isReminderRemote || TitleContent.Equals("远程提醒")) { foreach (ReminderModel model in ReminderManager.Instance.Reminders.ToArray()) { if (!string.IsNullOrEmpty(model.Contact)) { AddNewReminder(_mainListBox, model); } } } else { foreach (ReminderModel model in ReminderManager.Instance.Reminders.ToArray()) { if (string.IsNullOrEmpty(model.Contact)) { AddNewReminder(_mainListBox, model); } } } //ButtonContent = "编辑"; //if (target.Equals("Cancel")) //{ // _mainBorder.Child = _lastUIElement; //} if (!string.IsNullOrEmpty(target)) { _mainBorder.Child = _lastUIElement; } } catch (Exception e) { LogWriter.Instance.Error(e); } }