퇴근5분전

 

  가끔 로또와 연금복권을 사는데...

 

이걸 체크하려면 ... 보기 어려울때가 있네, 또 사이트 가니 체크하는게 있던데...

 

엑셀 수식으로 만들어진 체크기가 있는데... 심심해서 새로 만들어봤다.

 

 api.. 이런게 지원이 되서 편하게 되었다.

 

 

  

   회의록 프로그램을 만들면서 데이타를 객체로 구성하고, 저장데이타를 xml로 만들었다.

이때 xml 관련 Attribute등을 이용해서 직렬화과정을 거치게 되는데

 

아래껀 굳이 xml 관련 Attribute 를 지정하지 않아도 되더라...

 

 

 

public class Tmp
    {
        public string Name { get; set; }

        public List<CTmp> Items { get; set; }
        public Tmp()
        {
            Items = new List<CTmp>();
        }
    }

    public class CTmp
    {
        public string Name { get; set; }
        public string DESC { get; set; }
    }

 

 

 

 

 

            Tmp root = new Tmp();
            root.Name = "루트";
            root.Items.Add(new CTmp() { Name = root.Name + "_자식1", DESC = "자식1" });
            root.Items.Add(new CTmp() { Name = root.Name + "_자식2", DESC = "자식2" });
            root.Items.Add(new CTmp() { Name = root.Name + "_자식3", DESC = "자식3" });
            root.Items.Add(new CTmp() { Name = root.Name + "_자식4", DESC = "자식4" });

 

            string xml = root.Serialize<Tmp>();
            Tmp rt = xml.DeSerialize<Tmp>();

 

 

 

 public static class XmlEX
    {
        public static string Serialize<T>(this T value)
        {
            if (value == null) return string.Empty;

            var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T));

            using (var stringWriter = new System.IO.StringWriter())
            {
                using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings { Indent = true }))
                {
                    xmlSerializer.Serialize(xmlWriter, value);
                    return stringWriter.ToString();
                }
            }
        }

        public static T DeSerialize<T>(this string xml) where T : class, new()
        {
            T obj = default(T);
            var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
            using (var stringReader = new System.IO.StringReader(xml))
            {
                using (var reader = XmlReader.Create(stringReader, new XmlReaderSettings()))
                {
                    obj = xmlSerializer.Deserialize(reader) as T;
                }
            }
            return obj;
        }
    }

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

데이타 테이블정의서 Excel 생성하기.  (0) 2016.10.18
로또 체크기...?  (0) 2016.10.18
DevExpress WinForm] Layout 보완...  (0) 2014.10.12
DevExpress WinForm] Layout Control  (0) 2014.10.12
바로가기 만들기] shortcut  (0) 2014.09.27

 

# 작업을 하다보니 라벨과 텍스스가 하나로 묶어주면 좋겠는데... 라고 생각했었는데

layoutControl의 내부에 border넣는 방법을 겨우 찾았다.

 

 

Customization toolbox를 띄우고 라벨과 텍스트박스가 위치한 레이아웃컨트롤아이템 선택하고

Group을 지정한다.

 

 

 

요렇게 그룹으로 묶이게 된다.

  1. HideText

  2. Padding = 0

  3. Spacing = 0

 

이런식으로 바뀌는데 배경이 약간의 회색빛인게 맘에 안든다. 다른 색으로 바꾸고 싶을때 여러옵션을 가지고 조작해봤는데 복잡할 뿐더러

쉽게 잘 안된다. 그래서 가장 쉽게 처리 하는 방법을 찾았다.

배경색이 될 Resource Image파일을 만든다. ( white )

   # Resources.resx를 더블클릭하여 리소스추가 > 새 이미지 추가 > 이미지 흰색 바탕으로 하나 만듬.( WhiteGb)

 

그 다음 그룹에 대해 배경이미지를 셋팅한다.

 

 

적용된 화면이다.

 

 

 

 

WinForm에 TableLayout 을 대신해서 Layout Control을 사용해서 쉽게 디자인이 가능하다.

 

도구 상자에 Navigation & Layout 툴박스에 LayoutControl 을 이용한다.

 

레이아웃 컨트롤을 배치하면 아래처럼 컨트롤이 나온다. Drop Controls Here!!! 메세지.. 컨트롤들을 가져다 놓으면 된다.

 

 

 라벨을 드래그앤 드랍 하면 차례로 배치가 되는데 이때 아래처럼 영역을 알리는 외곽선 사각 박스가 그려지니 해당 위치에 배치할때 도움이 된다.

(# 마우스를 이용해서 놓을 위치를 확인하고 놓으면 된다. )

 Label을 빼고는 Label이 별도로 존재하는데 ExtJs의 Field 같다.

 Text를 조절하는것은 아래 속성이 있다. ( #AppearanceItemCaption.TextOptions )

Text는 숨기고 작업을 했다. TextVisible = false; 또는 ContextMenu에 보면 HideText가 있다.

좀 더 작업을 하다보면... 익숙해지니 쓸만하다.

 

 

 

바로가기 아이콘 만드는 프로그램.   

JSFW_Shortcut.zip

 

 

컨셉은 조금 다르다. 백업프로세스?를 가진 프로그램에 연결하는 바로가기 프로그램이다.

 

# 바로가기 생성

    : 바로가기 실행 프로그램을 띄우고 파일을 드래그 드랍 한다.

    : 바로가기가 바탕화면에 생성된다.

 

 

# 바로가기 실행

       : 파일(문서 : 엑셀, ppt, .txt.... )을 열때 생성된 바로가기를 이용해 연다.

       : 파일이 백업된다. ( 일자별로 1회 백업된다. )

       : 문서 편집기가 실행된다.

 

 

자리수만큼 잘라서 특정 문자 넣기.

 StringBuilder sb = new StringBuilder("abcdefghijklmnopqrstuvwxyz");
int cnt = 0;
const int LINECHARLENGTH = 4;
bool isRun = true;
while (isRun)
{
cnt += LINECHARLENGTH;
isRun = cnt < sb.Length;
if (isRun == false) break;

sb.Insert(cnt, Environment.NewLine);
cnt += Environment.NewLine.Length;
};

 

 

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

DevExpress WinForm] Layout Control  (0) 2014.10.12
바로가기 만들기] shortcut  (0) 2014.09.27
WinForm] Ribbon 컨트롤  (0) 2013.07.08
WinForm] 도킹 패널!  (0) 2013.07.08
WINFORM] 컨트롤 동적 사이즈 조절...  (0) 2013.03.26

 

 

리본컨트롤

http://www.codeproject.com/Articles/364272/Easily-Add-a-Ribbon-into-a-WinForms-Application-Cs

 

 

 

리본컨트롤 dll을 추가해서

 

항목 Ribbon 을 폼에 드래그 하면 위에 초기화면이 올라오고

 

각 컨트롤 클릭해서 addTab -> addPan추가하고 각 아이템 컬렉션에 필요한 엘리먼트 추가 하면 됨.

 

Style 프로퍼티에 따라 일반 버튼, 드롭박스 형태로 구분하여 구현가능함..

 

 

 

 

 

 

 

도킹패널 한번 써봤는데 굉장히 쉽넹???

 

전엔 소스 모두 분석한다고 파고 들고 들어가다가 어려워서 포기했었는뎅...

 

 

 

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

문자열] 자리수만큼 잘라서 특정 문자 넣기.  (0) 2013.08.20
WinForm] Ribbon 컨트롤  (0) 2013.07.08
WINFORM] 컨트롤 동적 사이즈 조절...  (0) 2013.03.26
WinForm] 단축키  (0) 2012.10.11
GDI+] 이미지 회전!  (0) 2012.08.13

 

 

 

새로 만든 컨트롤~~~!!

 

이전 컨트롤은 사이즈 조절이나 위치 조절시

마우스를 이동을 시키면 멀리 멀리 가면 절반쯤 따라왔었는데...

 

지금은 마우스 움직이면 바로 따라오게된다...

 

디자이너 기초 클래스들은 모두 만들어졌으니...

 

이제 다시 출발~!!

 

디자이너에 붙인모습...

 

 

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

WinForm] Ribbon 컨트롤  (0) 2013.07.08
WinForm] 도킹 패널!  (0) 2013.07.08
WinForm] 단축키  (0) 2012.10.11
GDI+] 이미지 회전!  (0) 2012.08.13
2010 WinForm ] 컨트롤 리사이징 예제...  (0) 2012.07.20

 

 

 단축키 관련 해서 질문글이 올라오길래 간단히 작성해보았음.

 

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