개발프로그램2019. 4. 5. 11:13

이전에 올린 같은그림찾기가 Winform 으로 제작이 되었고,

https://bemeal2.tistory.com/265

 

이 프로그램은 WPF 로 포팅한 프로그램입니다.

모든 기능 및 동작은 이전것과 동일하며, 컨트롤이 WPF 에 맞게 제작이 되었습니다.

 

 

같은그림찾기 게임으로, 2개의 같은 그림을 찾는 게임이다.

 

레벨은 1 ~ 5 까지 있으며,

1레벨 - 4 * 4

2레벨 - 6 * 6

3레벨 - 8 * 8

4레벨 - 10 * 10

5레벨 - 12 * 12

 

사용된 아이콘은 총 230개로, 이중에 랜덤으로 골라서 게임에 사용된다.

 

사용된 아이콘은 무료(Free License) 의 아이콘을 사용하였다.

출처 : https://www.flaticon.com/packs/gastronomy-set

(Published by Smashicons)

 

 

 

게임 시작전에, 프리뷰 이미지를 볼 수 있으며,

게임이 종료된 후에는, 점수를 기록할 수 있으며, Elapsed 시간을 기준으로, 레벨별로 순위를 메기게 된다.

 

HDMatchingGameWPF_v1_0.zip
3.80MB

 

ps. 닷넷 프레임웍 4.0 이상이 설치되어 있어야 실행됩니다.

 

 

본 프로그램(첨부파일)을 제작자의 허락없이, 절대 다른곳에 게시하실 수 없습니다. 
(블로그를 링크하거나 소개하는 것은 전혀 상관이 없습니다.)

 

Posted by 헝개
개발팁2019. 3. 28. 14:41

ToggleButton 은 버튼의 눌림을 표현 하는 방법으로,

한번 누르면 눌림상태로, 다시 누르면, 튀어 나온 상태를 말한다.


[Winform]

 

System.Windows.Forms 에는 별도의 ToggleButton 이 없고, 일반 Button 은 ToggleButton 처럼 사용할 수 없다.

 

System.Windows.Forms 의 CheckBox 나 RadioButton 의 Appearance 속성을 이용하여, ToggleButton 으로 사용할 수 있다.

 

일단, Panel 위에 CheckBox 나 RadioButton 을 올려놓는다.

 

한 Container 위에서, CheckBox 는 여러개 선택이 가능하고, RadioButton 은 단 1개만 선택이 가능하다.

 

 

CheckBox 나 RadioButton Control의 속성을 보면,

Appearance 의 기본값 Normal 을 Button 으로 바꿔준다.

 

 

이제 버튼의 모양도 동일하게 보여지게 된다.

 

 

System.Windows.Forms
CheckBox

버튼의 눌림은 .Checked = true, 눌림해제는 .Checked = false 로 체크박스나 라디오버튼으로 그대로 사용하며,

화면에 보여지는 형식만 다르다는것을 알 수 있다.

 

 

[WPF]

 

WPF 에는 ToggleButton 컨트롤이 있어서, 바로 사용이 가능하다.

 

<ToggleButton Height="25" Content="Level 1" IsChecked="{Binding level1_checked, UpdateSourceTrigger=PropertyChanged}" Checked="ShowScore"></ToggleButton>

 

Winform 에서 Checkbox 로 토글버튼을 만든것과 동일한 결과를 얻을수 있다.

 

추가적으로, RadioButton 으로 컨테이너 또는 그룹 안에서 하나의 토글 버튼만 선택이 가능하게 하기 위해서는,

Winform 처럼 RadioButton 으로 구현하면 된다.

 

WPF 의 RadioButton 컨트롤의 Style 속성을 지정하여, 토글버튼으로 보여지게 된다.

 

Style="{StaticResource {x:Type ToggleButton}}"

 

<RadioButton Height="25" Content="Level 1" Style="{StaticResource {x:Type ToggleButton}}" IsChecked="{Binding level1_checked, UpdateSourceTrigger=PropertyChanged}"></RadioButton>
<RadioButton Height="25" Content="Level 2" Style="{StaticResource {x:Type ToggleButton}}" IsChecked="{Binding level2_checked, UpdateSourceTrigger=PropertyChanged}"></RadioButton>
<RadioButton Height="25" Content="Level 3" Style="{StaticResource {x:Type ToggleButton}}" IsChecked="{Binding level3_checked, UpdateSourceTrigger=PropertyChanged}"></RadioButton>
<RadioButton Height="25" Content="Level 4" Style="{StaticResource {x:Type ToggleButton}}" IsChecked="{Binding level4_checked, UpdateSourceTrigger=PropertyChanged}"></RadioButton>
<RadioButton Height="25" Content="Level 5" Style="{StaticResource {x:Type ToggleButton}}" IsChecked="{Binding level5_checked, UpdateSourceTrigger=PropertyChanged}"></RadioButton>

 

WPF RadioButton 을 이용한 토글버튼

 

Posted by 헝개