Upload
nhat-tran-minh
View
230
Download
0
Embed Size (px)
Citation preview
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
1/38
I HC QUC GIA THNH PH H CH MINH
TRNG I HC CNG NGH THNG TIN
KHOA KHOA HC MY TNH
BI BO CO
N MN LP TRNH TR!C QUAN
N" #NG $%NG PIANO &IMULATOR
Lp: IT008.G22
GVHD: Hunh Tun Anh
NHM TH:
1 Trn Minh Nht 1!20!8
2 "h#$ %&' Tri(t 1!20)28
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
2/38
T".H* %h+ Minh, th-n 1 n/$ 201
'( C)*+,- I" G./. 0).12 34 56n $7t n 59n h'n ;h $7t ?n pi&n'. 34 56n tr@n nn tBn Cin'r$ %E. D6& tr@n Futt'n t4 ;h; n.
3( C)*+,- II" T).40 54 P.6,7 589:76;Zn t6 % DO, D
O, E, G AO
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
3/38
3(3( T).40 51 ?@0 K89
Thi(t ( ;b& M&inJ4 W SuOJ4 W ;Z OBn in nh&u ;h< h-; nh&u $u YP;
W +;h th>;.
M7t J4 Ya ?>; ;u t#' tX 2 thnh phn: $7t h^nh ;h\ nht $ 'utinJ W $7t
h^nh ;h\ nht nhc hZn nd$ e ;h+nh i\& $ nn:
M7t $&in J4 Ya ;= $u ;Z OBn : ?>fn Win Gr&4, nn ChitJ g ;n ?i Wi
YuOJ4 Ya : ?>fn Win Gr&4, nn F&;.
i Wi nh\n YuOJ4 ;= n'tJ % th^ Ya ?>; Wa th@$ + t6 % @n tr@n J4 ?
n>fi 5n 5_ 5n j-; ?Unh ?>; ;-; n'tJ tr@n t'n O7 J4O'&r5:
%'5J:
//nh ngha kiu enum KindOfKey xc nh loi ca keynote
publicenumKindOfKey !" #" $" %" &" '" (" #b" %b" &b" ')" !b*+
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
4/38
//nh ngha kiu enum Key)tate xc nh t,ng thi ca keynote
publicenumKey)tate -one" .,e" 0o1e,*+
//nh ngha c2u t,3c m4t Keynode
publict,uctKey-ote
publicKey)tatetate+ //5,ng thi ca key
publicintindex+ //index ca key
publicintkbm+ //bi6n xc nh m7 8idi pht ti6ng t9:ng ;ng 1n n?
publicKindOfKeykindkey+ //@oi Keynote
*+
H$ nhn W' $7t ?i t>n Gr, WU tr+ Wa, W ;-; ?7 5i , k.
p,i1ate1oid%,aAOneKeyB(,aphicg" Coat@ocationD" Coat@ocationE" Coat@engthD" Coat
@engthE" $olo,outline" $olo,back$olo,F
//1G outline
uingB(,aphic.ath#ackKey H IoundIectBneAIectangle'B@ocationD" @ocationE"
@engthD" @engthEF" J" J" J" JFF
)olid#,uhb H neA)olid#,uhBoutlineF+
g'ill.athBb" #ackKeyF+
*
//1G m4t phLm
uingB(,aphic.ath8ainKey H IoundIectBneAIectangle'BB@ocationD M NN' P
@engthDF" @ocationE M NN' P @engthE" NQN' P @engthD" NRQ' P @engthEF" J" J" J" JFF
)olid#,uhb H neA)olid#,uhBback$olo,F+ g'ill.athBb" 8ainKeyF+
*
*
3(( T).40 54 .6,7 589:76;
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
5/38
M7t pi&n' J4O'&r5 ?>; ;hi& $ h&i phn
J4O'&r5 "rJWiJl
2..1. J4O'&r5
M7t J4O'&r5 5m4 i@n t9; t9; ;-; ph+$ M&inJ4, W ;-; ph+$ SuOJ4 e tr@n
t>Zn n Wi M&inJ4:
%-; M&inJ4 Ya ?>; Wa tr>;, Y&u ?= Ya Wa ;-; SuOJ4 @n Y&u t>Zn n Wi M&inJ4
$ ;h& n=. %-; M&inJ4 Ya ;= 0 in5Jj !1 W SuOJ4 ;= !2 in5Jj
8 , W $oi M&inJ4 Ya >u #i in5Jj ;b& SuOJ4 $ n= ;h& Qn(u ;=R.
Th6; t( t& n>fi 5n ;= th 6& ;hn Y J4 Ya jut hi]n Qq&nJ "rJWiJl Ya n=i
e phn Y&uR, Wi]; Wa ;-; J4 Ya 56& W' Y >n ;-; J4 ?=.
j-; ?Unh WU tr+ $ M&inJ4 Ya jut hi]n @n tr@n J4O'&r5 th^ t& Ya 4:
LocationX=(indexRange [0 ])Width
Range [1 ]Range [0 ]
Tr'n ?=:
L';&ti'n : WU tr+ thJ' t& ?7 ;b& J4 ?&n jt
In5Jj: in5Jj ;b& J4 ?&n jt
q&nJs0 : in5Jj ;b& J4 Ya jut hi]n ?u ti@n
q&nJs0 : in5Jj ;b& J4 Ya jut hi]n ;ui ;n
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
6/38
Ci5th: ;hiu r7n ;b& pi&n' J4O'&r5
Width
Range [1 ]Range [0 ] Ya ?7 r7n ;b& $7t M&inJ4 QLJnthR
%n ?7 5i ;b& J4 Ya Odn LengthY=3
4Height QHJiht ;hiu ;&' ;b& pi&n'
J4O'&r5R
L';&ti'nk Ya Odn 0g
%'5J: p,i1ate1oid%,aA8ainKeyb,oadB(,aphicgF
int,ange H IangeST U IangeSNT M + //5Lnh tVng W Keynote 9Xc hin th
Coat@engthD H thiYidth / BCoatF,ange+ //@2y 4 dZi theo D ca Key
Coat@engthE H N[\' P thi0eight+ //@2y d4 dZi theo E ca Key
Coat@ocationE]Key H N+
$olo,outline+
$olo,back$olo,+
//1G cc key note n=m t,ong ,ange 1ieA
fo,Binti H IangeSNT+ i ^ IangeST M + iMMF
//8Zu m_c nh
back$olo, H $olo,Yhite+
outline H $olo,(,ay+
//8Zu khi 0o1e, ho_c .,e
ifBKey#oa,dSiTtate HH Key)tate0o1e,F
outline H $olo,Yhite+
ifBKey#oa,dSiTtate HH Key)tate.,eF
back$olo, H back$olo,.,e+
outline H outline$olo,.,e+
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
7/38
*
//`G 8ain Keynote
%,aAOneKeyBg" Bi U IangeSNTF P @engthD" @ocationE]Key" @engthD" @engthE" outline"
back$olo,F+
//-hng keynote nZo thu4c KindO'Key$ th G 9Xc 1 kL t $ l>n t,>n
inttemp H Bi / [F+
ifBKey#oa,dSiTkindkey HH KindOfKey$F
Coatfontie+
ifB,ange JNF
fontie H N\' P @engthD+
ele
fontie H N\' P BthiYidth / JN'F+
'onttemp'ont H neA'ontB$anda,a" fontie" 'ont)tyle#oldF+
)ie5extie H5extIende,e,8eau,e5extB$M temp5o)t,ingBF " temp'ontF+
g%,aA)t,ingB$M temp5o)t,ingBF" temp'ont" neA)olid#,uhB$olo,)il1e,F" BBi U
IangeSNTF P @engthDF M B@engthD / BCoatFF U B5extieYidth / BCoatF\F" N\' P thi0eightF+
*
*
*
S&u hi ?m Wa ;-; M&inJ4 t& Ya Wa SuOJ4 56& W' ;-; M&inJ4g SuOJ4 Ya nd$
W ph+& O@n phBi ;b& M&inJ4 ;h& n= Y&' ;h' n= nd$ ;h+nh i\& h&i M&inJ4
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
8/38
j-; ?Unh WU tr+ ;b& YuOJ4, t& Ya 5u4]t thJ' M&inJ4 nd$ tr'n q&nJViJl W
jJ$ nh\n M&inJ4 n' ;= ;h& SuOJ4 th^ Wa SuOJ4 ?= @n WU trU M&inJ4 ?=
GiB Y t& ?m ;= in5Jj ;b& M&inJ4 $ ;h& SuOJ4 ;n Wa, th^ WU trU ;b& SuOJ4
Ya :
Location XSubkey=(indexRange [0 ]+1 )LengthX1
2Length XSubkey
Tr'n ?=
In5Jj : in5Jj ;u& M&inJ4 ;h& SuOJ4 ;n Wa
LJnth : ?7 r7n ;b& M&inJ4
LJnthSuOJ4 : ?7 r7n ;b& SuOJ4 Q?7 r7n ;b&
Subkey=Width
21
13(Range [1 ]Range [0 ]) R
L';&ti'nk ;b& YuOJ4 Ya Odn 0.
%'5J:
p,i1ate1oid%,aA)ubKeyboa,dB(,aphicgF
int,ange H IangeST U IangeSNT M + //5Lnh tVng W key 9Xc hin th
Coat@ocationD]ubKey H Yidth / BCoatF,ange+ //@2y 1 t,L 1G ubkey
Coat@engthD]ubKey]'ull H thiYidth / BCoatFBP,ange/J'F+ //@2y 4 dZi theo D ca
ubkey Coat@engthE]ubKey]'ull H N\' P thi0eight+ //@2y 4 dZi theo E ca
ubkey
Coat@ocationE]ubKey H N+
Coat@engthD]ubKey H N[J' P BthiYidth / BCoatFQjF+ // dZi theo D ca phn
nn
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
9/38
Coat@engthE]ubKey H NRN' P BN\' P thi0eightF+ //4 dZi theo E ca phn
nn
$olo,outline+
$olo,back$olo,+
fo,Binti H IangeSNT+ i ^ IangeST M + iMMF
ifBi ^ \F //8ainkey th; \ khng ch;a ubkey
outline H $olo,(,ay+
back$olo, H $olo,#lack+
inttemp H i [+
ifBtemp HH N temp HH temp HH J temp HH \ temp HH F // kim t,a
nhng main key nZo ch;a ub key
ifBKey#oa,dSKey#oa,dSiTindex)ubkeyTtate HH Key)tate.,eF
back$olo, H back$olo,.,e+
outline H outline$olo,.,e+
*
ifBKey#oa,dSKey#oa,dSiTindex)ubkeyTtate HH Key)tate0o1e,F
outline H $olo,#lack+
*
//`G ub key
%,aAOneKeyBg" Bi U IangeSNT M F P @ocationD]ubKey U @engthD]ubKey]'ull /
BCoatF" @ocationE]ubKey" @engthD]ubKey]'ull" @engthE]ubKey]'ull" outline" back$olo,F+
*
*
*
*
3((3( P;8.8D
"rJWiJl Wn Oiu 5i_n ;h' t'n O7 J4O'&r5 ;n Wi $7t Wn q&nJViJl
QWn $u WnR ? Oi_u 5i_n Wn $ J4O'&r5 th hi]n
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
10/38
q&nJ $Bn Ya >u i- trU ;b& q&nJViJl n4, t>n n Wi q&nJs0 Ya >u
in5Jj ?u W q&nJs1 Ya >u in5Jj ;ui ;n.
Wa "rJWiJl ;vn t>Zn t6 nh> Wa J4O'&r5 nh>n nhc hZn
%'5J:
p,i1ate1oid%,aA.,e1ieAB(,aphicgF
//59:ng t nh9 1G ub key 1Z main key" nh9ng lZ 1G li toZn b4 key
CoattempD H thiYidth / \'+
CoattempE H BNj' P thi0eightF+
Coat@ocationE H N[\' P thi0eight+
Coat@engthD]ubKey H thiYidth / BCoatFQj'+
Coat@engthE]ubKey H N[' P BNj' P thi0eightF+
fo,Binti H N+ i ^ \+ iMMF
%,aAOneKeyBg" BCoatFi P tempD" @ocationE" tempD" tempE" $olo,(,ay" $olo,YhiteF+
*
fo,Binti H N+ i ^ \+ iMMF
inttemp H i [+
ifBtemp HH N temp HH temp HH J temp HH \ temp HH F
%,aAOneKeyBg" Bi M F P tempD U @engthD]ubKey / BCoatF" @ocationE"
@engthD]ubKey" @engthE]ubKey" $olo,(,ay" $olo,#lackF+
*
*
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
11/38
//`G Iange .,e1ieA
int,ange H IangeST U IangeSNT M +
Iectangle'ST ,ect H neAIectangle'ST+
,ectSNT H neAIectangle'BIangeSNT P'ull@engthD]8ainKey" @ocationE" ,ange P tempD"
tempEF+
,ectST H neAIectangle'BIangeSNT P 'ull@engthD]8ainKey M highlight.,e`ieA/'"
@ocationE M highlight.,e`ieA/'" ,ange P tempD U highlight.,e`ieA" tempE U highlight.,e`ieAF+
uingB(,aphic.ath#ackKey H neA(,aphic.athBFF
#ackKey!ddIectangleB,ectF+
)olid#,uhb H neA)olid#,uhB,ange.,e1ieA$olo,].,e1ieAF+
g'ill.athBb" #ackKeyF+
*
*
S6 i]n wn"&int Ya Wa tt ;B ;-; H$ Wa tr@n
%'5J:p,otectedo1e,,ide1oidOn.aintB.aint&1ent!,geF
baeOn.aintBeF+
e(,aphic)moothing8ode H )moothing8ode!nti!lia+
e(,aphicqnte,polation8ode H qnte,polation8ode0ighruality#icubic+
ifBback#use, HH nullF
back#use, H neA#itmapBthi$lient)ieYidth" thi$lient)ie0eightF+
*
(,aphicg H null+
g H (,aphic',omqmageBback#use,F+
g$lea,B$olo,',om!,gbBjQ" jQ" jQFF+
%,aA8ainKeyb,oadBgF+ //`G 8ain Key
%,aA)ubKeyboa,dBgF+ //`G )ub Key
ifB0ide.,e1ieA HH faleF //Kim t,a c? 1G .,e ieA khng
%,aA.,e1ieABgF+
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
12/38
g)moothing8ode H )moothing8ode!nti!lia+
g%ipoeBF+
e(,aphic%,aAqmagencaledBback#use," N" NF+
*
end,egion
( C)*+,- III" &E 5.1, F7, 0; F)2@0 5). ,), J, P.6,7 K89:76;; $7t Y6 i]n th^ ;-; j + Ya ;hi& $ h&i phn, $7t ;h' J4O'&r5, $7t
;h' "rJWiJl
('( &E 5.1, M78$7D,('('( 0;J, K89:76;; nhn th^ tr#n th-i ;b& n= Ya ;hu4n Y&n J4St&tJ."rJYY W J4 ?= Ya
?>; Wa #i Wi th#n th-i "rJYY, ?*n thfi ph-t r& ti(n ?n n Wi J4 ?=
+ tr@n J4O'&r5 ;vn ?>; ;hi& $ 2 phn:
TX tr@n ;n ;h' ti h(t SuOJ4 Qphn &R TX SuOJ4 ;h' ti h(t phn J4O'&r5 Qphn OR
+ tr@n phn O:
J4 ?>; nhn Ya ?>; j-; ?Unh Odn ;xn th; :
i=
Tr'n ?=
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
13/38
J. : WU tr+ ;hu7t thJ' t& ?7 j
LJnth : ?7 5i ;b& M&in J4
S&u ?= J4 Ya ?>; Wa #i Wi tr#n th-i "rJYY
i H BintFBeD / Btemp@engthDF M IangeSNTF+
Key#oa,dSiTtate H Key)tate.,e+
$u,,entKey H i+
+ tr@n phn &:
hi nhn (n phn & t& Ya Yt jJ$ ;= nhn @n SuOJ4 n' tr>; hxn r*i $i
jt ti M&inJ4
j-; ?Unh ?>; SuOJ4 n' ?>; nhn th^ t& j-; Ya t^$ in5Jj ;b& M&inJ4
n' $ ;h& SuOJ4 ?=.
T& ;n ?>& WU tr+ ;b& SuOJ4 ?= W #i tr@n M&inJ4 ;h& n=:
Fdn ;-;h ?>& ;'n trc ;hu7t W' h] `u4 ;hi(u tr@n Odn ;xn th;
tempeX=(float)e . X0.75 LengthX ;
S&u ?= j-; ?Unh in5Jj ;b& ;b& M&inJ4 56& W' WU tr+ ;'n trc ;hu7t $i:
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
14/38
tempeX
LengthXj=
Ti(p thJ' i$ tr& jJ$ WU tr+ ;'n trc ;hu7t ?&n nd$ tr@n SuOJ4 h&4 phn ;n#i ;b& M&inJ4
ifBtemp]eD ^ Bv P thiYidth / BCoatF,ange M thiYidth / B,angeP/J'FFF
N(u nh> ?m nhn @n WU tr+ SuOJ4 th^ ti(p t9; i$ tr& jJ$ e WU tr+ SuOJ4 ?= ;=
SuOJ4 n' hxn th^ ;hu4n tr#n th-i SuOJ4 ?>; nhn Y&n "rJYY
N(u nh> hxn nhn @n phn SuOJ4 h'[; hxn ;= SuOJ4 e WU tr+ ?= th^
M&inJ4 ;= in5Jj ti(p thJ' Ya ?>; ;hu4n Y&n tr#n th-i "rJYY.
V^ ?m ;hu4n ;'n trc ;hu7t Y&n h] `u4 ;hi(u h-; n@n J4 ?u ti@n e WU tr+
q&nJs0 ;h>& ?>; jt, J4 ?u ti@n ?>; nhn hi tJ$py z 0
('(3( 0;J, P;8.8D
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
15/38
hi nhn W' hu W6; q&nJ ViJl th^ Ya ;h' php th&4 ?{i WU q&nJViJl hi 5i
;hu4n ;hu7t
%'5J M'uYJD'ln WJnt:
int,ange H IangeST U IangeSNT M + //Dc nh tVng W keynote 9Xc hin th
inti+
Coattemp@engthD H thiYidth / BCoatF,ange+//5Lnh 4 ,4ng ca main key
ifBBeE ^H N\' P thi0eightF ww BeE H NFF //Kim t,a 1 t,L nh2n chu4t c? n=m t,ong
phn 0eight H N cho tn main key khng
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
16/38
ifBenable8ainKey HH t,ueF
Key#oa,dSv M IangeSNT M Ttate H Key)tate.,e+ //chuyn t,ng thi ang
.,e
$u,,entKey H v M IangeSNT M + //g{n key note nZy cho key hi|n
ti
8o1e&nable H t,ue+ //$ho ph}p l9n keyb,oad
.lay-oteB$u,,entKeyF+ //pht ti6ng t9:ng t 1n ca ,ange 1ieA
Key#oa,dSIangeSNTTtate H Key)tate.,e+
ifB$u,,entKey zH IangeSNTF
Key#oa,dS$u,,entKeyTtate H Key)tate-one+
$u,,entKey H IangeSNT+
8o1e&nable H t,ue+
.lay-oteB$u,,entKeyF+
*
*
ele
ifBeE N\' P thi0eight ww eE ^H N[\' P thi0eightF // nh2n 1Zo phn phLa d9
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
17/38
highlight.,e`ieA H N+
//(n cc 1 t,L ban u ca ,ange p,e1ieA cho cc bi6n
@ocationD]'i,t H eD+
@ocationIangeSNT H IangeSNT+
@ocationIangeST H IangeST+
*
*
*
thiqn1alidateBF+
*
(3( &E 5.1, M728M78"
hi 5i ;hu4n tr@n Wn J4O'&r5 th^ nh\n J4 n' e 5>i WU tr+ ;'n trc ;hu7t
Ya ;hu4n Y&n tr#n th-i H'WJr W n(u ?&n nhn ;hu7t th^ Ya ;hu4n Y&n "rJYY. V
;-; j
%-; j + tr@n Y6 i]n M'uYJM'WJ ;vn ?>; ;hi& $ h&i phn: J4O'&r5 W "rJWiJl
.2.1. + tr@n J4O'&r5
%-; j + W j-; ?Unh WU tr+ J4 ?>; nhn t>Zn t6 nh> Y6 i]n M'uYJD'ln, ;h; ;hu4n Y&n tr#n th-i H'WJr W n(u
nhn ;hu7t th^ Ya "rJYY.
[; Oi]t hi ;'n trc ;hu7t trc Y&n WU tr+ ;b& J4 h-; th^ J4 e 5>i ;'n trc ;hu7t Ya
;hu4n Y&n tr&n th-i t4 W' ;= nhn ;hu7t h&4 hxn, W J4 tr>; ?= Ya tre W tr#n
th-i N'nJ.
Key#oa,dSKey#oa,dSv M IangeSNTTindex)ubkeyTtate H temp)tate+
//Kim t,a c? thay Vi key hi|n ti khng
ifB$u,,entKey zH Key#oa,dSv M IangeSNTTindex)ubkeyF
)top-oteB$u,,entKeyF+ //d~ng pht ti6ng ca key note t,9
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
18/38
thiqn1alidateBF+
*
$u,,entKey H Key#oa,dSv M IangeSNTTindex)ubkey+
.2.2. + tr@n "rJWiJl
N(u nh> ?m nhn ;hu7t W' Wn q&nJViJl Qinq&nJViJl | truJR th^ ;h' php
5i ;hu4n Wn q&nJViJl thJ' ;'n trc ;hu7t, Odn ;-;h 4 h'Bn ;-;h ;b& ;'n trc
;hu7t hi]n t#i r*i `u4 r& Y J4 ?m ? 5U;h ;hu4n Y&n phBi h'[; Y&n tr-i t4 W'
;'n trc ;hu7t.
N(u Wn q&nJViJl W>t `u& hci "rJWiJl th^ hxn ;h' W>t `u& hci W thi(t
p #i ;-; thxn Y
%'5J M'uYJM'WJ WJnt:p,i1ate1oidKeyboa,d]8oue8o1eBobvectende," 8oue&1ent!,geF
//Kim t,a n6u nh2n chu4t th t,ng thi lZ .,e cn ng9Xc li lZ 0o1e,
Key)tatetemp)tate H Key)tate-one+
ifBe#utton HH 8oue#utton-oneF
temp)tate H Key)tate0o1e,+
ele
ifBe#utton HH 8oue#utton@eftF
temp)tate H Key)tate.,e+
int,ange H IangeST U IangeSNT M +
Coattemp@engthD H thiYidth / BCoatF,ange+
//$c x lL 1 Keyb,oad t9:ng t nh9 ki|n Key%oAn ifBBeE ^H N\' P thi0eightF ww BeE H NF ww inIange`ieA HH faleF
,ange.,e1ieA$olo,].,e1ieA H $olo,EelloA+
Coattemp]eD H BCoatFeD U N[\' P temp@engthD+
ifBtemp]eD NF
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
19/38
intv H BintFBtemp]eD / BthiYidth / BCoatF,angeFF+
boolenable8ainKey H t,ue+
ifBtemp]eD ^ Bv P thiYidth / BCoatF,ange M thiYidth / B,angeP/J'FFF
enable8ainKey H fale+
ifBKey#oa,dSv M IangeSNTTindex)ubkey zH U ww v M IangeSNT zH \F
Key#oa,dSKey#oa,dSv M IangeSNTTindex)ubkeyTtate H temp)tate+
//Kim t,a c? thay Vi key hi|n ti khng
ifB$u,,entKey zH Key#oa,dSv M IangeSNTTindex)ubkeyF
)top-oteB$u,,entKeyF+ //d~ng pht ti6ng ca key note t,9
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
20/38
$u,,entKey H i+
.lay-oteB$u,,entKeyF+
*
*
ele
Key#oa,dSIangeSNTTtate H temp)tate+
ifB$u,,entKey zH IangeSNTF
)top-oteB$u,,entKeyF+
Key#oa,dS$u,,entKeyTtate H Key)tate-one+
thiqn1alidateBF+
*
$u,,entKey H IangeSNT+
.lay-oteB$u,,entKeyF+
*
*
ele
ifBBBeE N\' P thi0eight ww eE ^H N[\' P thi0eightF B8o1e&nable HH t,ueww
eE N\' P thi0eightFF ww inIange`ieA HH faleF
,ange.,e1ieA$olo,].,e1ieA H $olo,EelloA+
inti H BintFBeD / BthiYidth / BCoatF,angeFF MIangeSNT+
ifBi IangeSTF
i H IangeST+
Key#oa,dSiTtate H temp)tate+
ifB$u,,entKey zH iF
)top-oteB$u,,entKeyF+
Key#oa,dS$u,,entKeyTtate H Key)tate-one+ thiqn1alidateBF+
*
$u,,entKey H i+
.lay-oteB$u,,entKeyF+
*
ele//%i chuyn Iange p,e1ieA
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
21/38
Key#oa,dS$u,,entKeyTtate H Key)tate-one+ //t, li t,ng thi -one cho Key note
t,9
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
22/38
@ocationD]'i,t H eD+
@ocationIangeSNT H IangeSNT+
@ocationIangeST H IangeST+
*
`ieA8o1e H t,ue+
thiqn1alidateBF+
*
*
ele
`ieA8o1e H fale+
,ange.,e1ieA$olo,].,e1ieA H $olo,EelloA+
thiqn1alidateBF+
*
*
*
*
(( &E 5.1, M78U"
hi ;hu7t tr-i ;hu7t ?>Z; thB r& th^ tt ;B ;-; tr#n th-i ;b& ;-; Oi(n ?iu hin ?>;
trB W i- trU O#n ?u W J4 hi]n t#i ?>; trB W tr#n th-i N'nJ
%'5J:p,i1ate1oidKeyboa,d]8ouepBobvectende," 8oue&1ent!,geF
//5, li cc gi t, cho cc bi6n
highlight.,e`ieA H \+
.,e1iouKey H U+
inIange`ieA H fale+
8o1e&nable H fale+
)top-oteB$u,,entKeyF+ //d~ng pht ti6ng key t,9
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
23/38
N(u ;'n trc ;hu7t ?i r& n'i hci "i&n' J4O'&r5 $ hi hxn ?&n nhn ;hu7t th^
J4 ;ui ;n ?>; >u Ya ;hu4n W tr#n th-i N'nJ
%'5J:
p,i1ate1oidKeyboa,d]8oue@ea1eBobvectende," &1ent!,geF
Key#oa,dS$u,,entKeyTtate H Key)tate-one+
thiqn1alidateBF+
*
(( P)0 0.4,- S,"
hi $7t J4 WX& ?>; ;hu4n Y&n tr#n th-i "rJYY th^ Ya ph-t ti(n ?n ;h' ti
hi n= ;hu4n #i tr#n th-i N'nJ Qhi Y6 i]n M'uYJ}p, h'[; ;hu4n J4 tr'n
M'uYJM'WJR
Th> Wi@n ? ph-t ti(n ?n th> Wi]n N&u5i', th> Wi]n n4 ho tr ?; W ph-t ;-;
'#i iJ $p, $i5i, l&W~. Ti(n ?n tr'n "i&n' Si$u&t'r Y 59n ph-t tX $7t
n'tJ ;b& ;u trK; MIDI.
T>Zn n Wi $oi J4 tr@n J4O'&r5 t& ;= $7t $m N'5J t>n n ?>; >u
tr'n thu7; t+nh O$ ;b& $oi n'tJ, nh> tr'n h^nh:
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
24/38
Fi(n 5n ? ph-t ti(n ?n : Mi5iwut $5'g
//.ht ti6ng Zn cho cho key note
public1oid.lay-oteBintcu,,entkeyF
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
25/38
ifBKey#oa,dScu,,entkeyTtate HH Key)tate.,e ww cu,,entkey zH .,e1iouKey ww mdo z
H nullF
mdo)endB8idi8eage)ta,t-oteBKey#oa,dScu,,entkeyTkbm" [" FIaA%ataF+
.,e1iouKey H cu,,entkey+
*
*
//%~ng ti6ng Zn cho key note
public1oid)top-oteBintcu,,entkeyF
ifBKey#oa,dScu,,entkeyTtate HH Key)tate.,e ww mdo zH nullF
mdo)endB8idi8eage)top-oteBKey#oa,dScu,,entkeyTkbm" [" FIaA%ataF+
.,e1iouKey H U+
*
*
( C)*+,- I" G.67
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
26/38
1. Futt'n ? ;hu4n Y&n ;h( ?7 ;hZi t6 5' QrJJ "&4R2. Futt'n ? ;hu4n Y&n ;h( 57 S-n t#' Q%rJ&tiWJ ;h>& h'n thnhR. Futt'n ? ;hu4n Y&n "&J ? thi(t p ;-; YJttin ;h' ;h>Zn tr^nh. Futt'n ? th'-t hci ;h>Zn tr^nh.!. L&OJ Intr'5u;J ii thi]u ?Zn iBn W Nh=$ th6; hi]n
.2. Gi&' 5i]n rJJ"&4 "&4"&J
.2.1. Futt'n F&;: u&4 #i $Jnu ;h+nh
.2.2. Futt'n MinuY: GiB$ q&nJViJl ;b& J4F'&r5 ?i $7t ?Zn WU
p,i1ate1oidbtn8inu]$lickBobvectende," &1ent!,geF
pianoKeyboa,dIange`ieA]IeieBUF+
.lay.ageqn1alidateBF+
*
.2.. B2007, P2" T/n q&nJViJl @n $7t ?Zn WUp,i1ate1oidbtn.lu]$lickBobvectende," &1ent!,geF
pianoKeyboa,dIange`ieA]IeieBF+
.lay.ageqn1alidateBF+
*
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
27/38
.2.. B2007, H.
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
28/38
ele
$u,,entE H N+
time,8o1eK#)topBF+
*
*
(3(( P.6,7 K89:76;Z; ;hZi, J4 ?= Ya ?>; >u W' $7t $Bn ;-; N'tJ"Jr'r$ ? Oiu thU @n hu W6;
hin thU Qhu W6; Y R
(3(V( &E 5.1, M728$7D, 0;J, P.6,7 K89:76;u W' LiYt N'tJ"Jr'r$ J4 WX& $i ?>; ;hZi, Wi in5Jj Odn Wi
in5Jj ;b& J4 ?>; ;hZi, thfi i&n Odn Wi thfi i&n hi]n t#i QOi(n %'; ?>;
?($ thJ' thfi i&n th6;R
p,i1ate1oidpianoKeyboa,d]8oue%oAnBobvectende," 8oue&1ent!,geF
ifBeE ^ N[\' P pianoKeyboa,d0eightF //n6u nh2n l>n l>n phn keyboa,d
-ote.e,fo,mnp H neA-ote.e,fo,mBF+ //Khi to m4t note pe,fo,m
np5ime)ta,t H clock+ //5hi gian b{t u b=ng thi gian hi|n ti
np&nd H fale+ //Key note 1n ch9a 9Xc th
npindexKey-ote H pianoKeyboa,d$u,,entKey+ //g{n index ca key note 9Xc 2n cho
index ca notepe,fo,m
note.e,fo,m!ddBnpF+ //th>m 1Zo note.e,fo,m
**
(3(W( &E 5.1, M728M78 0;J, P.6,7 K89:76;; ?= Odn ;-;h -n thfi
i&n hi]n t#i W' ti$Jn5 ;b& n'tJ W n5 | truJ. hei t#' W th@$ n'tJ pJr'r$ $i W'
LiYt
//Kim t,a c? ang nh2n chu4t t,i khng ww 7 c? note pe,fo,m nZo 9Xc add 1Z ch9a ww kim
t,a keynote hi|n ti c? khc 1
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
30/38
note.e,fo,mSnote.e,fo,m$ount U T&nd H t,ue+
note.e,fo,mSnote.e,fo,m$ount U T5ime&nd H clock+ //gn thi gian k6t th3c b=ng thi
gian hi|n ti
//5o m4t notepe,fo,m m
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
31/38
//0Zm 1G m4t note pe,fo,m
//index lZ ch ch mc ca key note t,>n piano Keyboa,d
public1oid%,aAOne-ote.e,fo,m§B(,aphicg" intindex "Coat@ocationD" Coat
@ocationE" Coat@engthD" Coat@engthEF
Coattemp H @engthD P Nj'+ //thi6t lp 4 bo t,n cho m4t note pe,fo,m b=ng Nj 4
,4ng ca note
//1G m4t m4t pe,fo,m
uingB(,aphic.athgp H IoundIectBneAIectangle'B@ocationD" @ocationE" @engthD"
@engthEF" temp" temp" temp" tempFF
g'ill.athBneA)olid#,uhBnote#ack$olo,F" gpF+ //`G nn ca note pe,fo,m
g%,aA.athBneA.enBnoteOutline$olo," F" gpF+ //`G 9ng 1in ca note pe,fo,m
*
//`G hnh t,n hin th t>n ca note pe,fo,m
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
32/38
uingB(,aphic.athgp H neA(,aphic.athBFF
gp!dd&llipeBneAIectangle'B@ocationD M " @ocationE M " @engthD U j " @engthD U
jFF+
g'ill.athBneA)olid#,uhB$olo,',om!,gbB[\" $olo,#lackFF" gpF+
*
//`G t>n ca note
Coatfontie H N\' P @engthD+ //thi6t lp c ch cho note
'ontfont H neA'ontB$anda,a" fontie" 'ont)tyle#oldF+ //$hn font
t,ingnamekey H
pianoKeyboa,dKey#oa,dSnote.e,fo,mSindexTindexKey-oteTkindkey5o)t,ingBFIeplaceB)"F+//@
2y t>n ca note 1Z Vi t>n ') thZnh '
)ie5extie H5extIende,e,8eau,e5extBnamekey" fontF+ //tLnh 4 dZi ca chuVi t>n
g%,aA)t,ingBnamekey" font" neA)olid#,uhB$olo,YhiteF" @ocationD M B@engthD /
BCoatFF U B5extieYidth / BCoatF\F" @ocationE M F+ //1G ,a mZn hnh
*
%h>Zn tr^nh Ya Wa tt ;-; N'tJ pJr'r$ @n Wn hin thU W 5U;h ;hu4n n= thJ'
thfi i&n, n(u nh> N'tJ pJr'r$ n' ;= ti$Jn5 W>t `u- Wn hin thU th^ ?>; j=&
hci LiYt.
public1oid%,aA.e,fo,m§B(,aphicg F
int,ange H pianoKeyboa,dIangeST U pianoKeyboa,dIangeSNT M + //5Lnh tVng cc
note 9Xc hin th
Coat@engthD H pianoKeyboa,dYidth / BCoatF,ange+ //5Lnh 4 ,4ng ca main
key note
Coat@engthD]ubkey H pianoKeyboa,dYidth / BCoatFB P ,ange / J'F+ //5Lnh d4 ,4ng
ca ub key note
//`G cc note
fo,Binti H N+ i ^ note.e,fo,m$ount+ iMMF
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
33/38
Coat@ocationD H pianoKeyboa,d@ocationD M Bnote.e,fo,mSiTindexKey-ote U
pianoKeyboa,dIangeSNTF P @engthD+ //5Lnh 1 t,L D ca note
Coat@ocationE H pianoKeyboa,d@ocationE U \ P Bclock U note.e,fo,mSiT5ime)ta,tF U
@engthD+ //5Lnh 1 t,L E ca note ty thu4c 1Zo thi gian hi|n ti
Coat@engthE+ //4 dZi ca note
ifBnote.e,fo,mSiT&nd HH faleF //n6u note 1n ch9a 9Xc th
@engthE H \ P Bclock U note.e,fo,mSiT5ime)ta,tF M @engthD+ //4 dZi 9Xc tLnh t~ u
note cho tn
mZn hnh
*
ele
intindex]mainkey H
pianoKeyboa,dKey#oa,dSnote.e,fo,mSiTindexKey-oteTindex)ubkey+ //@2y index ubkey t~
index mainkey
%,aAOne-ote.e,fo,m§Bg" i" Bindex]mainkey U pianoKeyboa,dIangeSNT M F P
@engthD U @engthD]ubkey / '" @ocationE" @engthD]ubkey" @engthEF+ //1G ub key l>n mZn hnh
*
//x?a nhng note nZo c? 1 t,L time end 19Xt ua panel
ifBnote.e,fo,mSiT5ime&nd zH N ww pianoKeyboa,d@ocationE U \ P Bclock Unote.e,fo,mSiT5ime&ndF ^ panel)ie0eightF
note.e,fo,mIemo1e!tBiF+
*
*
*
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
34/38
S6 i]n wn"&int Ya Wa tt ;B @n Mn h^nh
p,i1ate1oidpage.lay].aintBobvectende," .aint&1ent!,geF
// dng double buse,ed 1G cc Wi t9Xng ha
ifBback#use, HH nullF
back#use, H neA#itmapBthi$lient)ieYidth" thi$lient)ie0eightF+
*
(,aphicg H null+
g H (,aphic',omqmageBback#use,F+
g$lea,B.lay.age#ack$olo,F+
g)moothing8ode H )moothing8ode!nti!lia+
%,aA@ineBgF+ //`G cc 9ng k
%,aA.e,fo,m§BgF+ //`G cc note pe,fo,m
g%ipoeBF+
e(,aphic%,aAqmagencaledBback#use," N" NF+
*
(( G.67 fi 5n th&4 ?{i ;-; thJ$J ;b&
;h>Zn tr^nh.
%= thJ$J ;h+nh Liht, D&r, qJ5, "urpJ ?>; >u tr'n $7t $Bn 2 ;hiu
ThJ$J, $Bn n4 ;h& tt ;-; ;-; $u ;b& ;-; thJ$J t>Zn n Wi $oi hn $7t
thJ$J. MBn n4 ?>; hei t#' hi OPt ?u ;h#4 ;h>Zn tr^nh, W ?>; t6 4 $m thJ$J
?m 5n tr>; ?= ?>; >u W' "i&n'J4O'&r5."r'pJrtiJY.SJttin.DJ&ut.thJ$J
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
35/38
(('( B2007, L.-0) T)8?8"
%hu4n Y&n 5n Lith thJ$J
p,i1ate1oidbtn@ight5heme]$lickBobvectende," &1ent!,geF
$hange5hemeBNF+
.iano])imulato,.,ope,tie)etting%efaulttheme H N+
.iano])imulato,.,ope,tie)etting%efault)a1eBF+
*
((3( B2007, $6;5 T)8?8
%hu4n Y&n 5n D&r thJ$J
p,i1ate1oidbtn%,ak5heme]$lickBobvectende," &1ent!,geF
$hange5hemeBF+
.iano])imulato,.,ope,tie)etting%efaulttheme H +
.iano])imulato,.,ope,tie)etting%efault)a1eBF+
*
((( B2077, R8< T)8?8
%hu4n Y&n 5n qJ5 thJ$J
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
36/38
p,i1ate1oidbtnIed5heme]$lickBobvectende," &1ent!,geF
$hange5hemeBF+
.iano])imulato,.,ope,tie)etting%efaulttheme H +
.iano])imulato,.,ope,tie)etting%efault)a1eBF+
*
((( B2007, P2;8 T)8?8
%hu4n Y&n 5n "urpJ ThJ$J
p,i1ate1oidbtn.u,ple5heme]$lickBobvectende," &1ent!,geF
$hange5hemeBJF+ .iano])imulato,.,ope,tie)etting%efaulttheme H J+
.iano])imulato,.,ope,tie)etting%efault)a1eBF+
*
%-; ThJ$J ?>; ;hu4n e tr'n h$:
p,i1ate1oid$hange5hemeBintiF
btn',ee.lay#ack$olo, H btn$,eati1e#ack$olo, H btn)etting#ack$olo, H
btn&xit#ack$olo, H themeSi" NT+
btn',ee.lay#ae$olo, H btn$,eati1e#ae$olo, H btn)etting#ae$olo, H
btn&xit#ae$olo, H themeSi" T+
btn',ee.lay#utton$olo, H btn$,eati1e#utton$olo, H btn)etting#utton$olo, H
btn&xit#utton$olo, H themeSi" T+
btn',ee.lay'o,e$olo, H btn$,eati1e'o,e$olo, H btn)etting'o,e$olo, H btn&xit'o,e$olo,
H themeSi" JT+
thi#ack$olo, H themeSi" jT+
8enu.age#ack$olo, H )etting.age#ack$olo, H themeSi" \T+
.lay.age#ack$olo, H $,eati1e.age#ack$olo, H themeSi" T+
line$olo, H themeSi" [T+
panel#ack$olo, H panel#ack$olo, H themeSi" \T+
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
37/38
btn#ack]',ee.lay'o,e$olo, H btn.lu'o,e$olo, H btn8inu'o,e$olo, H
btn0ide)hoA'o,e$olo, H btn#ack]$,eati1e'o,e$olo, H btn#ack])etting'o,e$olo, H themeSi" QT+
noteOutline$olo, H themeSi" RT+
note#ack$olo, H themeSi" NT+
pianoKeyboa,doutline$olo,.,e H themeSi" RT+
pianoKeyboa,dback$olo,.,e H themeSi" NT+
//$huyn Vi cc #ackg,ound t9:ng ;ng 1
7/25/2019 TranMinhNhat PhamCaoTriet LTTQ IT008 g22
38/38
btn0ide)hoA#ackg,oundqmage H up H
.iano])imulato,.,ope,tieIeou,ceup]a,,oA+
b,eak+
*
*
( C)*+,- " H], C)4 S H*/,- P)0 T;. ,('( H], F)4"
n 59n ;n ?Zn iBn, ;h>& ;= nhiu t+nh n/n %h>Zn tr^nh ;h#4 ;n ;h$, 5' ;h>& j + ?>; ?& ti(n tr^nh ? th6; hi]n
Wa ;& ?i t>n(3( H*/,- P)0 0;.^,"
Ti >u h=& ;h>Zn tr^nh ? ;h#4 nh&nh hZn n 59n ;= th ?; ?>; iJ MIDI N>fi 5n ;= th t#' r& $7t OBn nh#; W jut r& iJ MIDI %hu4n n 59n Y&n thnh n 59n 5nh ;h' 5i ?7n