OSDN Git Service

SSTFEditor, StrokeStyle<T> を SSTFormat v3 に移行。
[strokestylet/CsWin10Desktop3.git] / SSTFEditor / クリップボード.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using SSTFormat.v3;
5
6 namespace SSTFEditor
7 {
8         class クリップボード
9         {
10                 public int セル数
11                 {
12                         get
13                                 => this.セルリスト.Count;
14                 }
15
16
17                 public クリップボード( メインフォーム form )
18                 {
19                         this.Form = form;
20                 }
21
22                 public void クリアする()
23                 {
24                         this.セルリスト.Clear();
25                 }
26
27                 public void 現在選択されているチップをボードにコピーする()
28                 {
29                         this.クリアする();
30
31                         foreach( var chip in this.Form.譜面.SSTFormatScore.チップリスト )
32                         {
33                                 if( chip.選択が確定している )
34                                 {
35                                         this.セルリスト.Add(
36                                                 new Cセル() { チップ = new チップ( chip ) } );
37                                 }
38                         }
39                 }
40
41                 public void チップを指定位置から貼り付ける( int 貼り付け先頭の譜面内絶対位置grid )
42                 {
43                         if( 0 == this.セル数 )
44                                 return;
45
46                         try
47                         {
48                                 this.Form.UndoRedo管理.トランザクション記録を開始する();
49
50                                 // すべてのセルについて、チップ位置を、ボード内でもっとも位置が前にあるセルを 0grid とした相対値に変換する。
51                                 int 最小値grid = this.セルリスト[ 0 ].チップ.譜面内絶対位置grid;
52                                 foreach( var cell in this.セルリスト )
53                                 {
54                                         if( cell.チップ.譜面内絶対位置grid < 最小値grid )
55                                                 最小値grid = cell.チップ.譜面内絶対位置grid;
56                                 }
57                                 foreach( var cell in this.セルリスト )
58                                         cell.チップ.譜面内絶対位置grid -= 最小値grid;
59
60                                 // すべてのセルについて、チップ位置を、実際に貼り付ける位置に変換する。
61                                 foreach( var cell in this.セルリスト )
62                                         cell.チップ.譜面内絶対位置grid += 貼り付け先頭の譜面内絶対位置grid;
63
64                                 // チップを譜面に貼り付ける。
65                                 foreach( var cell in this.セルリスト )
66                                 {
67                                         this.Form.譜面.チップを配置または置換する(
68                                                 this.Form.譜面.dicチップ編集レーン対応表[ cell.チップ.チップ種別 ],
69                                                 cell.チップ.チップ種別,
70                                                 cell.チップ.譜面内絶対位置grid,
71                                                 cell.チップ.チップ内文字列,
72                                                 cell.チップ.音量,
73                                                 cell.チップ.BPM,
74                                                 選択確定中: true );
75                                 }
76                         }
77                         finally
78                         {
79                                 this.Form.UndoRedo管理.トランザクション記録を終了する();
80
81                                 this.Form.UndoRedo用GUIのEnabledを設定する();
82                                 this.Form.選択チップの有無に応じて編集用GUIのEnabledを設定する();
83                                 this.Form.譜面をリフレッシュする();
84                                 this.Form.未保存である = true;
85                         }
86                 }
87
88
89                 protected class Cセル
90                 {
91                         public bool 貼り付け済み = false;
92                         public int グループID = 0;
93                         public チップ チップ = null;
94                 }
95
96                 protected メインフォーム Form;
97
98                 protected readonly List<Cセル> セルリスト = new List<Cセル>();
99         }
100 }