디시인사이드 갤러리

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

갤러리 본문 영역

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

맹꽁(121.155) 2011.10.14 21:44:27
조회 56 추천 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/07/28 - -
AD 휴대폰 액세서리 세일 중임! 운영자 25/07/28 - -
283891 횽아들~취업하면~진짜 궁금해서그래 [3] 잘생긴지용이갤로그로 이동합니다. 11.10.27 129 0
283889 아오 치질수술한거 예정날짜까지 안아물어서 [1] 빅바!갤로그로 이동합니다. 11.10.27 43 0
283888 소스 거이다 완성된거 좀 봐주세요 ㅠ [1] 티저영상갤로그로 이동합니다. 11.10.27 62 0
283887 전간디님이 쳐자러 갑니다 [1] 전간디갤로그로 이동합니다. 11.10.27 60 0
283886 이 빌어먹을 프레임웍들! [1] 돌아이바갤로그로 이동합니다. 11.10.27 53 0
283884 자바하는 회사에 기술면접볼예정인데 대충 어떤거물어볼지...... [8] !김실장!갤로그로 이동합니다. 11.10.27 169 0
283883 올해 11월 11일이 천년에 하루 있는 날이라구요? [3] ?(118.218) 11.10.27 89 0
283882 술먹고싶다 으아아아아ㅠㅠㅠㅠㅠ [6] 시그란♬갤로그로 이동합니다. 11.10.27 66 0
283881 이번 11년 11월 11일이 1000년에한번 오는거라고 광고하던데 [5] hd2갤로그로 이동합니다. 11.10.27 86 0
283879 object c 코드 보니까 신세계던데요? [5] hd2갤로그로 이동합니다. 11.10.26 138 0
283878 생각해보나 짤방 자바 2명 [6] 전간디갤로그로 이동합니다. 11.10.26 237 0
283877 여자한테 유일하게 받아본 초콜렛 엄마 제외하고 [3] hd2갤로그로 이동합니다. 11.10.26 70 0
283876 초콜릿 받아본 적 있음? [9] 전간디갤로그로 이동합니다. 11.10.26 103 0
283875 겜 개발자가 웹개발자보다 돈 더 벌지않아여? [2] 알오티씨플머갤로그로 이동합니다. 11.10.26 121 0
283874 오늘은 착한 형들이 많아서 기분이 좋네요 [2] hd2갤로그로 이동합니다. 11.10.26 48 0
283872 자기 개발에 10%정도 쓰면 적당하겠죠? [6] hd2갤로그로 이동합니다. 11.10.26 85 0
283871 컴사용지킴이 무력화 방법좀 [2] 딸돌갤로그로 이동합니다. 11.10.26 3666 2
283870 퇴근 후 어떤거 하세요? 인생이 재미가 없어요 ㅠㅠ [5] hd2갤로그로 이동합니다. 11.10.26 123 0
283869 일하시는곳에 여성 개발자들 많이 있나요? [3] hd2갤로그로 이동합니다. 11.10.26 107 0
283866 mc형 소환! Dawnwalkre갤로그로 이동합니다. 11.10.26 57 0
283865 현직 프로그래머 형들 하나만 물어볼게요 [7] hd2갤로그로 이동합니다. 11.10.26 124 0
283864 형들 구조체 질문 좀 봐주세용..ㅠㅠ... [2] ㅇㅇㅇ(116.121) 11.10.26 72 0
283863 머리 나쁘면 프로그래머 하지 말아야됨 [2] hd2갤로그로 이동합니다. 11.10.26 215 0
283862 여자들이 손가락 예쁜 남자를 싫어하는 이유.jpg ㅇㅇ(121.133) 11.10.26 170 0
283861 귀하가 사용하는 Compiler & Tools 은 무엇인가? [3] 343455(175.193) 11.10.26 94 0
283859 횽들 나는 무슨 프로그래머야? [2] hd2갤로그로 이동합니다. 11.10.26 96 0
283857 프로그래밍 관련된 괜찮은 해외사이트 있어? [2] schizoid322갤로그로 이동합니다. 11.10.26 62 0
283856 아 큰일났다... Ashenvale(220.90) 11.10.26 58 0
283855 굽신굽신 헬프좀요 씨언어 잘하는성님만 [2] 성님들부탁좀(116.125) 11.10.26 93 0
283854 횽들아 겜회사 가는거 어떻게 생각해?? [21] ㅋㅋㅋ(175.193) 11.10.26 421 0
283853 엉? 나 하드 살일 있는데?? 가격 올랐다네? [4] blackd갤로그로 이동합니다. 11.10.26 163 0
283852 여동생 얘기가 나와서 말인데... [3] 빅바!갤로그로 이동합니다. 11.10.26 176 0
283851 이제 집에가는 중인데 투표하러 가야함... [3] 빅바!갤로그로 이동합니다. 11.10.26 96 0
283850 프로그래머 이해 프로세스 [3] 어떡해갤로그로 이동합니다. 11.10.26 233 2
283849 진학이나 취업 어덯게하지 ... 상담좀 해줘 ㅠ [5] = _=갤로그로 이동합니다. 11.10.26 130 0
283848 보고싶은 책이 있는데 너무 비싸.. [4] ㅋㄱ(183.96) 11.10.26 113 0
283846 아스야 수정한거 [5] 쿄스케갤로그로 이동합니다. 11.10.26 93 0
283845 우와 선형대수학 [5] 빅바!갤로그로 이동합니다. 11.10.26 153 0
283844 솔까 한국은 IT자체가 필요없는 나라임 ㅇㅇ [6] ㅇㅇ(211.222) 11.10.26 235 1
283842 오늘의 병쉰질문.docx [4] Stan(220.244) 11.10.26 159 0
283840 아래 글이 너무 길어서 간추려봄. [15] blackd갤로그로 이동합니다. 11.10.26 159 0
283839 컴퓨터학원좀 추천해주세요. [4] ㅈㅈ(183.101) 11.10.26 173 0
283836 애드라 나경원 딸 언급하면 신고 크리 먹음? (219.255) 11.10.26 59 0
283835 횽들 포인트 선언 할때 어떤 방식으로 함? [9] 1(118.220) 11.10.26 125 0
283834 이거 어떻게 하지? 좋은 방법 있나? [5] blackd갤로그로 이동합니다. 11.10.26 134 0
283833 예전에는 프로그래머한다고 하면 꼭 친구들이 [2] 어떡해갤로그로 이동합니다. 11.10.26 190 0
283832 아스야 니가 아까 말한거 [1] 쿄스케갤로그로 이동합니다. 11.10.26 71 0
283829 이산수학 시간이다 흐하 [5] 남대생.갤로그로 이동합니다. 11.10.26 84 0
283828 아슈발 여동생 얼굴을 어떻게보지 [10] Adelposs갤로그로 이동합니다. 11.10.26 166 0
283825 아 그거 다른갤에서도 그랬는데.. 나중에는 봇 얘기까지 나옴 (219.255) 11.10.26 51 0
뉴스 더이상 못 참아…BTS 뷔, 팬들에 쓴소리 디시트렌드 07.31
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2