퇴근5분전


아 칙칙해보이넹. ㅋㅋ

< 달력 결과물 >


훈스에 달력을 직접 그려보고 싶어하시는 분이 계시는데... 훔... 그냥 이렇게... 후! 

좀 더 시간투자를 하면 완전 바꿨을텐데... 잠깐 짬내본거라.


internal class Day : Label
    {
        public static int _Width = 120;
        public static int _Height = 24;

        public Day()
        {
            this.AutoSize = false;
            this.Width = _Width;
            this.Height = _Height;
            this.MouseHover += new EventHandler(Day_MouseHover);

            this.BorderStyle = BorderStyle.Fixed3D;
        }

        public Day(string text, Point location) : this()
        {
            this.Text = text;
            this.Location = location;
        }

        void Day_MouseHover(object sender, EventArgs e)
        {
            ToolTip tip = new ToolTip();
            {
                tip.Show(this.Text, this, 2000 );
            }
        }
    }

    public class Calendar : UserControl
    {
        int month = DateTime.Now.Month;

        [Category("설정")]
        [Description("해당 월을 입력합니다.")]
        public int Month
        {
            get { return month; }
            set { month = value; Draw(year, month); }
        }
        int year = DateTime.Now.Year;

        [Category("설정")]
        [Description("해당 년을 입력합니다.")]
        public int Year
        {
            get { return year; }
            set { year = value; Draw(year, month);
            }
        }

        public Calendar()
        {
            this.BorderStyle = BorderStyle.FixedSingle;
            Draw(year, month);
        }

        void Draw(int year, int month)
        {
            int heighttotal = 0;
            int widthtotal = 0;
            this.Controls.Clear();
            DateTime date = new DateTime(year, month, 1); // 해당년월에 1일.

            int totalDay = DateTime.DaysInMonth(year, month);

            string[] dayofweek = Enum.GetNames(typeof(DayOfWeek));

            for (int i = 0; i < dayofweek.Length; i++)
            {
                Day weekctrl = new Day(dayofweek[i].Substring(0, 3), new Point(i * Day._Width, 0));
                this.Controls.Add(weekctrl);

                if ((i % 7 )== (int)DayOfWeek.Saturday) // 토요일
                    weekctrl.ForeColor = Color.Blue;
                else if ((i % 7 ) == (int)DayOfWeek.Sunday) // 일요일
                    weekctrl.ForeColor = Color.Red;

                widthtotal += Day._Width;
            }

            int y = 1;
            heighttotal += Day._Height;

            for (int day = 1 - (int)date.DayOfWeek; day <= totalDay; day++)
            {
                Day dayCtrl = new Day();

                dayCtrl.Location = new Point(((day + (int)date.DayOfWeek) % 7) * Day._Width, y * Day._Height);

                //설정
                if ((day + (int)date.DayOfWeek) % 7 == (int)DayOfWeek.Saturday ) // 토요일
                    dayCtrl.ForeColor = Color.Blue;
                else if ((day + (int)date.DayOfWeek) % 7 == (int)DayOfWeek.Sunday) // 일요일
                    dayCtrl.ForeColor = Color.Red;

                if (day <= 0)
                    dayCtrl.ResetText();
                else
                {
                    if (day == DateTime.Now.Day && year == DateTime.Now.Year && month == DateTime.Now.Month) // 오늘 날짜 표시
                    {
                        dayCtrl.Font = new Font(dayCtrl.Font.FontFamily, dayCtrl.Font.Size, FontStyle.Bold);
                    }

                    dayCtrl.Text = day.ToString();
                }
                this.Controls.Add(dayCtrl);
                if ((int)DayOfWeek.Saturday  == (day + (int)date.DayOfWeek) % 7)
                {
                    y++;
                    heighttotal += Day._Height;
                };// 다음주~ 로 넘어가는 부분   DayofWeek 요일 열거형
            }
            heighttotal += Day._Height;
            this.Height = heighttotal + 2;
            this.Width = widthtotal;
        }
   
    }


 회사에서 hwp 파일에 대해 모바일 지원 검토를 해보라고 하길래...

지난번 한글에서 표준문서포멧이 떠올라서 재미삼아 파일을 분해해보는데, 처음부터 걸리는게 너무 많았다.

 우선 포멧서에 나온 미리보기 이미지 PreImage 라는 태그로 있기에 이걸 뽑아올 수 있다면 이걸 페이지에 뿌리면 좋을텐데 라고 생각해서 시도하였다.

Compound File 규격으로 포멧팅 되어 있는 파일을 Stream으로 읽어들여서 규격서에 나온대로
BinaryReader를 이용해서 256을 짤랐는데. 당췌... 아무것도 안나온다.

Unicode, UTF-8 로 인코딩을 아무리 해봐도 제대로 보이는게 없을정도니까...

하다 하다 안되길래 Free로 된 Compound File 관련 뷰어 소스를 두세개 받아서 디버깅 해보았다.

우선 확인된 사항은 PreImage 는 아이콘에 미리보기용으로 만들어지는 이미지임을 확인했다.

소용없다는 얘기..

그래서 왜 아무것도 안나오는지 소스를 디버깅 걸면서 하나 하나 추적해보았더니... 쉐뜨.

Compound File 자체게 어떤 표준이 있어서 내부 RootEntry 전에 헤더값이 존재하는듯 하다.

다 걸러내고 RootEntry부터는 다음 Entry까지 binary를 Seek하면서 트리로 끌어올리는것을 확인하였다.

파일 형태는 대략

RootEntry .....  RootEntry
DocInfo ... DocInfo
PreImage ... PreImage

처럼... 앞태그  내용   뒷태그  형태로 존재하는듯 하다.

반나절 고생하고 소스 디버깅 3시간... 정도 하니 지친다.

결론은 저거 다 분석하면 한글 뷰어를 만들수 있다는거? 정도??? 
 
그러나 그닥 이득이 되지 않으므로... 여기서 마무리...

Compound File 이란 형태의 파일도 존재하는구나 했음... 음.. 멋진데?



'# 1) 프로그래밍' 카테고리의 다른 글

[C#] 배열 최대 크기  (0) 2011.04.26
ActiveDirectory] Query  (0) 2011.04.19
문자열 첫번째 검색 문자만 Replace  (0) 2010.09.30
일자가 해당 월에 몇주차인지 구하는 법.  (0) 2010.09.30
DateTime관련..  (0) 2010.09.09


오라클 강좌를 보면서 멋지다 생각했던 쿼리를 ms-sql로 바꾸어 보았다.

물론 이 쿼리는 테스트용도로 변경한 쿼리임.




select  (case [key] when '1' then ' '+t.[name] else '합계' end ) [구분],  
           sum( a ) [a합계],
           sum( b ) [b합계]
from
(
 select 'a' name, 1 a , 2  b
 union all
 select 'b' name, 1 a , 2  b
 union all
 select 'c' name, 1 a , 2  b
)t,
(
 select '1' [key]
 union all
 select '2' [key]
)u
group by ( case [key] when '1' then ' '+t.name else '합계' end )
 

굵게 표시된 그룹바이 키는 동일하게 적용되어야 표시가 된다.

결과 :




## 집합 적인 사고!!! 카티션곱!!