디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁이(121.155) 2011.10.14 03:51:10
조회 65 추천 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/06/30 - -
AD 휴대폰 바꿀까? 특가 구매 찬스! 운영자 25/07/02 - -
281543 대학교 시험기간+월요일이라 그른가 [1] Dawnwalkre갤로그로 이동합니다. 11.10.17 58 0
281540 64비트 컴파일러 [2] 수크라제갤로그로 이동합니다. 11.10.17 87 0
281539 개초봇 내일 시험에 힌트.... madcat_mk2갤로그로 이동합니다. 11.10.17 44 0
281538 형들 Aven갤로그로 이동합니다. 11.10.17 42 0
281537 txt 파일을 불러와서 입력한 값을 읽을 때, 특정위치만 읽게하고싶어요 [5] dddd(119.202) 11.10.17 55 0
281536 대세는 안드로이드에서 웹으로 ... [1] 장어구이(211.245) 11.10.17 68 0
281535 여러분 솔로는 진리입니다 모두 솔로가 됩시다 [1] 얼빠진호랑이갤로그로 이동합니다. 11.10.17 65 0
281534 리눅스 vmware로 설치법좀 ㅠㅠ [4] rdfsdaf(211.105) 11.10.17 184 0
281533 siri의 적절한 사용법.jpg [2] 534F444D61737465갤로그로 이동합니다. 11.10.17 138 0
281532 윈덤프 깔아본사람 존벨(210.123) 11.10.17 71 0
281530 ㅋㅋㅋ 웃기당.. [3] 일광면(119.198) 11.10.17 96 0
281527 ★ [랭킹시스템] 구구단 퀴즈 게임 ★ [6] 반짝단풍갤로그로 이동합니다. 11.10.17 97 0
281526 으아.. 매틀랩 이거 해석이안되요. [4] 매틀랩컨티뉴(121.134) 11.10.17 76 0
281525 사람은 폭풍전야를 느낄줄 알아야 하는거 같아. [4] blackd갤로그로 이동합니다. 11.10.17 106 0
281524 형들 void포인터에 대해 질문있어 [11] 얼빠진호랑이갤로그로 이동합니다. 11.10.17 151 0
281522 형들 부탁이야 도와줘영 힝힝 ㅠㅠ [9] 개초봇(155.230) 11.10.17 85 0
281521 딱풀? [2] iljeomobolt갤로그로 이동합니다. 11.10.17 71 0
281520 근데 확실히 웹개발자가..... .3(124.137) 11.10.17 80 0
281519 졸립다.. [3] 쿄스케갤로그로 이동합니다. 11.10.17 43 0
281518 그래 개발이 족같지... 534F444D61737465갤로그로 이동합니다. 11.10.17 46 0
281517 전에 누가 핸드폰에서 코딩할수 있는 어플있다고 했던것 같은데 [1] ㅇㅇ(222.113) 11.10.17 87 0
281515 후느님 책 로하로하알로하갤로그로 이동합니다. 11.10.17 44 0
281513 횽들 IOCP게임서버 만들고 있는데 클라이언트 종료에 관해서 질문 하나만 [12] 하루네코(59.25) 11.10.17 181 0
281512 디자인 감각 없는 새끼들 봐라 [2] 시불라미갤로그로 이동합니다. 11.10.17 198 0
281511 안녕형들 [3] 얼빠진호랑이갤로그로 이동합니다. 11.10.17 81 0
281510 급함: 네트웤 배울라면 어느 책 [4] 로하로하알로하갤로그로 이동합니다. 11.10.17 99 0
281509 횽들 논리게이트중에 [3] 멀티.갤로그로 이동합니다. 11.10.17 69 0
281508 네트워크 플밍책 추천좀요 ㅠㅠ [5] 멀티.갤로그로 이동합니다. 11.10.17 102 0
281507 입갤 三didas갤로그로 이동합니다. 11.10.17 35 0
281506 나 이제 리부심 안 돋고 [1] 로하로하알로하갤로그로 이동합니다. 11.10.17 55 0
281505 개발이 족같다 족같다 하지만... [3] .3(124.137) 11.10.17 99 0
281504 쎾쓰! 과제는 쎾쓰야 씨발! [1] 신세이어갤로그로 이동합니다. 11.10.17 71 0
281503 리눅스에서 c 코딩할라하는데 [7] 멀티.갤로그로 이동합니다. 11.10.17 111 0
281502 아 자바횽;; 이거 컴터가 병신이라서 안깔린다.. 아.. 시foot.. [2] 신세이어갤로그로 이동합니다. 11.10.17 61 0
281501 안녕하세요 횽들 질문하나만 올리겠습니다 [3] 늅늅(221.146) 11.10.17 58 0
281498 공모전이 꼭 좋은 것만도 아니구나..; [3] 어떡해갤로그로 이동합니다. 11.10.17 149 0
281497 이클립스 package explorer 아이콘 질문 [1] ㅍㅌ갤로그로 이동합니다. 11.10.17 92 0
281496 웹에 관해서 질문이 있어용 [5] 허허벌판갤로그로 이동합니다. 11.10.17 82 0
281495 전공살린 돈 그냥 그런 회사 vs 전공하고 딴판인데 돈많이주는 대기업 [4] 파괴대마왕(112.121) 11.10.17 115 0
281493 아이폰 앨범을 게시판에 업로드하려는데 [1] ㅂㅈㄷ(210.178) 11.10.17 44 0
281492 IncrediBuild Win7 호환 버전 몇 부터 되는지 아시는 분? Ynobe갤로그로 이동합니다. 11.10.17 42 0
281491 성님들 나 오늘 1시전까지 제출하는 과제가 있는데 도와주세여;; [11] 신세이어갤로그로 이동합니다. 11.10.17 130 0
281490 월욜 아침이라고 회의도 길게하네.. blackd갤로그로 이동합니다. 11.10.17 53 0
281488 STL list를 함수로 어떻게 넘겨줄까 횽들? [2] +어게인갤로그로 이동합니다. 11.10.17 62 0
281487 활기찬 월요일이다!! [1] McHello갤로그로 이동합니다. 11.10.17 53 0
281486 php 하시는 형들 질문 좀.... 완전간단한건데 [2] Dawnwalkre갤로그로 이동합니다. 11.10.17 80 0
281485 으앙이론시험ㅠㅠ 즐쿰갤로그로 이동합니다. 11.10.17 35 0
281484 2012년 대비해서 이거 만들어 팔아라 [3] 시불라미갤로그로 이동합니다. 11.10.17 123 0
281483 게임공학과는 커리큘럼이 어떻게되요? [3] 알오티씨플머갤로그로 이동합니다. 11.10.17 122 0
281482 방송이 중립이 있어야지... iljeomobolt갤로그로 이동합니다. 11.10.17 60 0
뉴스 '꼬꼬무', 연쇄살인범 강호순 자백 최초 영상 공개. . . 10명 외 추가 피해자 존재 가능성 충격 보도 디시트렌드 07.04
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2