Пример #1
0
        public NotesVM()
        {
            IsEditing = false;

            NewNotebookCommand    = new NewNotebookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            BeginEditCommand      = new BeginEditCommand(this);
            HasEditedCommand      = new HasEditedCommand(this);
            ReadNotebooksCommand  = new ReadNotebooksCommand(this);
            DeleteNotebookCommand = new DeleteNotebookCommand(this);

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();

            ReadNotebooks();
            ReadNotes();
        }
Пример #2
0
        public NotesVM()
        {
            IsEditing = false;

            NewNotebookCommand = new NewNotebookCommand(this);
            NewNoteCommand     = new NewNoteCommand(this);
            BeginEditCommand   = new BeginEditCommand(this);
            HasEditedCommand   = new HasEditedCommand(this);

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();

            Notebooks.CollectionChanged += Notebooks_CollectionChanged;

            ReadNotebooks();
            ReadNotes();
        }
Пример #3
0
        public NotesViewModel()
        {
            IsEditedNotebook = false;

            NewNotebookCommand    = new NewNotebookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            beginEditCommand      = new BeginEditCommand(this);
            hasEditedCommand      = new HasEditedCommand(this);
            deleteNotebookCommand = new DeleteNotebookCommand(this);
            deleteNoteCommand     = new DeleteNoteCommand(this);

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();

            ReadNotebooks();
            ReadNote();
        }
Пример #4
0
        public NotesVM()
        {
            // create tables in db as first task
            DatabaseHelper.CreateTables <Notebook>();
            DatabaseHelper.CreateTables <Note>();

            NewNotebookCommand        = new NewNotebookCommand(this);
            NewNoteCommand            = new NewNoteCommand(this);
            BeginEditCommand          = new BeginEditCommand(this);
            HasEditedCommand          = new HasEditedCommand(this);
            CancelNotebookEditCommand = new CancelNotebookEditCommand();

            HasEditedNoteCommand  = new HasEditedNoteCommand(this);
            CancelNoteEditCommand = new CancelNoteEditCommand();

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();
        }
Пример #5
0
        public NotesWindowVM()
        {
            IsEditing = false;

            NewNoteBookCommand    = new NewNoteBookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            CloseProgramCommand   = new CloseProgramCommand(this);
            BeginEditCommand      = new BeginEditCommand(this);
            HasEditedCommand      = new HasEditedCommand(this);
            DeleteNoteBookCommand = new DeleteNoteBookCommand(this);
            DeleteNoteCommand     = new DeleteNoteCommand(this);

            Notebooks = new ObservableCollection <NoteBook>();
            Notes     = new ObservableCollection <Note>();

            SelectedNote = new Note();
            ReadNoteBooks();
            ReadNotes();
        }
Пример #6
0
        public NotesVM()
        {
            IsEditing             = false;
            IsEditingNote         = false;
            NewNotebookCommand    = new NewNotebookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            DeleteNotebookCommand = new DeleteNotebookCommand(this);
            DeleteNoteCommand     = new DeleteNoteCommand(this);
            BeginEditCommand      = new BeginEditCommand(this);
            IsEditedCommand       = new IsEditedCommand(this);
            BeginEditNoteCommand  = new BeginEditNoteCommand(this);
            IsEditedNoteCommand   = new IsEditedNoteCommand(this);

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();
            FontSizes = new List <double>()
            {
                8, 9, 10, 11, 12, 14, 16, 28, 48, 72
            };

            ReadNotebooks();
            ReadNotes();
        }
Пример #7
0
        /// <summary>
        /// This virtual method is called when ApplicationCommands.Paste command is executed.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="args"></param>
        protected virtual void OnExecutedPaste(object target, ExecutedRoutedEventArgs args)
        {
            if (ExecutePasteEvent != null)
            {
                ExecutePasteEvent(target, args);
                if (args.Handled)
                {
                    return;
                }
            }

            // parse the clipboard data
            List <string[]> rowData = ClipboardHelper.ParseClipboardData();

            bool hasAddedNewRow = false;

            // call OnPastingCellClipboardContent for each cell
            int minRowIndex           = Items.IndexOf(CurrentItem);
            int maxRowIndex           = Items.Count - 1;
            int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0;
            int maxColumnDisplayIndex = Columns.Count - 1;
            int rowDataIndex          = 0;

            for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++)
            {
                if (i < Items.Count)
                {
                    CurrentItem = Items[i];

                    BeginEditCommand.Execute(null, this);

                    int columnDataIndex = 0;
                    for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++)
                    {
                        DataGridColumn column = ColumnFromDisplayIndex(j);
                        column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]);

                        //column.OnPastingCellClipboardContent(
                    }

                    CommitEditCommand.Execute(this, this);
                    if (i == maxRowIndex)
                    {
                        maxRowIndex++;
                        hasAddedNewRow = true;
                    }
                }
            }

            // update selection
            if (hasAddedNewRow)
            {
                UnselectAll();
                UnselectAllCells();

                CurrentItem = Items[minRowIndex];

                if (SelectionUnit == DataGridSelectionUnit.FullRow)
                {
                    SelectedItem = Items[minRowIndex];
                }
                else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader ||
                         SelectionUnit == DataGridSelectionUnit.Cell)
                {
                    SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex]));
                }
            }
        }
Пример #8
0
        // ******************************************************************
        /// <summary>
        /// This virtual method is called when ApplicationCommands.Paste command is executed.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="args"></param>
        protected virtual void OnExecutedPaste(object target, ExecutedRoutedEventArgs args)
        {
            if (ExecutePasteEvent != null)
            {
                ExecutePasteEvent(target, args);
                if (args.Handled)
                {
                    return;
                }
            }

            // parse the clipboard data            [row][column]
            List <string[]> clipboardData = ClipboardHelper.ParseClipboardData();

            bool hasAddedNewRow = false;

#if DEBUG
            StringBuilder sb = new StringBuilder();
#endif
            int minRowIndex            = Items.IndexOf(CurrentItem);
            int maxRowIndex            = Items.Count - 1;
            int startIndexOfDisplayCol = (SelectionUnit != DataGridSelectionUnit.FullRow) ? CurrentColumn.DisplayIndex : 0;
            int clipboardRowIndex      = 0;
            for (int i = minRowIndex; i <= maxRowIndex && clipboardRowIndex < clipboardData.Count; i++, clipboardRowIndex++)
            {
                if (i < this.Items.Count)
                {
                    CurrentItem = Items[i];

                    BeginEditCommand.Execute(null, this);

                    int clipboardColumnIndex = 0;
                    for (int j = startIndexOfDisplayCol; clipboardColumnIndex < clipboardData[clipboardRowIndex].Length; j++, clipboardColumnIndex++)
                    {
                        // DataGridColumn column = ColumnFromDisplayIndex(j);
                        DataGridColumn column = null;
                        foreach (DataGridColumn columnIter in this.Columns)
                        {
                            if (columnIter.DisplayIndex == j)
                            {
                                column = columnIter;
                                break;
                            }
                        }

                        column?.OnPastingCellClipboardContent(Items[i], clipboardData[clipboardRowIndex][clipboardColumnIndex]);

#if DEBUG
                        sb.AppendFormat("{0,-10}", clipboardData[clipboardRowIndex][clipboardColumnIndex]);
                        sb.Append(" - ");
#endif
                    }

                    CommitEditCommand.Execute(this, this);
                    if (i == maxRowIndex)
                    {
                        maxRowIndex++;
                        hasAddedNewRow = true;
                    }
                }

#if DEBUG
                sb.Clear();
#endif
            }

            // update selection
            if (hasAddedNewRow)
            {
                UnselectAll();
                UnselectAllCells();

                CurrentItem = Items[minRowIndex];

                if (SelectionUnit == DataGridSelectionUnit.FullRow)
                {
                    SelectedItem = Items[minRowIndex];
                }
                else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader ||
                         SelectionUnit == DataGridSelectionUnit.Cell)
                {
                    SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[startIndexOfDisplayCol]));
                }
            }
        }