디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁이(121.155) 2011.10.14 03:51:10
조회 67 추천 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 - -
280325 큐의 삽입과 삭제에 관련한건데 설명좀 ... [2] 돌멩이(220.83) 11.10.12 76 0
280323 큰일났다 책보면 잠온다 [1] 이힝(121.177) 11.10.12 272 0
280322 포인터 질문 ㅠ [4] ㅁㄴ(210.107) 11.10.12 62 0
280320 네이버 캐스트 프랙탈 나온거 기념해서 프랙탈열음 (윈도,크롬,오페라) [2] [성대아싸]갤로그로 이동합니다. 11.10.12 69 0
280319 워닝질문좀 ㅠㅠ [8] 군대지원(183.101) 11.10.12 167 0
280318 형들 엄청 초보적인거 질문 하나만 할게여;; [3] ㅁㄴㅇㄹ(119.196) 11.10.12 52 0
280317 안드로이드 페이지간 전송 꼭 intent객체 이용해야하는거임? [6] 얼룩돼지갤로그로 이동합니다. 11.10.12 75 0
280316 포인터 질문 [5] ㅁㄴ(210.107) 11.10.12 52 0
280315 히히히힛 [3] 116.44(110.11) 11.10.12 44 0
280314 형들 c++ 다시 질문좀할께... [12] 부적절(210.102) 11.10.12 95 0
280313 행맨 만들때 단어수에 따라 '_' 늘어나게 할려고 하는건데 [4] 리드블로우갤로그로 이동합니다. 11.10.12 64 0
280312 복습하다가 페북 프갤이라는 얘기를 봤는데... 1(121.182) 11.10.12 71 0
280311 직딩들에게 질문... [4] ㅅㄱㅅㄱㅅㄱ갤로그로 이동합니다. 11.10.12 60 0
280310 질문점 [3] ㅇㅇㅁㅇㄻㅁ갤로그로 이동합니다. 11.10.12 48 0
280309 횽들아 웹프가 그리 개 노가다라는게 사실인가염? [8] 거칠게갤로그로 이동합니다. 11.10.12 129 0
280308 시발 116.44(110.11) 11.10.12 40 0
280307 c로 행맨 만드는거 어떻게 할까요 [2] 리드블로우갤로그로 이동합니다. 11.10.12 53 0
280306 이것도 필요한 때가 있지 않을까여 [2] ㅇㅇㅁㅇㄻㅁ갤로그로 이동합니다. 11.10.12 49 0
280305 포인터 질문 [3] ㅁㄴ(210.107) 11.10.12 45 0
280302 종나 간단한 문제를 2시간동이나 쳐해맸다. 잣알.. [2] 쵸쵸(219.251) 11.10.12 66 0
280301 학교 C언어 한 3번째 시간쯤에 배우는 tmp [24] ㅇㅇㅁㅇㄻㅁ갤로그로 이동합니다. 11.10.12 462 0
280300 교수님이 c++ 하나 내줬는데 힌트 좀 주세요 [3] ㅂㅂ(114.200) 11.10.12 66 0
280298 바이너리파일 텍스트 파일 구별하는 방법 뭐 있음요? [8] ㅇㅇㅇ(121.144) 11.10.12 66 0
280297 형들 C 언어 하나만 해결해줘ㅓㅓ [10] 210(182.210) 11.10.12 116 0
280296 오늘도 역시 ! 퇴근 후 !!!! [1] 돌아이바갤로그로 이동합니다. 11.10.12 54 0
280295 진짜 아무리 찾아봐도 모르겠는데 아는 분 ,, ; [9] 더래갤로그로 이동합니다. 11.10.12 95 0
280294 방금 돈내고 앱허브 등록했음... [1] 이문동쮸쮸바갤로그로 이동합니다. 11.10.12 73 0
280292 이거 malloc을 없에고 배열로 쓸려면 어떻게 할까요 [3] 리드블로우갤로그로 이동합니다. 11.10.12 70 0
280288 회식후 퇴근중 madcat_mk2갤로그로 이동합니다. 11.10.12 45 0
280287 아아 헬쥐 U+ 또다시 [2] 막장갤신학생갤로그로 이동합니다. 11.10.12 60 0
280285 프갤 간만에 와서 한 3페이지 넘겨봤는데... [5] Dynast(59.151) 11.10.12 96 0
280283 혹시 rfid장비 써본형 있음? laoshanlong갤로그로 이동합니다. 11.10.12 50 0
280282 내일 시험을 위해 날 새야하니 지금 자야지 534F444D61737465갤로그로 이동합니다. 11.10.12 34 0
280281 인생은 선택의 연속 [3] 초이스(125.143) 11.10.12 95 0
280280 횽들 C++ 지네릭할때... [4] ㄴㄴㅇ(116.36) 11.10.12 59 0
280277 홈페이지 배끼면서 공부하는게이인데 +조공 [6] 교복여중고딩갤로그로 이동합니다. 11.10.12 161 0
280276 기아타이거즈가 멸망했슴다 [5] 꼬꼬월드갤로그로 이동합니다. 11.10.12 67 0
280275 delay time 50 이면 몇초임 ? [3] 시개갤로그로 이동합니다. 11.10.12 59 0
280273 프로그래밍 학원중에 비트가 그렇게 甲인가여 [3] LASTOR갤로그로 이동합니다. 11.10.12 240 0
280272 형들 멀티미디어 질문 !! 쉬운 계산이야 [18] 형들(175.116) 11.10.12 128 0
280269 훈방조치를 위한 떡밥글 [2] 꼬꼬월드갤로그로 이동합니다. 11.10.12 70 0
280268 나 진짜 고소당하면 어떡하지? [8] 꼬꼬월드갤로그로 이동합니다. 11.10.12 133 0
280267 하아횽은 며짤임? [1] ^0^갤로그로 이동합니다. 11.10.12 42 0
280266 너님들 좌욕하는 기분 암? 534F444D61737465갤로그로 이동합니다. 11.10.12 42 0
280265 아 얼혼지 뭔지 짱나니까 [8] y녀6디리(220.118) 11.10.12 106 0
280264 코딩 하는거 무시하는 [5] 로하로하알로하갤로그로 이동합니다. 11.10.12 85 0
280263 아 글고 또 질문여 질문 [13] LASTOR갤로그로 이동합니다. 11.10.12 84 0
280262 적어도 내가 아는 보안쪽 파던 애들은 지금 다 서버관리자함 [7] 꼬꼬월드갤로그로 이동합니다. 11.10.12 160 0
280261 학교에서 물리1,2화학생물도 필수로 들어야되는게 짱남 [1] abbey road갤로그로 이동합니다. 11.10.12 66 0
280260 대기업si는 스펙 뭐필요해? [10] ^0^갤로그로 이동합니다. 11.10.12 193 0
뉴스 트와이스, 자신감 넘치는 에너지로 컴백... 새 정규 앨범 'THIS IS FOR' 발매 디시트렌드 10:00
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2