Get it on Google Play


Wm뮤 :: 자주 쓰는 윈폼 코드 모음

블로그 이미지
가끔 그림그리거나 3D모델링하거나
취미로 로봇만드는
퇴직한 전자과 게임프로그래머
2020.3.48f1 , 2022.3.6f1 주로 사용
모카쨩
@Ahzkwid

Recent Comment

Archive


2020. 10. 31. 09:56 윈도우폼

 

 

윈폼의 Debug로그이다.

System.Diagnostics.Debug.WriteLine("디버그 메세지");

 

팝업띄우는 버전

System.Windows.Forms.MessageBox.Show("디버그 메세지");

 

 

윈폼 리퀘스트

//v2
public static string DownloadText(string url)
{
    try
    {
        var webClient = new System.Net.WebClient();
        return webClient.DownloadString(url);
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
        return null;
    }
}

//v1
/*
public static string DownloadText(string url)
{
    try
    {
        var webClient = new System.Net.WebClient();
        var response = webClient.OpenRead(url);
        using (var streamReader = new System.IO.StreamReader(response))
        {
            string result = streamReader.ReadToEnd();
            streamReader.Close();
            return result;
        }
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
        return null;
    }
}
*/

 

 

현재 컴퓨터 유저 이름을 반환합니다. 

System.Environment.UserName

 

 

 

 

 

Lerp

double Lerp(double a,double b,double t)
{
    //return a*(1.0-t)+b*t;
    return a + (b - a)* t;
}
Vector3 Lerp(Vector3 a, Vector3 b, float t)
{
    return a + (b - a)* t;
}

 

 

 

새창 띄울때

var form = Application.OpenForms[nameof(Form2_Prediction)];
if (form==null)
{
    form = new Form2_Prediction();
    form.Show();
}
else
{
    form.Activate();
}

 

 

 

프로세스 확인 (unity가 켜져있는지 확인하는 코드이다)

var processes=System.Diagnostics.Process.GetProcesses();
var processesNames = System.Array.ConvertAll(processes, x => x.HasExited ?"": x.ProcessName).ToList();
processesNames = processesNames.GroupBy(x=>x).Select(x=>x.First()).ToList();
processesNames = processesNames.FindAll(x => string.IsNullOrWhiteSpace(x) == false);
processesNames = processesNames.FindAll(x => x.ToLower().Contains("unity"));
foreach (var processesName in processesNames)
{
    Debug.Log(processesName);
}

 

 

콤보박스에 Enum 할당

var ProportionalOptionNames = System.Enum.GetNames(typeof(ProportionalOption));
ProportionalOptionBoxs[i].Items.AddRange(ProportionalOptionNames);

 

 

 

window form

.net

닷넷

'윈도우폼' 카테고리의 다른 글

c# 멀티스레드 기본소스  (0) 2020.11.23
c# 윈도우 폼  (0) 2018.01.28
OPENCV 오류  (0) 2017.11.19
posted by 모카쨩

  • total
  • today
  • yesterday

Recent Post

저사양 유저용 블로그 진입