Example #1
0
        private void RibbonCommandCheck_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Element currentElement = elementControl.CurrentElement;
            try
            {
                if (currentElement != null)
                {
                    if (currentElement.IsHeading)
                    {
                        CheckWindow cw = new CheckWindow(currentElement);
                        if (cw.ShowDialog().Value)
                        {
                            elementControl.Check(currentElement, cw.RemoveFromToday);

                            LogControl.Write(
                                currentElement,
                                LogEventAccess.Ribbon,
                                LogEventType.Check,
                                LogEventStatus.NULL,
                                LogEventInfo.RemoveFromToday + LogControl.COMMA + cw.removeFromToday.ToString());
                        }
                    }
                    else
                    {
                        elementControl.Check(currentElement);

                        LogControl.Write(
                            currentElement,
                            LogEventAccess.Ribbon,
                            LogEventType.Check,
                            LogEventStatus.NULL,
                            null);
                    }

                    GetFocusToElementTextBox(currentElement, -1, false, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Oops!\nSomething unexpected happened, please close this Planz window and reopen.");
                //MessageBox.Show("RibbonCommandCheck_Executed\n" + ex.Message);

                LogControl.Write(
                    currentElement,
                    LogEventAccess.Ribbon,
                    LogEventType.Check,
                    LogEventStatus.Error,
                    LogEventInfo.ErrorMessage + LogControl.COMMA + ex.Message);
            }
        }
Example #2
0
        private void FlagImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            StartLoadingUI();

            StackPanel sp = VisualTreeHelper.GetParent(sender as DependencyObject) as StackPanel;
            TextBox tb = sp.FindName("ElementTextBox") as TextBox;
            Element currentElement = GetElement(tb);
            try
            {
                if (currentElement != null)
                {
                    if (tb.Text != currentElement.NoteText)
                    {
                        currentElement.NoteText = tb.Text;

                        LogControl.Write(
                           elementControl.CurrentElement,
                           LogEventAccess.Hotkey,
                           LogEventType.TextChanged,
                           LogEventStatus.NULL,
                           null);
                    }

                    if (currentElement.IsHeading)
                    {
                        if (currentElement.FlagStatus == FlagStatus.Normal)
                        {
                            FlagWindow fw = new FlagWindow(currentElement);
                            if (fw.ShowDialog().Value)
                            {
                                elementControl.Flag(currentElement,
                                    fw.HasStart, fw.StartDate, fw.StartTime, fw.StartAllDay,
                                    fw.HasDue, fw.DueDate, fw.DueTime, fw.DueAllDay,
                                    fw.AddToToday, fw.AddToReminder, fw.AddToTask);

                                foreach (Element ele in elementControl.FindAllHeadingElements(elementControl.Root))
                                {
                                    if (ele.Path.ToLower() == currentElement.Path.ToLower() && ele.ID != currentElement.ID)
                                    {
                                        elementControl.Flag(ele);
                                    }
                                }

                                LogControl.Write(
                                    currentElement,
                                    LogEventAccess.FlagIcon,
                                    LogEventType.Flag,
                                    LogEventStatus.NULL,
                                    LogEventInfo.HasStart + LogControl.COMMA + fw.HasStart.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.StartDate + LogControl.COMMA + fw.StartDate.ToShortDateString() + LogControl.DELIMITER +
                                    LogEventInfo.StartTime + LogControl.COMMA + fw.StartTime.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.StartAllDay + LogControl.COMMA + fw.StartAllDay.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.HasDue + LogControl.COMMA + fw.HasDue.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.DueDate + LogControl.COMMA + fw.DueDate.ToShortDateString() + LogControl.DELIMITER +
                                    LogEventInfo.DueTime + LogControl.COMMA + fw.DueTime.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.DueAllDay + LogControl.COMMA + fw.DueAllDay.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.AddToToday + LogControl.COMMA + fw.AddToToday.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.AddToReminder + LogControl.COMMA + fw.AddToReminder.ToString() + LogControl.DELIMITER +
                                    LogEventInfo.AddToTask + LogControl.COMMA + fw.AddToTask.ToString()
                                    );
                            }
                            else
                            {
                                LogControl.Write(
                                    currentElement,
                                    LogEventAccess.FlagIcon,
                                    LogEventType.Flag,
                                    LogEventStatus.Cancel,
                                    null);
                            }
                        }
                        else if (currentElement.FlagStatus == FlagStatus.Flag)
                        {
                            CheckWindow cw = new CheckWindow(currentElement);
                            if (cw.ShowDialog().Value)
                            {
                                elementControl.Check(currentElement, cw.RemoveFromToday);

                                foreach (Element ele in elementControl.FindAllHeadingElements(elementControl.Root))
                                {
                                    if (ele.Path.ToLower() == currentElement.Path.ToLower() && ele.ID != currentElement.ID && ele.IsExpanded)
                                    {
                                        elementControl.Check(ele);
                                    }
                                }

                                LogControl.Write(
                                    currentElement,
                                    LogEventAccess.FlagIcon,
                                    LogEventType.Check,
                                    LogEventStatus.NULL,
                                    LogEventInfo.RemoveFromToday + LogControl.COMMA + cw.RemoveFromToday.ToString());
                            }
                            else
                            {
                                LogControl.Write(
                                    currentElement,
                                    LogEventAccess.FlagIcon,
                                    LogEventType.Check,
                                    LogEventStatus.Cancel,
                                    null);
                            }
                        }
                        else if (currentElement.FlagStatus == FlagStatus.Check)
                        {
                            elementControl.Uncheck(currentElement);

                            foreach (Element ele in elementControl.FindAllHeadingElements(elementControl.Root))
                            {
                                if (ele.Path.ToLower() == currentElement.Path.ToLower() && ele.ID != currentElement.ID)
                                {
                                    elementControl.Uncheck(ele);
                                }
                            }

                            LogControl.Write(
                                currentElement,
                                LogEventAccess.FlagIcon,
                                LogEventType.Uncheck,
                                LogEventStatus.NULL,
                                null);
                        }
                    }
                    else
                    {
                        if (currentElement.FlagStatus == FlagStatus.Normal)
                        {
                            elementControl.Flag(currentElement);

                            LogControl.Write(
                                currentElement,
                                LogEventAccess.FlagIcon,
                                LogEventType.Flag,
                                LogEventStatus.NULL,
                                null);
                        }
                        else if (currentElement.FlagStatus == FlagStatus.Flag)
                        {
                            elementControl.Check(currentElement);

                            LogControl.Write(
                                currentElement,
                                LogEventAccess.FlagIcon,
                                LogEventType.Check,
                                LogEventStatus.NULL,
                                null);
                        }
                        else if (currentElement.FlagStatus == FlagStatus.Check)
                        {
                            elementControl.Uncheck(currentElement);

                            LogControl.Write(
                                currentElement,
                                LogEventAccess.FlagIcon,
                                LogEventType.Uncheck,
                                LogEventStatus.NULL,
                                null);
                        }
                    }
                }

                GetFocusToElementTextBox(currentElement, -1, false, false);

                e.Handled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Oops!\nSomething unexpected happened, please close this Planz window and reopen.");
                //MessageBox.Show("FlagImage_MouseDown\n" + ex.Message);

                LogControl.Write(
                    currentElement,
                    LogEventAccess.FlagIcon,
                    LogEventType.Flag,
                    LogEventStatus.Error,
                    LogEventInfo.ErrorMessage + LogControl.COMMA + ex.Message);
            }
            finally
            {
                EndLoadingUI();
            }
        }