디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁이(121.155) 2011.10.14 03:51:10
조회 61 추천 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
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 힘들게 성공한 만큼 절대 논란 안 만들 것 같은 스타는? 운영자 24/06/10 - -
이슈 [디시人터뷰] 웃는 모습이 예쁜 누나, 아나운서 김나정 운영자 24/06/11 - -
293672 형들 안녕? [1] 좋은아버지갤로그로 이동합니다. 11.12.11 45 0
293670 현상금 10만원 드립니다 [3] 돈돈돈갤로그로 이동합니다. 11.12.11 147 0
293669 컴퓨터전공인데요.. 3학년 복학하기전에 공부좀하려는데 어떻게해야할까요 [2] ㅇㅇㅇ(220.92) 11.12.11 106 0
293668 포인터변수 어디에 쓰이는지 아시는분? [1] 디올^^;갤로그로 이동합니다. 11.12.11 60 0
293667 WANTED 돈돈돈갤로그로 이동합니다. 11.12.11 24 0
293666 asp.netBulletedList 질문좀 받아주십쇼~~!! [1] 마를린멘슨갤로그로 이동합니다. 11.12.11 27 0
293663 안드로이드로 게임만들려고 하는데 [10] ㅇㅇ(125.182) 11.12.11 117 0
293661 횽들 플머쪽 길 가려면 꼭 대학교 나와야되??? [5] 히히(125.181) 11.12.11 115 0
293660 미치겠음 진짜 이거 무슨 증상임? [9] SlayeR갤로그로 이동합니다. 11.12.11 121 0
293659 ㅏㅏㅣ [2] 돌던지는나그네갤로그로 이동합니다. 11.12.11 35 0
293658 웹프로그래밍 독학 질문 [2] 백수(218.147) 11.12.11 97 0
293657 혹시나 FBML 아시는분? [1] 행인(121.138) 11.12.11 36 0
293656 수치해석학 잘하시는 분 찾아요 ㅜㅜ 사례해드려요 [1] 도와주세요(58.233) 11.12.11 67 0
293655 성님들, 안드로이드 앱쪽으로 공부해보려고 하는데 개발툴 설치하는 팁좀.. [17] 응잉앙앵(211.48) 11.12.11 129 0
293654 C++ 잘하는 님들 ㅠㅠ [2] 헝 ㅠㅠ(117.17) 11.12.11 69 0
293653 오픈지엘이나 다이랙트3d에서 물체를 원운동 시킬려면 어떻게 해야 되는거죠 [2] ㅇㅇ(210.102) 11.12.11 355 0
293652 곧군남이 질문하나드려요 [3] 곧군남(121.165) 11.12.11 64 0
293650 왜 리눅스 갤은 없지;; [1] C_Perl갤로그로 이동합니다. 11.12.11 41 0
293648 주소창 한글 [1] DevilCruiser갤로그로 이동합니다. 11.12.11 57 0
293647 asdfasdf, 꿀렁꿀렁 봐라 [2] 요하임plus갤로그로 이동합니다. 11.12.11 67 0
293646 c++도와주세요 형들.ㅠㅠ 힘들어용 [3] 도와주세요형(165.246) 11.12.11 119 0
293645 c++ 고수님들~~ [1] asdfasdf(165.246) 11.12.11 70 0
293644 c++좀 만지작해보신느님 [21] 꿀렁꿀렁(165.246) 11.12.11 166 0
293643 ㅋㅋㅋ 프갤 공지웃기다 나폴리빠갤로그로 이동합니다. 11.12.11 96 0
293641 일정관리 프로그램짜는거에서 목록,수정,종료 함수어찌만들어요? [6] 구냑(175.113) 11.12.11 557 0
293640 형들 나 지금 뭔 언어 배워야하는지좀 소개좀해줘 [7] 이빕갤로그로 이동합니다. 11.12.11 122 0
293639 사람을 만나는 것이 두렵다. [3] Lover♥갤로그로 이동합니다. 11.12.11 129 0
293638 근데 열강C 보고 있는데 파트4부터 왜케 어렵지 -_-; [1] 프로개이머(118.176) 11.12.11 98 0
293636 일하기 싫다. [1] -쏭-갤로그로 이동합니다. 11.12.11 63 0
293635 왜 제대로된 html 에디터는 없는거임??? [7] ㅁㄴㅇㄹ(115.137) 11.12.11 163 0
293633 싸지방인데 코딩하고 싶어요 [2] 꼬비갤로그로 이동합니다. 11.12.11 107 0
293631 형들 이건 다른 질문~~~ [3] 푸르스름하다(123.214) 11.12.11 75 0
293629 횽아들 헤더파일 꼬인거 같은데 뭐가 문제인지 모르겠다;;; [7] 마겔첩자갤로그로 이동합니다. 11.12.11 96 0
293625 아 ~이거 뭐가 문제인지 모르겠어 ㅜㅠ흐규흐규 [3] 프로개이머(118.176) 11.12.11 82 0
293624 나좀 도와주라 C++ 2006 쓰다가 2010으로 바꿧는데. [2] ㅇㅇ(121.165) 11.12.11 83 0
293621 재밌는 떡밥이 있었구려 [14] 땡칠도사갤로그로 이동합니다. 11.12.11 295 0
293620 컴공 3학년 2학기 기말고사를 준비하는 이시점에 느끼는바... [9] 요하임plus갤로그로 이동합니다. 11.12.11 373 1
293619 야 이놈아 SSD에 리눅스 콘솔깔아라 [2] C_Perl갤로그로 이동합니다. 11.12.11 128 0
293618 형들 우리집 이클립스가 완전느려 SSD로 바꾸면 빨라져? [8] C언어찌랭이갤로그로 이동합니다. 11.12.11 149 0
293617 Hello World.. [3] ifone.갤로그로 이동합니다. 11.12.11 126 0
293615 형들 나좀 도와줘ㅠ [8] 스카치테이프(110.14) 11.12.11 85 0
293614 형들 도와줘..ㅜㅜㅜㅜㅜㅜㅜㅜ [10] 푸르스름하다(123.214) 11.12.11 124 0
293613 윤드림형의 뇌자극 네트워크를 보고 있음 116.44(203.229) 11.12.11 57 0
293612 문서는 좀 쓰냐? [4] -쏭-갤로그로 이동합니다. 11.12.11 99 0
293611 소개팅에서 프로그래머라고 하면 엄청 멋있어하드라.. [2] 므해?갤로그로 이동합니다. 11.12.11 206 0
293609 지금 서프라이즈 보고있는데 [1] 하얀사람갤로그로 이동합니다. 11.12.11 74 0
293607 마스터 정리 이해하려면 필요한 수학지식이 뭐가 있나? [1] dd(59.9) 11.12.11 76 0
293606 SSD사고프다 [2] 써니덕후갤로그로 이동합니다. 11.12.11 88 0
293605 형들 정말 친절하구나 장떡갤로그로 이동합니다. 11.12.11 35 0
293604 오픈지엘등에서 setTimer의 역할이 뭔가여 [2] 오픈지엘(59.21) 11.12.11 62 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2