using System.Drawing;
using System.Drawing.Drawing2D;

void drawforeground(int xx,int yy,int width,int height,int ____hatchstyle)
{
HatchStyle hs = (HatchStyle)____hatchstyle;//0-52까지 가능
Brush myBrush = new HatchBrush(hs, System.Drawing.Color.SteelBlue);
Pen myPen = new Pen(System.Drawing.Color.LightGray, 1);

System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(xx, yy, width, height));
formGraphics.DrawRectangle(myPen , xx, yy, width, height);
}
void drawforeground(int xx,int yy,int width,int height,int ____hatchstyle)
{
HatchStyle hs = (HatchStyle)____hatchstyle;//0-52까지 가능
Brush myBrush = new HatchBrush(hs, System.Drawing.Color.LightYellow);
Pen myPen = new Pen(System.Drawing.Color.LightGray, 1);

System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(xx, yy, width, height));
formGraphics.DrawRectangle(myPen , xx, yy, width, height);
}

ex31.cs
0.00MB
ex11.cs
0.02MB

 

1. Hexa,ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

1. Horizon Direction
2. Vertical Direction
3. LeftToRight Direction
4. LightToLeft Direction

2. Tettris,ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

1. Horizon Direction

파일첨부

frm_common.cs
0.02MB




LINQ 쿼리 소개(C#)

쿼리 는 데이터 소스에서 데이터를 검색하는 식입니다. 
쿼리는 일반적으로 특수화된 쿼리 언어로 표현됩니다. 
관계형 데이터베이스에는 SQL이 사용되고 XML에는 XQuery가 사용되는 것처럼 시간에 따라 다양한 형식의 데이터 소스에 대해 서로 다른 언어가 개발되었습니다. 
따라서 개발자는 지원해야 하는 데이터 소스의 형식이나 데이터 형식에 따라 새로운 쿼리 언어를 배워야 했습니다. 
LINQ는 다양한 데이터 소스 및 형식에 사용할 수 있는 일관된 모델을 제공함으로써 이러한 상황을 단순화합니다. 
LINQ 쿼리에서는 항상 개체를 사용합니다. 
XML 문서, SQL 데이터베이스, ADO.NET 데이터 세트, .NET 컬렉션 및 LINQ 공급자를 사용할 수 있는 다른 모든 형식에서 데이터를 쿼리하고 변환하는 데 동일한 기본 코딩 패턴을 사용합니다.

쿼리 작업의 세 부분
모든 LINQ 쿼리 작업은 다음과 같은 세 가지 고유한 작업으로 구성됩니다.

1. 데이터 소스 가져오기.(Data Source)
2. 쿼리 만들기.(Query)
3. 쿼리 실행.(Query Execution)


ex)

using System.Linq;
using System;

class IntroToLINQ
{
    static void Main()
    {
        // The Three Parts of a LINQ Query:
        // 1. Data source.
        int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };

        // 2. Query creation.
        // numQuery is an IEnumerable<int>
        var numQuery =
            from num in numbers
            where (num % 2) == 0
            select num;

        // 3. Query execution.
        foreach (int num in numQuery)
        {
            Console.Write("{0,1} ", num);
        }
    }
}

 

/*execution display
D:\tmp\console>ex200
0 2 4 6
D:\tmp\console>
D:\tmp\console>
D:\tmp\console>
*/


설명) Form에 테트리스게임이 수행되고 인는중이라도, 백그라운드로 쓰레드 2개가 현재 동작하는 모습을 나타냅니다.
여러모로 실전활용가능한 모델입니다.

1. Form Activate & Other Statistic Possible(Threading Background)
2. BackgroundWorker
3. Form Drawing
4. Data set,get
5. Tris
6. Form - WM_PAINT Logic

basic !!

ex11.cs
0.01MB

Background class
Tris class divide!!!

ex12.cs
0.01MB

static class ----> #define instead!!

ex13.cs
0.01MB

design pattern various!!

ex14.cs
0.01MB

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


class Program
{
public static void Main(string[] args)
{
ContinueNoLoginCls nm = new ContinueNoLoginCls();
nm.running();
}
}

class ContinueNoLoginCls
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);

[DllImport("User32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("User32.dll")]
public static extern IntPtr FindWindowEx(int hWnd1, int hWnd2, string lpClassName, string lpWindowName);

const uint WM_KEYDOWN = 0x0100;
const uint WM_KEYUP = 0x0101;
const uint WM_CHAR = 0x0102;
const int VK_TAB = 0x09;
const int VK_ENTER = 0x0D;
const int VK_UP = 0x26;
const int VK_DOWN = 0x28;
const int VK_RIGHT = 0x27;
const int VK_F5 = 0x74;
const int VK_F6 = 0x75;
 
//According to SPY++ in IE

//ENTER key is
// P KEYDOWN
// P CHAR
// S CHAR
// P KEY_UP

//TAB key is
// P KEYDOWN
// P KEYUP

//DOWN, UP, RIGHT, LEFT is
// P KEYDOWN
// S KEYDOWN
// P KEYUP

//Letters is
// P KEYDOWN
// S KEYDOWN
// P CHAR
// S CHAR
// P KEYUP

IntPtr tailHandle = IntPtr.Zero;
IntPtr Handle_1 = IntPtr.Zero;
IntPtr Handle_2 = IntPtr.Zero;
//const string captionmsg="파일 탐색기";
//const string captionmsg="명령 프롬프트";
const string captionmsg="네이버 부동산 - Microsoft Edge";

public void running()
{
Console.Title = "";
tailHandle = FindWindow(null, captionmsg);

ConsoleKeyInfo keyinfo;

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

debug(">>>>KEY:[" + keyinfo.Key.ToString() + "]");

if(keyinfo.Key==ConsoleKey.Enter)
{
debug(">>>>SendTab() method call!!");
SendTab();
}
else if(keyinfo.Key==ConsoleKey.RightArrow)
{
debug(">>>>SendArrowKey() method call!!");
SendChar(VK_F5);
}
else if(keyinfo.Key==ConsoleKey.Spacebar)
{
debug(">>>>SendArrowKey() method call!!");
SendArrowKey(VK_F5);
}

else if(keyinfo.Key==ConsoleKey.Escape)
{
debug(">>>>Quit() method call!!");
break;
}
}
}

void debug(string str)
{
Console.WriteLine(str);
}

    private void SendEnter()
    {
        PostMessage(tailHandle, WM_KEYDOWN, (IntPtr)VK_ENTER, IntPtr.Zero);
        PostMessage(tailHandle, WM_CHAR, (IntPtr)VK_ENTER, IntPtr.Zero);
        SendMessage(tailHandle, WM_CHAR, (IntPtr)VK_ENTER, IntPtr.Zero);
        PostMessage(tailHandle, WM_KEYUP, (IntPtr)VK_ENTER, IntPtr.Zero);
    }

    private void SendTab()
    {
        PostMessage(tailHandle, WM_KEYDOWN, (IntPtr)VK_TAB, IntPtr.Zero);
        PostMessage(tailHandle, WM_KEYUP, (IntPtr)VK_TAB, IntPtr.Zero);
    }

    private void SendArrowKey(int key)
    {
        PostMessage(tailHandle, WM_KEYDOWN, (IntPtr)key, IntPtr.Zero);
        SendMessage(tailHandle, WM_KEYDOWN, (IntPtr)key, IntPtr.Zero);
        PostMessage(tailHandle, WM_KEYUP, (IntPtr)key, IntPtr.Zero);
    }

    private void SendChar(int key)
    {
        //Keydown wParam values are 0x020 less than WM_CHAR wParam
        PostMessage(tailHandle, WM_KEYDOWN, (IntPtr)(key - 0x020), IntPtr.Zero);
        SendMessage(tailHandle, WM_KEYDOWN, (IntPtr)(key - 0x020), IntPtr.Zero);
        PostMessage(tailHandle, WM_CHAR, (IntPtr)key, IntPtr.Zero);
        SendMessage(tailHandle, WM_CHAR, (IntPtr)key, IntPtr.Zero);
        PostMessage(tailHandle, WM_KEYUP, (IntPtr)(key - 0x020), IntPtr.Zero);
    }
}



Assembly.LoadFrom() : DLL 활용하여, Form을 띄우기
/*----------------------------------------------------------------------
Description : 클래스라이브러리로 생성되어진 폼을 띄울때에 사용되어진다.(폼형태만 가지고 인는것을 폼처럼 만들어서 띄울수있다.)
ex) 
1. frm's name : UAPDBMQ0010
2. dll's name : DBM.DLL
----------------------------------------------------------------------*/

sample code>>

string formName = "UAPDBMQ0010";
string dllName = formName.Substring(3,3); //DBM.DLL
string assembly = dllName + ".DLL";
string classname = dllName + "." + formName;

Assembly asm = Assembly.LoadFrom(assembly);
object o = asm.CreateInstance(classname);
var doc = (Form)o;

Form frm = doc;
frm.Tag = assembly;
if(frm == null) return null;

frm.MdiParent = this; //MDI CASE
frm.FormBorderStyle = FormBorderStyle.None; //NEW FORM
frm.Dock = DockStyle.Fill //POPUP, WHEN DELETE

frm.Text="";
frm.TopLevel=false;
frm.Parent=this;
frm.Show();

[C#] PDB(*.pdb) 파일(?)

PDB 파일이란 무엇이며 솔루션을 다시 빌드 할 때 릴리스 폴더에서 PDB 파일을 어떻게 제외시킬 수 있습니까?

PDB 파일에는 디버거가 작업 할 정보가 들어 있습니다. 
릴리스 빌드에는 디버그 빌드보다 정보가 적습니다. 
그러나 전혀 생성하지 않으려면 프로젝트의 빌드 속성으로 이동하여 릴리스 구성을 선택하고 “고급 …”을 클릭 한 다음 
"디버그 정보"에서 "없음"을 선택하십시오.

오늘까지는 Exception.StackTrace예외를 해결하는 데 필요한 파일 및 줄 번호 정보가없는 메시지 상자에 왜 누락 되었는지 알아 내려고 시도 할 때까지 모든 것이 제대로 작동했습니다 . 
이 게시물을 다시 읽고 중요한 정보를 발견했습니다 
.PDB는 앱을 실행하는 데 필요하지 않지만 파일과 줄 번호가 StackTrace문자열 에 있어야 합니다. 
PDB 파일을 실행 가능 폴더에 포함 시켰으며 이제는 모두 정상입니다.

PDB 는 P rogram D ata B ase 의 약자입니다. 
이름에서 알 수 있듯이 프로그램을 디버그 모드로 실행하는 데 필요한 정보를 유지 관리하는 저장소 (데이터베이스와 같은 영구 저장소)입니다. 
여기에는 코드를 디버깅하는 동안 (Visual Studio에서) 디버거가 Visual Studio에서 중단 될 것으로 예상되는 지점을 삽입 한 지점과 같은 중요한 관련 정보가 많이 포함되어 있습니다.

*.pdb디버그 폴더에서 파일 을 제거하면 Visual Studio가 중단 점에 여러 번 실패하는 이유 입니다. Visual Studio 디버거는 파일을 사용하여 스택 추적에서 예외가 발생한 정확한 줄 번호의 코드 파일을 알려줄 수도 *.pdb있습니다. 따라서 효과적으로 pdb 파일은 프로그램을 디버깅하는 동안 개발자에게 큰 도움이됩니다.

일반적으로 *.pdb파일 생성을 제외하지 않는 것이 좋습니다 . 
프로덕션 릴리스 관점에서해야 할 일은 pdb 파일을 작성하지만 제품 설치 프로그램의 고객 사이트에는 제공하지 않는 것입니다. 
생성 된 모든 PDB 파일을 필요한 경우 나중에 사용 / 참조 할 수있는 기호 서버에 보존하십시오. 
특히 프로세스 충돌과 같은 문제를 디버깅하는 경우에 적합합니다. 
크래시 덤프 파일 분석을 시작하고 *.pdb빌드 프로세스 중에 만들어진 원본 파일이 유지되지 않으면 Visual Studio에서 크래시를 일으키는 정확한 코드 줄을 만들 수 없습니다 .

PDB 파일은 디버거에 의해 사용되는 정보가 포함되어 있습니다. 
응용 프로그램을 실행할 필요가 없으며 릴리스 된 버전에 포함시킬 필요가 없습니다.

Visual Studio에서 pdb 파일이 생성되지 않도록 설정할 수 있습니다. 
명령 행 또는 스크립트에서 빌드하는 경우 /Debug스위치 를 생략하십시오.


C#프로젝트를 빌드하면, exe 혹은 dll파일과 함께 pdb파일도 함께 나오는 것을 종종 확인하셨을 것입니다.
pdb파일은 프로그램을 디버깅할 때 필요한 파일입니다.
pdb파일 속에는 디버깅에 필요한 정보들이 포함되어 있습니다.
이 말을 뒤집으면 프로그램을 배포할 때에는 pdb파일이 있어선 안 되겠죠.
그래서 혹시 배포 패키지에 pdb파일이 섞여 들어가는 것을 막기 위해 빌드 옵션을 설정할 수가 있습니다.
그럼 지금부터 pdb파일을 나오게 하는 법, 안 나오게 하는법에 대해 알아보도록 하겠습니다.

>>>>PDB파일 안나오게 하는 법

1. 프로젝트 우클릭 2. Properties 클릭 3. 좌측의 Build 클릭 4. Advanced 클릭 5. Debugging information을 Pdb-only로 설정

 

+ Recent posts