WinForm] 단축키
단축키 관련 해서 질문글이 올라오길래 간단히 작성해보았음.
Key 와 대응하는 Execute 핸들러를 등록하여 관리 가능.
Execute 핸들러를 별도로 관리한다면... 게임에서 단축키등 교체하는 형태로도 바꿀수 있지 않을까??
namespace KeyMapping
{
public partial class Form1 : Form
{
KeyCommandHelper KeyHelper = null;
public Form1()
{
InitializeComponent();
//사용방법1
//KeyCommand F1CMD = new KeyCommand(Keys.F1, (s, e) => { label1.Text = "" + e.keyCMD.Key; });
//KeyCommand F2CMD = new KeyCommand(Keys.F2, (s, e) => { label1.Text = "" + e.keyCMD.Key; });
//KeyHelper = new KeyCommandHelper() {
// F1CMD,
// F2CMD
//};
//사용방법2
KeyHelper = new KeyCommandHelper() {
new KeyCommand(Keys.F1, (s, e) => { label1.Text = "" + e.keyCMD.Key; }),
new KeyCommand(Keys.F2, (s, e) => { label1.Text = "" + e.keyCMD.Key; })
};
//기타..
// KeyHelper.Add...
// Event별도로 추가가능...
}
// 간단하게!!
//protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
//{
// if (keyData == Keys.F1)
// {
// label1.Text = ""+keyData;
// }
// return base.ProcessCmdKey(ref msg, keyData);
//}
// 복잡하게
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
KeyHelper.Execute(keyData);
return base.ProcessCmdKey(ref msg, keyData);
}
}
}
// KeyCommand Interface
public interface IKeyCommand
{
Keys Key { get; }
void Execute();
}
// KeyCommand 객체
public class KeyCommand : IKeyCommand
{
public KeyCommand(Keys key)
{
Key = key;
}
public KeyCommand( Keys key,EventHandler<KeyCommandExecuteEventArgs> handler)
{
Key = key;
Executed += handler;
}
public Keys Key
{
get;
private set;
}
public void Execute()
{
OnExecute(new KeyCommandExecuteEventArgs(this));
}
public event EventHandler<KeyCommandExecuteEventArgs> Executed = null;
protected void OnExecute(KeyCommandExecuteEventArgs e)
{
if (Executed != null)
{
Executed(this, e);
}
}
}
// Execute 시 이벤트 아규먼트
public class KeyCommandExecuteEventArgs : EventArgs
{
public IKeyCommand keyCMD {get; private set;}
public KeyCommandExecuteEventArgs(IKeyCommand cmd)
{
keyCMD = cmd;
}
}
// Command 관리 도우미
// IList 구현 이외의 코드
public class KeyCommandHelper : IList<IKeyCommand>
{
public KeyCommandHelper()
{
KeyLst = new List<IKeyCommand>();
}
public List<IKeyCommand> KeyLst { get; private set; }
public void Execute(Keys key)
{
IKeyCommand cmd = this[key];
if (cmd != null )
{
cmd.Execute();
}
}
#region IList 구현
public int IndexOf(IKeyCommand item)
{
return KeyLst.IndexOf(item);
}
public void Insert(int index, IKeyCommand item)
{
KeyLst.Insert(index, item);
}
public void RemoveAt(int index)
{
KeyLst.RemoveAt(index);
}
public IKeyCommand this[Keys key]
{
get {
return this[KeyLst.FindIndex(c => c.Key == key)];
}
}
public IKeyCommand this[int index]
{
get
{
return KeyLst[index];
}
set
{
KeyLst[index] = value;
}
}
public void Add(IKeyCommand item)
{
if (KeyLst.FindIndex(k => k.Key == item.Key) >= 0) throw new Exception("등록된 키입니다.");
KeyLst.Add(item);
}
public void Add(Keys key , EventHandler<KeyCommandExecuteEventArgs> evt )
{
KeyCommand cmd = new KeyCommand(key, evt);
if (KeyLst.FindIndex(k => k.Key == key) >= 0)
{
cmd = this[key] as KeyCommand;
if( cmd != null ) cmd.Executed += evt;
}
else
{
KeyLst.Add(cmd);
}
}
public void Clear()
{
KeyLst.Clear();
}
public bool Contains(IKeyCommand item)
{
return KeyLst.Contains(item);
}
public void CopyTo(IKeyCommand[] array, int arrayIndex)
{
KeyLst.CopyTo(array, arrayIndex);
}
public int Count
{
get { return KeyLst.Count; }
}
public bool IsReadOnly
{
get { return false; }
}
public bool Remove(IKeyCommand item)
{
return KeyLst.Remove(item);
}
public IEnumerator<IKeyCommand> GetEnumerator()
{
return KeyLst.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
#endregion
}
'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글
WinForm] 도킹 패널! (0) | 2013.07.08 |
---|---|
WINFORM] 컨트롤 동적 사이즈 조절... (0) | 2013.03.26 |
GDI+] 이미지 회전! (0) | 2012.08.13 |
2010 WinForm ] 컨트롤 리사이징 예제... (0) | 2012.07.20 |
.Net] 버튼 Pressed Event!! (0) | 2012.05.09 |
PRJMNG] 구조
대략적인 구조를 그려봤음.
UI는 이런식으로 페이지 연결구조를 갖고 ...
여기에 Tools 과 ...
그리드는 이번주만 손보고 작업을 시작해볼까낭!!!
쓸쓸한 가을인데 이짓이라도 미친척 하다보면 봄이 오겠지..
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
PRJMNG] 패턴? 패널? 이름이 뭔가?? 이건 (0) | 2012.10.24 |
---|---|
툴바 ] 리본바 흉내내기... (0) | 2012.10.23 |
PRJMNG] 구조 (0) | 2012.08.13 |
PRJMNG] 프로젝트 등록화면 (0) | 2012.08.13 |
PRJMNG] 메뉴 등록화면 (0) | 2012.08.13 |
Jquery ] 페이지 로딩중 ... 샘플
'# 6) JavaScript > JQuery' 카테고리의 다른 글
JQUERY ] 팝업 박스 ( 배경 검은 레이어로 덮기 ) (0) | 2012.09.25 |
---|---|
JQEURY 플러그인] 로딩바. 블럭킹 (0) | 2012.09.25 |
Jquery ~ 블로그 소개 (0) | 2012.05.17 |
JQUERY ] 팝업 박스 ( 배경 검은 레이어로 덮기 )
'# 6) JavaScript > JQuery' 카테고리의 다른 글
Jquery ] 페이지 로딩중 ... 샘플 (0) | 2012.09.28 |
---|---|
JQEURY 플러그인] 로딩바. 블럭킹 (0) | 2012.09.25 |
Jquery ~ 블로그 소개 (0) | 2012.05.17 |
JQEURY 플러그인] 로딩바. 블럭킹
로딩 블럭킹!!! 처리... 등.. 플러그인
GPL, MIT
http://jquery.malsup.com/block/#page
-- 사용 예~
# 표시될 메세지.
var MSG = {
Loading: { message: "<h4><img src='/images/tree/skin/loading.gif' /> Processing...</h4>",
overlayCSS: { backgroundColor: '#b2d0af', opacity: .3 },
css: { border: '2px solid #D0D7E5',
padding: '3px',
backgroundColor: '#777',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .7,
color: '#fff'
}
},
...
}
# 로딩되는 상위 페이지 ( Parent Page )
<script type="text/javascript" src="/Scripts/jquery.blockUI.js" ></script>
function Load_Tab() {
var url = "SubPage.aspx";
var pmrs = "";
var html = "<iframe id='frameGridContents' src='" + url + pmrs + "' style='width:100%;
height:302px; padding:0px;margin:0px;' scrolling='no' frameborder='0'></iframe>";
$("#tab_Contents").html(html);
BlockUI();
}
function BlockUI() {
$("#tab_Contents").block(MSG.Loading);
}
function UnBlockUI() {
$("#tab_Contents").unblock();
}
# 로딩되는 페이지 ( Sub Page ) .cs
protected override void OnPreRenderComplete(EventArgs e)
{
base.OnPreRenderComplete(e);
Page.ClientScript.RegisterClientScriptBlock(
this.GetType(),
"unblock",
"try{ var t = setTimeout(function () { parent.UnblockUI(); clearTimeout(t); }, 50); }catch(exception){}",
true);
}
'# 6) JavaScript > JQuery' 카테고리의 다른 글
Jquery ] 페이지 로딩중 ... 샘플 (0) | 2012.09.28 |
---|---|
JQUERY ] 팝업 박스 ( 배경 검은 레이어로 덮기 ) (0) | 2012.09.25 |
Jquery ~ 블로그 소개 (0) | 2012.05.17 |
PRJMNG] 구조
# 구조..
- Access DB를 바탕으로 모든 기록작업!!
- 프로젝트 관리가 주목적이고, 이와 관련해 발생하는 모든 기록저장.
- 디자인 툴 Addin!
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
툴바 ] 리본바 흉내내기... (0) | 2012.10.23 |
---|---|
PRJMNG] 구조 (0) | 2012.10.09 |
PRJMNG] 프로젝트 등록화면 (0) | 2012.08.13 |
PRJMNG] 메뉴 등록화면 (0) | 2012.08.13 |
PRJMNG] 대충 프레임... (0) | 2012.08.09 |
PRJMNG] 프로젝트 등록화면
# 프로젝트 등록화면
생성 -> 관련 폴더 및 DB 파일들 생성 하고 커넥션 정보 생성!
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
PRJMNG] 구조 (0) | 2012.10.09 |
---|---|
PRJMNG] 구조 (0) | 2012.08.13 |
PRJMNG] 메뉴 등록화면 (0) | 2012.08.13 |
PRJMNG] 대충 프레임... (0) | 2012.08.09 |
PRJMNG] 프로젝트관리 프로그램 (0) | 2012.08.05 |
PRJMNG] 메뉴 등록화면
# 메뉴
메뉴등록 후 관련 작업 이력관리/ 이슈관리/ 파일관리 UI
왼쪽 트리 : 메뉴명 , 메뉴링크( 소스파일 ) 각각 변환해서 보여주도록 처리!!
각 그리드는 기본적으로 등록/수정/삭제/ 완료처리.
파일은 리비젼 관리.
메뉴트리에서는 SP로 데이타 추출기능!!
( 특정 소스 버젼에 맞출지 말지 고민중... : 특정 포멧기준으로 컨버젼 되도록 적용해볼까낭.. )
# 폴더
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
PRJMNG] 구조 (0) | 2012.10.09 |
---|---|
PRJMNG] 구조 (0) | 2012.08.13 |
PRJMNG] 프로젝트 등록화면 (0) | 2012.08.13 |
PRJMNG] 대충 프레임... (0) | 2012.08.09 |
PRJMNG] 프로젝트관리 프로그램 (0) | 2012.08.05 |
GDI+] 이미지 회전!
회전!! 뱅글 뱅글..
Resource.R 은 회전 될 이미지
public partial class Form1 : Form
{
float angle = 0f;
Timer tm = new Timer();
public Form1()
{
InitializeComponent();
tm.Interval = 500;
tm.Tick += new EventHandler(tm_Tick);
tm.Start();
}
void tm_Tick(object sender, EventArgs e)
{
angle += 10;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawImage( rotateImage( Resources.r , angle ), 100f, 100f);
}
/// <summary>
/// 튜토리얼 : http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-rotate
/// </summary>
/// <param name="b"></param>
/// <param name="angle"></param>
/// <returns></returns>
private Bitmap rotateImage(Bitmap b, float angle)
{
//create a new empty bitmap to hold rotated image
Bitmap returnBitmap = new Bitmap(b.Width, b.Height);
//make a graphics object from the empty bitmap
Graphics g = Graphics.FromImage(returnBitmap);
//move rotation point to center of image
g.TranslateTransform((float)b.Width / 2, (float)b.Height / 2);
//rotate
g.RotateTransform(angle);
//move image back
g.TranslateTransform(-(float)b.Width / 2, -(float)b.Height / 2);
//draw passed in image onto graphics object
g.DrawImage(b, new Point(0, 0));
return returnBitmap;
}
}
'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글
WINFORM] 컨트롤 동적 사이즈 조절... (0) | 2013.03.26 |
---|---|
WinForm] 단축키 (0) | 2012.10.11 |
2010 WinForm ] 컨트롤 리사이징 예제... (0) | 2012.07.20 |
.Net] 버튼 Pressed Event!! (0) | 2012.05.09 |
.NET ] 멀티 랭귀지 지원 ... (0) | 2012.03.06 |
PRJMNG] 대충 프레임...
첫번째...
음... 메인으로 삼을 화면인뎅... 쩝.. 디자인 참 내가 만든거 너무 티나~ 티나도 너~~~~ 무 티나!
두번째...
음.. 데이타 정의는 대략 끝났으니... UserControl을 가지고 놀아볼까낭!!
어떤걸로 한다... 두번째꺼로 해볼까낭...
챠트도 넣고 싶지만 ... 나중에~~
출근시간, 퇴근시간까지 찍어줄까 하는데...
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
PRJMNG] 구조 (0) | 2012.10.09 |
---|---|
PRJMNG] 구조 (0) | 2012.08.13 |
PRJMNG] 프로젝트 등록화면 (0) | 2012.08.13 |
PRJMNG] 메뉴 등록화면 (0) | 2012.08.13 |
PRJMNG] 프로젝트관리 프로그램 (0) | 2012.08.05 |