コード例 #1
0
        private void OnMoveItem(int targetListIndex, object item)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnMoveItem {0} {1}", targetListIndex, item));

            if ((TaskListGroup != null) && (SelectedTaskList < TaskListGroup.NumLists))
            {
                if (item is DataGrid)
                {
                    List <TaskView> tasksToRemove = new List <TaskView>();

                    DataGrid dg = item as DataGrid;

                    foreach (TaskView t in dg.SelectedItems)
                    {
                        Log.Instance.LogInfo(string.Format("MainViewModel.OnMoveItem - move {0} from {1} to {2}", t.Description, SelectedTaskList, targetListIndex));
                        TaskListGroup.AddNewTask(targetListIndex, t.Description, t.Colour, t.Note);
                        tasksToRemove.Add(t);
                    }

                    foreach (TaskView t in tasksToRemove)
                    {
                        PropertyDataGridViewModel.DeleteTask(dg.Items.IndexOf(t));
                    }
                }
                else
                {
                    Log.Instance.LogError("MainViewModel.OnMoveItem - item is not a DataGrid, skipping");
                }
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnMoveItem - TaskListGroup is null, skipping");
            }
        }
コード例 #2
0
        // copy the task list into an observable collection of list names
        private void UpdateView(int newSelection = 0)
        {
            Log.Instance.LogDebug(string.Format("MainViewModel.UpdateView {0}", newSelection));

            TaskLists.Clear();
            ContextMenuItems.Clear();

            if (TaskListGroup != null)
            {
                for (int i = 0; i < TaskListGroup.NumLists; i++)
                {
                    Log.Instance.LogDebug(string.Format("MainViewModel.Adding Task List {0}", TaskListGroup.ListName(i)));

                    TaskLists.Add(new TaskListView(TaskListGroup.ListName(i)));
                    ContextMenuItems.Add(new ContextMenuItem(TaskListGroup.ListName(i), new CustomCommandHandler(i, OnMoveItem)));
                }
            }
            else
            {
                Log.Instance.LogDebug(string.Format("MainViewModel.UpdateView - TaskListGroup is null, skipping"));
            }

            RaisePropertyChanged("TaskLists");
            RaisePropertyChanged("ContextMenuItems");

            SelectedTaskList = newSelection;

            PropertyDataGridViewModel = new DataGridViewModel(TaskListGroup, SelectedTaskList);
        }
コード例 #3
0
        private void OnSaveAs(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnSaveAs {0}", parameter));

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = DefaultFileName;       // Default file name
            dlg.DefaultExt = DefaultFileType;       // Default file extension
            dlg.Filter     = DefaultFileFilter;     // Filter files by extension

            // Show save file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                Log.Instance.LogInfo(string.Format("MainViewModel.OnSaveAs Saving as {0}", dlg.FileName));

                CurrentFileName = dlg.FileName;

                //set the filename into the taskListGroup
                if (TaskListGroup != null)
                {
                    TaskListGroup.SetPersistCallback(this);
                    TaskListGroup.Persist();
                }
                else
                {
                    Log.Instance.LogDebug("MainViewModel.OnSaveAs - TaskListGroup is null, skipping");
                }
            }
            else
            {
                Log.Instance.LogInfo("MainViewModel.OnSaveAs - save cancelled");
            }
        }
コード例 #4
0
        //private helper functions
        // copy the task list into an observable collection of list names
        private void UpdateView()
        {
            Log.Instance.LogDebug("DataGridViewModel.UpdateView");

            PropertyTasks.CollectionChanged -= OnViewChanged;

            PropertyTasks.Clear();

            if (CurrentTaskList >= 0)
            {
                for (int i = 0; i < TaskListGroup.NumTasks(CurrentTaskList); i++)
                {
                    TaskView tv = new TaskView(
                        TaskListGroup.GetTask(CurrentTaskList, i),
                        TaskListGroup.GetTaskColour(CurrentTaskList, i),
                        TaskListGroup.GetTaskNote(CurrentTaskList, i));
                    tv.PropertyChanged += OnTaskEdited;

                    PropertyTasks.Add(tv);
                }
            }

            PropertyTasks.CollectionChanged += OnViewChanged;

            RaisePropertyChanged("Tasks");
        }
コード例 #5
0
        private void OnNew(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnNew {0}", parameter));

            // reset filename
            CurrentFileName = null;

            // create a new group
            TaskListGroup = new TaskListGroup();
            TaskListGroup.AddNewList("Example", true);

            UpdateView(0);
        }
コード例 #6
0
        private void OnRenameList(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnRenameList {0}", parameter));

            if (TaskListGroup != null)
            {
                RenameDialog w = new RenameDialog(TaskListGroup.ListName(SelectedTaskList), OnDoRename);
                w.ShowDialog();
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnRenameList - TaskListGroup is null, skipping");
            }
        }
コード例 #7
0
        private void OnNewList(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnNewList {0}", parameter));

            if (TaskListGroup != null)
            {
                int newList = TaskListGroup.AddNewList("New List", true);
                UpdateView(newList - 1);
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnNewList - TaskListGroup is null, skipping");
            }
        }
コード例 #8
0
        private void OnClearList(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnClearList {0}", parameter));

            if (TaskListGroup != null)
            {
                TaskListGroup.RemoveAllTasks(SelectedTaskList);

                UpdateView(SelectedTaskList);
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnClearList - TaskListGroup is null, skipping");
            }
        }
コード例 #9
0
        private void OnSave(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnSave {0}", parameter));

            if (CurrentFileName == null)
            {
                Log.Instance.LogDebug("MainViewModel.OnSave - no filename specified - calling SaveAs");
                OnSaveAs(parameter);
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnSave - filename specified, saving...");
                TaskListGroup.Persist();
            }
        }
コード例 #10
0
        private void OnDoRename(string s)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnDoRename {0}", s));

            if (TaskListGroup != null)
            {
                Log.Instance.LogDebug(string.Format("Rename list {0} to {1}", SelectedTaskList, s));

                TaskListGroup.RenameList(SelectedTaskList, s);
                UpdateView(SelectedTaskList);
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnDoRename - TaskListGroup is null, skipping");
            }
        }
コード例 #11
0
        private void OnDeleteList(object parameter)
        {
            Log.Instance.LogInfo(string.Format("MainViewModel.OnDeleteList {0}", parameter));

            if (TaskListGroup != null)
            {
                int newSelection = SelectedTaskList - 1;

                TaskListGroup.DeleteList(SelectedTaskList);

                UpdateView(newSelection);
            }
            else
            {
                Log.Instance.LogDebug("MainViewModel.OnDeleteList - TaskListGroup is null, skipping");
            }
        }
コード例 #12
0
        private void CopyViewChangesToModel()
        {
            Log.Instance.LogDebug("DataGridViewModel.CopyViewChangesToModel");

            if (TaskListGroup != null)
            {
                TaskListGroup.RemoveAllTasks(CurrentTaskList);

                foreach (TaskView t in PropertyTasks)
                {
                    TaskListGroup.AddNewTask(CurrentTaskList, t.Description, t.Colour, t.Note);
                }
            }
            else
            {
                Log.Instance.LogDebug("DataGridViewModel.CopyViewChangesToModel - TaskListGroup is null, skipping");
            }
        }
コード例 #13
0
        private void OnEditTaskNote(object parameter)
        {
            Log.Instance.LogInfo(string.Format("DataGridViewModel.OnEditTaskNote {0}", parameter));

            if (parameter is DataGridRow)
            {
                int r = (parameter as DataGridRow).GetIndex();

                if (r >= 0)
                {
                    Log.Instance.LogDebug(string.Format("DataGridViewModel.OnDeleteTask - editing  note for task {0}", r));

                    NotesDialog d = new NotesDialog(r, TaskListGroup.GetTaskNote(CurrentTaskList, r), OnChangeNote);
                    d.ShowDialog();
                }
            }
            else
            {
                Log.Instance.LogError("DataGridViewModel.OnDeleteTask - parameter is not a DataGridRow");
            }
        }