닷넷 프레임워크

닷넷 프레임워크(.NET Framework, 이전 이름: 닷넷)는 마이크로소프트에서 개발한 윈도우 프로그램 개발 및 실행 환경이다. 
네트워크 작업, 인터페이스 등의 많은 작업을 캡슐화하였고, 
공통 언어 런타임(Common Language Runtime)(CLR)이라는 이름의 가상 머신 위에서 작동한다.

닷넷 프레임워크의 구조

.NET 프레임워크의 가장 중요한 콤포넌트는 공통 언어 기반(Common Language Infrastructure)이다. 
다른 말로 CLI라고 한다. 
CLI를 둔 목적은 애플리케이션의 개발과 실행 시 언어에 종속적이지 않은 플랫폼을 제공하기 위해서이다. 
예외 처리, 가비지 콜렉션, 보안, 호환 등을 위한 소프트웨어 콤포넌트를 포함한다. 
마이크로소프트가 구현한 CLI를 일컬어, 공통 언어 런타임(Common Language Runtime, CLR)이라고 한다.

 



#YYYY-MM-DD HH:MM:SS 에서 MM이 변경되면 출력
#YYYY-MM-DD HH:MM:SS 에서 MM이 변경되면 출력
#YYYY-MM-DD HH:MM:SS 에서 MM이 변경되면 출력

using System;
using System.IO;
using System.Timers;

namespace ____trigia_pyeongchon
{
    class Program
    {
        public static void Main(string[] args)
        {
            ___proud_hill pro = new ___proud_hill();

            pro.running();
        }
    }

    class ___proud_hill
    {
        ConsoleKeyInfo keyinfo;
        int xpos,ypos;
        Timer tm;
        string ____old_month, ____now_month;

        public void running()
        {
            tm = new Timer();
            tm.Interval = 1000;

            xpos=ypos=2;

            ____old_month="INIT";
            ____now_month="INIT";

            tm.Elapsed += new ElapsedEventHandler(__time_tick);
            tm.Start();

            Logging("Start");

            while(true)
            {
                keyinfo = Console.ReadKey(true);

                if(keyinfo.Key == ConsoleKey.RightArrow) xpos++;
                else
                if(keyinfo.Key == ConsoleKey.LeftArrow) xpos--;
                else
                if(keyinfo.Key == ConsoleKey.UpArrow) ypos++;
                else
                if(keyinfo.Key == ConsoleKey.DownArrow) ypos++;
                else
                if(keyinfo.Key == ConsoleKey.Escape) break;

                if(keyinfo.KeyChar=='+')
                {
                    tm.Stop();
                    tm.Interval += 10;
                    tm.Start();
                }
                else
                if(keyinfo.KeyChar=='-')
                {
                    tm.Stop();
                    tm.Interval -= 10;
                    tm.Start();
                }

                Logging("Key");
            }
            tm.Stop();
            tm.Elapsed -= __time_tick;

            Logging("Stop");
        }

        void __time_tick(object sender, ElapsedEventArgs e)
        {
            ypos++;

            Logging("Time");
        }

        void Logging(string msg)
        {
            DateTime now;

            now = DateTime.Now;

            ____now_month = now.ToString("mm");
            if(____now_month != ____old_month)
            {
                if(____old_month !="INIT" )
                {
                    Console.WriteLine("Minute is changed!!!!!, KeyBoard HIT is needed!!");
                }
            }

            Console.WriteLine("Debug>>Time:" + now.ToString("yyyy-MM-dd hh:mm:ss") + 
                  " YYYY:" + now.ToString("yyyy") + 
                  " MM:" + now.ToString("MM") + 
                  " mm:" + now.ToString("mm") + 
                  " Pos:[" + ypos.ToString("000000") + "," + xpos.ToString("000000") + "]" +
                  " Interval:" + tm.Interval + 
                  " Event:" + msg);
            ____old_month = ____now_month;
        }
    } //end of class
} //end of namespace





    

(BEGIN)RPUSH & BLPOP Usage-------------------------------------------------
1. 터미널에서 RPUSH 커맨드로 list2 키를 추가한다.
127.0.0.1:6379> RPUSH list2 a b c
(integer) 3

2. 터미널에서 BLPOP 커맨드를 호출한다. 리스트의 앞 엘리먼트부터 pop한 것을 확인할 수 있다.
127.0.0.1:6379> BLPOP list1 list2 0
1) "list2"
2) "a"

127.0.0.1:6379> BLPOP list1 list2 0
1) "list2"
2) "b"

127.0.0.1:6379> BLPOP list1 list2 0
1) "list2"
2) "c"

127.0.0.1:6379> BLPOP list1 list2 0
(블럭됨)
(END)RPUSH & BLPOP Usage-------------------------------------------------

c# code example(approximately)
c# code example(approximately)

RedisClient sendRedis = null;
RedisClient recvRedis = null;
byte[] jsonByteData = sendQueue.Dequeue();

int rc = sendRedis.RPush("QCS", jsonByteData);
jsonByteData = recvRedis.BLPop("CLI:" + ClientCurrentId.GetInstance.MyID,10);

#Redis의 기본지식이 필요하다.
#Redis의 기본지식이 필요하다.
#Redis의 기본지식이 필요하다.

#IDE를 이용해서, NuGet패키지관리자에서 StackExchange.Redis 검색및 설치를 진행합니다.
#IDE를 이용해서, NuGet패키지관리자에서 StackExchange.Redis 검색및 설치를 진행합니다.
#IDE를 이용해서, NuGet패키지관리자에서 StackExchange.Redis 검색및 설치를 진행합니다.

#Redis Server를 이용한 데이타 저장(Key,Value)과 불러오기(Key)
#Redis Server를 이용한 데이타 저장(Key,Value)과 불러오기(Key)
#Redis Server를 이용한 데이타 저장(Key,Value)과 불러오기(Key)

using StackExchange.Redis;

class Redis
{
    private ConnectionMultiplexer redisConnection;
    private IDatabase db;

    public Redis()
    {
        //
    }

    public bool Init(string host, int port)
    {
        try
        {
            this.redisConnection = ConnectionMultiplexer.Connect(host + ":" + port);
            if(this.redisConnection.IsConnected)
            {
                this.db = this.redisConnection.GetDatabase();
                return true;
            }
            return false;
        }
        catch(Exception e)
        {
            return false;
        }
    }
    //Load-------------------------------------------------
    public string GetString(string key)
    {
        return this.db.StringGet(key);
    }
    //Save--------------------------------------------------
    public string SetString(string key, string val)
    {
        return this.db.StringSet(key, val);
    }
}

#위의 Redis class를 이용한 실행프로그램은 다음글에서 작성할예정입니다.

/*
 * static Color [] fogarr = new Color[140];
 */

fogarr[0]= Color.FromArgb(240,248,255);
fogarr[1]= Color.FromArgb(255,160,122);
fogarr[2]= Color.FromArgb(250,235,215);
fogarr[3]= Color.FromArgb(32,178,170);
fogarr[4]= Color.FromArgb(0,255,255);
fogarr[5]= Color.FromArgb(135,206,250);
fogarr[6]= Color.FromArgb(127,255,212);
fogarr[7]= Color.FromArgb(119,136,153);
fogarr[8]= Color.FromArgb(240,255,255);
fogarr[9]= Color.FromArgb(176,196,222);
fogarr[10]= Color.FromArgb(245,245,220);
fogarr[11]= Color.FromArgb(255,255,224);
fogarr[12]= Color.FromArgb(255,228,196);
fogarr[13]= Color.FromArgb(0,255,0);
fogarr[14]= Color.FromArgb(0,0,0);
fogarr[15]= Color.FromArgb(50,205,50);
fogarr[16]= Color.FromArgb(255,255,205);
fogarr[17]= Color.FromArgb(250,240,230);
fogarr[18]= Color.FromArgb(0,0,255);
fogarr[19]= Color.FromArgb(255,0,255);
fogarr[20]= Color.FromArgb(138,43,226);
fogarr[21]= Color.FromArgb(128,0,0);
fogarr[22]= Color.FromArgb(165,42,42);
fogarr[23]= Color.FromArgb(102,205,170);
fogarr[24]= Color.FromArgb(222,184,135);
fogarr[25]= Color.FromArgb(0,0,205);
fogarr[26]= Color.FromArgb(95,158,160);
fogarr[27]= Color.FromArgb(186,85,211);
fogarr[28]= Color.FromArgb(127,255,0);
fogarr[29]= Color.FromArgb(147,112,219);
fogarr[30]= Color.FromArgb(210,105,30);
fogarr[31]= Color.FromArgb(60,179,113);
fogarr[32]= Color.FromArgb(255,127,80);
fogarr[33]= Color.FromArgb(123,104,238);
fogarr[34]= Color.FromArgb(100,149,237);
fogarr[35]= Color.FromArgb(0,250,154);
fogarr[36]= Color.FromArgb(255,248,220);
fogarr[37]= Color.FromArgb(72,209,204);
fogarr[38]= Color.FromArgb(220,20,60);
fogarr[39]= Color.FromArgb(199,21,112);
fogarr[40]= Color.FromArgb(0,255,255);
fogarr[41]= Color.FromArgb(25,25,112);
fogarr[42]= Color.FromArgb(0,0,139);
fogarr[43]= Color.FromArgb(245,255,250);
fogarr[44]= Color.FromArgb(0,139,139);
fogarr[45]= Color.FromArgb(255,228,225);
fogarr[46]= Color.FromArgb(184,134,11);
fogarr[47]= Color.FromArgb(255,228,181);
fogarr[48]= Color.FromArgb(169,169,169);
fogarr[49]= Color.FromArgb(255,222,173);
fogarr[50]= Color.FromArgb(0,100,0);
fogarr[51]= Color.FromArgb(0,0,128);
fogarr[52]= Color.FromArgb(189,183,107);
fogarr[53]= Color.FromArgb(253,245,230);
fogarr[54]= Color.FromArgb(139,0,139);
fogarr[55]= Color.FromArgb(128,128,0);
fogarr[56]= Color.FromArgb(85,107,47);
fogarr[57]= Color.FromArgb(107,142,45);
fogarr[58]= Color.FromArgb(255,140,0);
fogarr[59]= Color.FromArgb(255,165,0);
fogarr[60]= Color.FromArgb(153,50,204);
fogarr[61]= Color.FromArgb(255,69,0);
fogarr[62]= Color.FromArgb(139,0,0);
fogarr[63]= Color.FromArgb(218,112,214);
fogarr[64]= Color.FromArgb(233,150,122);
fogarr[65]= Color.FromArgb(238,232,170);
fogarr[66]= Color.FromArgb(143,188,143);
fogarr[67]= Color.FromArgb(152,251,152);
fogarr[68]= Color.FromArgb(72,61,139);
fogarr[69]= Color.FromArgb(175,238,238);
fogarr[70]= Color.FromArgb(40,79,79);
fogarr[71]= Color.FromArgb(219,112,147);
fogarr[72]= Color.FromArgb(0,206,209);
fogarr[73]= Color.FromArgb(255,239,213);
fogarr[74]= Color.FromArgb(148,0,211);
fogarr[75]= Color.FromArgb(255,218,155);
fogarr[76]= Color.FromArgb(255,20,147);
fogarr[77]= Color.FromArgb(205,133,63);
fogarr[78]= Color.FromArgb(0,191,255);
fogarr[79]= Color.FromArgb(255,192,203);
fogarr[80]= Color.FromArgb(105,105,105);
fogarr[81]= Color.FromArgb(221,160,221);
fogarr[82]= Color.FromArgb(30,144,255);
fogarr[83]= Color.FromArgb(176,224,230);
fogarr[84]= Color.FromArgb(178,34,34);
fogarr[85]= Color.FromArgb(128,0,128);
fogarr[86]= Color.FromArgb(255,250,240);
fogarr[87]= Color.FromArgb(255,0,0);
fogarr[88]= Color.FromArgb(34,139,34);
fogarr[89]= Color.FromArgb(188,143,143);
fogarr[90]= Color.FromArgb(255,0,255);
fogarr[91]= Color.FromArgb(65,105,225);
fogarr[92]= Color.FromArgb(220,220,220);
fogarr[93]= Color.FromArgb(139,69,19);
fogarr[94]= Color.FromArgb(248,248,255);
fogarr[95]= Color.FromArgb(250,128,114);
fogarr[96]= Color.FromArgb(255,215,0);
fogarr[97]= Color.FromArgb(244,164,96);
fogarr[98]= Color.FromArgb(218,165,32);
fogarr[99]= Color.FromArgb(46,139,87);
fogarr[100]= Color.FromArgb(128,128,128);
fogarr[101]= Color.FromArgb(255,245,238);
fogarr[102]= Color.FromArgb(0,128,0);
fogarr[103]= Color.FromArgb(160,82,45);
fogarr[104]= Color.FromArgb(173,255,47);
fogarr[105]= Color.FromArgb(192,192,192);
fogarr[106]= Color.FromArgb(240,255,240);
fogarr[107]= Color.FromArgb(135,206,235);
fogarr[108]= Color.FromArgb(255,105,180);
fogarr[109]= Color.FromArgb(106,90,205);
fogarr[110]= Color.FromArgb(205,92,92);
fogarr[111]= Color.FromArgb(112,128,144);
fogarr[112]= Color.FromArgb(75,0,130);
fogarr[113]= Color.FromArgb(255,250,250);
fogarr[114]= Color.FromArgb(255,240,240);
fogarr[115]= Color.FromArgb(0,255,127);
fogarr[116]= Color.FromArgb(240,230,140);
fogarr[117]= Color.FromArgb(70,130,180);
fogarr[118]= Color.FromArgb(230,230,250);
fogarr[119]= Color.FromArgb(210,180,140);
fogarr[120]= Color.FromArgb(255,240,245);
fogarr[121]= Color.FromArgb(0,128,128);
fogarr[122]= Color.FromArgb(124,252,0);
fogarr[123]= Color.FromArgb(216,191,216);
fogarr[124]= Color.FromArgb(255,250,205);
fogarr[125]= Color.FromArgb(253,99,71);
fogarr[126]= Color.FromArgb(173,216,230);
fogarr[127]= Color.FromArgb(64,224,208);
fogarr[128]= Color.FromArgb(240,128,128);
fogarr[129]= Color.FromArgb(238,130,238);
fogarr[130]= Color.FromArgb(224,255,255);
fogarr[131]= Color.FromArgb(245,222,179);
fogarr[132]= Color.FromArgb(250,250,210);
fogarr[133]= Color.FromArgb(255,255,255);
fogarr[134]= Color.FromArgb(144,238,144);
fogarr[135]= Color.FromArgb(245,245,245);
fogarr[136]= Color.FromArgb(211,211,211);
fogarr[137]= Color.FromArgb(255,255,0);
fogarr[138]= Color.FromArgb(255,182,193);
fogarr[139]= Color.FromArgb(154,205,50);

#Color class 배열을 이용한 다양한 색상나타내기
#Color class 배열을 이용한 다양한 색상나타내기

#현재 Form에 대한 this 핸들얻기
#현재 Form에 대한 this 핸들얻기

#Color 배열(140개)



using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Drawing2D;

class Program : Form
{
    private const int WM_KEYDOWN = 0x0100;
    private const int WM_PAINT = 0x000F;
    private const int WM_CREATE = 0x0001;

    static Graphics graphics;
    static Font font;
    static Color [] fogarr = new Color[140]; //배열선언
    static int toggle=0;
    static int ____index=0;
    static Program fi;

    [STAThread]
    static void Main(string[] args)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Program());
    }

    static void __time_tick(object sender, ElapsedEventArgs e)
    {
        for (int h = 0; h <= 52; h++)
        {
            HatchStyle hs = (HatchStyle)h;
            Brush hb = new HatchBrush(hs, fogarr[____index % 140]);
            graphics.FillRectangle(hb, new Rectangle((h/26)*250, (h%26)*20, 50, 20));
            graphics.DrawString(hs.ToString(), font, Brushes.DarkGreen, (h/26)*250+50, (h%26)*20);
        }
        fi.Text = fogarr[____index % 140].ToString();
        ____index++;
    }

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);

        switch(m.Msg)
        {
            case WM_PAINT:
            if(toggle==0)
            {
                this.Size = new Size(800,600);
                this.Text = "HatchStyle Window Information";

                graphics = this.CreateGraphics();
                font = new Font("고딕", 12, FontStyle.Bold);
                toggle=100;
            }
            break;
            case WM_CREATE :
               

                fi = new Program();
                fi = this;


                fogarr[0]= Color.FromArgb(240,248,255); //초기화 
                fogarr[1]= Color.FromArgb(255,160,122);
                fogarr[2]= Color.FromArgb(250,235,215);
                fogarr[3]= Color.FromArgb(32,178,170);
                fogarr[4]= Color.FromArgb(0,255,255);
                fogarr[5]= Color.FromArgb(135,206,250);
                /*
                ,, 자세한 Color.FromArgb List는 c#강의리스트에 올려놓았습니다. 참고부탁드려요.^
                */
                fogarr[134]= Color.FromArgb(144,238,144);
                fogarr[135]= Color.FromArgb(245,245,245);
                fogarr[136]= Color.FromArgb(211,211,211);
                fogarr[137]= Color.FromArgb(255,255,0);
                fogarr[138]= Color.FromArgb(255,182,193);
                fogarr[139]= Color.FromArgb(154,205,50);
                break;
            case WM_KEYDOWN :

            Keys keyCode = (Keys)m.WParam & Keys.KeyCode;

            if(keyCode.ToString() == "F1")
            {
                tm = new System.Timers.Timer();
                tm.Interval=100;
                tm.Elapsed += new ElapsedEventHandler(__time_tick);
                tm.Start();
            }
            else if(keyCode.ToString() == "F2")
            {

                if(tm != null)   //예외 사항체크
                {
                    tm.Stop();
                    tm.Elapsed -= __time_tick;
                }            }
            else
            {
                for (int h = 0; h <= 52; h++)
                {
                    HatchStyle hs = (HatchStyle)h;
                    Brush hb = new HatchBrush(hs, fogarr[____index % 140]);
                    graphics.FillRectangle(hb, new Rectangle((h/26)*250, (h%26)*20, 50, 20));
                    graphics.DrawString(hs.ToString(), font, Brushes.DarkGreen, (h/26)*250+50, (h%26)*20);
                }
                this.Text = fogarr[____index % 140].ToString();
                ____index++;
                break;
            }//end if else

        }//end of switch
    }//end of method
}//end of class

#컨트롤에 포커스가 자동으로 안갈 때
#컨트롤에 포커스가 자동으로 안갈 때
#컨트롤에 포커스가 자동으로 안갈 때
#컨트롤에 포커스가 자동으로 안갈 때



case WM_PAINT:
if(toggle==0)
{
this.Size = new Size(1000,600);
this.Text = "TRIS BY CONSOLE FORM";

graphics = CreateGraphics();
font = new Font("바탕체", 17, FontStyle.Bold);

toggle=100;

timer = new System.Timers.Timer();
timer.Interval = 800;
timer.Elapsed += new ElapsedEventHandler(__time_tick);
timer.Start();

mainBackColor = this.BackColor;

MessageBox.Show("TRIS START, Time Interval:" + timer.Interval);

//Form에 focus가 가도록 하기. 키보드 컨트롤을 이용할수 있다.
this.Activate();
this.Focus();


var handle = GetConsoleWindow();
ShowWindow(handle, SW_HIDE); // 숨기기

init(ref t_tris, ref xpos, ref ypos, ref __design);
DrawTerisAll(t_tris);
}
break;

#설명:Windows10 Console창에서 실행하는 테트리스 프로그램 소스입니다.
#메모장에서 코드작성후에, C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe 로 컴파일 & 링크
#IDE는 사용하지 않습니다.(Visual Studio와 같은)

#HatchStyle 적용

#Tris Form Game by console base
#Tris Form Game by console base

#IDE(No Needed), Memo is sufficient, Window10 csc.exe is sufficient.

 

if(____t_tris[mm, nn]==0) 
{
#if false
    Brush brush = new SolidBrush(mainBackColor);
    graphics.FillRectangle(brush, 
    new Rectangle(50 + nn * ____WIDTH, 
                      40 + mm * ____HEIGHT, 
                      ____WIDTH-1, ____HEIGHT-1));
#endif   
  
#if true
    HatchStyle hs = (HatchStyle)____hatch_style;
    Brush hb = new HatchBrush(hs, mainBackColor);
    graphics.FillRectangle(hb, new Rectangle(50 + nn * ____WIDTH, 
                  40 + mm * ____HEIGHT, 
                  ____WIDTH-1, ____HEIGHT-1));
#endif   
}
else
{
#if false
    Brush brush = new SolidBrush(realBackColor[ ____t_tris[mm, nn] ]);
    graphics.FillRectangle(brush, 
                new Rectangle(50 + nn * ____WIDTH, 
                  40 + mm * ____HEIGHT, 
                  ____WIDTH-1, ____HEIGHT-1));
#endif   
  
#if true
    HatchStyle hs = (HatchStyle)____hatch_style;
    Brush hb = new HatchBrush(hs, realBackColor[ ____t_tris[mm, nn] ]);
    graphics.FillRectangle(hb, new Rectangle(50 + nn * ____WIDTH, 
                  40 + mm * ____HEIGHT, 
                  ____WIDTH-1, ____HEIGHT-1));
#endif   
}

 

#File Attach

f33.cs
0.04MB

+ Recent posts