IFormattable 와 ( IFormatProvider, ICustomFormatter )
IFormattable 은 객체자체적으로 특정 포멧을 제공할때 사용하고
IFormatProvider 는 객체에 특정 포멧들을 외부에서 제공할때 사용한다.
소스 변환기를 만들면서 각 디자인 아이템들의 내부에서 제공할것들과 외부에서 만들어지는 것들을
별도로 분리하여 설계할때 도움이 컸다.
마냥 사용하던 두가지를 분리해서 사용하니 편하였음.
Data data = new Data();
string Result1 = string.Format("{0:FMT}", data);
DataFormatter fmt2 = new DataFormatter();
string Result2 = string.Format(fmt2, "{0:FMT2}", data);
요렇게 사용하면
Result1 에는 "사용자정의 = Data" 이 반환되고
Result2 에는 "FMT2 [사용자정의 = Data]" 가 반환 된다.
public class Data : IFormattable
{
#region IFormattable 멤버
public string ToString(string format, IFormatProvider formatProvider)
{
if (format == "FMT")
{
return "사용자정의 = Data";
}
return ToString();
}
#endregion
}
public class DataFormatter : IFormatProvider , ICustomFormatter
{
#region IFormatProvider 멤버
public object GetFormat(Type formatType)
{
if (formatType == typeof(ICustomFormatter)) return this;
return null;
}
#endregion
#region ICustomFormatter 멤버
public string Format(string format, object arg, IFormatProvider formatProvider)
{
if (format == "FMT2")
{
return "FMT2 ["+ string.Format("{0:FMT}", arg) + "]";
}
return "";
}
#endregion
}
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
Winform] Effect 효과 처리! (0) | 2013.08.23 |
---|---|
WinForm + WebApi ] HighLight( 하이라이트 ) (0) | 2013.08.22 |
FlexGrid ] Cols[ 컬럼명 ].DataMap (0) | 2011.12.07 |
GlassForm (1) | 2011.11.15 |
Array.ConvertAll 관련... (0) | 2011.11.15 |
FlexGrid ] Cols[ 컬럼명 ].DataMap
DataSet ds = new DataSet();
FlexGrid.Cols[ucTY_EVALUE].DataMap
= new MultiColumnDictionary(ds.Tables[0], "DS_CODE", new string[]{"CD_CODE","DS_CODE"}, 1);
위처럼 FlexGrid에서 MultiColumnDictionary가 지원된다.
생성자가 몇가지 오버로드 되있는데 그중 위에 걸로 하면 될것 같고,
참고링크!!
http://helpcentral.componentone.com/nethelp/c1flexgrid/default.htm?turl=flexgridforwinformssamples.htm
위처럼 했을 경우
보이는건 DS_CODE 에 있는 것이 표시되고
콤보를 선택하려 클릭했을 때는
CD_CODE | DS_CODE 형태로 리스트로 아래로 뿌려진다.
맨앞 컬럼은 실제 선택시 값인데 DB에 저장할 때 위에는 DS_CODE로 코드가 아닌 이름을 그대로 저장하기 때문에
DS_CODE로 지정한 것 이다.
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
WinForm + WebApi ] HighLight( 하이라이트 ) (0) | 2013.08.22 |
---|---|
IFormattable 와 ( IFormatProvider, ICustomFormatter ) (0) | 2013.08.20 |
GlassForm (1) | 2011.11.15 |
Array.ConvertAll 관련... (0) | 2011.11.15 |
ClickOnce UpdateAsync ~!! (0) | 2011.10.31 |
GlassForm
이거 괜츈타~~~
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
IFormattable 와 ( IFormatProvider, ICustomFormatter ) (0) | 2013.08.20 |
---|---|
FlexGrid ] Cols[ 컬럼명 ].DataMap (0) | 2011.12.07 |
Array.ConvertAll 관련... (0) | 2011.11.15 |
ClickOnce UpdateAsync ~!! (0) | 2011.10.31 |
LINQ] GroupBy (0) | 2011.10.12 |
Array.ConvertAll 관련...
int[] intArray = Array.ConvertAll<char,int>(
"1234567890".ToCharArray(),
new Converter<char, int>(
(c)=>Convert.ToInt32( c.ToString() )
));
람다식 이용하니... 나름 쉽게 됨.
주민번호 유효성 체크를 하면서 한꺼번에 변환 하는 부분을 처리하다가 ArrayConverter를 써봄.
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
FlexGrid ] Cols[ 컬럼명 ].DataMap (0) | 2011.12.07 |
---|---|
GlassForm (1) | 2011.11.15 |
ClickOnce UpdateAsync ~!! (0) | 2011.10.31 |
LINQ] GroupBy (0) | 2011.10.12 |
컨텐츠 판넬 이전/ 다음 구현.. (0) | 2011.09.14 |
ClickOnce UpdateAsync ~!!
'스포너'님이 답변해주셨는데...
테스트 해보았다. 음 시나리오 잘 작성하면 꾀 쓸만할 듯 하다.
관련 키워드 : ApplicationDeployment.CurrentDeployment
.CheckForUpdateAsync()
.UpdateAsync()
링크
http://msdn.microsoft.com/ko-kr/library/system.deployment.application.applicationdeployment.updateasync.aspx
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
GlassForm (1) | 2011.11.15 |
---|---|
Array.ConvertAll 관련... (0) | 2011.11.15 |
LINQ] GroupBy (0) | 2011.10.12 |
컨텐츠 판넬 이전/ 다음 구현.. (0) | 2011.09.14 |
Vs2008] 성능 카운터 (0) | 2011.08.16 |
LINQ] GroupBy
데이타 생성.
string[] arr = "a,b,c,d,e,e,e,f,g".Split(',').ToList<string>().ToArray();
1번
var ar = arr.GroupBy(g => g).Where(w => w.Count() > 1).Select(s => s.Key);
string rar = string.Join(",", ar.ToArray());
2번
var aar = from t in arr
group t by t into g
where g.Count() > 1
select g.Key;
string raar = string.Join(",", aar.ToArray());
위 둘다 동일한 방법임... 한줄이냐 여러줄이냐 차이... ?
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
Array.ConvertAll 관련... (0) | 2011.11.15 |
---|---|
ClickOnce UpdateAsync ~!! (0) | 2011.10.31 |
컨텐츠 판넬 이전/ 다음 구현.. (0) | 2011.09.14 |
Vs2008] 성능 카운터 (0) | 2011.08.16 |
vs2008] WMI 관련.. (0) | 2011.08.16 |
컨텐츠 판넬 이전/ 다음 구현..
내부 컨텐츠를 변경하는 방법을 구현한 것임.
매번 쓸때마다 구현하기도 구찮긴 한뎅... 이제 플그램 많이 안할것 같으니 적어만 둔다.
public partial class Form1 : Form
{
List<Control> Contents = new List<Control>();
int currentControlIndex = 0;
public Form1()
{
InitializeComponent();
Contents.Add(new ContenControl() { Text = "TXT01" });
Contents.Add(new ContenControl() { Text = "TXT02" });
Contents.Add(new ContenControl() { Text = "TXT03" });
Contents.Add(new ContenControl() { Text = "TXT04" });
Contents.Add(new ContenControl() { Text = "TXT05" });
Contents.Add(new ContenControl() { Text = "TXT06" });
Contents.Add(new ContenControl() { Text = "TXT07" });
Contents.Add(new ContenControl() { Text = "TXT08" });
foreach (Control ctrl in Contents)
{
this.panel1.Controls.Add(ctrl);
}
UpdateButtonStates();
}
private void NextBtn_Click(object sender, EventArgs e)
{
// Next
Control Current = GetContentControl(+1);
Current.BringToFront();
UpdateButtonStates();
}
private void UpdateButtonStates()
{
NextBtn.Enabled = currentControlIndex < Contents.Count - 1;
PrevBtn.Enabled = 0 < currentControlIndex;
}
private Control GetContentControl(int idx)
{
Control ctrl = Contents[currentControlIndex];
if (idx < 0)
{
if (currentControlIndex + idx < 0)
{
idx = 0;
}
}
else if (0 < idx)
{
if (Contents.Count - 1 < currentControlIndex + idx)
{
idx = Contents.Count - 1;
}
}
currentControlIndex = currentControlIndex + idx;
ctrl = Contents[ currentControlIndex ];
return ctrl;
}
private void PrevBtn_Click(object sender, EventArgs e)
{
// Prev
Control Current = GetContentControl(-1);
Current.BringToFront();
UpdateButtonStates();
}
}
public class ContenControl : UserControl
{
Label lb = new Label();
public ContenControl()
{
this.lb.BorderStyle = BorderStyle.FixedSingle;
lb.AutoSize = false;
lb.TextAlign = ContentAlignment.MiddleCenter;
lb.Dock = DockStyle.Fill;
this.Controls.Add(lb);
this.BorderStyle = BorderStyle.FixedSingle;
this.Dock = DockStyle.Fill;
}
public override string Text
{
get
{
return lb.Text;
}
set
{
lb.Text = value;
}
}
}
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
ClickOnce UpdateAsync ~!! (0) | 2011.10.31 |
---|---|
LINQ] GroupBy (0) | 2011.10.12 |
Vs2008] 성능 카운터 (0) | 2011.08.16 |
vs2008] WMI 관련.. (0) | 2011.08.16 |
노트북 셋팅.. (0) | 2011.08.02 |
WPF 에서 Keyboard 입력 하기 Winfom SendKeys 같은..
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/a80296be-e810-449a-843e-bba4a31c1b0e/
KeyEventArgs enter = new KeyEventArgs( Keyboard.PrimaryDevice , Keyboard.PrimaryDevice.ActiveSource , 0, Key.Enter );
enter.RoutedEvent = Keyboard.KeyDownEvent;
enter.Source = 대상객체;
InputManager.Current.ProcessInput(enter);
'# 3) .Net ( Vs 2008 ) > WPF' 카테고리의 다른 글
이벤트를 한곳에 몰아주기?? (0) | 2015.09.09 |
---|---|
WPF Textbox의 Numeric! (0) | 2015.09.05 |
FlexGrid : WPF 콤보 컬럼 (Combo Column Type) (0) | 2010.09.07 |
IValueConverter 사용 데모 (0) | 2010.09.06 |
WPF 쓰레드 ( 프로그래스바 ) (0) | 2010.08.10 |
Vs2008] 성능 카운터
카운터의 카테고리를 가져온것임.
이를 이용해 값을 쉽게 가져올 수 있음.
<<프로그램으로 카테고리의 카운터값, 인스턴스값을 추출해서 보여주는 프로그램>>
성능카운터를 이용해서 카테고리를 가져온 결과...
CategoryName="Telephony"
CategoryName="Terminal Services"
CategoryName="LogicalDisk"
CategoryName="Thread"
CategoryName="SMSvcHost 4.0.0.0"
CategoryName="SQLServer:Resource Pool Stats"
CategoryName="Job Object"
CategoryName="UDPv4"
CategoryName="UDPv6"
CategoryName="Browser"
CategoryName="SQLAgent:Jobs"
CategoryName="System"
CategoryName="Teredo Client"
CategoryName="RAS Port"
CategoryName="SQLServer:Replication Dist."
CategoryName="SQLAgent:Statistics"
CategoryName="MSDTC Bridge 3.0.0.0"
CategoryName="SQLServer:Catalog Metadata"
CategoryName="SQLServer:Buffer Partition"
CategoryName="Synchronization"
CategoryName="ICMPv6"
CategoryName="SQLServer:Backup Device"
CategoryName="Search Indexer"
CategoryName="SQLServer:Replication Agents"
CategoryName="Memory"
CategoryName=".NET CLR Networking 4.0.0.0"
CategoryName="Processor"
CategoryName="SQLServer:Replication Snapshot"
CategoryName="SQLServer:Replication Logreader"
CategoryName="SQLServer:Broker TO Statistics"
CategoryName="SQLServer:Cursor Manager by Type"
CategoryName="SQLAgent:JobSteps"
CategoryName="IPv4"
CategoryName="SQLServer:Broker Statistics"
CategoryName="Process"
CategoryName="ServiceModelEndpoint 3.0.0.0"
CategoryName="Print Queue"
CategoryName="ICMP"
CategoryName="Generic IKEv1, AuthIP, and IKEv2"
CategoryName="ReadyBoost Cache"
CategoryName="Per Processor Network Interface Card Activity"
CategoryName="USB"
CategoryName="NBT Connection"
CategoryName="SQLServer:Broker/DBM Transport"
CategoryName="IPsec IKEv2 IPv6"
CategoryName="SQLServer:Workload Group Stats"
CategoryName="IPsec IKEv2 IPv4"
CategoryName="Job Object Details"
CategoryName="SQLServer:Buffer Manager"
CategoryName="ServiceModelService 3.0.0.0"
CategoryName="SQLAgent:Alerts"
CategoryName="SQLServer:Broker Activation"
CategoryName="WFP"
CategoryName="SQLServer:Plan Cache"
CategoryName="Pacer Pipe"
CategoryName="Processor Information"
CategoryName="Paging File"
CategoryName="Power Meter"
CategoryName="Redirector"
CategoryName="SQLServer:Cursor Manager Total"
CategoryName="SQLServer:Wait Statistics"
CategoryName="IPsec AuthIP IPv4"
CategoryName="IPsec AuthIP IPv6"
CategoryName="SQLServer:Transactions"
CategoryName="PhysicalDisk"
CategoryName="TCPv6"
CategoryName="WFPv4"
CategoryName="WFPv6"
CategoryName="SQLServer:Databases"
CategoryName="SQLServer:SQL Errors"
CategoryName="Server Work Queues"
CategoryName="MSDTC Bridge 4.0.0.0"
CategoryName="Server"
CategoryName="IPsec IKEv1 IPv4"
CategoryName="Terminal Services Session"
CategoryName="IPsec IKEv1 IPv6"
CategoryName="Per Processor Network Activity Cycles"
CategoryName="Teredo Server"
CategoryName="SQLServer:Exec Statistics"
CategoryName="SQLServer:Memory Manager"
CategoryName="SQLServer:Replication Merge"
CategoryName="Windows Workflow Foundation"
CategoryName="Teredo Relay"
CategoryName="SQLServer:User Settable"
CategoryName="DTC(Distributed Transaction Coordinator)"
CategoryName=".NET Data Provider for Oracle"
CategoryName="Event Tracing for Windows"
CategoryName="RAS Total"
CategoryName="Cache"
CategoryName="Objects"
CategoryName="SQLServer:Database Mirroring"
CategoryName="SQLServer:Access Methods"
CategoryName="SMSvcHost 3.0.0.0"
CategoryName="TCPv4"
CategoryName="SQLServer:Buffer Node"
CategoryName="SQLServer:General Statistics"
CategoryName="IPv6"
CategoryName="Network Interface"
CategoryName="SQLServer:SQL Statistics"
CategoryName=".NET CLR Data"
CategoryName="SQLServer:Latches"
CategoryName="SQLServer:Deprecated Features"
CategoryName="SQLServer:CLR"
CategoryName="ServiceModelOperation 3.0.0.0"
CategoryName="SQLServer:Locks"
CategoryName=".NET CLR Networking"
CategoryName=".NET Data Provider for SqlServer"
CategoryName="IPsec Driver"
CategoryName="Event Tracing for Windows Session"
CategoryName="IPHTTPS Global"
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
LINQ] GroupBy (0) | 2011.10.12 |
---|---|
컨텐츠 판넬 이전/ 다음 구현.. (0) | 2011.09.14 |
vs2008] WMI 관련.. (0) | 2011.08.16 |
노트북 셋팅.. (0) | 2011.08.02 |
[LINQ] group by 여러조건 넣기. (0) | 2010.11.08 |
vs2008] WMI 관련..
WMI 로 쿼리 할수 있는 객체 정보를 볼수 있는 쿼리는 다음과 같음.
//WMI ~~
using (System.Management.ManagementObjectSearcher s = new System.Management.ManagementObjectSearcher())
{
s.Query = new System.Management.ObjectQuery(
@"SELECT * FROM Meta_Class WHERE __Class LIKE ""%Win32%"" ");
//s.Query = new System.Management.ObjectQuery(@"SELECT * FROM Win32_Process WHERE NAME = ""NateOnMain.exe"" ");
//s.Query = new System.Management.ObjectQuery("Select * from Win32_Processor");
//Win32_Processor
var k = s.Get();
foreach (var M in k)
{
foreach (var Q in M.Qualifiers)
{
string text = string.Format(
"Q}} Name:{0}, Value:{1}",
Q.Name,
Q.Value
);
this.textBox1.AppendText(text + Environment.NewLine);
}
foreach (var P in M.Properties)
{
string text = string.Format(
"P}} Name:{0}, Value:{1}",
P.Name,
P.Value
);
this.textBox1.AppendText(text + Environment.NewLine);
}
this.textBox1.AppendText(
Environment.NewLine
);
}
}
위처럼 하면 쿼리 할수 있는 객체들로 나타나고.. 이를 바탕으로 정보를 쿼리 할 수 있음.
여기서
디스크 정보를 알고 싶을때 : Win32_LogicalDisk 관련 객체를 위 쿼리결과에서 찾아보고
파라미터명으로 GetPropertyValue를 통해서 값을 취할수 있다.
s.Query = new System.Management.ObjectQuery("Select * from Win32_LogicalDisk");
var k = s.Get();
foreach (var M in k)
{
this.textBox1.AppendText("> " + M.GetPropertyValue("Caption") + Environment.NewLine);
this.textBox1.AppendText(
Environment.NewLine
);
}
> \\DOKEBI-PC\ROOT\cimv2:Win32_LogicalDisk
Q} Name:dynamic, Value:True
Q} Name:Locale, Value:1033
Q} Name:provider, Value:CIMWin32
Q} Name:SupportsUpdate, Value:True
Q} Name:UUID, Value:{8502C4B7-5FBB-11D2-AAC1-006008C78BC7}
P} Name:Access, Value:
P} Name:Availability, Value:
P} Name:BlockSize, Value:
P} Name:Caption, Value:
P} Name:Compressed, Value:
P} Name:ConfigManagerErrorCode, Value:
P} Name:ConfigManagerUserConfig, Value:
P} Name:CreationClassName, Value:
P} Name:Description, Value:
P} Name:DeviceID, Value:
P} Name:DriveType, Value:
P} Name:ErrorCleared, Value:
P} Name:ErrorDescription, Value:
P} Name:ErrorMethodology, Value:
P} Name:FileSystem, Value:
P} Name:FreeSpace, Value:
P} Name:InstallDate, Value:
P} Name:LastErrorCode, Value:
P} Name:MaximumComponentLength, Value:
P} Name:MediaType, Value:
P} Name:Name, Value:
P} Name:NumberOfBlocks, Value:
P} Name:PNPDeviceID, Value:
P} Name:PowerManagementCapabilities, Value:
P} Name:PowerManagementSupported, Value:
P} Name:ProviderName, Value:
P} Name:Purpose, Value:
P} Name:QuotasDisabled, Value:
P} Name:QuotasIncomplete, Value:
P} Name:QuotasRebuilding, Value:
P} Name:Size, Value:
P} Name:Status, Value:
P} Name:StatusInfo, Value:
P} Name:SupportsDiskQuotas, Value:
P} Name:SupportsFileBasedCompression, Value:
P} Name:SystemCreationClassName, Value:
P} Name:SystemName, Value:
P} Name:VolumeDirty, Value:
P} Name:VolumeName, Value:
P} Name:VolumeSerialNumber, Value:
'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글
컨텐츠 판넬 이전/ 다음 구현.. (0) | 2011.09.14 |
---|---|
Vs2008] 성능 카운터 (0) | 2011.08.16 |
노트북 셋팅.. (0) | 2011.08.02 |
[LINQ] group by 여러조건 넣기. (0) | 2010.11.08 |
MS-Chart Demo (0) | 2010.11.05 |