2017년 6월 27일 화요일

[C#] Wpf Style 사용법

1.  styleDictionary.xmal 만듬.

--




--


2. App.xaml 에서 다음을 추가.
--

           
               
           

       
   

--

3. Form에서는 다음과 같이 사용
--




--






2017년 6월 26일 월요일

[WPF] Grid Line

http://www.sysnet.pe.kr/Default.aspx?mode=2&sub=0&detail=1&pageno=0&wid=739&rssMode=1&wtype=0

[c#] wpf startup wpf window

https://stackoverflow.com/questions/18138934/startup-code-in-a-windows-presentation-form-application


[C#] event Propagate

//In winform
// event is propagated c3 => c2 => c1 => winform

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EventPropagate
{
    public partial class Form1 : Form
   
{

        c1 cc1 = new c1();
        public Form1()
        {
            InitializeComponent();
            cc1.evtcc1 += new ff( test );
        }

        private void button1_Click( object sender , EventArgs e )
        {
            cc1.fire();
        }

        void test( int input )
        {
            label1.Text = input.ToString();
        }

    }


    public class c1
    {
        c2 cc2 = new c2();

        public void fire() { cc2.fire(); }

        public event ff evtcc1
        {
            add
            {
                Debug.WriteLine("c1");
                cc2.evtcc2 += value;
            }
            remove { }

        }

    }

    public class c2
    {
        c3 cc3 = new c3();
        public void fire() { cc3.fire(); }

        public event ff evtcc2
        {
            add
            {
                Debug.WriteLine("c2");
                cc3.evt += value;
            }
            remove { }

        }

    }

    public delegate void ff( int input );
    public class c3
    {
        public event ff evt ;

        public void fire()
        {
            Debug.WriteLine( "c3" );
            evt( 10000 );
        }
    }

}

2017년 6월 22일 목요일

[C#] casting

1. (int)3.4 =: InvalidCastException.
2.  as : null faster


[C#] Attribute

1. GetMethod()

-> 반환되는 메소드는 알파벳 순서로 나열이 된다.
-> bindingFlag 로 필터링해 메소드를 얻을 수 있다.

가져오는것은 다음과 같다.

https://msdn.microsoft.com/ko-kr/library/system.reflection.methodinfo(v=vs.110).aspx

2017년 6월 21일 수요일