private void btnCreateNewList_Click(object sender, EventArgs e)
        {
            var box = new SPSBox();

            box.FilePath = "test2.sps";
            Dispatcher.SendServiceCode(SPSServiceCode.CreateToDoList, Dispatcher.GetView(), box);
            listView.Clear();
            box.Dispose();
        }
        public Main(SPSDispatcher dispatcher)
        {
            Dispatcher = dispatcher;

            InitializeComponent();
            var box = new SPSBox();

            box.ListView = listView;
            Dispatcher.SendServiceCode(SPSServiceCode.Update, dispatcher.GetView(), box);
            box.Dispose();
        }
 private void btnDeleteTask_Click(object sender, EventArgs e)
 {
     if (listView.SelectedItems.Count > 0)
     {
         var index = listView.Items.IndexOf(listView.SelectedItems[0]);
         var box   = new SPSBox();
         box.index = index;
         Dispatcher.SendServiceCode(SPSServiceCode.DeleteTask, Dispatcher.GetView(), box);
         box.ListView = listView;
         Dispatcher.SendServiceCode(SPSServiceCode.Update, Dispatcher.GetView(), box);
         box.Dispose();
     }
 }
        private void btnLoadFromfile_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "sps files (*.sps)|*.sps|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    SPSBox box = new SPSBox();
                    box.FilePath = openFileDialog.FileName;
                    Dispatcher.SendServiceCode(SPSServiceCode.CreateToDoList, Dispatcher.GetView(), box);
                    box.ListView = listView;
                    Dispatcher.SendServiceCode(SPSServiceCode.Update, Dispatcher.GetController(), box);
                    box.Dispose();
                }
            }
        }
        private void btnAddTask_Click(object sender, EventArgs e)
        {
            if (
                dateTimePickerStart.Value <= dateTimePickerEnd.Value &&
                !string.IsNullOrEmpty(tbxTextInfo.Text) &&
                !string.IsNullOrWhiteSpace(tbxTextInfo.Text) &&
                cmbPriority.SelectedIndex > -1 &&
                cmbTag.SelectedIndex > -1
                )
            {
                box.SPSTask.DateTimeStartTask = dateTimePickerStart.Value;
                box.SPSTask.DateTimeEndTask   = dateTimePickerEnd.Value;
                switch ((Model.Tag)cmbTag.SelectedIndex)
                {
                case Model.Tag.Important:
                    box.SPSTask.TagTask = Model.Tag.Important;
                    break;

                case Model.Tag.Home:
                    box.SPSTask.TagTask = Model.Tag.Home;
                    break;

                case Model.Tag.Work:
                    box.SPSTask.TagTask = Model.Tag.Work;
                    break;

                case Model.Tag.Personal:
                    box.SPSTask.TagTask = Model.Tag.Personal;
                    break;

                default:
                    break;
                }
                switch ((Model.Priority)cmbPriority.SelectedIndex)
                {
                case Priority.Low:
                    box.SPSTask.PriorityTask = Priority.Low;
                    break;

                case Priority.Normal:
                    box.SPSTask.PriorityTask = Priority.Normal;
                    break;

                case Priority.High:
                    box.SPSTask.PriorityTask = Priority.High;
                    break;

                case Priority.Middle:
                    box.SPSTask.PriorityTask = Priority.Middle;
                    break;

                default:
                    break;
                }
                box.SPSTask.InfoAboutTask = tbxTextInfo.Text;
                if (index == -1)
                {
                    listView.Items.Add(box.SPSTask.ToString());
                    dispatcher.SendServiceCode(SPSServiceCode.CreateToDoTask, dispatcher.GetView(), box);
                }
                else
                {
                    switch (change)
                    {
                    case SPSChange.Priority:
                        box.Change = SPSChange.Priority;
                        dispatcher.SendServiceCode(SPSServiceCode.SetPriority, dispatcher.GetView(), box);
                        break;

                    case SPSChange.Tag:
                        box.Change = SPSChange.Tag;
                        dispatcher.SendServiceCode(SPSServiceCode.SetTag, dispatcher.GetView(), box);
                        break;

                    case SPSChange.Info:
                        box.Change = SPSChange.Info;
                        dispatcher.SendServiceCode(SPSServiceCode.SetInfo, dispatcher.GetView(), box);
                        break;

                    case SPSChange.DateEnd:
                        box.Change = SPSChange.DateEnd;
                        dispatcher.SendServiceCode(SPSServiceCode.SetDueDate, dispatcher.GetView(), box);
                        break;

                    case SPSChange.Task:
                        box.Change = SPSChange.Task;
                        dispatcher.SendServiceCode(SPSServiceCode.Change, dispatcher.GetView(), box);
                        break;

                    default:
                        break;
                    }
                    box.ListView = listView;
                    dispatcher.SendServiceCode(SPSServiceCode.Update, dispatcher.GetView(), box);
                }
                box.Dispose();
                Close();
            }
            else
            {
                MessageBox.Show("Not all parameters satisfy");
            }
        }