예제 #1
0
        /**
         * 添加一级子任务
         */
        internal SubTask addParentSubTask(int taskId, SubTask subTask)
        {
            //插入
            string sql = string.Format($"INSERT INTO subtask(subtask_name, subtask_state,root_id) VALUES ('{subTask.SubTaskName}','{subTask.SubTaskState}','{taskId}')");

            return(addParentSubTask(sql, subTask));
        }
예제 #2
0
        /**
         * 创建文本框-双按钮的子任务树节点
         */
        private TreeViewItem createTreeViewItem(SubTask subTask)
        {
            TreeViewItem result = new TreeViewItem();

            result.IsExpanded = true;
            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation         = Orientation.Horizontal;
            stackPanel.HorizontalAlignment = HorizontalAlignment.Left;

            TextBox textBox = new TextBox();

            textBox.HorizontalAlignment = HorizontalAlignment.Left;
            textBox.Height = 30;
            textBox.Width  = 180;
            textBox.Text   = subTask.SubTaskName;
            if (subTask.SubTaskState == 1)
            {
                textBox.Text      += "(已完成)";
                textBox.Background = new SolidColorBrush(Color.FromRgb(169, 169, 169));
            }
            textBox.Tag        = subTask.Id;
            textBox.LostFocus += subTaskName_LostFocus;
            stackPanel.Children.Add(textBox);

            Button link = new Button();

            link.Style  = FindResource("MaterialDesignFloatingActionMiniLightButton") as Style;
            link.Height = 20;
            link.Width  = 20;
            link.HorizontalAlignment = HorizontalAlignment.Right;
            PackIcon linkIcon = new PackIcon();

            linkIcon.Kind   = PackIconKind.Link;
            linkIcon.Height = 12;
            linkIcon.Width  = 12;
            link.Content    = linkIcon;
            stackPanel.Children.Add(link);

            Button edit = new Button();

            edit.Style  = FindResource("MaterialDesignFloatingActionMiniLightButton") as Style;
            edit.Height = 20;
            edit.Width  = 20;
            edit.HorizontalAlignment = HorizontalAlignment.Right;
            PackIcon editIcon = new PackIcon();

            editIcon.Kind   = PackIconKind.Pen;
            editIcon.Height = 12;
            editIcon.Width  = 12;
            edit.Content    = editIcon;
            stackPanel.Children.Add(edit);

            result.Header = stackPanel;
            result.Tag    = subTask.Id;
            return(result);
        }
예제 #3
0
        private SubTask addParentSubTask(string sql, SubTask subTask)
        {
            //插入子任务
            SQLiteExecutor.execute(sql);
            //获取刚插入的数据返回
            string           sql_select       = string.Format("select id from subtask order by id desc limit 1");
            SQLiteDataReader sQLiteDataReader = SQLiteExecutor.select(sql);

            if (!sQLiteDataReader.Read())
            {
                return(subTask);
            }
            subTask.Id = sQLiteDataReader.GetInt32(0);
            return(subTask);
        }
예제 #4
0
        private static List <SubTask> getSubTasks(int taskId, string parentIdName)
        {
            List <SubTask>   result           = new List <SubTask>();
            string           sql_select       = string.Format($"select id,subtask_name,subtask_state from subtask where {parentIdName} = {taskId}");
            SQLiteDataReader sQLiteDataReader = SQLiteExecutor.select(sql_select);

            while (sQLiteDataReader.Read())
            {
                SubTask subTask = new SubTask();
                subTask.Id           = sQLiteDataReader.GetInt32(0);
                subTask.SubTaskName  = sQLiteDataReader.GetString(1);
                subTask.SubTaskState = sQLiteDataReader.GetInt32(2);
                result.Add(subTask);
            }
            return(result);
        }
예제 #5
0
        private void showTask(Task task, bool isExpand)
        {
            int      priority    = task.Priority;
            string   taskName    = task.TaskName;
            string   description = task.TaskDescription;
            DateTime dateTime    = task.TaskDate;

            //整体卡片
            Card card = new Card();

            card.Tag    = task;
            card.Width  = 406;
            card.Margin = new Thickness(0, 16, 0, 0);
            taskList.Children.Add(card);

            //收缩框
            Expander expander = new Expander();

            expander.HorizontalAlignment = HorizontalAlignment.Stretch;
            expander.Header = taskName;
            if (task.TaskState == 1)
            {
                expander.Header    += "(已完成)";
                expander.Background = new SolidColorBrush(Color.FromRgb(169, 169, 169));
            }
            card.Content = expander;
            expander.Tag = task.TaskId;
            //展开任务面板
            if (isExpand)
            {
                expander.IsExpanded = true;
            }

            //stack面板
            StackPanel stackPanel = new StackPanel();

            stackPanel.Margin = new Thickness(24, 8, 24, 16);
            expander.Content  = stackPanel;

            //任务名
            TextBox nameBox = new TextBox();

            nameBox.Opacity      = 0.68;
            nameBox.Text         = taskName;
            nameBox.TextWrapping = TextWrapping.Wrap;
            HintAssist.SetHint(nameBox, "任务名称");
            nameBox.Style  = FindResource("MaterialDesignOutlinedTextFieldTextBox") as Style;
            nameBox.Margin = new Thickness(0, 16, 0, 0);
            stackPanel.Children.Add(nameBox);
            nameBox.Tag          = expander;
            nameBox.TextChanged += TaskNameChanged;
            nameBox.LostFocus   += NameChanged;
            //任务的描述文本框
            TextBox descBox = new TextBox();

            descBox.Opacity      = 0.68;
            descBox.Text         = description;
            descBox.TextWrapping = TextWrapping.Wrap;
            HintAssist.SetHint(descBox, "任务描述");
            descBox.Style  = FindResource("MaterialDesignOutlinedTextFieldTextBox") as Style;
            descBox.Margin = new Thickness(0, 16, 0, 0);
            stackPanel.Children.Add(descBox);
            descBox.Tag        = task.TaskId;
            descBox.LostFocus += DescChanged;;

            //优先级选择栏
            ComboBox comboBox = new ComboBox();

            comboBox.Style = FindResource("MaterialDesignFilledComboBox") as Style;
            HintAssist.SetHint(comboBox, "优先级");
            comboBox.Margin = new Thickness(0, 8, 0, 0);
            comboBox.Width  = 230;
            comboBox.HorizontalAlignment = HorizontalAlignment.Left;
            comboBox.Items.Add("十万火急");
            comboBox.Items.Add("很急");
            comboBox.Items.Add("一般");
            comboBox.Items.Add("不急");
            comboBox.SelectedIndex     = priority;
            comboBox.Tag               = task.TaskId;
            comboBox.SelectionChanged += Priority_Changed;
            stackPanel.Children.Add(comboBox);

            //时间日期面板
            StackPanel stackPanel1 = new StackPanel();

            stackPanel1.HorizontalAlignment = HorizontalAlignment.Left;
            stackPanel1.Orientation         = Orientation.Horizontal;
            stackPanel1.Margin = new Thickness(0, 8, 0, 0);
            stackPanel.Children.Add(stackPanel1);
            //日期
            DatePicker datePicker = new DatePicker();

            datePicker.HorizontalAlignment = HorizontalAlignment.Left;
            datePicker.Width = 82;
            datePicker.Style = FindResource("MaterialDesignFloatingHintDatePicker") as Style;
            HintAssist.SetHint(datePicker, "任务日期");
            datePicker.Margin               = new Thickness(16, 0, 16, 0);
            datePicker.SelectedDate         = dateTime;
            datePicker.Tag                  = task.TaskId;
            datePicker.SelectedDateChanged += Date_Changed;;
            stackPanel1.Children.Add(datePicker);
            //时间
            TimePicker timePicker = new TimePicker();

            timePicker.HorizontalAlignment = HorizontalAlignment.Left;
            timePicker.Width = 82;
            timePicker.Style = FindResource("MaterialDesignFloatingHintTimePicker") as Style;
            HintAssist.SetHint(timePicker, "时间");
            timePicker.SelectedTime         = dateTime;
            timePicker.Tag                  = task.TaskId;
            timePicker.SelectedTimeChanged += Time_Changed;
            stackPanel1.Children.Add(timePicker);

            //子任务树
            TreeView subTaskTree = new TreeView();

            subTaskTree.Margin   = new Thickness(0, 16, 0, 0);
            subTaskTree.MinWidth = 220;
            subTaskTree.Tag      = task.TaskId;

            List <SubTask> subTasks = task.SubTasks;

            if (subTasks != null)
            {
                for (int j = 0; j < subTasks.Count; j++)
                {
                    SubTask        subTask      = subTasks.ElementAt(j);
                    List <SubTask> subSonTasks  = subTask.SubTasks;
                    TreeViewItem   treeViewItem = createTreeViewItem(subTask);
                    //二级子任务
                    for (int k = 0; k < subSonTasks.Count; k++)
                    {
                        TreeViewItem sonTreeViewItem = createTreeViewItem(subSonTasks.ElementAt(k));
                        treeViewItem.Items.Add(sonTreeViewItem);
                    }
                    //新增二级子任务按钮
                    TreeViewItem addSon = new TreeViewItem();
                    addSon.Header   = "+";
                    addSon.MouseUp += AddSon_MouseUp;
                    addSon.Tag      = treeViewItem;
                    treeViewItem.Items.Add(addSon);

                    subTaskTree.Items.Add(treeViewItem);
                }
            }
            //新增子任务按钮
            TreeViewItem addParent = new TreeViewItem();

            addParent.Header   = "+";
            addParent.Tag      = subTaskTree;
            addParent.MouseUp += AddParent_MouseUp;
            subTaskTree.Items.Add(addParent);
            stackPanel.Children.Add(subTaskTree);
        }