2022년 4월 24일 일요일

WPF Brush RGB in code

 





///WPF Brush RGB in code
var brush = new SolidColorBrush(Color.FromArgb(255, (byte)35, (byte)164, (byte)37));
button.Background = brush;


2022년 4월 22일 금요일

( c# create class object by name) c# 이름으로 클래스 객체 생성

 


using System.Reflection;


public object GenNewClass(string Type)
{
    Assembly creator = Assembly.GetExecutingAssembly();
    object obj = creator.CreateInstance(Type);
    return obj;
}


foreach (PacketID state in Enum.GetValues(typeof(PacketID)))
{
    ts.Add(GenNewClass(state.ToString()));
}

(Check all arguments of an Enum)Enum의 모든 인자 확인하기

 




public enum customEnum
{
  aaaa,
  bbbb,
  ccccc,
  ddddd,
}

foreach (customEnum item in Enum.GetValues(typeof(customEnum)))
{
  Console.WriteLine(item.ToString());
}

2022년 4월 21일 목요일

c# A function that changes the value of a specific class field(특정클래스 필드값 변경하는 함수)

/// <summary>
        /// 특정클래스의 field값을 변경하는 함수
        /// ex) m_PLC_Data.Field_Write(m_PLC_Data, "posX",100);
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="exm"></param>
        /// <param name="valueName"></param>
        /// <param name="subject"></param>
        public void Field_Write<T>(T exm, string valueName, object subject)
        {
            //Type tp = typeof(T);
            Type tp = exm.GetType();
            FieldInfo[] flds = tp.GetFields(BindingFlags.Instance |
                                                 BindingFlags.NonPublic |
                                                 BindingFlags.Public |
                                                 BindingFlags.NonPublic);
            foreach (var t in flds)
            {
                if (valueName != t.Name)
                    continue;

                object point = t.GetValue(exm);
                if (point is int)
                    t.SetValue(exm, int.Parse(subject.ToString()));
                if (point is float)
                    t.SetValue(exm, float.Parse(subject.ToString()));
                if (point is string)
                    t.SetValue(exm, subject);
            }
        }


        /// <summary>
        /// 특정 클래스의 값을 읽어오는 함수
        /// ex) Console.WriteLine(m_PLC_Data.Field_GetValue(m_PLC_Data, "posX"));
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="exm"></param>
        /// <param name="valueName"></param>
        /// <returns></returns>
        public object Field_GetValue<T>(T exm, string valueName)
        {
            Type tp = exm.GetType();
            FieldInfo[] flds = tp.GetFields(BindingFlags.Instance |
                                                 BindingFlags.NonPublic |
                                                 BindingFlags.Public |
                                                 BindingFlags.NonPublic);

            object point = null;
            foreach (var t in flds)
            {
                if (valueName != t.Name)
                    continue;
                point = t.GetValue(exm);
                break;
            }

            return point;
        }

2022년 4월 20일 수요일

git history를 통해 과거 commit 파일 가져오기


 history를 누르고 커밋이력을 확인해서 원하는 커밋에 있는 파일을 가져온다~






history가 안보인다면

branch를 클릭해서 바꿔보자


근로소득원천징수 영수증 발급방법(제일간단 2022년기준)

 1.홈텍스 접속

2.로그인하기(다양한 방법으로 로그인)

3.로그인 성공했으면 끝임 밑에 그림따라서 누르시면 됩니다.

홈텍스->연말정산 지급명세서->지급명세서 등 제출내역


원하는 지급명세서 보기후 출력


2022년 4월 19일 화요일

Winform class-based dynamic UI creation(winform 클래스기반 동적 UI 생성)

 


public void DynamicButton_Load(object sender, EventArgs e)
{
    PLCDataButton(TargetClass 원하는클래스);
}

public void PLCDataButton<T>(T target)
{
    List<string> fieldNames = new List<string>();
   
    foreach (var prop in target.GetType().GetFields())
    {
       
        fieldNames.Add(prop.Name);
    }

    m_PLC_Data.Field_Write(m_PLC_Data, "posX",100);
    Console.WriteLine(m_PLC_Data.Field_GetValue(m_PLC_Data, "posX"));

    Control[] BTN = new Control[fieldNames.Count];
    Control[] TB = new Control[fieldNames.Count];

    for (int idx = 0; idx < fieldNames.Count; idx++)
    {
        BTN[idx] = new Button();
        BTN[idx].Name = "btn_"+fieldNames[idx];
        BTN[idx].Parent = this;
        BTN[idx].Size = new Size(90, 30);


        TB[idx] = new TextBox();
        TB[idx].Name = "tb_"+fieldNames[idx];
        TB[idx].Parent = this;
        TB[idx].Size = new Size(90, 30);

        BTN[idx].Text = fieldNames[idx];

        if (m_PLC_Data.Field_GetValue(m_PLC_Data, fieldNames[idx]) == null)
            TB[idx].Text = "0";
        else
            TB[idx].Text = m_PLC_Data.Field_GetValue(m_PLC_Data, fieldNames[idx]).ToString();
       

        //BTN[idx].Click += TB_PLC_Change;
        TB[idx].TextChanged += TB_PLC_Change;

        WIDTH += 80;

        HEIGHT += 30;

        ///[flp_btns] 이것은 따로 만들어주는게 맘이편함
        ///[flp_btns] I like to make this separately.
        flp_btns.Controls.Add(BTN[idx]);
        flp_btns.Controls.Add(TB[idx]);
    }

    this.Controls.Add(flp_btns);
}


특정 클래스에 있는 Field 부분만 UI로 만들어서

UI에서 변경하면 직접 변경되게 하는 코드(버튼은 의미없긴함)


By making only the Field part in a specific class as UI

Code that makes changes directly when changed in UI (buttons are meaningless)











2022년 4월 11일 월요일

Upload your unity project to gitlab(gitlab에 유니티 프로젝트 올리기)




gitlab에 유니티 프로젝트 올리기
Upload your unity project to gitlab


1. 주소창에 gitlab.com 입력합니다.
 (Enter gitlab.com in the address bar.)



2. gitlab에서 회원가입을 하고 로그인을 합니다.
(기존 구글회원가입이 되어있어 저는 구글로 했습니다.)
Register as a member in gitlab and log in.
(I have already registered as a Google member, so I used Google.)




3.New project 아이콘 클릭
(Click the New project icon)






4.빈프로젝트 생성
(Create an empty project)



5. 빈 프로젝트 이름 설정
(Set empty project name)



6.클론 클릭후 HTTPS 저장(Ctrl+C)
(Click Clone and save HTTPS (Ctrl+C))




7.아무 폴더에서 git Bash Here클릭
(Click git Bash Here in any folder)



8.git clone 명령어+복사한 HTTPS 주소 입력(shift+insert누르면 붙여넣기됨)
(git clone command + Enter the copied HTTPS address (press shift + insert to paste))



9.명령어 입력후 해당 저장소 폴더 생성되는것 확인
(Check that the storage folder is created after entering the command)

10.폴더안에 .git만 복사하거나 잘라내거나 하기
(Copying or cutting only .git in the folder)

11.원하는 UnityProject경로에 붙여넣고 해당 경로에서 다시 git bash로 터미널 열기
(Paste it in the desired UnityProject path and open the terminal again with git bash from that path)

12. 해당 경로에 .gitignore 파일도 추가(필수는 아님)
(필요없는 파일은 안올리는거라고 보시면됩니다)
Also add the .gitignore file to that path (not required)
(You can think of it as not uploading files you don't need)
Unity.gitignore DownLoad Here



13. 터미널에 명령어 순서대로 입력
git status로 확인
git add .
git commit -m "원하는 주석"
git push -u origin main

확인 끝~

(Enter the command sequence in the terminal
check with git status
git add .
git commit -m "any comment you want"
git push -u origin main

Confirmation done~)































 

2022년 4월 4일 월요일

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...