http://msdn.microsoft.com/ko-kr/library/ms228296.aspx

위에 링크를 따라 가보시면 C# 컴파일러 오류와 경고가 번호순으로 나열되어 있습니다.
많은 분이 아실수도 있겠지만 즐겨찾기는 기본이겠네요 :)

ps. 요즘 디버깅 책을 보고 있는데 흥미 있는 내용이 많네요. 포스팅 기대하세요 :)
Posted by glycerine
,

이 페이지는 계속 없데이트 할거예요.

요즘들어 부쩍 관심이 많아졌습니다. 실버라이트 이야기를 마지막으로 포스팅은 처음이네요.
Exchange 와 Active Directory 쪽에 관심을 귀울여 요즘 보고 있어요.

입에서 입으로 들은 것에 대해 오늘 점심먹고 검색 좀 했습니다~


위 페이지는
Visual Studio 2010 and .NET Framework 4.0 Training Kit - November Preview 설치후 메인페이지예요.
영어의 압박이 좀 있지만 흥미로운 이야기 들이네요.

제가 튜토리얼을 정리한 MVC 부분이 인상적이면서도 아직 저도 다 확인해지 못했지만 CLR 버전이 4.0으로 올라가는점, DLR 쪽이 차후 좀더 정리해 볼 흥미요소 같습니다.:)

Kirill Osenkov Blog's Links about Visual Studio 2010 and C# 4.0


Posted by glycerine
,

최종 버전이 될것 같네요.
선택되어 확대된 패널 버튼을 클릭하면 다시 초기의 6개 정렬로 돌아가게끔 추가하였습니다.

초기 변수 설정에서 초기 패널 크기와 currentPanel 과 beforePanel 이라는 부분이 추가되었습니다.
currentPanel은 선택되어 확대된 패널의 버튼이름을 가지고 있고, 확대 상태에서 다른 버튼을 클릭하여 확대되면 currentPanel은 beforePanel로 설정되어 beforePanel은 클릭 이벤트 핸들러를 바꿔줍니다.
초기 배열 핸들러 부분이 새로 추가되었습니다.

        // 표시 설정
        int panelTotalCount = 4;
        int panelRowCount = 3;

        // 초기 패널 크기 설정
        int initPanelWidth = 200;
        int initPanelHeight = 200;

        // 메인 패널 크기 설정
        int mainPanelWidth = 400;
        int mainPanelHeight = 300;

        // 서브패널 크기 설정
        int subPanelWidth = 200;
        int subPanelHeight = 40;

        // 시간 설정
        int time = 500;

        int keyNum = 0;
        string currentPanel = "";
        string beforePanel = "";

        ...

        // 선택 패널 크기 확장
        void btnSize_Click(object sender, RoutedEventArgs e)
        {
            if (currentPanel == "")
            {
                currentPanel = (sender as Button).Name;
            }
            else
            {
                beforePanel = currentPanel;
                currentPanel = (sender as Button).Name;
            }

            ...

            for (int i = 0; i < LayoutRoot.Children.Count; i++)
            {
                ...

                if ((((sender as Button).Parent as Grid).Parent as UCPanel).Name !=
                    (LayoutRoot.Children[i] as UCPanel).Name)
                {
                    // 선택되지 않은 나머지 패널 값 설정

                    if ((LayoutRoot.Children[i] as UCPanel).btnSize.Name == beforePanel)
                    {
                        (LayoutRoot.Children[i] as UCPanel).btnSize.Click 
                           -= new RoutedEventHandler(Page_Click);
                        (LayoutRoot.Children[i] as UCPanel).btnSize.Click
                           += new RoutedEventHandler(btnSize_Click);
                        
                        ...
                    }
                }
                else
                {
                    (sender as Button).Click -= new RoutedEventHandler(btnSize_Click);
                    (sender as Button).Click += new RoutedEventHandler(Page_Click);

                    ...
                } 
            }
        }

        // 초기 정렬
        void Page_Click(object sender, RoutedEventArgs e)
        {
            (sender as Button).Click -= new RoutedEventHandler(Page_Click);
            (sender as Button).Click += new RoutedEventHandler(btnSize_Click);

            currentPanel = "";

            sb = new Storyboard();

            for (int i = 0; i < LayoutRoot.Children.Count; i++)
            {
                int index = int.Parse((LayoutRoot.Children[i] as UCPanel).Name.Split('_')[1].ToString());

                ani1 = new DoubleAnimation();
                ani2 = new DoubleAnimation();
                ani3 = new DoubleAnimation();
                ani4 = new DoubleAnimation();

                ani1.Duration = duration;
                ani2.Duration = duration;
                ani3.Duration = duration;
                ani4.Duration = duration;

                ani1.To = initPanelWidth;
                ani2.To = initPanelHeight;
                ani3.To = (initPanelWidth + 10) * (index / panelRowCount) + 10;
                ani4.To = (initPanelHeight + 10) * (index % panelRowCount) + 10;

                Storyboard.SetTarget(ani1, LayoutRoot.Children[i] as UCPanel);
                Storyboard.SetTarget(ani2, LayoutRoot.Children[i] as UCPanel);
                Storyboard.SetTarget(ani3, LayoutRoot.Children[i] as UCPanel);
                Storyboard.SetTarget(ani4, LayoutRoot.Children[i] as UCPanel);

                Storyboard.SetTargetProperty(ani1, new PropertyPath("(Width)"));
                Storyboard.SetTargetProperty(ani2, new PropertyPath("(Height)"));
                Storyboard.SetTargetProperty(ani3, new PropertyPath("(Canvas.Top)"));
                Storyboard.SetTargetProperty(ani4, new PropertyPath("(Canvas.Left)"));

                sb.Duration = duration;

                sb.Children.Add(ani1);
                sb.Children.Add(ani2);
                sb.Children.Add(ani3);
                sb.Children.Add(ani4);

                ani1 = null;
                ani2 = null;
                ani3 = null;
                ani4 = null;
            }

            LayoutRoot.Resources.Add("selectedPanel" + keyNum++, sb);

            sb.Completed += new EventHandler(sb_Completed);
            sb.Begin();
        }   


코드의 문제점은 언제든지 지적해주세요. :)


Posted by glycerine
,

#1을 약간 응용하여 만들어 보았습니다.
하지만 Blacklight을 모방한 것이죠 :)
코딩실력이 허접해서 문제점 투성이 이네요. 지적 사항은 언제나 환영입니다.

로드 후 첫 화면은 다음과 같구요.


버튼을 클릭하면 선택된 아이템은 크게 보이고, 나머지는 우측 메뉴로 이동합니다.


일단은 여기까지이고 다음에 추가되는 사항은 예상되시겠죠.:)


페이지가 로드되면, 다음과 같이 UC_Panel 이라는 사용자 정의 컨트롤 6개를 위치시킵니다.

        // 표시 설정
        int panelTotalCount = 6;
        int panelRowCount = 3;

        // 메인 패널 크기 설정
        int mainPanelWidth = 400;
        int mainPanelHeight = 300;

        // 서브패널 크기 설정
        int subPanelWidth = 200;
        int subPanelHeight = 40;

        // 시간 설정
        int time = 500;

        int keyNum = 0;

        Storyboard sb = null;
        Duration duration;
        DoubleAnimation ani1 = null;
        DoubleAnimation ani2 = null;
        DoubleAnimation ani3 = null;
        DoubleAnimation ani4 = null;

        // 초기 패널 배열
        void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            // 이미지 샘플
            List<string> list = new List<string>();
            list.Add("img_1.png");
            list.Add("img_2.png");
            list.Add("img_3.png");
            list.Add("img_4.jpg");
            list.Add("img_5.jpg");
            list.Add("img_6.jpg");

            UCPanel ucPanel = null;

            for (int i = 0; i < panelTotalCount; i++)
            {
                ucPanel = new UCPanel();
                ucPanel.Name = "panel_" + i;
                ucPanel.SetValue(Canvas.LeftProperty, (ucPanel.Width + 10) * (i % panelRowCount) + 10);
                ucPanel.SetValue(Canvas.TopProperty, (ucPanel.Height + 10) * (i / panelRowCount) + 10);

                ucPanel.tbPanelName.Text = list[i].Split('.')[0].ToString();

                ucPanel.btnSize.Content = ">";
                ucPanel.btnSize.Name = "panel_" + i;
                ucPanel.btnSize.Click += new RoutedEventHandler(btnSize_Click);

                ucPanel.imgPic.Source = new BitmapImage(new Uri(list[i], UriKind.RelativeOrAbsolute));
                
                LayoutRoot.Children.Add(ucPanel);
            }

            ucPanel = null;

            duration = new Duration(TimeSpan.FromMilliseconds(time));
        }


UC_Panel 안에는 TextBlock, Button, Image 컨트롤이 존재합니다.

클릭시에는 #1과 같은 애니메이션 코드로 되어있습니다.
아래 코드는 전체 코드가 아닌 일부 코드예요. 각 6개 패널에 DoubleAnimation을 설정하는 부분인데,
선택된 패널과 그렇지 않은 패널에 애니메이션 값을 따로 설정 하는 부분입니다.
선택한 버튼의 부모, 부모를 올라가 그 패널의 이름과 자식이름이 같은 경우에 확대 시키는 것이죠.
코드가 많이 허접하네요;;

                if ((((sender as Button).Parent as Grid).Parent as UCPanel).Name !=
                    (LayoutRoot.Children[i] as UCPanel).Name)
                {
                    // 선택되지 않은 나머지 패널 값 설정
                    ani1.To = subPanelWidth;
                    ani2.To = subPanelHeight;
                    ani3.To = (subPanelHeight + 10) * pos++ + 10;
                    ani4.To = mainPanelWidth + 20;

                    Storyboard.SetTarget(ani1, LayoutRoot.Children[i] as UCPanel);
                    Storyboard.SetTarget(ani2, LayoutRoot.Children[i] as UCPanel);
                    Storyboard.SetTarget(ani3, LayoutRoot.Children[i] as UCPanel);
                    Storyboard.SetTarget(ani4, LayoutRoot.Children[i] as UCPanel);
                }
                else
                {
                    // 선택된 패널 값 설정
                    ani1.To = mainPanelWidth;
                    ani2.To = mainPanelHeight;
                    ani3.To = 10;
                    ani4.To = 10;

                    Storyboard.SetTarget(ani1, (((sender as Button).Parent as Grid).Parent as UCPanel));
                    Storyboard.SetTarget(ani2, (((sender as Button).Parent as Grid).Parent as UCPanel));
                    Storyboard.SetTarget(ani3, (((sender as Button).Parent as Grid).Parent as UCPanel));
                    Storyboard.SetTarget(ani4, (((sender as Button).Parent as Grid).Parent as UCPanel));
                }


위 코드는 클릭이벤트로 인하여 애니메이션이 연속적으로 계속 일어난다면, 리소스 측에 문제가 있습니다.
GC.GetTotalMemory(true) 로 확인하실 수 있구요.
이 부분에서 조언 부탁드리겠습니다. :)


Posted by glycerine
,

매우 간단한 애니메이션 예제입니다.
조그마한 Rectangle이 클릭한 위치로 움직이는 모션이에요.


일단 간단하게 Xaml 코드는 Canvas 만 있고 영역 밖을 넘어가면 숨기게 Clip을 설정했습니다.

    <Canvas x:Name="LayoutRoot" Width="800" Height="600" Background="Black">
        <Canvas.Clip>
            <RectangleGeometry Rect="0, 0, 800, 600" />
        </Canvas.Clip>
    </Canvas>

LayoutRoot 가 로드하고 나면 Rectangle을 하나 만들어 보겠습니다.

        Rectangle rec = null;
        int keyNum = 0;

        void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            rec = new Rectangle();
            rec.Width = 100;
            rec.Height = 100;
            Color col = Color.FromArgb(255, 255, 0, 0);
            SolidColorBrush brush = new SolidColorBrush();
            brush.Color = col;
            rec.Fill = brush;
            rec.VerticalAlignment = VerticalAlignment.Top;
            rec.HorizontalAlignment = HorizontalAlignment.Left;

            LayoutRoot.Children.Add(rec);
        }


Canvas 에 클릭할 때 마다 움직이게 이벤트를 걸겠습니다.

        void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            double tmpX = e.GetPosition(this).X;
            double tmpY = e.GetPosition(this).Y;

            CreateAndRunAnimation(tmpX, tmpY);
        }


CreateAndRunAnimation() 메소드는 다음과 같습니다.
좌표값을 던져주면 그 좌표로 이동하는 것입니다.
포인트는 변화하는 속성마다 DoubleAnimation 개체를 만들고 정의해 두어야 하는것입니다.

        private void CreateAndRunAnimation(double moveX, double moveY)
        {
            Duration duration = new Duration(TimeSpan.FromMilliseconds(500));

            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
            DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();

            myDoubleAnimation1.Duration = duration;
            myDoubleAnimation2.Duration = duration;

            Storyboard sb = new Storyboard();
            sb.Duration = duration;

            sb.Children.Add(myDoubleAnimation1);
            sb.Children.Add(myDoubleAnimation2);

            Storyboard.SetTarget(myDoubleAnimation1, rec);
            Storyboard.SetTarget(myDoubleAnimation2, rec);
           
            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
            Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)"));

            myDoubleAnimation1.To = moveX;
            myDoubleAnimation2.To = moveY;

            LayoutRoot.Resources.Add("move_id" + keyNum++, sb);

            sb.Completed += new EventHandler(sb_Completed);
            sb.Begin();
        }


애니메이션이 끝나면 꼭 리소스를 해제해야 합니다.

        void sb_Completed(object sender, EventArgs e)
        {
            LayoutRoot.Resources.Clear();
            keyNum = 0;
        }

keyNum 변수는 애니메이션이 동작 중일때 클릭 이벤트가 또 발생하면 중복 리소스를 방지하기 위한 변수입니다.

정리.
LayoutRoot.Resource 자식에 Storyboard를 붙인뒤에, Storyboard.duration을 설정 하고, 그 자식으로 DoubleAnimiation을 붙입니다. DoubleAnimation 역시 duration 값을 설정하고, Target과 TargetProperty을 설정합니다.

Posted by glycerine
,