Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions pixart/ColorlevelColoring.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion pixart/ColorlevelColoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public enum DifficultyLevel { Easy, Medium, Hard, VeryHard } // 도안 생성

private bool isPatternGenerated = false; // 도안 생성 여부 체크용

private Stack<ColoringAction> undoStack = new Stack<ColoringAction>();
private Stack<ColoringAction> redoStack = new Stack<ColoringAction>();



Expand Down Expand Up @@ -88,7 +90,7 @@ private void btnGenerate_Click(object sender, EventArgs e)
return;
}

// 이미 도안이 있다면 사용자 확인
// 이미 도안이 있다면 사용자 확인
if (isPatternGenerated)
{
DialogResult overwrite = MessageBox.Show(
Expand Down Expand Up @@ -552,6 +554,10 @@ private void panelCanvas_MouseClick(object sender, MouseEventArgs e)
isFilled[y, x] = true;
filledColors[y, x] = selectedColor;

Color prevColor = filledColors[y, x]; // 기존 색 저장
undoStack.Push(new ColoringAction(x, y, prevColor, selectedColor)); // 행동 기록
redoStack.Clear(); // 새 행동 시 Redo 초기화

if (paintedResultBitmap != null &&
x >= 0 && x < paintedResultBitmap.Width &&
y >= 0 && y < paintedResultBitmap.Height)
Expand Down Expand Up @@ -1396,6 +1402,23 @@ private void tsButtonGridLoad_Click(object sender, EventArgs e)
}
}

// 색칠된 좌표, 원래 색상 기억
public class ColoringAction
{
public int X { get; set; }
public int Y { get; set; }
public Color PreviousColor { get; set; }
public Color NewColor { get; set; }

public ColoringAction(int x, int y, Color prev, Color curr)
{
X = x;
Y = y;
PreviousColor = prev;
NewColor = curr;
}
}


//그리드 저장하기용 클래스
public class GridSaveData
Expand Down
Loading