디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

C# 코딩관련 질문!!!!!!!!!!!!!!!!!!!!!!!!!!

맹꽁(121.155) 2011.10.14 21:44:27
조회 57 추천 0 댓글 1

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

namespace alphabet_batch
{
    public partial class Form1 : Form
    {
        Size bound;

        List<Bitmap> [] alphabets;

        List<Character> text;

        List<PictureBox> pictureList;

        Graphics g;

        public Form1()
        {
            pictureList = new List<PictureBox>();

            bound = Screen.PrimaryScreen.Bounds.Size;

            text = new List<Character>();

            alphabets = new List<Bitmap>[26];

            g = this.CreateGraphics();

            for (char i = \'a\'; i < 123; i++)
            {
                alphabets[i-97] = new List<Bitmap>();

                for (int j = 1; j < 27; j++)
                {
                    String fileName = ((char)i).ToString() +"-"+ j + ".jpg";

                    Bitmap b = new Bitmap(fileName);

                    b.MakeTransparent(Color.White);

                    alphabets[i-97].Add(b);
                }
            }

            InitializeComponent();
           
            Width = pictureBox1.Width = bound.Width;
            Height = pictureBox1.Height = bound.Height;

            Left = pictureBox1.Left = 0;
            Top = pictureBox1.Top = 0;
            
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {

            Keys input = e.KeyCode;

            int KeyValue = (int)input - 65;


            if (KeyValue == 47) //esc
            {
                if(MessageBox.Show("정말 종료하시겠습니까?","경고", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    Close();
            }
            else if (KeyValue == -57) //backspace
            {
                if (text.Count != 0)
                {
                    text.RemoveAt(text.Count-1);
                }
            }
            else if (KeyValue == -33) //space
            {
                text.Add(new Character(28, 0));
            }
            else if (KeyValue == -52) //enter
            {
                text.Add(new Character(27,0));
            }
            else if (KeyValue >= 0 && KeyValue < 26)
            {
                Random rd = new Random();

                int type = rd.Next(26);

                text.Add(new Character(KeyValue, type));
            }

            //pictureBox1.Invalidate();

            Invalidate();
           
        }
              private void Draw()
        {
            for (int i = 0; i < pictureList.Count; i++)
            {
                pictureList[i].Dispose();
            }
            pictureList.Clear();
            pictureList = new List<PictureBox>();
            List<int> returnCoord = new List<int>();

            Bitmap buffer = new Bitmap(bound.Width, bound.Height);

            Graphics backBuffer = CreateGraphics();
            backBuffer = Graphics.FromImage(buffer);

            int widthTotal = 0;

            int heightNow = 0;
            int heightTotal = 0;

            for (int i = 0; i < text.Count; i++)
            {
                if (text[i].alphabet == 27)
                {
                    returnCoord.Add(i);
                    widthTotal = 0;
                    heightTotal += heightNow;
                }
                else if (text[i].alphabet == 28)
                {
                    widthTotal += 60;
                }
                else if (widthTotal + alphabets[text[i].alphabet][text[i].typeIdx].Width > bound.Width)
                {
                    returnCoord.Add(i);
                    widthTotal = 0;
                    heightTotal += heightNow;
                }
                else
                {
                    widthTotal += alphabets[text[i].alphabet][text[i].typeIdx].Width;

                    if (heightNow < alphabets[text[i].alphabet][text[i].typeIdx].Height)
                    {
                        heightNow = alphabets[text[i].alphabet][text[i].typeIdx].Height;
                    }
                }
            }

            heightTotal += heightNow;

            int lastCoord = 0;
            int heightStart = bound.Height / 2 - heightTotal / 2;

            heightNow = 0;


            for (int i = 0; i <= returnCoord.Count; i++)
            {
                int width = 0;

                int target = 0;

                if (returnCoord.Count == i)
                {
                    target = text.Count;
                }
                else
                {
                    target = returnCoord[i];
                }

                for (int j = lastCoord; j < target ; j++)
                {
                    if (text[j].alphabet == 28)
                        width += 60;
                    else if (text[j].alphabet != 27)
                        width += alphabets[text[j].alphabet][text[j].typeIdx].Width;
                }

                int startPos = (bound.Width) / 2 - width / 2;

                for (int j = lastCoord; j < target; j++)
                {
                    if (text[j].alphabet == 27)
                        continue;
                    else if (text[j].alphabet == 28)
                    {
                        startPos += 60;
                        continue;
                    }

                    backBuffer.DrawImage(alphabets[text[j].alphabet][text[j].typeIdx], new Point(startPos, heightStart));

                    PictureBox p = new PictureBox();
                    p.Image = alphabets[text[j].alphabet][text[j].typeIdx];
                    p.Width = alphabets[text[j].alphabet][text[j].typeIdx].Width;
                    p.Height = alphabets[text[j].alphabet][text[j].typeIdx].Height;
                    p.Left = startPos;
                    p.Top = heightStart;
                    pictureList.Add(p);

                    if (heightNow < alphabets[text[j].alphabet][text[j].typeIdx].Height)
                    {
                        heightNow = alphabets[text[j].alphabet][text[j].typeIdx].Height;
                    }

                    startPos += alphabets[text[j].alphabet][text[j].typeIdx].Width;
                }

                heightStart += heightNow;

                if(returnCoord.Count > 0 && i != returnCoord.Count)
                    lastCoord = returnCoord[i];
            }

            for (int i = 0; i < pictureList.Count; i++)
            {
                //Controls.Add(pictureList[i]);
            }

            //g.DrawImage(buffer, new Point(0, 0));

            pictureBox1.Image = buffer;
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {

          
        }

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
          
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Invalidate();
            Draw();
        }
    }

    class Character
    {
        public int alphabet; //27: 엔터 . 28: 스페이스
        public int typeIdx;

        public Character(int alphabet, int typeIdx)
        {
            this.alphabet = alphabet;
            this.typeIdx = typeIdx;
        }
    }
}

 

---------------

 

흰 화면에 문자를 타이핑하면 그에 맞는 글자들이 나오는 프로그램 입니다.

 

그런데 너무 흰 화면만 있어서 GIF파일로 커서를 만들었고, 특수기호들도 만들었는데

 

코딩을 어떻게 수정해야 할 지 문의드립니다..

 

제가 프로그래머가 아니라서..--; 일단 커서파일 이름은 cc.gif이고

 

느낌표는 ooo-1.jpg, 물음표는 que-1.jpg, que-2.jpg 파일 두개이고 (랜덤으로 나와야 합니다.)

마침표는 dot-1.jpg, 쉼표는 pu-1.jpg, pu-2.jpg 두개입니다...

 

조언 부탁드려요..

<>                 function googleUrl() {                        open("http://services.google.com/feedback/abg?url=https://gall.dcinside.com/list.php%3Fid%3Daccident%26no%3D2410966%26page%3D1&hl=ko&client=ca-pub-7860453437827280&adU=brandnew.co.kr&adT=%EB%B9%84%ED%82%A4%EB%8B%88%EC%88%98%EC%98%81%EB%B3%B5+%EB%B8%8C%EB%9E%9C%EB%93%9C%EB%89%B4&adU=www.aka.co.kr/&adT=100%ED%8D%BC%EC%84%BC%ED%8A%B8+%EC%B6%94%EC%B2%9C%EB%B9%84%ED%82%A4%EB%8B%88+%EC%95%84%EC%B9%B4&adU=www.ninosports.co.kr&adT=%EC%95%84%EB%A0%88%EB%82%98+%EB%9E%A0%EB%A6%AC+%EB%8B%88%EB%85%B8%EC%8A%A4%ED%8F%AC%EC%B8%A0&done=1");                  }                </>
<IFRAME height=605 marginHeight=0 src="https://wstatic.dcinside.com/ad/ad_bar/google_ad10.html" frameBorder=0 width=165 marginWidth=0 scrolling=no></IFRAME>

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 반응이 재밌어서 자꾸만 놀리고 싶은 리액션 좋은 스타는? 운영자 25/07/28 - -
AD 휴대폰 액세서리 세일 중임! 운영자 25/07/28 - -
284179 스티브잡스 전기 요약.. [3] 이문동쮸쮸바갤로그로 이동합니다. 11.10.28 109 0
284178 오늘책읽다가 [1] 三didas갤로그로 이동합니다. 11.10.28 44 0
284177 ㅋㄱ형은 봅니다 [5] Adelposs갤로그로 이동합니다. 11.10.28 75 0
284176 옹 디씨 모바일도 되는 구나 [2] 써니덕후갤로그로 이동합니다. 11.10.28 57 0
284175 난 지금 매우 화나있다 [4] Adelposs갤로그로 이동합니다. 11.10.28 72 0
284174 새로운 뉴비들이 유입되는 프갤이지만... [2] 이문동쮸쮸바갤로그로 이동합니다. 11.10.28 81 0
284173 외국인 대학원생이 자바를 영어로 가르치는데 저더러 도우미를 하라네요 [2] 3학년(125.139) 11.10.28 161 0
284172 이것좀 봐줘 ..............미치겠어...3일째 진전이없어 [5] 뉴비뉴비(112.172) 11.10.28 67 0
284171 친절한 프갤 뿌잉~ [3] ㅋㄱ(183.96) 11.10.28 84 0
284170 게임 프로그래머가 게임을 많이하는건... 이문동쮸쮸바갤로그로 이동합니다. 11.10.28 83 0
284169 아 크라이엔진 배우고 싶은데 영어가 딸린다 ㅅㅂ [7] 1(183.104) 11.10.28 98 0
284167 형들 C-Like 표현법이 머야? [4] 혼전순결(121.88) 11.10.28 79 0
284166 게임개발은 개발자라면 누구나 한번쯤은 꿈꿔봤겠지만... [12] 꼬꼬월드갤로그로 이동합니다. 11.10.28 240 0
284165 새벽인데 혐짤이나 봐요 [2] 데세랄(61.33) 11.10.28 86 0
284164 (ㅇㅂㅇ)/ 봐라 ㄴㄴㅇ(116.36) 11.10.28 42 0
284163 안녕형들 잉여잉간이 또 C언어숙제 막혀서 물어보러옴 ㅠ [12] 잉여잉간(110.76) 11.10.28 137 0
284162 언리얼 공개형 배우는 중인데 소스도 몇개 없구만 이걸로 무슨 겜을 만들어 [6] 1(183.104) 11.10.28 92 0
284160 foundations of computer science 이책 1독하면 --(220.72) 11.10.28 39 0
284159 입문자를 도와주세요 [2] rnmn갤로그로 이동합니다. 11.10.28 68 0
284157 똥을 싸고 난 후에... [1] 빅바!갤로그로 이동합니다. 11.10.28 52 0
284156 야들아 게시판 조회수 늘리는 쿼리좀. [3] 쵸쵸(219.251) 11.10.28 54 0
284155 유투브 설문 뭐임?? [1] 떡고매갤로그로 이동합니다. 11.10.28 46 0
284154 형들 인성면접은 어떤식으로 하는게 좋을까? [7] ㅠㅠ(112.148) 11.10.28 89 0
284151 아... 공지에 올라온 어떡해횽 일기 읽고있다가... [6] Re-FEEL갤로그로 이동합니다. 11.10.28 67 0
284150 아주 기본적인 게임만드는거 [7] 밀제갤로그로 이동합니다. 11.10.28 75 0
284149 ArrayList 제대로 안되면 과제한거 싹 뒤집어야되는데 [15] 3학년(125.139) 11.10.28 107 0
284148 mp3 메타파일 읽어오는 것좀 가르쳐주세요 [5] 자바초보자(202.31) 11.10.28 52 0
284147 소프트웨어가 프로그래밍임? [2] 호옹이(112.148) 11.10.28 73 0
284146 근데 제네릭이나 컬렉션 이거저거 안쓰게 되지 않냐 [4] 꼬꼬월드갤로그로 이동합니다. 11.10.28 60 0
284145 게임 쪽 갈려는 사람은 다음게임들은 꼭 플레이해보길 [6] 전간디갤로그로 이동합니다. 11.10.28 143 0
284143 어레이리스트는말이지 [2] 돌아이바갤로그로 이동합니다. 11.10.28 45 0
284142 C#배우는데.. [1] Sayrin갤로그로 이동합니다. 11.10.27 63 0
284141 저도 ArrayList 질문 [3] 3학년(125.139) 11.10.27 68 0
284140 곰짜르올림 [3] Adelposs갤로그로 이동합니다. 11.10.27 39 0
284139 으아아 정신력 운지다!!! 막장갤신학생갤로그로 이동합니다. 11.10.27 34 0
284138 드라이버 개발쪽은 어떰? [5] (210.205) 11.10.27 77 0
284137 테이블 생성 질문좀 [8] ㅋㅌㅊ(175.201) 11.10.27 57 0
284136 내가 보기엔 자바나 웹하는 사람들 c 어려워 한다. [3] 전간디갤로그로 이동합니다. 11.10.27 143 0
284135 낄낄 쓰지마라 원숭이 우는소리 같다 [4] 빅바!갤로그로 이동합니다. 11.10.27 42 0
284134 웹이 쉽다는 개소리는 대체 어디서 나온거냐... [6] 빅바!갤로그로 이동합니다. 11.10.27 105 0
284133 ArrayList 입니다. [5] 막장갤신학생갤로그로 이동합니다. 11.10.27 73 0
284130 웹프로그래머들이 C개발이 뭐 어려워서 안하냐... [1] 꼬꼬월드갤로그로 이동합니다. 11.10.27 191 0
284129 크롬북 성공 한거임?? [5] 막장갤신학생갤로그로 이동합니다. 11.10.27 66 0
284128 프로그램 메모리 최대 한도가 왜 2g임? [6] 1(183.104) 11.10.27 75 0
284127 이제 시대는 웹 프로그래머가 답인감? [7] 감난(116.32) 11.10.27 143 0
284126 저...여기에 질문글 올려도 괜찮은가요..? [5] 안녕하세요(116.46) 11.10.27 43 0
284125 또올려야지 [1] Adelposs갤로그로 이동합니다. 11.10.27 31 0
284124 내가 오늘 곰돌짜응 봤는데 [4] Adelposs갤로그로 이동합니다. 11.10.27 55 0
284123 헠헠 오늘 곰돌이짜응 보고옴 [4] Adelposs갤로그로 이동합니다. 11.10.27 77 0
284122 c에서 유효성 검사할때 if 문 [6] 탐욕의두들리갤로그로 이동합니다. 11.10.27 64 0
뉴스 ‘슈퍼맨이 돌아왔다’ 심형탁, 아들 하루 목욕 스킬 대방출! 육아 선배 박수홍, “안정적으로 잘 한다” 폭풍 칭찬 디시트렌드 07.31
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2