//因为外部更改了category 这个也要通过show 更新 //所以需要show 才能展示 protected override void OnShow() { Clear(); var data = ToDoDataManager.Data; if (data.categoryList.Count > 0) { popupView = new PopupView(0, data.categoryList.Select(x => x.name).ToArray()) .Width(100f).Height(20).AddTo(this); } var inputTextArea = new TextAreaView(todoName).Height(20).FontSize(15); inputTextArea.Content.Bind(x => todoName = x); Add(inputTextArea); var addBtn = new ImageButtonView(ImageButtonIcon.addIcon, () => { if (!string.IsNullOrEmpty(todoName)) { onInputClick?.Invoke(ToDoDataManager.ToDoCategoryAt(PopupIndex), todoName); inputTextArea.Content.Val = string.Empty; GUI.FocusControl(null); } }).Width(30).Height(20).BackgroundColor(Color.yellow); Add(addBtn); }
public static ProcessSystem ToDoSplitChoice(this ProcessSystem processSystem) { var first = string.Empty; var second = string.Empty; return(processSystem.BeginChoice("拆解多步") .BeginQuestion() .SetTitle("先做什么?") .SetContext(string.Empty) .SetContextTextArea(string.Empty, (str1) => { first = str1; }) .NewBtn("保存", () => { ToDoDataManager.AddToDoItem(first); EditorGUI.FocusTextInControl(null); }) .EndQuestion() //================= .BeginQuestion() .SetTitle("接着做什么?") .SetContext(string.Empty) .SetContextTextArea(string.Empty, (str2) => { second = str2; }) .RepeatSelfMenu("接着", () => { ToDoDataManager.AddToDoItem(second); EditorGUI.FocusTextInControl(null); //processSystem.RepeatThen(); }) .NewBtn("保存并结束", () => { ToDoDataManager.AddToDoItem(second); EditorGUI.FocusTextInControl(null); }) .EndQuestion() .EndChoice()); }
private void ReBuildToDoItems() { verticalLayout.Clear(); var data = ToDoDataManager.Data; foreach (var item in data.categoryList) { var layout = new HorizontalLayout("box").AddTo(verticalLayout); //new BoxView(item.name).BackgroundColor(item.color.ToColor()).AddTo(layout); new CategoryComponent(item).AddTo(layout); new FlexibleSpaceView().AddTo(layout); new ImageButtonView(ImageButtonIcon.editorIcon, () => OpenSubWindow(item)) .Width(25).Height(25).BackgroundColor(Color.black).AddTo(layout); new ImageButtonView(ImageButtonIcon.deleteIcon, () => { ToDoDataManager.RemoveToDoCategory(item); UpdateToDoItems(); }) .Width(25).Height(25).BackgroundColor(Color.red).AddTo(layout); } }
private void SaveOrCreateEvent() { ToDoListMainWindow.instance.Focus(); if (isCreate) { ToDoFeature feature = new ToDoFeature(nameInputView.Content, descInputView.Content); if (productParent != null) { productParent.features.Add(feature); } else { featureOrParent.childFeatures.Add(feature); } inputView.AddNewToView(feature); } else { featureOrParent.name = nameInputView.Content.Val; featureOrParent.description = descInputView.Content.Val; inputView.RefreshFoldoutViewContent(); } ToDoDataManager.Save(); }
private void DeleteItemNote(ToDoNote note) { EnqueueCmd(() => { ToDoDataManager.RemoveToDoNote(note); UpdateList(); }); }
private void AddFoldoutItem(ToDoCategory category, string todoName) { EnqueueCmd(() => { var item = ToDoDataManager.CreateToDoItem(todoName, false, category, productVersion.id); ToDoDataManager.AddProductToDoItem(productVersion, item); AddToDoToFoldoutView(item); RefreshStateWithView(); }); }
private void DeleteFeature() { if (parentView.isHeader) { parentView.product.features.Remove(currentFeature); } else { parentView.currentFeature.childFeatures.Remove(currentFeature); } ToDoDataManager.Save(); EnqueueCmd(() => parentView.featureDetailView.Remove(this)); }
private void AddToDoToFoldoutView(ToDoData todoItem) { var itemToDoView = new ToDoListItemView(todoItem, (_) => RefreshStateWithView()); itemToDoView.deleteAct = (_) => { EnqueueCmd(() => { ToDoDataManager.RemoveProductToDoItem(productVersion, todoItem); foldoutView.RemoveFoldoutView(itemToDoView); }); }; foldoutView.AddFoldoutView(itemToDoView); }
private void SaveProduct(string productName, string productDescription) { if (todoProduct == null) { ToDoDataManager.AddProduct(productName, productDescription); } else { todoProduct.name = productName; todoProduct.description = productDescription; ToDoDataManager.Save(); } productView.Rebuild(); Close(); }
public ToDoListNoteEditorView(Action saveAction, Action closeAction) { Style = "box"; new LabelView("笔记编辑器") .TextMiddleCenter() .FontBold() .FontSize(40) .AddTo(this); textEditor = new TextAreaView(string.Empty) .Height(130) .ExpandHeight(true) .AddTo(this); new ButtonView("保存", () => { if (note == null) { ToDoDataManager.AddToDoNote(textEditor.Content.Val); } else { note.content = textEditor.Content.Val; ToDoDataManager.Save(); } EditorGUI.FocusTextInControl(null); saveAction(); note = null; }, true) .AddTo(this); new ButtonView("关闭", () => { EditorGUI.FocusTextInControl(null); closeAction(); note = null; }, true) .AddTo(this); }
public void SaveProduct() { if (productVersion != null) { productVersion.name = productName; productVersion.version.SetVersion(todoVersion); productView.RefreshProductFoldoutDetailView(); } else { var version = new ToDoProductVersion() { name = productName, version = todoVersion }; todoProduct.versions.Add(version); productView.CreateAndInsertProductVersion(version); } ToDoDataManager.Save(); Close(); ToDoListMainWindow.instance.Focus(); }
public void ResetWindow(ToDoCategory item = null) { if (item == null) { textAreaView.Content.Val = string.Empty; colorView.ColorProperty.Val = Color.black; changeButton.Text = "添加"; changeButton.OnClickEvent = () => { var data = ToDoDataManager.Data; if (data.categoryList.All(x => x.name != textAreaView.Content.Val)) { ToDoDataManager.AddToDoCategory(textAreaView.Content.Val, colorView.ColorProperty.Val.ToText()); listView.UpdateToDoItems(); Close(); } }; } else { textAreaView.Content.Val = item.name; colorView.ColorProperty.Val = item.color.ToColor(); changeButton.Text = "修改"; changeButton.OnClickEvent = () => { item.name = textAreaView.Content.Val; item.color = colorView.ColorProperty.Val.ToText(); ToDoDataManager.Data.Save(); listView.UpdateToDoItems(); Close(); }; } }
public void ResetWindow(ToDoData item) { var data = ToDoDataManager.Data; contentTextArea.Content.Val = item.content; bool isHide = item.isHide; showHideButton.Text = isHide ? "显示" : "隐藏"; showHideButton.OnClickEvent = () => { isHide = !isHide; showHideButton.Text = isHide ? "显示" : "隐藏"; //itemView.UpdateItem(); //Close(); }; if (data.categoryList.Count > 0) { var index = ToDoDataManager.ToDoCategoryIndexOf(item.category); enumPopupView.ValueProperty.Val = index < 0 ? 0 : index; enumPopupView.MenuArray = data.categoryList.Select(category => category.name).ToArray(); } saveButton.OnClickEvent = () => { item.isHide = isHide; item.content = contentTextArea.Content.Val; item.category = data.categoryList[enumPopupView.ValueProperty.Val]; ToDoDataManager.Save(); itemView.UpdateItem(); Close(); }; }
private void AddAction(ToDoCategory category, string _todoName) { ToDoDataManager.AddToDoItem(_todoName, false, category); UpdateToDoItems(); }
public void BuildItem() { container.Clear(); if (data.state == ToDoData.ToDoState.NoStart) { var startBtn = new ImageButtonView(ImageButtonIcon.playIcon, () => { data.startTime = DateTime.Now; data.state.Val = ToDoData.ToDoState.Started; //改变了state会自动储存 UpdateItem(); }).Height(20).Width(40).BackgroundColor(Color.green); container.Add(startBtn); } else if (data.state == ToDoData.ToDoState.Started) { var finishedBtn = new ImageButtonView(ImageButtonIcon.finishIcon, () => { data.finishTime = DateTime.Now; data.state.Val = ToDoData.ToDoState.Done; UpdateItem(); }).Height(20).Width(40).BackgroundColor(Color.green); container.Add(finishedBtn); } else if (data.state == ToDoData.ToDoState.Done) { var resetBtn = new ImageButtonView(ImageButtonIcon.resetIcon, () => { data.createTime = DateTime.Now; data.state.Val = ToDoData.ToDoState.NoStart; UpdateItem(); }).Height(20).Width(40).BackgroundColor(Color.grey); container.Add(resetBtn); } var boxView = new BoxView("无").AddTo(container) .TextMiddleCenter().Width(20).FontSize(12) .FontColor(Color.white).FontBold(); new CategoryComponent(data.category).AddTo(container); var contentLabel = new LabelView(data.content).Height(20).FontSize(15).TextMiddleCenter(); container.Add(contentLabel); if (showTime) { new LabelView(data.finishTime.ToString("完成于 HH:mm:ss")) .Height(20).Width(80).TextMiddleLeft().FontBold(); new LabelView(data.UsedTimeText) .Height(20).Width(100).TextMiddleLeft().AddTo(container); } var priorityVal = data.priority.Val; Color priorityColor = Color.clear; switch (priorityVal) { case ToDoData.ToDoPriority.A: boxView.Context = "A"; priorityColor = Color.red; boxView.BackgroundColor(Color.red); break; case ToDoData.ToDoPriority.B: boxView.Context = "B"; priorityColor = Color.yellow; boxView.BackgroundColor(Color.yellow); break; case ToDoData.ToDoPriority.C: boxView.Context = "C"; priorityColor = Color.cyan; boxView.BackgroundColor(Color.cyan); break; case ToDoData.ToDoPriority.D: boxView.Context = "D"; priorityColor = Color.blue; boxView.BackgroundColor(Color.blue); break; case ToDoData.ToDoPriority.None: boxView.Context = "无"; priorityColor = Color.gray; boxView.BackgroundColor(Color.gray); break; } var priority = new EnumPopupView <ToDoData.ToDoPriority>(priorityVal) .Width(30).Height(20).BackgroundColor(priorityColor).AddTo(container); priority.ValueProperty.RegisterValueChanged((val) => { data.priority.Val = val; switch (val) { case ToDoData.ToDoPriority.A: boxView.Context = "A"; priority.BackgroundColor(Color.red); boxView.BackgroundColor(Color.red); break; case ToDoData.ToDoPriority.B: boxView.Context = "B"; priority.BackgroundColor(Color.yellow); boxView.BackgroundColor(Color.yellow); break; case ToDoData.ToDoPriority.C: boxView.Context = "C"; priority.BackgroundColor(Color.cyan); boxView.BackgroundColor(Color.cyan); break; case ToDoData.ToDoPriority.D: boxView.Context = "D"; priority.BackgroundColor(Color.blue); boxView.BackgroundColor(Color.blue); break; case ToDoData.ToDoPriority.None: boxView.Context = "无"; priority.BackgroundColor(Color.gray); boxView.BackgroundColor(Color.gray); break; } UpdateItem(); }); new ImageButtonView(ImageButtonIcon.editorIcon, () => { OpenSubWindow(); }) .Width(25).Height(25).BackgroundColor(Color.black).AddTo(container); var deleteBtn = new ImageButtonView(ImageButtonIcon.deleteIcon, () => { data.finished.ClearValueChanged(); ToDoDataManager.RemoveToDoItem(data); deleteAct?.Invoke(data); UpdateItem(); }).Height(25).Width(25).BackgroundColor(Color.red); container.Add(deleteBtn); }
private void ConvertToDoNote(ToDoNote note, bool isHide) { listView.UpdateList(); ToDoDataManager.ConvertToDoNote(note, isHide); }