디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁(121.155) 2011.10.14 21:44:27
조회 55 추천 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/06/30 - -
AD 휴대폰 바꿀까? 특가 구매 찬스! 운영자 25/07/02 - -
공지 프로그래밍 갤러리 이용 안내 [88] 운영자 20.09.28 45210 65
2870074 위대한 실천가 루비님 발명도둑잡기(118.216) 05:52 2 0
2870072 [박한슬의 숫자 읽기] 토건 보수와 개미 진보 발명도둑잡기(118.216) 05:44 6 0
2870070 현직 개발자의 소개팅 후기 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 발명도둑잡기(118.216) 05:12 16 0
2870069 학생들을 속여 정신대로 보내버린, 선생님이라고 할 수도 없는 파렴치한 친 [1] 발명도둑잡기(118.216) 05:08 11 0
2870068 피부 건조한 사람들 꼭봐!!! ㅇㅇㅇㅇ(125.7) 04:58 9 0
2870067 '케이팝 데몬 헌터스' 그 시작은 제주의 '女神' 이었다. 발명도둑잡기(118.216) 04:56 8 0
2870066 국비지원 들어야하나 진로 상담좀 해줘 프갤러(125.185) 04:45 31 1
2870063 리액트 문서 다 읽어봤는데 왜 당시 혁명이었는지 알겠네 ㅆㅇㅆ(124.216) 04:20 10 0
2870062 정보) 국가별 게임 목록.jpg [2] ㅇㅇ(218.144) 04:06 27 1
2870060 학회지 제 36회 논문 판다. 거래는 알뜰나눔장터 [1] 도리스아(112.170) 03:53 16 0
2870059 위대한 오픈소스와 나르시시즘: 목차 제안 [1] 루비갤로그로 이동합니다. 03:38 24 0
2870056 오늘의 발명 실마리: 디씨에 AI로 힙합 기수 칭찬, 욕하는 자동글 발명도둑잡기(118.216) 03:26 30 0
2870054 AI가 일으킨 첫 번째 전쟁 발명도둑잡기(118.216) 03:05 16 0
2870052 러스트 FFI의 모순 루비갤로그로 이동합니다. 02:42 17 0
2870050 일본 손글씨 기계 [1] 발명도둑잡기(118.216) 02:36 16 0
2870048 러빠 이제 러스트 손절치냐 ㅋㅋ 루비갤로그로 이동합니다. 02:26 25 0
2870046 애드센스 또 거부 당했네 ㅠㅠ 루비갤로그로 이동합니다. 02:17 16 0
2870045 빌보드 핫100 노래 모두 이 노래보다는 사실 얌전한 내용이다 [1] 발명도둑잡기(118.216) 02:16 22 0
2870044 Jpa는 쓰면쓸수록 병신같노 프갤러(118.235) 02:16 22 0
2870042 요즘 아이들의 '친일 혐중', 오늘도 원인을 찾는 중입니다 발명도둑잡기(118.216) 02:12 14 0
2870041 피부 건조한 사람들 꼭봐!!! ㅇㅇㅇㅇ(115.144) 02:12 15 0
2870039 강남 같은 동네 주민들의 닭싸움 케이지 발명도둑잡기(118.216) 01:55 13 0
2870037 우디 거스리 발명도둑잡기(118.216) 01:47 12 0
2870035 RPA취업 프갤러(1.243) 01:43 13 0
2870034 공부하기 좋은 세상이다 [1] 초코냥갤로그로 이동합니다. 01:40 34 0
2870033 오늘한일 [2] PyTorch갤로그로 이동합니다. 01:39 35 0
2870032 이 땅은 너희의 땅 [1] 발명도둑잡기(118.216) 01:29 20 0
2870031 똥양인들은 머리에 번식,동족포식 생각밖에없음?? 뒷통수한방(1.213) 01:29 13 0
2870030 썡노가다 하다보니 IAT 찾았다 [1] 루도그담당(58.239) 01:22 22 0
2870028 What The Fuck Is A Kilometer 발명도둑잡기(118.216) 01:13 14 0
2870027 [로터리] 토지공개념은 '소설'이 아니다. 발명도둑잡기(118.216) 01:06 12 0
2870026 재활용 할가요 도리스아(112.170) 01:01 17 0
2870025 오늘의 소설, 영화 실마리: 거대 닭이 인간에게 복수 발명도둑잡기(118.216) 00:54 11 0
2870024 요즘 자라나는 새싹들 마인드 ) 크게 통수한방치고 해외로 튀기 뒷통수한방(1.213) 00:52 18 0
2870022 NFT는 저작권 보호 도구인가 저작권 침해 도구인가 [1] 발명도둑잡기(118.216) 00:39 18 0
2870021 트위터 창업자 “모든 지재권 법 없애자” 주장 논란…머스크도 맞장구 발명도둑잡기(118.216) 00:38 14 0
2870020 "GPU는 사면서, 데이터는 왜 훔쳐" 빅테크의 질주, 뒤에서 발명도둑잡기(118.216) 00:33 14 0
2870019 어셈블리어 발명도둑잡기(118.216) 00:22 23 0
2870017 내일까지 이거 끝내고 블로그 글 적고 [1] ㅆㅇㅆ(124.216) 00:15 21 1
2870016 가끔 뜻밖에 행운이 찾아올 때 있지 않음?????????????? ㅇㅅㅇ(117.111) 00:15 21 0
2870015 이 기사 보는 즉시 비번 바꿔라…구글·애플 160억개 개인정보 유출 발명도둑잡기(118.216) 00:09 16 0
2870014 뭐냐 졸다가 점점 세진다. 강도가... 넥도리아(112.170) 00:07 14 0
2870013 C井と書いて [3] 슈퍼막코더(110.133) 00:06 27 0
2870012 고향가면 구축 2억이면 사는데 ㅇㅇ(118.235) 00:01 21 0
2870011 진앙지가 우리집일까 집 군포로 뜨는데 안양시 동안구인데, 넥도리아(112.170) 00:00 14 0
2870009 정크푸드 케이라면 [1] 발명도둑잡기(118.216) 07.05 22 0
2870008 뭐지? 지진? 우리집인가? 40년된 주택 넥도리아(112.170) 07.05 19 0
2870007 피부 건조한 사람들 꼭봐!!! [2] ㅇㅇㅇㅇ(121.126) 07.05 20 0
2870006 고춧가루 ㅇㅇ(117.111) 07.05 17 0
뉴스 '꼬꼬무', 연쇄살인범 강호순 자백 최초 영상 공개. . . 10명 외 추가 피해자 존재 가능성 충격 보도 디시트렌드 07.04
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2