디시인사이드 갤러리

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

갤러리 본문 영역

C#프로그래밍 관련 질문입니다,,

맹꽁이(121.155) 2011.10.14 03:51:10
조회 66 추천 0 댓글 0

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 두개입니다...

 

조언 부탁드려요..

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 모태 솔로도 구제해 줄 것 같은 연애 고수 스타는? 운영자 25/07/21 - -
AD 곧 휴가!! 홈캉스, 바캉스 SALE 운영자 25/07/21 - -
280157 얼호누나도 아스처럼... [1] Adelposs갤로그로 이동합니다. 11.10.12 71 0
280156 이엠택에 비해서 암드쪽은 서비스가 좋은데? [1] blackd갤로그로 이동합니다. 11.10.12 78 0
280155 난 가슴 큰 여자보단 다리 잘 빠진 여자가 좋드라 [8] 얼빠진호랑이갤로그로 이동합니다. 11.10.12 264 0
280154 아니..자바 이거 왜 오류남..ㅠ? 맞게 쳤는데-_- [6] 없쥐갤로그로 이동합니다. 11.10.12 68 0
280153 입갤한게 자랑 [5] Adelposs갤로그로 이동합니다. 11.10.12 57 0
280152 그런 의미에서 은꼬르~ [1] 얼빠진호랑이갤로그로 이동합니다. 11.10.12 99 0
280150 걍 소개팅 안나가기로 했음 [2] 얼빠진호랑이갤로그로 이동합니다. 11.10.12 102 0
280149 난 개인적으로 17호가 젤 이쁘더라~ 거칠게갤로그로 이동합니다. 11.10.12 68 0
280147 프로세싱을 배우는 학생입니다, [4] 엉엉이(175.197) 11.10.12 146 0
280146 진짜 마우스 우클릭시 좌클릭 동시에 인식하는거 어찌 하는거냐?? [6] 거칠게갤로그로 이동합니다. 11.10.12 1090 0
280145 월 200ㅠ_ㅠ [11] 백탈자(61.250) 11.10.12 242 0
280143 엄마걱정마세요 우현애비갤로그로 이동합니다. 11.10.12 45 0
280142 형들 C++좀 도와주세요 ㅠㅠ [4] Masaki갤로그로 이동합니다. 11.10.12 98 0
280141 java 로 마우스 우클릭하면 [4] qqq(119.70) 11.10.12 98 0
280140 형들 한번만 도와주세요 ㅜ [1] 벵굼벵이붕갤로그로 이동합니다. 11.10.12 61 0
280138 컴공 -> 전자 전과 어떰? [3] ㅠㅠ(211.222) 11.10.12 174 0
280136 api 써서 윈도우 만들었는데 좌표값이 이상혀 빡곰갤로그로 이동합니다. 11.10.12 81 0
280135 육봉에 털 난 횽들 있나염?? [5] 거칠게갤로그로 이동합니다. 11.10.12 307 0
280133 형들 link.exe 종료되었습니다 이건 왜 뜨는거야? 과제셔틀(155.230) 11.10.12 141 0
280132 사진수정해주실 능력자님 구합니다.사진몇개만수정하면됩니다.사례드립니다. [4] 포토샵..(218.209) 11.10.12 83 0
280131 [19+] 경★ 일베 기념 - 5 - ★축 빡곰갤로그로 이동합니다. 11.10.12 92 0
280130 [19+] 경★ 일베 기념 - 4 - ★축 빡곰갤로그로 이동합니다. 11.10.12 80 0
280129 [19+] 경★ 일베 기념 - 3 - ★축 빡곰갤로그로 이동합니다. 11.10.12 110 0
280128 [19+] 경★ 일베 기념 - 2 - ★축 빡곰갤로그로 이동합니다. 11.10.12 136 0
280127 위대한(?) 스승 [3] ㅅㄱㅅㄱㅅㄱ갤로그로 이동합니다. 11.10.12 82 0
280125 횽들 자바 조이스틱 입력 라이브러리 오류좀~ 십라(203.252) 11.10.12 45 0
280122 JS (& XHTML 1.0)에 능한 분에게 질문 좀 [11] ㅁㄴㄻㄹ갤로그로 이동합니다. 11.10.12 69 0
280120 가산쪽 it회사 빌딩이름중에 [7] 3(116.42) 11.10.12 142 0
280118 클라우드 나인인가 담배가 새로나왔길래 [7] 어떡해갤로그로 이동합니다. 11.10.12 596 0
280116 아이폰에서 블루투스 프로그래밍하는법 자세히 아는 형 있어?? [8] Aven갤로그로 이동합니다. 11.10.12 83 0
280115 while loop 이랑 try 함께 쓰는법좀 가르쳐줘 ㅜㅜ [5] 혁먀새(129.128) 11.10.12 70 0
280113 싱글족 최고 스킬이 혼자서 고기집 가기라네.. [9] 쿄스케갤로그로 이동합니다. 11.10.12 289 0
280112 2015년 디지털 교과서!! [5] 쿄스케갤로그로 이동합니다. 11.10.12 120 0
280111 형들 임베디드 전망은 어때?? Aven갤로그로 이동합니다. 11.10.12 130 0
280110 ios5 깔면 icloud 5기가 공짜로 제공되는 게 좃트루? 분당살람갤로그로 이동합니다. 11.10.12 53 0
280107 여름휴가때 폐가체험 다녀왔었음 ㅋ.ㅋ [3] 꼬꼬월드갤로그로 이동합니다. 11.10.12 91 0
280104 짜증난다고 짜증내면, 짜증만 더나더라고.. [4] blackd갤로그로 이동합니다. 11.10.12 75 0
280103 진짜 간단한건데 그럼 이것만 좀 ㅠㅠ [2] 정글쥬스(220.68) 11.10.12 53 0
280102 이번텀 레알 주옥됐음 ㅋㅋㅋㅋ [1] 땡칠도사갤로그로 이동합니다. 11.10.12 112 0
280101 형들 진짜 초 간단한 자바 문제좀 알려줘요 진짜 간단함 정글쥬스(220.68) 11.10.12 51 0
280100 오늘 저녁에 iOS5 나오지?? Aven갤로그로 이동합니다. 11.10.12 37 0
280099 후우.. 역시 왠만한 것들은 바로바로 포스팅 해놔야 겠어. [6] blackd갤로그로 이동합니다. 11.10.12 92 0
280098 근데 소개팅 말이야 [5] 얼빠진호랑이갤로그로 이동합니다. 11.10.12 125 0
280097 형들 치킨집 얘기 자꾸 하는데 [6] Dawnwalkre갤로그로 이동합니다. 11.10.12 138 0
280095 형들 도와주삼여 if else 문제 [38] c언어(14.53) 11.10.12 191 0
280094 으잌ㅋㅋㅋㅋㅋㅋㅋ형들 나 친구가 소개팅 시켜준댘ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ [4] 얼빠진호랑이갤로그로 이동합니다. 11.10.12 146 0
280093 으잌ㅋㅋ 횽들은 VB에서 기본적으로 Call By Ref인거 알고있었음? [10] ㅇㅇㅇ(121.144) 11.10.12 149 0
280090 새벽에 프갤에서 병1림픽 쩔었네 [1] Dawnwalkre갤로그로 이동합니다. 11.10.12 90 0
280084 형들 안녕 수요일이다 + 크롬북 대안-_- [5] Dawnwalkre갤로그로 이동합니다. 11.10.12 99 0
280083 이것좀 풀어봐 [2] ㅁㄴㅇㄻㄴㅇ(128.134) 11.10.12 60 0
뉴스 '스프링 피버' 안보현-이주빈, 출연 확정! 직진과 철벽을 오가는 코믹 로맨스 COMING SOON 디시트렌드 07.23
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2