디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁(121.155) 2011.10.14 21:44:27
조회 54 추천 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 - -
413576 c언어 뉴비 질문.. [10] 좆초보..(121.254) 14.03.20 207 0
413575 프로그래밍갤 형들은 [4] 소방차게이ㅁ갤로그로 이동합니다. 14.03.20 109 0
413574 지가 짱이라고 생각하는 애들은 언어 하나만 배워도 된다 ^오^ [1] ㅇㅇ(211.36) 14.03.20 90 0
413573 왜 언어를 하나만 배운다고 생각하지?????? ㅇㅇ(211.61) 14.03.20 85 0
413572 아오 시발 ㅋㅋㅋㅋㅋㅋ ㅇㅇ(123.140) 14.03.20 53 1
413571 왕초보 C언어) 헬프 [3] 과학과(203.237) 14.03.20 117 0
413570 c언어 winapi로 tcp/ip소켓 프로그래밍 배웠는데 닷넷으로 채팅프 [6] 수크라제갤로그로 이동합니다. 14.03.20 170 0
413568 개인 프로젝트라면 어느정도 수준이야? [1] 허세갑(59.23) 14.03.20 110 0
413566 프갤 형님들 자바 random메소드??이렇게 쓰는거 맞나요?? [1] 버리는캐갤로그로 이동합니다. 14.03.20 96 0
413565 C언어 에러해결 앙망 ㅠ [9] newbie(118.34) 14.03.20 142 0
413563 책한권에 투자하는 시간이 어떻게들되냐?? [1] 쪼꾸미갤로그로 이동합니다. 14.03.20 92 0
413562 형들 cmd로 컴파일한 java파일 실행하는데 실행이 안돼..ㅠㅠㅠㅠㅠㅠ [4] 타햐갤로그로 이동합니다. 14.03.20 230 0
413561 형들 x,y위치만가지고 함수 수식화하는방법없을까? naiad(114.70) 14.03.20 59 0
413560 c++에서 부모클래스 생성자의 명시적 호출 [1] ㅇㅇ(180.228) 14.03.20 136 0
413559 몸살 걸림 ㅜㅜ [1] 에어로홍갤로그로 이동합니다. 14.03.20 46 0
413558 레드공재갈 가품구별법 등드름(115.144) 14.03.20 62 0
413557 형들 cmd에서 자바컴파일하려는데 jli.dll이 없다는데 어떻게해야돼 [1] 타햐갤로그로 이동합니다. 14.03.20 436 0
413556 보안쪽재대로아는세기만답해라 시발수박겉할기꺼지고 아올(203.226) 14.03.20 148 0
413555 아오 시바 비도 오고 으스스하니 감기 걸린거 같다 사장(223.33) 14.03.20 32 0
413554 DDR(핀번호) 이 도데체 뭐죠; (DDRA, DDRB, DDRC 등등) [1] ㅍㄴㅅ(1.246) 14.03.20 470 0
413553 액티브x 없앤다며? [2] ㅇㅇ(211.36) 14.03.20 136 1
413550 궁금한게 ㅉㅉ(117.16) 14.03.20 50 0
413548 아오 시바 아직도 야근 [3] 사장(223.62) 14.03.20 93 0
413547 형들 궁금한게 2가지나 있는데 설명해주면 정말 고맙겠어!! 흑두(49.1) 14.03.20 59 0
413545 우리나라의 사람들은 애초에 주인의식이 아닌 노예의식이 팽배하다. [2] 이론좆문가(211.244) 14.03.20 105 0
413543 우리나라에 왜 개발자들은 곡소리가 나오는가? [5] 이론좆문가(211.244) 14.03.20 420 0
413541 c언어 도와주세요 ㅜ dad(112.150) 14.03.20 6998 0
413539 러브링추천 정보사이트 하동균(203.109) 14.03.20 53 0
413538 리눅스(우분투)에 gui 입혀서 프로그래밍 할수 있지? [1] asdfg(203.229) 14.03.20 62 0
413537 여기새끼들존나웃긴게 머냐면ㅋㅋ [20] (39.7) 14.03.20 2618 36
413536 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ (125.182) 14.03.20 244 0
413535 답좀죠 심각해 [4] ㅇㅇㅇㅇ(222.107) 14.03.20 86 0
413534 채팅 프로그램 만들려고 하는데 이거 가능한건지요??? [7] 수크라제갤로그로 이동합니다. 14.03.20 130 0
413533 아오 퇴근 직전에 요구사항 주는거 보소 [2] 사장(223.62) 14.03.20 87 0
413532 개씹쉬움 c문제 하나만더! [57] 11(175.193) 14.03.20 291 0
413531 형들 최첨단을 걷는 똑똑이들이니깐 어려운 거 질문 좀 할게 고구려(163.152) 14.03.20 60 0
413530 복숭아묘목 에 대하여 정보추천 ㅇㅇ(221.142) 14.03.20 278 0
413529 딸딸이도구 사이트인기 소녀시대(121.126) 14.03.20 66 0
413528 8bit 에 소수 넣으면 어떻게 되냐 니김(175.197) 14.03.20 63 0
413527 어느릉애이로게즈응고늬ㅠ 요미코치료사(59.17) 14.03.20 47 0
413526 네트워크 관련 프로그램 좋은 아이디어 생각남. 123(203.226) 14.03.20 55 0
413525 C언어 질문 있습니다. [1] aqeq12312(203.226) 14.03.20 143 0
413524 형님들 비주얼없이 c코드 확인하는 웹 홈페이지 있지않나염?? [2] 프로그래밍 &#039;뀨&am.(203.247) 14.03.20 78 0
413523 월급은 주식을 하기위한 총알이에여 [5] 풀개미&#039;ㅅ&#.갤로그로 이동합니다. 14.03.20 110 0
413522 나 아무래도 프로그래밍적성에 너무잘맞는듯 [1] 3(114.201) 14.03.20 130 0
413521 도대체왜 이름입력을 못하는거냐고!!!!!(개씹쉬움) [2] 11(175.193) 14.03.20 84 0
413520 프로그래밍을 꼭 회사에서 해야 하냐 사장(223.62) 14.03.20 65 0
413518 야 C언어 좆밥문제인데 좀 봐줘봐 [1] 유동새끼(125.139) 14.03.20 64 0
413517 웹개발을꿈꾸는자 [1] ㄹㄹ(39.7) 14.03.20 130 0
413516 한이음 맨토링 아는 갤러 있나요¿ [5] 요미코번역인(175.223) 14.03.20 108 0
뉴스 ♥문원 ‘돌싱’ 고백에 싸늘한 시선…신지, 걱정 댓글에 직접 남긴 한마디 디시트렌드 10:00
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2