Пример #1
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);
        }
Пример #2
0
        private void BtnNote_Click(object sender, RoutedEventArgs e)
        {
            var nw = new NoteWindow();

            nw.Owner = this;
            nw.Show();
        }
Пример #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_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);
        }
Пример #5
0
        private void OpenSelectedNote()
        {
            if (this.SelectedNote == null)
            {
                return;
            }

            try
            {
                foreach (Window existingWindow in Application.Current.Windows)
                {
                    if (!existingWindow.Equals(Application.Current.MainWindow) && existingWindow.Title == this.SelectedNote.Title)
                    {
                        existingWindow.WindowState = WindowState.Normal;
                        // In case the window is minimized

                        ((NoteWindow)existingWindow).ActivateNow();
                        return;
                    }
                }

                NoteWindow newWindow = new NoteWindow(this.SelectedNote.Title, "", this.noteService.GetNotebook(this.SelectedNote.NotebookId), this.searchService.SearchText, false, this.appearanceService, this.jumpListService, this.eventAggregator, this.noteService,
                                                      this.dialogService);

                ((NoteWindow)newWindow).ActivateNow();
            }
            catch (Exception ex)
            {
                LogClient.Error("Could not open the note. Exception: {0}", ex.Message);
            }
        }
Пример #6
0
        private void ShowNote(object sender, MouseButtonEventArgs e)
        {
            var listBox = sender as ListBox;

            if (!(listBox?.SelectedItem is Note noteModel))
            {
                return;
            }
            foreach (var window in Application.Current.Windows)
            {
                if (!(window is NoteWindow noteWindow) || noteWindow.Id != noteModel.Id)
                {
                    continue;
                }
                noteWindow.Focus();
                return;
            }
            var note = new NoteWindow(_controller, noteModel.Id);

            note.ShowNoteList.Click += ShowNoteList;
            note.DeleteNote.Click   += DeleteNote;
            note.AddNote.Click      += AddNote;
            note.Show();
            listBox.UnselectAll();
        }
Пример #7
0
        private void NewNote(object param)
        {
            bool createUnfiled = Convert.ToBoolean(param);

            try
            {
                string initialTitle = this.noteService.GetUniqueNoteTitle(ResourceUtils.GetString("Language_New_Note"));

                FlowDocument flowDoc = new FlowDocument();

                Notebook theNotebook = default(Notebook);

                if (!createUnfiled & (this.SelectedNotebook != null && !this.SelectedNotebook.IsDefaultNotebook))
                {
                    theNotebook = this.SelectedNotebook.Notebook;
                }
                else
                {
                    theNotebook = NotebookViewModel.CreateUnfiledNotesNotebook().Notebook;
                }

                NoteWindow notewin = new NoteWindow(initialTitle, "", theNotebook, this.searchService.SearchText, true, this.appearanceService, this.jumpListService, this.eventAggregator, this.noteService,
                                                    this.dialogService);

                notewin.ActivateNow();

                RefreshNotes();
            }
            catch (Exception)
            {
                this.dialogService.ShowNotificationDialog(null, title: ResourceUtils.GetString("Language_Error"), content: ResourceUtils.GetString("Language_Problem_Creating_Note"), okText: ResourceUtils.GetString("Language_Ok"), showViewLogs: false);
            }
        }
    public override void HandleState(EuiStateBase state)
    {
        if (state is not AdminNotesEuiState s)
        {
            return;
        }

        NoteWindow.SetTitlePlayer(s.NotedPlayerName);
        NoteControl.SetNotes(s.Notes);
        NoteControl.SetPermissions(s.CanCreate, s.CanDelete, s.CanEdit);
    }
Пример #9
0
    public void AddNote(object obj, EventArgs args)
    {
        NotesDatabase database = new NotesDatabase();

        database.QueryNoResults("INSERT INTO notes (text, color, pos_x, pos_y) VALUES ('', '#ffffff', 100, 100)");

        NoteData   new_note_data = new NoteData("", RandomNoteColor(), 450, 450, database.get_last_id());
        NoteWindow new_window    = new NoteWindow(new_note_data, this.background_window);

        new_window.ShowAll();
        this.note_windows.Append(new_window);
    }
Пример #10
0
 private void txtNoteGHeader_Click(object sender, EventArgs e)
 {
     if (noteWindow == null)
     {
         noteWindow             = new NoteWindow(note);
         noteWindow.FormClosed += new FormClosedEventHandler(noteWindow_FormClosed);
         noteWindow.Show(this);
     }
     else
     {
         noteWindow.Activate();
     }
 }
        public void ParameterizedConstructorTest()
        {
            NoteWindow noteWindow  = new NoteWindow("test");
            bool       eventCalled = false;
            string     eventArg    = null;

            noteWindow.Check += (s) => {
                eventCalled = true;
                eventArg    = s;
            };

            noteWindow.Show();
            noteWindow.Close();

            Assert.IsTrue(eventCalled);
            Assert.AreEqual("test", eventArg);
        }
Пример #12
0
        private async void AddNote(object sender, RoutedEventArgs e)
        {
            var id = Guid.NewGuid().ToString("N");
            await _controller.AddNote(new Note
            {
                Id     = id,
                Color  = new SolidColorBrush(Colors.OrangeRed),
                Edited = DateTime.Now
            });

            var note = new NoteWindow(_controller, id);

            note.ShowNoteList.Click += ShowNoteList;
            note.DeleteNote.Click   += DeleteNote;
            note.AddNote.Click      += AddNote;
            note.Show();
            ShowNoteList();
        }
Пример #13
0
        private static void OnOpenNoteWindow(object parameter)
        {
            var win = new NoteWindow
            {
                Owner         = MainWindow.Current,
                ShowInTaskbar = false
            };
            var vm = new NoteViewModel
            {
                CloseWindow = () =>
                {
                    if (win.IsActive)
                    {
                        win.Close();
                    }
                }
            };

            win.DataContext = vm;
            win.ShowDialog();
        }
Пример #14
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);
        }
Пример #15
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;
            }
        }
Пример #16
0
	public void AddNote(object obj, EventArgs args){

		NotesDatabase database = new NotesDatabase();
		database.QueryNoResults("INSERT INTO notes (text, color, pos_x, pos_y) VALUES ('', '#ffffff', 100, 100)");

		NoteData new_note_data = new NoteData("", RandomNoteColor(), 450, 450, database.get_last_id());
		NoteWindow new_window = new NoteWindow(new_note_data, this.background_window);
		new_window.ShowAll();
		this.note_windows.Append(new_window);

	}
Пример #17
0
 private void noteWindow_FormClosed(object sender, FormClosedEventArgs e)
 {
     noteWindow = null;
 }
Пример #18
0
 private NoteWindow createNoteWindow(Note n)
 {
     var newWindow = new NoteWindow(this,n.ID);
     this.notes.Add(newWindow);
     newWindow.Left = n.x;
     newWindow.Top = n.y;
     newWindow.text.Text = n.value;
     newWindow.col = n.col;
     newWindow.changeColor();
     newWindow.ShowInTaskbar = false;
     newWindow.Width = n.w;
     newWindow.Height = n.h;
     return newWindow;
 }
 public override void Opened()
 {
     NoteWindow.OpenCentered();
 }
Пример #20
0
 public NoteWindowHandle(NoteWindow window)
 {
     this.window = window;
 }
Пример #21
0
        public override void Execute()
        {
            var noteWindow = new NoteWindow(this);

            noteWindow.Show();
        }