Grid
private void InitGrid()
{
gridView1.OptionsView.ShowGroupPanel = false;
var col1 = gridView1.Columns.Add();
col1.FieldName = "Key";
col1.Caption = "메뉴ID";
col1.Width = 120;
col1.Visible = true;
var col2 = gridView1.Columns.Add();
col2.FieldName = "Name";
col2.Caption = "메뉴명";
col2.Width = 220;
col2.Visible = true;
gridControl1.DataSource = GetDataSource();
}
음.. 버튼도 넣어볼까나?
private void InitGrid()
{
gridView1.OptionsView.ShowGroupPanel = false;
var col1 = gridView1.Columns.Add();
col1.FieldName = "Key";
col1.Caption = "메뉴ID";
col1.Width = 120;
col1.Visible = true;
var col2 = gridView1.Columns.Add();
col2.FieldName = "Name";
col2.Caption = "메뉴명";
col2.Width = 220;
col2.Visible = true;
var col3 = gridView1.Columns.Add();
col3.Caption = "컬럼";
col3.Width = 150;
col3.Visible = true;
var redit = new DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit();
redit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
var btnEdit = new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph);
redit.Buttons.Add(btnEdit);
redit.Buttons[0].Caption = "001";
redit.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph;
redit.Buttons[1].Caption = "002";
redit.Buttons[1].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph;
redit.ButtonClick += redit_ButtonClick;
col3.ColumnEdit = redit; gridControl1.DataSource = GetDataSource();
}
void redit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
if (e.Button.Index == 0)
{
MessageBox.Show(e.Button.Caption);
}
else if (e.Button.Index == 1)
{
MessageBox.Show(e.Button.Caption);
}
}
'# 4) .Net ( Vs 2010 ) > DevExpress' 카테고리의 다른 글
ButtonEdit (0) | 2015.01.25 |
---|---|
TreeList (0) | 2015.01.25 |
TreeList
+ TreeList... 그리고 VGridControl
지금 프로젝트에서 사용하는 사용컨트롤인데...
처음 접하는 프로젝트였으므로 공부를 해볼 시간이 필요했는데, 잘 안되었다...
경험자였던 팀원분은 두달간 메뉴 여섯개 두달간 만드시다 잘렸고...
근데 막상 쭉 해보니 별건 아닌데... 왜 두달이 걸렸을까?
추가사항이나 수정사항이 나올때마다 왜 프로그래밍을 이렇게 했을까 싶을 정도로... 생각이 안잡힌다.
너무 복잡했던 사용법들때문에 그냥 집에서 사용법들을 알아봤다.
private void InitTreeList()
{
TreeListColumn tcKey = treeList1.Columns.Add();
tcKey.FieldName = "Key";
tcKey.Caption = "메뉴ID";
tcKey.Visible = true;
tcKey.VisibleIndex = 2;
TreeListColumn tcName = treeList1.Columns.Add();
tcName.FieldName = "Name";
tcName.Caption = "메뉴명";
tcName.Visible = true;
tcName.VisibleIndex = 1;
treeList1.KeyFieldName = "Key";
treeList1.ParentFieldName = "Prn_Key";
treeList1.DataSource = GetDataSource();
}
초간단 바인딩.
그러면 트리가 짠!
데이타 입력 수정 삭제 처리시 트리에 색상 반영은.
private void treeList1_NodeCellStyle(object sender, DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs e)
{
DataRowView currentNode = treeList1.GetDataRecordByNode(e.Node) as DataRowView;
if (currentNode != null)
{
if (currentNode.Row.RowState == DataRowState.Added)
{
e.Column.AppearanceCell.ForeColor = Color.Blue;
}
else if (currentNode.Row.RowState == DataRowState.Modified)
{
e.Column.AppearanceCell.ForeColor = Color.Green;
}
else if (currentNode.Row.RowState == DataRowState.Deleted)
{
e.Column.AppearanceCell.ForeColor = Color.Silver;
}
else
{
e.Column.AppearanceCell.ForeColor = Color.Black;
}
}
}
그리고 treeList1.GetDataRecordByNode <-- 요 메서드
바인딩 된 노드의 데이타객체로 변환하는 메서드
추가적으로
private void GetChangeDataButton_Click(object sender, EventArgs e)
{
StringBuilder query = new StringBuilder();
var table = treeList1.DataSource as DataTable;
var chage = table.GetChanges();
if (chage != null)
foreach (DataRow dr in chage.Rows)
{
if ((dr.RowState & (DataRowState.Modified | DataRowState.Added | DataRowState.Deleted)) > 0)
{
query.AppendFormat("MenuID = {0}, MenuName = {1}" + Environment.NewLine, dr[0], dr[1]);
}
}
MessageBox.Show("" + query);
}
이건 바인딩 된 데이타의 변경된 데이타만을 가져오는 부분.
또 여기에 VGridControl 췟!
팀원이었던 분이 써놓은 컨트롤인데 ... 이것도 당췌 왜 그렇게 사용했는지 알수가 없는데
사용이 겁나게 단순한데...
private void InitVGrid()
{
var keyEdit = new DevExpress.XtraVerticalGrid.Rows.EditorRow("Key");
keyEdit.Properties.Caption = "메뉴ID";
keyEdit.Properties.ReadOnly = true;
vGridControl1.Rows.Add(keyEdit);
var nameEdit = new DevExpress.XtraVerticalGrid.Rows.EditorRow("Name");
nameEdit.Properties.Caption = "메뉴명";
nameEdit.Properties.ReadOnly = false;
vGridControl1.Rows.Add(nameEdit);
vGridControl1.DataSource = treeList1.DataSource;
}
요렇게 ㅡ.,ㅡ;; 끝.
그냥 저거 한줄이면 되는데...
음... 그분은 왜? 객체를 몇개나 만들어서 줬다 받았다 했을까?
'# 4) .Net ( Vs 2010 ) > DevExpress' 카테고리의 다른 글
ButtonEdit (0) | 2015.01.25 |
---|---|
Grid (0) | 2015.01.25 |
Visual studio Community 2013 설치!
Visual Studio 2013 Community를 드디어 설치했다.
설치가 참 힘들었다 계속 오류가 떨어져서... 왜 안될까 .... 찾다 찾다...
마지막 포멧을 앞두고.
http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx
닷넷 삭제 툴. dotnetfx_cleanup_tool.zip
이걸로 삭제하고 설치했더니 오류없이 넘어가서 ... 설치가 완료되었다.
JSFW 프로젝트를 로드했더니 좋당!!!
게다가 설치 후 닷넷(.net)프로그래머 모임 에 게시글을 보고 흥미가 더 생기는데...
과연 C#으로 아이폰, 안드로이드폰 개발이 가능해지니까... C#하길 잘했다 봐야겠지?
'# 1) 프로그래밍' 카테고리의 다른 글
Cell Merge를 구현할 알고리즘! (0) | 2015.10.17 |
---|---|
Xaml 정리기 (0) | 2015.09.04 |
app.config Section 작성 변환기... (0) | 2014.11.05 |
비동기 처리] IAsyncResult 를 이용함. (0) | 2014.10.30 |
before, do, after를 묶어보자!! (0) | 2014.10.28 |
PRJMNG] 소스변환기 util
소스 변환기 가장 핵심적인것만 구현된 유틸이다.
UI다 버리고도 이걸로 퉁쳐도...
어차피 만들고 있는 디자이너에 내부 컨트롤 모듈로 붙일 계획이지만, 이 자체만으로도 훌륭한 기능을 하고 있으니..
혼자서 비밀 테스트 중이다. 화면개발이 엄청 빨라졌으니까. 응용하면 웹이든 윈폼이든 wpf든 가져다가
써먹을 수 있으니... 굿!!
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
LayerGrid II] 새로운 레이어 그리드! (0) | 2015.10.29 |
---|---|
SQL_FMT] 포멧터... (0) | 2015.08.30 |
PRJMNG] 레이아웃용 그리드 다시!!! (0) | 2014.10.30 |
PRJMNG] Image Viewer (만화책 보기... ) (0) | 2014.08.01 |
PRJMNG] SlidePanel 컨트롤! (0) | 2014.07.29 |
app.config Section 작성 변환기...
이번 일하면서 프로그램내 설정을 app.config에 담을 일생겼는데 이게 settings 같은걸로 분리해서 담아서 쓰면 데이타에 대한 분류가 안되고 섞일 것 같아서 데이타를 나누어 관리하기 위해 사용자정의 형태로 만들었다. 이번에 만들면서도 또 구글링하며 번거롭게 했다. 전에도 했었는데...
그래서 이번엔 아예 코드를 작성해주는 프로그램을 만들었다.
만들기전에 혹시나 하고 프로그램을 찾아봤더니... 비슷해보이는데 다운로드 해볼수가 없어서... 그림을 보고 소스를 살짝 봤더니 원하는 모양이 아닌듯 해서 그냥 넘겼다.
이 로직으론 저장할 xml만 만들면 된다. xml을 넘겨주면 .cs 코드를 받을수 있고 이 코드를 저장하면 쉽게 app.config( or web.config) 에서 설정관련
데이타를 관리할 수 있다.
요렇게 생긴 대상 데이타를 xml로 만든다.
<SectionName Att="1111">
<EEL Att1="222" >
<Add Key="VV" Value="TT" />
</EEL>
<PPL>
<AS Value="a"/>
<AS Value="b"/>
</PPL>
<MySection>
<MySettings MyKey="John" MyValue1="Developer" MyValue2="Expert"/>
<MySettings MyKey="Tomas" MyValue1="Developer" MyValue2="Junior"/>
<MySettings MyKey="Robert" MyValue1="Developer" MyValue2="Senior"/>
<MySettings MyKey="Kurt" MyValue1="IT" MyValue2="Expert"/>
<MySettings MyKey="Anna" MyValue1="HR" MyValue2="Senior"/>
</MySection>
</SectionName>
그리고
요렇게 xml을 담아 변환 시키면..
요렇게 소스로 준다... ( 길어서 짤림 )
테스트 모양이다. 각 변수에 담긴 값을 확인할 수 있다.
'# 1) 프로그래밍' 카테고리의 다른 글
Xaml 정리기 (0) | 2015.09.04 |
---|---|
Visual studio Community 2013 설치! (0) | 2014.12.07 |
비동기 처리] IAsyncResult 를 이용함. (0) | 2014.10.30 |
before, do, after를 묶어보자!! (0) | 2014.10.28 |
ExtJs > ExtNet 변환 툴!!! (0) | 2014.07.10 |
비동기 처리] IAsyncResult 를 이용함.
최근에 나온 task나 await 는 못써봤다. 가끔 문서는 봤는데 어렵더랑...
간단하게 비동기 처리를 할 수 있는 옛날 버젼으로다가.
정리해본다. ( 전에 해둔것 같은데 못찾겠다... )
delegate void Async<T>(T ctrl, Action begin, Action complite) where T : Control;
Async<Control> async = (ctrl, begin, complite) =>
{
if (begin != null)
{
// 비동기 처리 시작!
begin.BeginInvoke((ir) => {
begin.EndInvoke(ir);
// 종료...
ctrl.DoInvoke(c =>
{
complite();
});
}, begin);
}
};
// 컨트롤의 크로스 스레드 작업이 잘못되었습니다. 의 메세지를 회피할 수 있는 확장 메서드다.
public static class Ex
{
public static void DoInvoke<T>(this T ctrl, Action<T> callMethod) where T : Control
{
if (ctrl.InvokeRequired)
{
ctrl.Invoke(new Action<T, Action<T>>(DoInvoke), ctrl, callMethod);
}
else
{
callMethod(ctrl);
}
}
}
대리자 하나를 선언한다.
: begin~~~~처리 ~~~~~complite
테스트!!!
폼에 버튼 하나를 둔다. ( : 추후에 프로그래스 바를 움직을 것임. )
테스트에 실행될 메서드
bool isRun = false;
void DemoAsyncMethod()
{
while (isRun)
{
System.Threading.Thread.Sleep(10000);// 10sec
isRun = false;
}
}
아무런 처리를 하지 않았을때...
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
isRun = true;
DemoAsyncMethod();
button1.Enabled = true;
}
실행하면 비동기 버튼은 비활성화 되면서 DemoAyncMethod가 실행되면서 10초간 꼼짝도 하지 않는다.
이렇게 되면 사용자는 ...
그래서 비동기 처리를 해봤다.
private void button1_Click(object sender, EventArgs e)
{
// button1.Enabled = false;
async(this, () => // begin Invoke ~ endInvoke
{
button1.Enabled = false; // 크로스 쓰레드 error가 발생한다.
// button1.DoInvoke(b => b.Enabled = false); 주석을 해제하고 위 라인을 삭제하면 Invoke 처리로 정상 동작을 할 수 있다.
isRun = true;
DemoAsyncMethod();
}, () => // async complite
{
button1.Enabled = true;
});
}
실행을 하면 버튼이 비활성화 된채 폼을 이리저리 움직여도 아까와 다르게 움직여진다...
좀더 시각적 효과를 주기위해 프로그래스를 기능을 포함한다.
bool isRun = false;
void DemoAsyncMethod()
{
int progressValue = 0;
while (isRun)
{
progressBar1.DoInvoke(p => p.Value = (++progressValue) * 10);
System.Threading.Thread.Sleep(1000);// 10sec
if (progressValue >= 10) isRun = false;
}
}
'# 1) 프로그래밍' 카테고리의 다른 글
Visual studio Community 2013 설치! (0) | 2014.12.07 |
---|---|
app.config Section 작성 변환기... (0) | 2014.11.05 |
before, do, after를 묶어보자!! (0) | 2014.10.28 |
ExtJs > ExtNet 변환 툴!!! (0) | 2014.07.10 |
Directory.Create 관련... (0) | 2014.06.09 |
PRJMNG] 레이아웃용 그리드 다시!!!
기존에 만들어 사용하던 그리드가 첨엔 괜찮더니 컨트롤을 많이 올리니 사이즈 조정이나 레이아웃 재배치 하면 느려서...
하다보니 다시 만들게 되었따.
우선은 괜찮은데...
테스트를 좀 더 해봐야겠다.
'# 9) My Program(.NET) > PRJMNG' 카테고리의 다른 글
SQL_FMT] 포멧터... (0) | 2015.08.30 |
---|---|
PRJMNG] 소스변환기 util (0) | 2014.11.21 |
PRJMNG] Image Viewer (만화책 보기... ) (0) | 2014.08.01 |
PRJMNG] SlidePanel 컨트롤! (0) | 2014.07.29 |
PRJMNG] 디자인목업에 이벤트와 핸들러! (0) | 2014.07.22 |
before, do, after를 묶어보자!!
오늘 조회, 수정, 삭제 관련 폼 작업을 하며 코드를 정리하다가...
조회를 할때 동작전, 동작, 동작 후 세단계를 계속 거치는데, 이걸 코드에 표현해서 메서드로 나열하자니
놓치는게 있는 듯 하고 해서 이걸 묶어서 코딩하면 좀더 앞으로의 코딩이 줄것 같고 놓칠게 줄어들듯 하여
바꿔봤다!
public delegate void DoAction(Func<bool?> beforeaction, Action doaction, Action afteraction);
대리자로 이렇게 동작을 연결짓는 매개체로 삼고
protected DoAction SearchAction = (beforeaction, doaction, afteraction) =>
{
if (beforeaction == null || (beforeaction() ?? true))
{
// progress
if (doaction != null) doaction();
if (afteraction != null) afteraction();
}
};
이렇게 SearchAction을 만들었다.
우선은 별게 없다!
조회버튼이 클릭했을 때...
if (SearchAction != null)
{
SearchAction(
beforeaction: () =>
{
// todo : 조회 조건 체크
return true;
},
doaction: () =>
{
// todo : 조회 동작 처리
},
afteraction: () =>
{
// todo : 조회 후 동작 처리
});
}
이렇게 연쇄적으로 호출할 수 있다면 어떨까 해서 ... 만들었다.
특정 동작에 대한 전 후 동작을 같은 곳에 표현할 수 있게 된다.
이건 저장 동작에 대한 틀이다.
protected DoAction SaveAction = (beforeaction, doaction, afteraction) =>
{
if (beforeaction == null || (beforeaction() ?? true))
{
DialogResult confirmDialogResult = MessageBox.Show("저장하시겠습니까?", "Save", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (confirmDialogResult == DialogResult.OK)
{
// progress
if (doaction != null) doaction();
if (afteraction != null) afteraction();
}
}
};
저장 버튼이 클릭했을때!
if (SaveAction != null)
{
SaveAction(
beforeaction: () =>
{
// todo : 저장전 유효성 체크
return true;
},
doaction: () =>
{
// todo : 저장 동작 처리
},
afteraction: () =>
{
// todo : 저장 이후 동작 처리.
});
}
우선 beforeaction에서 넘어오는 반환값에 따라 이후 동작들이 연쇄 호출이 되는 셈!
적용해보니 괜찮은데... 이번 프로젝트는 이걸로 가볼까!!!
'# 1) 프로그래밍' 카테고리의 다른 글
app.config Section 작성 변환기... (0) | 2014.11.05 |
---|---|
비동기 처리] IAsyncResult 를 이용함. (0) | 2014.10.30 |
ExtJs > ExtNet 변환 툴!!! (0) | 2014.07.10 |
Directory.Create 관련... (0) | 2014.06.09 |
C#] 프로세스의 파일경로 읽어오기. (0) | 2014.05.30 |
DevExpress WinForm] Layout 보완...
# 작업을 하다보니 라벨과 텍스스가 하나로 묶어주면 좋겠는데... 라고 생각했었는데
layoutControl의 내부에 border넣는 방법을 겨우 찾았다.
Customization toolbox를 띄우고 라벨과 텍스트박스가 위치한 레이아웃컨트롤아이템 선택하고
Group을 지정한다.
요렇게 그룹으로 묶이게 된다.
1. HideText
2. Padding = 0
3. Spacing = 0
이런식으로 바뀌는데 배경이 약간의 회색빛인게 맘에 안든다. 다른 색으로 바꾸고 싶을때 여러옵션을 가지고 조작해봤는데 복잡할 뿐더러
쉽게 잘 안된다. 그래서 가장 쉽게 처리 하는 방법을 찾았다.
배경색이 될 Resource Image파일을 만든다. ( white )
# Resources.resx를 더블클릭하여 리소스추가 > 새 이미지 추가 > 이미지 흰색 바탕으로 하나 만듬.( WhiteGb)
그 다음 그룹에 대해 배경이미지를 셋팅한다.
적용된 화면이다.
'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글
로또 체크기...? (0) | 2016.10.18 |
---|---|
Class를 XML변환, XML을 Class변환 (0) | 2016.09.12 |
DevExpress WinForm] Layout Control (0) | 2014.10.12 |
바로가기 만들기] shortcut (0) | 2014.09.27 |
문자열] 자리수만큼 잘라서 특정 문자 넣기. (0) | 2013.08.20 |
DevExpress WinForm] Layout Control
WinForm에 TableLayout 을 대신해서 Layout Control을 사용해서 쉽게 디자인이 가능하다.
도구 상자에 Navigation & Layout 툴박스에 LayoutControl 을 이용한다.
레이아웃 컨트롤을 배치하면 아래처럼 컨트롤이 나온다. Drop Controls Here!!! 메세지.. 컨트롤들을 가져다 놓으면 된다.
라벨을 드래그앤 드랍 하면 차례로 배치가 되는데 이때 아래처럼 영역을 알리는 외곽선 사각 박스가 그려지니 해당 위치에 배치할때 도움이 된다.
(# 마우스를 이용해서 놓을 위치를 확인하고 놓으면 된다. )
Label을 빼고는 Label이 별도로 존재하는데 ExtJs의 Field 같다.
Text를 조절하는것은 아래 속성이 있다. ( #AppearanceItemCaption.TextOptions )
Text는 숨기고 작업을 했다. TextVisible = false; 또는 ContextMenu에 보면 HideText가 있다.
좀 더 작업을 하다보면... 익숙해지니 쓸만하다.
'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글
Class를 XML변환, XML을 Class변환 (0) | 2016.09.12 |
---|---|
DevExpress WinForm] Layout 보완... (0) | 2014.10.12 |
바로가기 만들기] shortcut (0) | 2014.09.27 |
문자열] 자리수만큼 잘라서 특정 문자 넣기. (0) | 2013.08.20 |
WinForm] Ribbon 컨트롤 (0) | 2013.07.08 |