Ejemplo n.º 1
0
        public void AnimatedDelete(bool deleteFromDatabase = true)
        {
            if (_isDeleting)
            {
                return;
            }

            CloseToolTip();

            if (deleteFromDatabase && _appointment != null)
            {
                if (_appointment.IsRepeating)
                {
                    EditRecurring dlg = new EditRecurring(Application.Current.MainWindow, EditingType.Delete);

                    if (dlg.ShowDialog() == false)
                    {
                        return;
                    }

                    if (dlg.EditResult == EditResult.Single)
                    {
                        AppointmentDatabase.DeleteOne(_appointment, _appointment.RepresentingDate);
                    }
                    else
                    {
                        AppointmentDatabase.Delete(_appointment);
                    }
                }
                else
                {
                    AppointmentDatabase.Delete(_appointment);
                }

                ReminderQueue.RemoveItem(_appointment.ID, _appointment.IsRepeating ? _appointment.RepresentingDate.Add(_appointment.StartDate.TimeOfDay) : _appointment.StartDate, ReminderType.Appointment);
            }

            _isDeleting = true;
            DeleteStartEvent(EventArgs.Empty);

            if (Settings.AnimationsEnabled)
            {
                AnimationHelpers.DeleteAnimation delAnim = new AnimationHelpers.DeleteAnimation(this);
                delAnim.OnAnimationCompletedEvent += delAnim_OnAnimationCompletedEvent;
                delAnim.Animate();
            }
            else
            {
                DeleteEndEvent(EventArgs.Empty);
            }
        }
Ejemplo n.º 2
0
        public void Delete(EditResult?result = null)
        {
            CloseToolTip();

            if (_appointment != null)
            {
                if (_appointment.IsRepeating)
                {
                    if (!result.HasValue)
                    {
                        EditRecurring dlg = new EditRecurring(Window.GetWindow(this), EditingType.Delete);

                        if (dlg.ShowDialog() == false)
                        {
                            return;
                        }

                        if (dlg.EditResult == EditResult.Single)
                        {
                            AppointmentDatabase.DeleteOne(_appointment, _appointment.RepresentingDate);
                        }
                        else
                        {
                            AppointmentDatabase.Delete(_appointment);
                        }
                    }
                    else
                    {
                        if (result.Value == EditResult.Single)
                        {
                            AppointmentDatabase.DeleteOne(_appointment, _appointment.RepresentingDate);
                        }
                        else
                        {
                            AppointmentDatabase.Delete(_appointment);
                        }
                    }
                }
                else
                {
                    AppointmentDatabase.Delete(_appointment);
                }

                ReminderQueue.RemoveItem(_appointment.ID, _appointment.IsRepeating ? _appointment.RepresentingDate.Add(_appointment.StartDate.TimeOfDay) : _appointment.StartDate, ReminderType.Appointment);
            }

            IsHitTestVisible = false;

            DeleteStartEvent(EventArgs.Empty);
            DeleteEndEvent(EventArgs.Empty);
        }
        public void DeleteAllAppointments()
        {
            foreach (MonthDetail each in stackPanel.Children)
            {
                if (!each.Appointment.ReadOnly && !each.Appointment.Category.ReadOnly)
                {
                    if (each.Appointment.IsRepeating)
                    {
                        AppointmentDatabase.DeleteOne(each.Appointment, each.Appointment.RepresentingDate);
                    }
                    else
                    {
                        AppointmentDatabase.Delete(each.Appointment);
                    }

                    ReminderQueue.RemoveItem(each.Appointment.ID, each.Appointment.IsRepeating ? each.Appointment.RepresentingDate.Add(each.Appointment.StartDate.TimeOfDay) : each.Appointment.StartDate, ReminderType.Appointment);

                    each.Delete(false);
                }
            }
        }