출처 : http://www.microsoft.com/showcase/en/US/details/58757441-f910-425d-b1eb-da09faf4628c#


'.NET Framework > .NET Framework 4.0' 카테고리의 다른 글

윈도우7(WPF4)에서 멀티터치 구현하기  (0) 2010/07/15
Posted by 데모집팀 황리건
시간은 TimeSpan으로, 색상은 Color 클래스의 정적 메소드로 생성할 수 있다.

TimeSpan.FromSeconds(2);
Color.FromArgb(255, 255, 0, 0);


저작자 표시 비영리 동일 조건 변경 허락
Posted by 데모집팀 황리건

http://msdn.microsoft.com/en-us/library/cc189019(VS.96).aspx

  • Create a DoubleAnimation

  • Create a Storyboard

  • Begin the Storyboard in response to an even

  • private void Create_And_Run_Animation(object sender, EventArgs e)
    {
        // Create a red rectangle that will be the target
        // of the animation.
        Rectangle myRectangle = new Rectangle();
        myRectangle.Width = 200;
        myRectangle.Height = 200;
        Color myColor = Color.FromArgb(255, 255, 0, 0);
        SolidColorBrush myBrush = new SolidColorBrush();
        myBrush.Color = myColor;
        myRectangle.Fill = myBrush;

        // Add the rectangle to the tree.
        LayoutRoot.Children.Add(myRectangle);

        // Create a duration of 2 seconds.
        Duration duration = new Duration(TimeSpan.FromSeconds(2));

        // Create two DoubleAnimations and set their properties.
        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, myRectangle);
        Storyboard.SetTarget(myDoubleAnimation2, myRectangle);

        // Set the attached properties of Canvas.Left and Canvas.Top
        // to be the target properties of the two respective DoubleAnimations.
        Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
        Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)"));

        myDoubleAnimation1.To = 200;
        myDoubleAnimation2.To = 200;

        // Make the Storyboard a resource.
        LayoutRoot.Resources.Add("unique_id", sb);

        // Begin the animation.
        sb.Begin();
    }
    저작자 표시 비영리 동일 조건 변경 허락
    Posted by 데모집팀 황리건

    MSDN 실버라이트3 레퍼런스 중 : http://msdn.microsoft.com/en-us/library/cc189084(VS.95).aspx

    <Grid x:Name="LayoutRoot" Background="White">

      <!-- Just a TextBlock to show the output of the timer. -->
      <TextBlock Loaded="StartTimer" x:Name="myTextBlock" />
    </Grid>



     

    public void StartTimer(object o, RoutedEventArgs sender)
    {
        System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
        myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 Milliseconds
        myDispatcherTimer.Tick += new EventHandler(Each_Tick);
        myDispatcherTimer.Start();
    }

    // A variable to count with.
    int i = 0;

    // Raised every 100 miliseconds while the DispatcherTimer is active.
    public void Each_Tick(object o, EventArgs sender)
    {
        myTextBlock.Text = "Count up: " + i++.ToString();
    }


    저작자 표시 비영리 동일 조건 변경 허락
    Posted by 데모집팀 황리건
    비교적 간단한 구현 : http://wildermuth.com/2009/02/09/Drag_and_Drop_in_Silverlight_2

    public partial class Page : UserControl
    {
      bool isDragging = false;
      Point offset;
      // ...
    }
    

    void theDragon_MouseLeftButtonDown(object sender,
                                       MouseButtonEventArgs e)
    {
      // Mark that we're doing a drag
      isDragging = true;

      // Ensure that the mouse can't leave the dragon
      theDragon.CaptureMouse();

      // Determine where the mouse 'grabbed'
      // to use during MouseMove
      offset = e.GetPosition(theDragon);
    }

    void theDragon_MouseMove(object sender, MouseEventArgs e)
    {
      if (isDragging)
      {
        // Where is the mouse now?
        Point newPosition = e.GetPosition(LayoutRoot);
        info.Text = string.Concat("Position: ",
                                  newPosition.X,
                                  " x ",
                                  newPosition.Y);

        // Move the dragon via the new position less the offset
        theDragon.SetValue(Canvas.LeftProperty,
                           newPosition.X - offset.X);
        theDragon.SetValue(Canvas.TopProperty,
                           newPosition.Y - offset.Y);
      }
    }

    void theDragon_MouseLeftButtonUp(object sender, 
                                     MouseButtonEventArgs e)
    {
      if (isDragging)
      {
        // Turn off Drag and Drop
        isDragging = false;
    
        // Free the Mouse
        theDragon.ReleaseMouseCapture();
      }
    }

    MSDN Drag & Drop 샘플 : http://msdn.microsoft.com/en-us/library/cc189066(VS.96).aspx HitTest를 이용해서 오브젝트 추적 : http://nickssoftwareblog.com/2008/10/07/silverlight-20-in-examples-part-drag-and-drop-inside-out/

    드래그엔드롭 매니저 : http://www.codeplex.com/silverlightdragdrop
    저작자 표시 비영리 동일 조건 변경 허락
    Posted by 데모집팀 황리건
    C#에서는 eval()이나 ["오브젝트 이름"]을 사용할 수 없는 대신, FindName()을 이용해서 직접적으로 참조할 수 있다.

    VisualStateManager.GoToState(FindName("myCoverStates"+i),"position"+position,true);
    저작자 표시 비영리 동일 조건 변경 허락
    Posted by 데모집팀 황리건


    1.      닷넷프레임워크 기술 용어들

    A.     CLI – Common Language Infrastructure
    서로 다른 컴퓨터 플랫폼에서도 여러 가지 개발 언어를 사용할 수 있도록 하는 실행 가능한 코드와 런타임 환경을 기술한 공개된 표준 스펙입니다. 아래와 같이 구성이 되어 있어요.

                                                                i.         CTS - Common Type System
    CTS
    에 호환되는 프로그래밍 언어들 간에 공유할 수 있는 데이터 타입의 모음입니다. 크게 두 가지로 구성하는데 하나는 Value Type으로 직접적으로 값을 갖고, 또 다른 하나로 Reference Type으로 값이 위치한 주소를 가져요.

                                                               ii.         CIL – Common Intermediate Language

                                                              iii.         CLS - Common Language Specification

                                                              iv.         VES – Virtual Execution System

    B.     CLR - Common Language Runtime : 개발자들이 특정 CPU 의 많은 디테일한 부분들을 신경 쓰지 않고도 프로그램을 작성하고 실행할 수 있도록 제공하는 실행 환경이에요.

    C.     DLR – Dynamic Language Runtime

    D.     네이티브 코드(Native Code)

    E.      매니지드 코드(Managed Code)

    F.      BCL - Base Class Library

    G.     FCL - Framework Class Library
    CAS - Code Access Security


    작성중....

    '.NET Framework' 카테고리의 다른 글

    닷넷프레임워크의 이해  (0) 2009/04/09
    .NET Framework 관련 축약어  (1) 2009/01/30
    Posted by 데모집팀 황리건

    WinForm의 경우는 앞단에 cs파일이 있고, UI를 구성하는 디자이너 cs 파일이 있지만...




    WPF는 마크업 언어인 XAML이 있고, 이를 뒷받침하는 로직으로 구성된 비하인드 코드가 있다.

    마크업은 계층 구조를 명확하게 보여주기 때문에 가독성이 좋고 직관적이며, 컴파일 방식이 아닌 파싱 방식이기 때문에 동적으로 변경이 가능하여 유연 구조를 가진다. 또한, XML 기반이기 때문에 개방적이고 처리하기가 쉽다.

    개념적인 차이로는 WinForm이 개발자-디자이너의 작업 흐름에 맞추어져 있는 반면, WPF는 디자이너-개발자 작업 흐름에 따른다.

    Posted by 데모집팀 황리건
    TAG CS, WinForm, WPF, XAML



    블렌드에서 레이아웃 잡고, 비주얼 스튜디오에서 C# 코딩...

    learning...
    XAML 제작을 할 때 UI 개발자 또는 블렌드의 역할 중요하다는 점 재확인.
    Posted by 데모집팀 황리건
    TAG c#, WPF, XAML

    프로젝트 이름을 잘못 지으면 나중에 변경하기가 까다롭다.

    프로젝트 이름을 변경하는 방법을 순서대로 적어본다.

    1. 솔루션 익스플로러에서 solution을 오른 쪽 클릭하여 rename을 선택한 후 이름을 변경한다. 프로젝트 이름도 마찬가지로 방법으로 변경한다.

    2. 솔루션 익스플로러에서 프로젝트를 선택한 상태에서 Propertie(왼쪽 상단) 아이콘을 클릭하여, Application 설정에서 asembly name과 default namespace를 변경한다.

    3. C# 코드 상에서 namespace 뒤에 오는 이름을 오른 쪽 클릭하여 Refactor-Rename을 이용해서 코드 상의 이름도 변경한다.

    4. 열려있는 솔루션을 우선 닫은 후에, 탐색기를 열어서 솔루션 폴더와 프로젝트 폴더의 이름을 각각 변경한다.

    5. 다시 솔루션을 열고, 솔루션 익스플로러에서 프로젝트를 선택한 상태에서 하단의 Properties 창에서 경로를 새로운 이름으로 수정한다.


    이렇게 하면 깔끔하게 변경할 수는 있는데, 더 쉬운 방법은 없을까...?

    Posted by 데모집팀 황리건