diff --git a/SinTachiePlugin/Parts/PartsListControllerViewModelBase.cs b/SinTachiePlugin/Parts/PartsListControllerViewModelBase.cs index 69dae62..5e595da 100644 --- a/SinTachiePlugin/Parts/PartsListControllerViewModelBase.cs +++ b/SinTachiePlugin/Parts/PartsListControllerViewModelBase.cs @@ -25,12 +25,15 @@ public abstract class PartsListControllerViewModelBase : Bindable, INotifyProper public event EventHandler? BeginEdit; public event EventHandler? EndEdit; + /// + /// パーツブロックのリストの内容 + /// public ImmutableList Parts { get => parts; set => Set(ref parts, value); } ImmutableList parts = []; - public bool PartsPopupIsOpen { get => partsPopupIsOpen; set => Set(ref partsPopupIsOpen, value); } - bool partsPopupIsOpen = false; - + /// + /// リストで選択されているパーツブロックのインデックス + /// public int SelectedPartIndex { get => selectedPartIndex; @@ -42,6 +45,15 @@ public int SelectedPartIndex } int selectedPartIndex = -1; + /// + /// リスト内のいずれかのパーツブロックが選択されている状態か否か + /// + public bool SomeBlockSelected { get => someBlockSelected; set => Set(ref someBlockSelected, value); } + bool someBlockSelected = false; + + /// + /// 右クリックメニューで「切り取り」を選択したときの処理 + /// public void ScissorsFunc() { BeginEdit?.Invoke(this, EventArgs.Empty); @@ -50,19 +62,26 @@ public void ScissorsFunc() EndEdit?.Invoke(this, EventArgs.Empty); } + /// + /// 右クリックメニューで「コピー」を選択したときの処理 + /// public void CopyFunc() { clipedBlock = new(Parts[SelectedPartIndex]); } - public bool SomeBlockSelected { get => someBlockSelected; set=>Set(ref someBlockSelected, value); } - bool someBlockSelected = false; - + /// + /// 右クリックメニューで「貼り付け」が選択可能か否か + /// public bool PasteEnable { get => pasteEnable; set => Set(ref pasteEnable, value); } bool pasteEnable = false; + + /// + /// 右クリックメニューで「貼り付け」を選択したときの処理 + /// public void PasteFunc() { - if(clipedBlock == null) + if (clipedBlock == null) { string className = GetType().Name; string? mthName = MethodBase.GetCurrentMethod()?.Name; @@ -76,24 +95,35 @@ public void PasteFunc() if (tmpSelectedIndex < 0) { Parts = Parts.Add(new PartBlock(clipedBlock)); - SelectedPartIndex = Parts.Count - 1; + tmpSelectedIndex = Parts.Count - 1; } else { Parts = Parts.Insert(tmpSelectedIndex, new PartBlock(clipedBlock)); - SelectedPartIndex = tmpSelectedIndex; } SetProperties(); + SelectedPartIndex = tmpSelectedIndex; + EndEdit?.Invoke(this, EventArgs.Empty); } + /// + /// 右クリックメニューで「複製」を選択したときの処理 + /// public void DuplicationFunc() { BeginEdit?.Invoke(this, EventArgs.Empty); - DuplicationPartBlock(); + var tmpSelectedIndex = SelectedPartIndex; + var copied = new PartBlock(Parts[SelectedPartIndex]); + Parts = Parts.Insert(tmpSelectedIndex, new PartBlock(copied)); + SetProperties(); + SelectedPartIndex = tmpSelectedIndex + 1; EndEdit?.Invoke(this, EventArgs.Empty); } + /// + /// 右クリックメニューで「削除」を選択したときの処理 + /// public void RemoveFunc() { BeginEdit?.Invoke(this, EventArgs.Empty); @@ -101,6 +131,9 @@ public void RemoveFunc() EndEdit?.Invoke(this, EventArgs.Empty); } + /// + /// 右クリックメニューが開かれている状態か否か + /// public bool ContextMenuIsOpen { get => contextMeneIsOpen; @@ -112,6 +145,9 @@ public bool ContextMenuIsOpen } bool contextMeneIsOpen = false; + /// + /// DirectorySelector「素材の場所」のパス + /// public string Root { get => root; @@ -119,8 +155,21 @@ public string Root } string root = string.Empty; + /// + /// パーツ選択ツリーの内容 + /// public List PartNameTree { get => partNameTreeNode; set => Set(ref partNameTreeNode, value); } List partNameTreeNode = []; + + /// + /// パーツ選択ツリーが表示されているか否か + /// + public bool PartsPopupIsOpen { get => partsPopupIsOpen; set => Set(ref partsPopupIsOpen, value); } + bool partsPopupIsOpen = false; + + /// + /// パーツ選択ツリーの選択されている項目 + /// public object SelectedTreeViewItem { get => _selectedTreeViewItem; @@ -180,7 +229,7 @@ public object SelectedTreeViewItem SinTachieDialog.ShowWarning("パーツ追加時にエラーが発生しました" + "\n" + e.Message); } - } + } } } private object _selectedTreeViewItem = new PartNameTreeNode(); @@ -219,11 +268,11 @@ public PartsListControllerViewModelBase(ItemProperty[] properties) PartNameTree = new PartNameTreeNode(di).Children; } - if(PartNameTree.Count == 0 || RootUnexist) + if (PartNameTree.Count == 0 || RootUnexist) { var intro = RootUnexist ? "素材の場所のパスが無効です。" : "素材の場所にパーツが見つかりませんでした。"; var dialog = SinTachieDialog.GetDialog($"{intro}\n画像未指定のパーツブロックを追加しますか?"); - if(dialog == DialogResult.OK) + if (dialog == DialogResult.OK) { var tmpSelectedIndex = SelectedPartIndex; BeginEdit?.Invoke(this, EventArgs.Empty); @@ -235,7 +284,7 @@ public PartsListControllerViewModelBase(ItemProperty[] properties) while (tags.Contains($"{tag}({sideNum})")) sideNum++; tag += $"({sideNum})"; } - if(tmpSelectedIndex < 0) + if (tmpSelectedIndex < 0) { Parts = Parts.Add(new PartBlock("", tag, tags.ToArray())); SelectedPartIndex = Parts.Count - 1; @@ -358,23 +407,6 @@ private void RemovePartBlock() else SelectedPartIndex = -1; } - private void DuplicationPartBlock() - { - var tmpSelectedIndex = SelectedPartIndex; - var copied = new PartBlock(Parts[SelectedPartIndex]); - if (tmpSelectedIndex < 0) - { - Parts = Parts.Add(new PartBlock(copied)); - SelectedPartIndex = Parts.Count - 1; - } - else - { - Parts = Parts.Insert(tmpSelectedIndex, new PartBlock(copied)); - SelectedPartIndex = tmpSelectedIndex; - } - SetProperties(); - } - public abstract void SetProperties(); private void Item_PropertyChanged(object? sender, PropertyChangedEventArgs e)