디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁(121.155) 2011.10.14 21:44:27
조회 49 추천 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
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 힘들게 성공한 만큼 절대 논란 안 만들 것 같은 스타는? 운영자 24/06/10 - -
294092 캐%s닭형 내 선물을 받아줘 [5] DevilCruiser갤로그로 이동합니다. 11.12.13 117 0
294090 하고싶은데 못하는거 2200 vs 관심은 없는데 나름 하는거 2750 [5] ASKY(58.236) 11.12.13 142 0
294089 캐%s닭형 원래 닉이 뭐임? [3] DevilCruiser갤로그로 이동합니다. 11.12.13 83 0
294088 아니 크리스마스가 10일 정도 밖에 안남았는데 분위기가 전혀 안산다??? [5] 거칠게갤로그로 이동합니다. 11.12.13 80 0
294086 내가 오늘 연말정산 존나 파헤쳐봤는데 답나옴 [1] 4(125.7) 11.12.13 86 0
294085 ㄷㅂ 싱글황태자갤로그로 이동합니다. 11.12.13 34 0
294083 근데 왜 우리 월급은 안오르냐? [2] 4(125.7) 11.12.13 95 0
294082 -------------!메모리스캔(3) 솔라리스와리눅스갤로그로 이동합니다. 11.12.13 42 0
294080 횽들 왜 atoi, itoa 가지구 싸움? 이게 어려움?? [10] 캐좇밥닭(115.92) 11.12.13 176 0
294079 adblock 존나좋군 [1] DevilCruiser갤로그로 이동합니다. 11.12.13 40 0
294078 아오 나도 프리 선언할까??? [4] 거칠게갤로그로 이동합니다. 11.12.13 123 0
294076 좋은아버지형 신세 한탄 글 적당히 쓰면 안될까?? [13] 나쁜아들(203.226) 11.12.13 177 2
294075 잡담그만하고 일하로 가야겠음 [1] 백탈자(61.250) 11.12.13 31 0
294074 회사내 성추행의 기준이 뭐냐??? [3] 거칠게갤로그로 이동합니다. 11.12.13 244 0
294073 뉘들 여직원만 이야기 하는데 여자나 남자나 똑같다...ㅄ은 ㅄ일뿐이다. [6] ㅅㄱㅅㄱㅅㄱ갤로그로 이동합니다. 11.12.13 140 0
294072 프겔러들은 다들 35세 이하라는게 사실인가여??? [3] 거칠게갤로그로 이동합니다. 11.12.13 143 0
294071 솔직히 SI [6] 백탈자(61.250) 11.12.13 201 0
294069 어제 하이킥을 보면서 느낀점 거칠게갤로그로 이동합니다. 11.12.13 49 0
294068 게임개발자가 꿈인 잉여인데 [10] DevilCruiser갤로그로 이동합니다. 11.12.13 159 0
294067 야호 ! 목요일날 또 면접보러 오래 [4] 좋은아버지갤로그로 이동합니다. 11.12.13 120 0
294066 디시가 광고수익을 2배로 올릴수있는방법 [3] ㅋㅌㅊ(210.178) 11.12.13 83 0
294065 여자가 상사인데 노처녀면 얼렁 도망가라 [2] 거칠게갤로그로 이동합니다. 11.12.13 171 0
294063 짤방같은 여직원인데 개발 x vs 개발퀸인데 옥동자 누나 [10] 거칠게갤로그로 이동합니다. 11.12.13 182 0
294062 아 그래도 하나는 될 줄 알았는데 진짜... [5] 좋은아버지갤로그로 이동합니다. 11.12.13 87 0
294061 여직원...하니까 [3] 백탈자(61.250) 11.12.13 90 0
294059 아니 왜 프겔러들은 여직원 있는걸 싫어해??? [5] 거칠게갤로그로 이동합니다. 11.12.13 115 0
294057 큼파일러고수님들, 공부하다 막히는데 closure 연산부분이여 [19] 츤츤(210.107) 11.12.13 71 0
294056 다음 중 가지 말아야 할 회사는? [6] 거칠게갤로그로 이동합니다. 11.12.13 139 0
294055 프갤이 활발하니까 좋네요 [3] [성대아싸]갤로그로 이동합니다. 11.12.13 71 0
294054 횽들은 개발자 하면서 안아퍼?? [3] 거칠게갤로그로 이동합니다. 11.12.13 83 0
294053 알바몬에 알씨소프트에서 정직원 하실거면 연락달라는데 [5] 좋은아버지갤로그로 이동합니다. 11.12.13 156 0
294051 데니스 리치고 나발이고 [1] madcat_mk2갤로그로 이동합니다. 11.12.13 75 0
294050 itoa atoi strcmp 손코딩할수잇느냐 [2] ㅂㅈㄷ(210.178) 11.12.13 117 0
294049 한물간 델파이가 진짜 최고다 백탈자(61.250) 11.12.13 129 0
294047 닭집은 너무 많으니 다른걸 생각해야겠네 [3] 거칠게갤로그로 이동합니다. 11.12.13 61 0
294045 닭집 하려면 돈이 얼마나 있어야 가능한가염? 'ㅅ'? [4] 거칠게갤로그로 이동합니다. 11.12.13 85 0
294044 배수광님 회사 안간다고 전화드리고 메일 확일을 했는데 ! [2] 좋은아버지갤로그로 이동합니다. 11.12.13 215 0
294043 좋은 회사와 나쁜 회사를 구분하는 법. [2] 거칠게갤로그로 이동합니다. 11.12.13 115 0
294038 포인터 ㄷㄷ 9m(203.236) 11.12.13 43 0
294037 아이폰 앱 개발 하려면 꼭 맥 계열 컴터 놋북 있어야 댐?? [3] [성대아싸]갤로그로 이동합니다. 11.12.13 150 0
294031 c포인터 이해 안간다는 애들 봐라.... [8] madcat_mk2갤로그로 이동합니다. 11.12.13 163 0
294030 바보플머의 '내 인생의 영화' [3] 바보플머(119.207) 11.12.13 70 0
294028 배수광님 회사는 일단 가봐야겠다.. 죽이기야 하겠어.. [3] 좋은아버지갤로그로 이동합니다. 11.12.13 232 0
294026 좋은아버지 십새야 [4] 알탱o갤로그로 이동합니다. 11.12.13 109 0
294023 씨발샛킈들.... [4] 프갤했(115.90) 11.12.13 59 0
294022 취업한다는 분 글 보니까 [1] 9m(203.236) 11.12.13 66 0
294021 좋은아버지봐라 내가 충고할 입장은 아니지만.. [6] McHello갤로그로 이동합니다. 11.12.13 143 0
294020 아 대박이다 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ오늘 슈발 왜 이럼? [8] 좋은아버지갤로그로 이동합니다. 11.12.13 202 0
294019 내 스펙이 정말 않좋은거야? [16] 좋은아버지갤로그로 이동합니다. 11.12.13 289 0
294018 명령어 형식 [10] 귤알맹이갤로그로 이동합니다. 11.12.13 105 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2