Пример #1
0
        private void do_ext_add(object sender, RoutedEventArgs e)
        {
            this.update_selected_topic();
            ExternalNote note = new ExternalNote("", DateTime.Now);

            note.topics.Add(this.guid);
            NoteWindow dialog_window = new NoteWindow(this.save_state, note, topics: this.topics)
            {
                Owner = this
            };

            dialog_window.ShowDialog();
            ExternalNote             new_note = dialog_window.get_note() as ExternalNote;
            Dictionary <Guid, Topic> topics   = dialog_window.get_topics();

            if ((new_note is null) || (topics is null))
            {
                return;
            }
            this.add_topics(topics, new_note);
            this.notes[Guid.NewGuid()] = new_note;
            this.topic_cache.Clear();
            this.populate_topic_cache();
            this.set_topic(this.guid);
        }
Пример #2
0
        private void do_external_note_add(object sender, RoutedEventArgs e)
        {
            if ((this.topics is null) || (this.notes is null) || (this.save_state is null))
            {
                return;
            }
            ExternalNote note = new ExternalNote("", DateTime.Now);
            Guid?        sel  = this.topic_list.SelectedValue as Guid?;

            if ((sel is not null) && (sel.Value != Guid.Empty))
            {
                note.topics.Add(sel.Value);
            }
            NoteWindow dialog_window = new NoteWindow(this.save_state, note)
            {
                Owner = Window.GetWindow(this)
            };

            dialog_window.ShowDialog();
            ExternalNote             new_note = dialog_window.get_note() as ExternalNote;
            Dictionary <Guid, Topic> topics   = dialog_window.get_topics();

            if ((new_note is null) || (topics is null))
            {
                return;
            }
            this.add_topics(topics, new_note);
            this.notes[Guid.NewGuid()] = new_note;
            this.topic_cache.Clear();
            this.change_callback(null, topics: this.topics, topic_refs: this.topic_refs, notes: this.notes);
        }
Пример #3
0
        private void do_note_add(object sender, RoutedEventArgs e)
        {
            this.update_selected_topic();
            Guid ent_guid = this.entry_guid ?? Guid.NewGuid();
            Note note     = new Note("", ent_guid);

            note.topics.Add(this.guid);
            NoteWindow dialog_window = new NoteWindow(this.save_state, note, this.now, this.topics)
            {
                Owner = this
            };

            dialog_window.ShowDialog();
            Note new_note = dialog_window.get_note() as Note;
            Dictionary <Guid, Topic> topics = dialog_window.get_topics();

            if ((new_note is null) || (topics is null))
            {
                return;
            }
            this.add_topics(topics, new_note);
            Guid guid = this.state.notes.add_note(new_note);

            this.actions.Add(new ActionNoteCreate(guid, new_note));
            this.topic_cache.Clear();
            this.populate_topic_cache();
            this.set_topic(this.guid);
        }
Пример #4
0
        private void do_note_add(object sender, RoutedEventArgs e)
        {
            if (this.save_state is null)
            {
                return;
            }
            Guid ent_guid = this.entry_guid ?? Guid.NewGuid();
            Note note     = new Note("", ent_guid);
            Guid?sel      = this.topic_list.SelectedValue as Guid?;

            if ((sel is not null) && (sel.Value != Guid.Empty))
            {
                note.topics.Add(sel.Value);
            }
            NoteWindow dialog_window = new NoteWindow(this.save_state, note, this.now)
            {
                Owner = Window.GetWindow(this)
            };

            dialog_window.ShowDialog();
            if (this.change_callback is null)
            {
                return;
            }
            Note new_note = dialog_window.get_note() as Note;
            Dictionary <Guid, Topic> topics = dialog_window.get_topics();

            if ((new_note is null) || (topics is null))
            {
                return;
            }
            this.add_topics(topics, new_note);
            List <EntryAction> actions = new List <EntryAction>()
            {
                new ActionNoteCreate(Guid.NewGuid(), new_note)
            };

            this.change_callback(actions, ent_guid, this.topics, this.topic_refs, this.notes);
        }
Пример #5
0
        private void do_entity_view(object sender, RoutedEventArgs e)
        {
            EntityRow sel = this.entity_list.SelectedValue as EntityRow;

            if ((sel is null) || (sel.type is null) || (sel.guid is null))
            {
                return;
            }

            switch (sel.type.Value)
            {
            //TODO: view selection (ITEM, EVENT, TASK)
            case EntityType.NOTE:
            {
                if (!this.state.notes.notes.ContainsKey(sel.guid.Value))
                {
                    return;
                }
                Note       note          = this.state.notes.notes[sel.guid.Value];
                NoteWindow dialog_window = new NoteWindow(this.save_state, note, this.now, this.topics)
                {
                    Owner = this
                };
                dialog_window.ShowDialog();
                Note new_note = dialog_window.get_note() as Note;
                if (new_note is null)
                {
                    return;
                }
                Dictionary <Guid, int> adjust_topics = new Dictionary <Guid, int>();
                foreach (Guid topic_guid in note.topics)
                {
                    if (!new_note.topics.Contains(topic_guid))
                    {
                        adjust_topics[topic_guid] = -1;
                    }
                }
                foreach (Guid topic_guid in new_note.topics)
                {
                    if (!note.topics.Contains(topic_guid))
                    {
                        adjust_topics[topic_guid] = 1;
                    }
                }
                if ((new_note.contents != note.contents) || (adjust_topics.Count > 0))
                {
                    string contents_from = null, contents_to = null;
                    if (new_note.contents != note.contents)
                    {
                        contents_from = note.contents;
                        contents_to   = new_note.contents;
                        note.contents = contents_to;
                    }
                    if (adjust_topics.Count > 0)
                    {
                        foreach (Guid topic_guid in adjust_topics.Keys)
                        {
                            if (adjust_topics[topic_guid] > 0)
                            {
                                note.topics.Add(topic_guid);
                            }
                            else
                            {
                                note.topics.Remove(topic_guid);
                            }
                        }
                    }
                    else
                    {
                        adjust_topics = null;
                    }
                    this.actions.Add(new ActionNoteUpdate(sel.guid.Value, contents_from, contents_to, adjust_topics));
                    sel._contents = contents_to;
                    if (adjust_topics.Count > 0)
                    {
                        sel.topics.Clear();
                        foreach (Guid topic_guid in note.topics)
                        {
                            if (this.topics.ContainsKey(topic_guid))
                            {
                                sel.topics.Add(new TopicRow(topic_guid, this.topics[topic_guid].name));
                            }
                        }
                        sel.topics.Sort((x, y) => x.name.CompareTo(y.name));
                    }
                    this.entity_list.Items.Refresh();
                }
            }
            break;

            case EntityType.EXTERNAL_NOTE:
            {
                if (!this.notes.ContainsKey(sel.guid.Value))
                {
                    return;
                }
                ExternalNote note          = this.notes[sel.guid.Value];
                NoteWindow   dialog_window = new NoteWindow(this.save_state, note, topics: this.topics)
                {
                    Owner = this
                };
                dialog_window.ShowDialog();
                ExternalNote new_note = dialog_window.get_note() as ExternalNote;
                if (new_note is null)
                {
                    return;
                }
                Dictionary <Guid, int> adjust_topics = new Dictionary <Guid, int>();
                foreach (Guid topic_guid in note.topics)
                {
                    if (!new_note.topics.Contains(topic_guid))
                    {
                        adjust_topics[topic_guid] = -1;
                    }
                }
                foreach (Guid topic_guid in new_note.topics)
                {
                    if (!note.topics.Contains(topic_guid))
                    {
                        adjust_topics[topic_guid] = 1;
                    }
                }
                if ((new_note.contents != note.contents) || (adjust_topics.Count > 0))
                {
                    note.contents = new_note.contents;
                    sel._contents = note.contents;
                    if (adjust_topics.Count > 0)
                    {
                        foreach (Guid topic_guid in adjust_topics.Keys)
                        {
                            if (adjust_topics[topic_guid] > 0)
                            {
                                note.topics.Add(topic_guid);
                            }
                            else
                            {
                                note.topics.Remove(topic_guid);
                            }
                        }
                        sel.topics.Clear();
                        foreach (Guid topic_guid in note.topics)
                        {
                            if (this.topics.ContainsKey(topic_guid))
                            {
                                sel.topics.Add(new TopicRow(topic_guid, this.topics[topic_guid].name));
                            }
                        }
                        sel.topics.Sort((x, y) => x.name.CompareTo(y.name));
                    }
                    this.entity_list.Items.Refresh();
                }
            }
            break;

            default: return;
            }
        }