forked from Karimgebril09/Paint-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddhexagonaction.cpp
More file actions
64 lines (51 loc) · 1.49 KB
/
Addhexagonaction.cpp
File metadata and controls
64 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include"Addhexagonaction.h"
#include "CHexagon.h"
#include<Windows.h>
#include<mmsystem.h>
#include"ApplicationManager.h"
#include "GUI/Input.h"
#include "GUI/Output.h"
AddhexaAction::AddhexaAction(ApplicationManager* pApp) :Action(pApp)
{
if (UI.sound)//play sound when dawing hexagon
PlaySound(TEXT("hexagon-select"), NULL, SND_SYNC);
}
void AddhexaAction::ReadActionParameters()
{
//Get a Pointer to the Input / Output Interfaces
Output* pOut = pManager->GetOutput();
Input* pIn = pManager->GetInput();
pOut->PrintMessage("New Hexagone: Click at any point");
//Read center and store in point P1
pIn->GetPointClicked(p1.x, p1.y);
hexaGfxInfo.isFilled = UI.isfilled; //default is not filled
//get drawing, filling colors and pen width from the interface
hexaGfxInfo.DrawClr = pOut->getCrntDrawColor();
hexaGfxInfo.FillClr = pOut->getCrntFillColor();
pOut->ClearStatusBar();
}
//Execute the action
bool AddhexaAction::Execute(bool readparams )
{
//This action needs to read some parameters first
if (readparams == true)
ReadActionParameters();
//Create a hexagon with the parameters read from the user
CHexagon* hex = new CHexagon(p1,hexaGfxInfo);
//Add the hexagon to the list of figures
pManager->AddFigure(hex);
pManager->UpdateInterface(); //update interface before playing the sound
if (UI.sound)
PlaySound(TEXT("hexagon-sound"), NULL, SND_SYNC);
return false;
}
bool AddhexaAction::record_me() const
{
return true;
}
void AddhexaAction::Undo()
{
}
void AddhexaAction::Redo()
{
}