/// <summary>
 /// ルートグループ以外の全グループを取得します。
 /// </summary>
 /// <returns>取得結果</returns>
 public List <TaskGroupInfo> GetGroupListExcludeRoot()
 {
     return(ResourceManager.Instance.taskInfoRoot.TaskGroupList
            .Where(x => !x.Key.Equals(TaskGroupInfo.GetRootGroup().Key))
            .Select(x => x.Value)
            .ToList());
 }
Beispiel #2
0
        /// <summary>
        /// タスクグループ一覧の選択変更時イベント
        /// </summary>
        /// <param name="sender">イベント送信オブジェクト</param>
        /// <param name="e">イベント引数</param>
        private void LsvGroupOnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.LsvGroup.SelectedItems.Count > 0)
            {
                var selectedItemIndex = this.LsvGroup.SelectedItems[0].Index;
                var selected          = this.LsvGroup.SelectedItems[0].Tag as KeyInfo;
                if (selected != null)
                {
                    if (selected.Equals(TaskGroupInfo.GetRootGroup().Key))
                    {
                        this.ShowAllTaskListInDgvAllTasks();
                    }
                    else
                    {
                        var group = ResourceManager.Instance.GetGroupInfo(selected);

                        this.DgvAllTasks.RefleshTaskItems(group.ChildTaskItems.ToList(), group);

                        this.LblDisplayGroup.Text = string.Format("[{0}]", group.Name);
                    }

                    this.isSuspentGroupListView = true;
                    this.LsvGroup.Items[selectedItemIndex].Focused  = true;
                    this.LsvGroup.Items[selectedItemIndex].Selected = true;
                    this.isSuspentGroupListView = false;
                }
            }
        }
        /// <summary>
        /// 初期化処理
        /// </summary>
        /// <param name="group">編集対象のグループ情報</param>
        /// <param name="isAddOperation">追加画面かどうか</param>
        /// <param name="parent">親グループ</param>
        public void Initialize(TaskGroupInfo group, bool isAddOperation, TaskGroupInfo parent)
        {
            this.isAdd = isAddOperation;

            foreach (var item in ResourceManager.Instance.GetGroupList())
            {
                if (item.ParentGroup == null || item.ParentGroup.Equals(TaskGroupInfo.GetRootGroup().Key))
                {
                    // ルートグループのみ対象
                    this.CmbParentGroup.Items.Add(item);
                }
            }

            // this.CmbParentGroup.Enabled = false;
            // this.CmbParentGroup.SelectedItem = TaskGroupInfo.GetRootGroup();

            if (group != null)
            {
                this.target = group;

                // 自分を削除
                if (this.CmbParentGroup.Items.Contains(group))
                {
                    this.CmbParentGroup.Items.Remove(group);
                }

                if (group.ParentGroup != null)
                {
                    this.CmbParentGroup.SelectedItem = group.ParentGroup;
                }

                this.TxtGroupName.Text = group.Name;
            }
        }
        /// <summary>
        /// 全タスクの情報を取得します。
        /// </summary>
        /// <returns>取得けっk</returns>
        public List <TaskItem> GetAllTaskItems()
        {
            var list = new List <TaskItem>();

            ResourceManager.Instance.ExecInnerGroupAndTasks(
                TaskGroupInfo.GetRootGroup(),
                null,
                (task) => { list.Add(task); });

            return(list);
        }
        /// <summary>
        /// 確定ボタン押下時イベント
        /// </summary>
        /// <param name="sender">イベント送信オブジェクト</param>
        /// <param name="e">イベント引数</param>
        private void BtnKakutei_Click(object sender, EventArgs e)
        {
            this.CmbParentGroup.BackColor = Color.White;
            this.TxtGroupName.BackColor   = Color.White;

            var           canUpdate = true;
            TaskGroupInfo parent;

            if (string.IsNullOrEmpty(this.CmbParentGroup.Text))
            {
                // トップの親
                parent = TaskGroupInfo.GetRootGroup();
            }
            else
            {
                var selected = this.CmbParentGroup.SelectedItem as TaskGroupInfo;
                if (selected == null)
                {
                    this.CmbParentGroup.BackColor = Color.Red;
                    canUpdate = false;
                    parent    = null;
                }
                else
                {
                    parent = selected;
                }
            }

            if (string.IsNullOrEmpty(this.TxtGroupName.Text))
            {
                this.TxtGroupName.BackColor = Color.Red;
                canUpdate = false;
            }

            if (canUpdate)
            {
                if (this.isAdd)
                {
                    ResourceManager.Instance.AddTaskGroup(this.TxtGroupName.Text, parent);
                }
                else
                {
                    ResourceManager.Instance.EditTaskGroup(this.target, this.TxtGroupName.Text, parent);
                }

                this.CloseWindow(SubWindowResult.Submit);
            }
        }
Beispiel #6
0
 /// <summary>
 /// グループ削除ボタン押下時イベント
 /// </summary>
 /// <param name="sender">イベント送信オブジェクト</param>
 /// <param name="e">イベント引数</param>
 private void BtnRemoveGroup_Click(object sender, EventArgs e)
 {
     if (this.LsvGroup.SelectedItems.Count > 0)
     {
         var selected = this.LsvGroup.SelectedItems[0].Tag as KeyInfo;
         if (selected != null)
         {
             var item = ResourceManager.Instance.GetGroupInfo(selected);
             if (!selected.Equals(TaskGroupInfo.GetRootGroup().Key) && !selected.Equals(TaskGroupInfo.GetDefaultGroup().Key))
             {
                 ResourceManager.Instance.RemoveTaskGroup(item);
                 this.RefleshTaskGroupIchiran();
             }
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// グループリネームボタン押下時イベント
        /// </summary>
        /// <param name="sender">イベント送信オブジェクト</param>
        /// <param name="e">イベント引数</param>
        private async void BtnReNameGroup_Click(object sender, EventArgs e)
        {
            if (this.LsvGroup.SelectedItems.Count > 0)
            {
                var selected = this.LsvGroup.SelectedItems[0].Tag as KeyInfo;
                if (selected != null)
                {
                    var item = ResourceManager.Instance.GetGroupInfo(selected);
                    if (!selected.Equals(TaskGroupInfo.GetRootGroup().Key) && !selected.Equals(TaskGroupInfo.GetDefaultGroup().Key))
                    {
                        var win = new TaskGroupEditForm();
                        win.Initialize(item, false, ResourceManager.Instance.GetGroupInfo(item.ParentGroup));
                        var ret = await win.ShowWindow(this);

                        this.RefleshTaskGroupIchiran();
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// タスクグループ一覧を再描画します。
        /// </summary>
        private void RefleshTaskGroupIchiran()
        {
            if (this.isSuspentGroupListView)
            {
                return;
            }

            this.LsvGroup.BeginUpdate();

            this.LsvGroup.Items.Clear();

            {
                // 全タスク表示用の項目
                var lvItem      = this.LsvGroup.Items.Add("全てのタスク");
                var allTaskList = ResourceManager.Instance.GetAllTaskItems();
                lvItem.SubItems.Add(string.Format("{0:D}件", allTaskList.Count));
                lvItem.Tag = TaskGroupInfo.GetRootGroup().Key;
            }

            // グループ表示
            var topTasks = ResourceManager.Instance.GetRootGroups();

            foreach (var taskGroupInfo in topTasks)
            {
                var taskName = taskGroupInfo.Name;
                var taskNum  = taskGroupInfo.ChildTaskItems.Count;
                var lvItem   = this.LsvGroup.Items.Add(taskName);
                lvItem.SubItems.Add(string.Format("{0:D}件", taskNum));
                lvItem.Tag = taskGroupInfo.Key;

                foreach (var childGroup in taskGroupInfo.ChildGroups)
                {
                    var group         = ResourceManager.Instance.GetGroupInfo(childGroup);
                    var childTaskName = group.Name;
                    var childTaskNum  = group.ChildTaskItems.Count;
                    var childLvItem   = this.LsvGroup.Items.Add("  |-- " + childTaskName);
                    childLvItem.SubItems.Add(string.Format("{0:D}件", childTaskNum));
                    childLvItem.Tag = childGroup;
                }
            }

            this.LsvGroup.EndUpdate();
        }
        /// <summary>
        /// ルートのグループ情報を取得します。
        /// </summary>
        /// <returns>取得けっk</returns>
        public List <TaskGroupInfo> GetRootGroups()
        {
            var result = new List <TaskGroupInfo>();

            foreach (var item in instance.taskInfoRoot.TaskGroupList)
            {
                var key   = item.Key;
                var value = item.Value;

                if (value.ParentGroup != null)
                {
                    if (value.ParentGroup.Equals(TaskGroupInfo.GetRootGroup().Key))
                    {
                        result.Add(value);
                    }
                }
            }

            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// グループ追加ボタン押下時イベント
        /// </summary>
        /// <param name="sender">イベント送信オブジェクト</param>
        /// <param name="e">イベント引数</param>
        private async void BtnAddGroup_Click(object sender, EventArgs e)
        {
            var parent = TaskGroupInfo.GetRootGroup();

            if (this.LsvGroup.SelectedItems.Count > 0)
            {
                var selected = this.LsvGroup.SelectedItems[0].Tag as KeyInfo;
                if (selected != null)
                {
                    var item = ResourceManager.Instance.GetGroupInfo(selected);
                    parent = item;
                }
            }

            var win = new TaskGroupEditForm();

            win.Initialize(null, true, parent);
            var ret = await win.ShowWindow(this);

            this.RefleshTaskGroupIchiran();
        }
        /// <summary>
        /// 初期化処理
        /// </summary>
        /// <returns>実行結果</returns>
        public bool Initialize()
        {
            this.taskInfoRoot = new TaskInfoRoot();

            KeyInfo.Initialize();

            var path = Utils.GetFullPath(TaskListSavePath);

            if (File.Exists(path))
            {
                var text    = File.ReadAllText(path);
                var jsonObj = JsonConvert.DeserializeObject <TaskInfoRoot>(text);

                instance.taskInfoRoot = jsonObj;

                var rootGroupKey = TaskGroupInfo.GetRootGroup().Key;
                if (instance.taskInfoRoot.TaskGroupListJsonObj.Any(x => x.Key.Equals(rootGroupKey)))
                {
                    var item = instance.taskInfoRoot.TaskGroupListJsonObj.First(x => x.Key.Equals(rootGroupKey));
                    TaskGroupInfo.OverriteRootGroup(item);
                }

                var defaultGroupKey = TaskGroupInfo.GetDefaultGroup().Key;
                if (instance.taskInfoRoot.TaskGroupListJsonObj.Any(x => x.Key.Equals(defaultGroupKey)))
                {
                    var item = instance.taskInfoRoot.TaskGroupListJsonObj.First(x => x.Key.Equals(defaultGroupKey));
                    TaskGroupInfo.OverriteDefaultGroup(item);
                }

                // 全グループに対してキーの再生成
                foreach (var taskGroupInfo in instance.taskInfoRoot.TaskGroupListJsonObj)
                {
                    if (!KeyInfo.IsCreatedKeyGroup(taskGroupInfo.Key))
                    {
                        var keyGroup = KeyInfo.CreateKeyInfoGroup();

                        taskGroupInfo.ChildGroups.Clear();
                        var filetered =
                            instance.taskInfoRoot.TaskGroupListJsonObj.Where(x =>
                                                                             x.ParentGroup != null && x.ParentGroup.Equals(taskGroupInfo.Key)).ToList();
                        if (filetered.Any())
                        {
                            foreach (var groupInfo in filetered)
                            {
                                if (!KeyInfo.IsCreatedKeyGroup(groupInfo.Key))
                                {
                                    var keyGroupChildGroup = KeyInfo.CreateKeyInfoGroup();
                                    groupInfo.Key = keyGroupChildGroup;
                                }

                                groupInfo.ParentGroup = keyGroup;
                                taskGroupInfo.ChildGroups.Add(groupInfo.Key);
                            }
                        }

                        taskGroupInfo.Key = keyGroup;
                    }

                    foreach (var childTaskItem in taskGroupInfo.ChildTaskItems)
                    {
                        if (!KeyInfo.IsCreatedKeyTask(taskGroupInfo.Key, childTaskItem.Key))
                        {
                            var keyGroup = KeyInfo.CreateKeyInfoTask(taskGroupInfo.Key);
                            childTaskItem.Key = keyGroup;
                        }

                        childTaskItem.Group = taskGroupInfo.Key;
                    }

                    if (!instance.taskInfoRoot.TaskGroupList.ContainsKey(taskGroupInfo.Key))
                    {
                        instance.taskInfoRoot.TaskGroupList.Add(taskGroupInfo.Key, taskGroupInfo);
                    }
                }
            }
            else
            {
                instance.taskInfoRoot.AddTaskGroup(TaskGroupInfo.GetRootGroup(), null);
                instance.taskInfoRoot.AddTaskGroup(TaskGroupInfo.GetDefaultGroup(), TaskGroupInfo.GetRootGroup());
            }

            return(true);
        }