Example #1
0
        void OpenTemplateButtonClicked(object sender, EventArgs args)
        {
            NoteManager manager       = Tomboy.DefaultNoteManager;
            Note        template_note = manager.Find(NoteOfTheDay.TemplateTitle);

            if (template_note == null)
            {
                // Create a new template note for the user
                try {
                    template_note = manager.Create(
                        NoteOfTheDay.TemplateTitle,
                        NoteOfTheDay.GetTemplateContent(
                            NoteOfTheDay.TemplateTitle));
                    template_note.QueueSave(ChangeType.ContentChanged);
                } catch (Exception e) {
                    Logger.Warn("Error creating Note of the Day Template note: {0}\n{1}",
                                e.Message, e.StackTrace);
                }
            }

            // Open the template note
            if (template_note != null)
            {
                template_note.Window.Show();
            }
        }
        public override void Shutdown()
        {
            if (timeout_owner)
            {
                NoteOfTheDay.CleanupOld(manager);
                timeout.Timeout -= CheckNewDay;
                timeout.Cancel();
                timeout = null;
            }

            initialized = false;
        }
        // Called only by instance with timeout_owner set.
        void CheckNewDay(object sender, EventArgs args)
        {
            Note notd = NoteOfTheDay.GetNoteByDate(manager, DateTime.Today);

            if (notd == null && !manager.ReadOnly)
            {
                NoteOfTheDay.CleanupOld(manager);

                // Create a new NotD if the day has changed
                NoteOfTheDay.Create(manager, DateTime.Now);
            }

            // Re-run every minute
            timeout.Reset(1000 * 60);
        }