만약 여러분이 실버라이트에 익숙하다면 새로운 것은 없습니다. 이 속성 FrameworkElement에 새로이 추가가 되었었는데 각 길이를 반올림 하는 기능입니다. 기본 값은 실버라이트와 다르게 False이며 값을 설정하게 되면 자식 요소에 상속 됩니다. 이 속성을 설정한 것과 설정하지 않은 것은 다음과 같이 차이를 볼 수 있습니다.
Easing 함수들은 여러분들의 애니메이션들에 사용자 정의 수학 방정식들을 추가할 수 있게 해줍니다. 이런 사용자 정의 수학 방정식들을 이용하면 애니매이션들은 더 실제와 같거나 부드럽습니다. WPF 4에서는 이런 사용자 정의 수학 방정식 11개가 미리 정의 되어 있습니다. 이들 각 함수들은 3개의 모드(EaseIn, EaseOut, EaseInOut)를 가집니다.
이번 WPF 4에서 기존에 있었거나 새롭게 추가된 애니매이션 관련 클래스들 - ByteAnimation, ColorAnimation, DecimalAnimation, DoubleAnimation, Int16Animation, Int32Animation, Int64Animation, Point3DAnimation, PointAnimation, QuaternionAnimation, RectAnimation, Rotation3DAnimation, SingleAnimation, SizeAnimation, ThicknessAnimation, Vector3DAnimation, VectorAnimation 등 - 전반적으로 EasingFunction 속성이 추가되었다. 이 속성은 IEasingFunction이라는 인터페이스로 정의 되어 있으며, 이것은 개발자에게 다양한 효과를 애니메이션에 적용할 수 있도록 만들수 있도록 해줍니다.
IEasingFunction에 대해서 더 자세하게 얘기하자면 0과 1사이의 정규화된 시간에 각각 값을 반환할 수 있는 함수를 만들 수 있도록 해준다. 쉽게 얘기하면 0은 애니메이션이 시작하는 값이고 1은 애니메이션이 끝나는 값을 가리킵니다.
WPF 4에서는 IEasingFunction을 상속받아 미리 정의해놓은 클래스가 11개가 있다고 했습니다. 이들은 클래스는 공통적으로 System.Windows.Media.Animation.EasingFunctionBase 클래스를 상속합니다. 대부분 미리 정의해 놓은 EasingFunction을 사용하지 않고 사용자가 직접 개발한다면 이 클래스를 상속 받아 사용합니다. EaseInCore 함수를 오버라이드 하여 작성하면 되는데 다음과 같이 하면 됩니다.
namespace CustomEasingFunction
{
publicclass CustomSeventhPowerEasingFunction : EasingFunctionBase
{
public CustomSeventhPowerEasingFunction()
: base()
{
}
// Specify your own logic for the easing function by overriding
// the EaseInCore method. Note that this logic applies to the "EaseIn"
// mode of interpolation.
protected override double EaseInCore(double normalizedTime)
{
// applies the formula of time to the seventh power.
return Math.Pow(normalizedTime, 7);
}
// Typical implementation of CreateInstanceCore
protected override Freezable CreateInstanceCore()
{
returnnew CustomSeventhPowerEasingFunction();
}
}
}
EasingFunctionBase는 EasingMode 속성을 가지고 있습니다. EasingMode는 다음과 같이 3가지 모드가 있습니다. - EaseIn : 기본 EaseInCore 구현대로 작동됩니다. - EaseOut : 기본 EaseInCore와 반대로 작동됩니다. (X, Y좌표 -1 곱한값) - EaseInOut : EaseIn 실행후 EaseOut 실행됩니다.
미리 정의해놓은 EasingFunction은 다음과 같습니다.
결론적으로 어떻게 보면 기존 Spline 사용하는 것을 더 넓게 적용, 더 자세하게 제어할 수 있게 되었다고 생각하면 될 것 같습니다.
WPF 4 부터는 TextBoxBase를 상속 받는 RichTextBox와 TextBox 컨트롤와 PasswordBox 컨트롤에 새로운 속성인 CaretBrush, SelectionBrush 그리고 SelectionOpacity가 추가되었다.
이전 버전에서는 텍스트 선택 색상과 투명도를 조절할 수 없었으며, 현재 커서 색상을 수정할 수 없었습니다. WPF4 부터는 텍스트 선택 부분을 개발자가 Brush로 설정하거나 텍스트 선택 부분의 투명도를 설정할 수 있습니다. 또, 현재 커서도 개발자가 Brush로 설정할 수 있습니다.
CaretBrush는 현재 커서의 표시를 Brush로 설정하거나 가져옵니다. SelectionBrush는 현재 선택 부분의 표시를 Brush로 설정하거나 가져옵니다. SelectionOpacity는 현재 선택 부분의 표시의 투명도를 설정하거나 가져옵니다.
if (!cache.TryGetValue(key, out value)) { lock ( this ) { if (!cache.TryGetValue(key, out value)) { eventArgs.Proceed(); value = eventArgs.ReturnValue; cache.Add(key, value); return; } } } eventArgs.ReturnValue = value; } }
저는 실제로 INotifyPropertyChanged를 구현할때 일일히 속성을 정의하는게 귀찮아서 어떻게 Attribute로 할 수 없을까 구글로 검색했는데 PostSharp를 사용하면 쉽게 할수 있었습니다.
Next we’ll need to edit the configuration file for the subversion webdav module. You can use a different editor if you’d like.
sudo gedit /etc/apache2/mods-enabled/dav_svn.conf
The Location element in the configuration file dictates the root directory where subversion will be acessible from, for instance: http://www.server.com/svn
<Location /svn>
The DAV line needs to be uncommented to enable the dav module
# Uncomment this to enable the repository, DAV svn
The SVNPath line should be set to the same place your created the repository with the svnadmin command.
# Set this to the path to your repository SVNPath /svn
The next section will let you turn on authentication. This is just basic authentication, so don’t consider it extremely secure. The password file will be located where the AuthUserFile setting sets it to… probably best to leave it at the default.
# Uncomment the following 3 lines to enable Basic Authentication AuthType Basic AuthName “Subversion Repository” AuthUserFile /etc/apache2/dav_svn.passwd
To create a user on the repository use, the following command:
Note that you should only use the -c option the FIRST time that you create a user. After that you will only want to use the -m option, which specifies MD5 encryption of the password, but doesn’t recreate the file.
Example:
sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd geek New password: Re-type new password: Adding password for user geek
Restart apache by running the following command:
sudo /etc/init.d/apache2 restart
Now if you go in your browser to http://www.server.com/svn, you should see that the repository is enabled for anonymous read access, but commit access will require a username.
If you want to force all users to authenticate even for read access, add the following line right below the AuthUserFile line from above. Restart apache after changing this line.
위 코드를 보면 여러분은 ref 생략이 가능하지만, 아직 COM interoperability를 사용하지 않을 경우 ref를 생략하면 안된다. 또, 여러분의 .NET 응용프로그램과 Primary Interop Assembly (PIA)를 포함되어야 했다. C# 4.0에서는 이 작업이 필요없다.
오늘날 C#에서 여러분은 아래 코드와 같이 특정 클래스의 인스턴스를 가져와서 그 인스턴스의 Add이라는 함수를 호출해서 두 정수의 합을 가져와야 하는 필요하가 있을 수도 있다.
Calculator calc = GetCalculator(); int sum = calc.Add(10, 20);
위의 코드는 만약은 Calculator 클래스가 정적 타입이 아니라 COM, Ruby, Python 아니면 심지어 JavaScript으로 쓰져 있다면 더 재미있어 진다. 우리가 Calculator 클래스가 .NET 객체라고 알고 있지만 정확하게 어떤 타입인지 몰라도 우리는 Reflection을 이용하여 런타임일 때의 속성 타입을 알수 있고 Add 함수를 동적으로 호출할 수 있다.
object calc = GetCalculator(); Type type = calc.GetType(); object result = type.InvokeMember( "Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 }); int sum = Convert.ToInt32(result);
C# 4.0에서는 다음 처럼 간단하게 코딩할 수 있다.
dynamic calc = GetCalculator(); int sum = calc.Add(10, 20);
위 코드 예제에서 우리는 dynamic이라는 정적 타입을 가지는 calc라는 변수를 선언했다. 다음에 Add 함수를 동적으호 호출하여, 호출되는 결과가 동적으로 정적 타입 정수로 변환한다.
When we want to declaratively use our custom controls or reference the types we defined in XAML, we should declare the XML namespace to map to the CLR namespace in which the controls and types are defined as the following XAML snippt demonstrates:
Recently, I am heavily engaged with writing a resuable WPF control library, and quite often I need to create some pages to test those controls I create, so ever now and then I have to use the cumbersome syntax like above to declare the XML namespace, personally I don't like the syntax, and I thought Microsoft WPF team should come up with a more elegant way of doing it, and in actuality, they did introduce an alternative to do it since the CTP releases. there is a custom attribute called XmlnsDefinitionAttribute in the System.Windows.Markup namespace which allows you to apply to the assembly which contains the types and controls the XAML code would reference.the built-in WPF assemblies such as WindowsBase.dll, PresentationCore.dll, and PresentationFramework.dll all have this attribute applied, and all have http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace mapped with the CLR namespaces introduced by them. and of cause you can use this attribute in your own project, just open the AssemblyInfo.cs file, and append the following directive:
Leave your greetings here.