참조 : http://blogs.msdn.com/llobo/archive/200 ··· ush.aspx

WPF 4 부터는 TextBoxBase를 상속 받는 RichTextBox와 TextBox 컨트롤와 PasswordBox 컨트롤에 새로운 속성인 CaretBrush, SelectionBrush 그리고 SelectionOpacity가 추가되었다.

이전 버전에서는 텍스트 선택 색상과 투명도를 조절할 수 없었으며, 현재 커서 색상을 수정할 수 없었습니다. WPF4 부터는 텍스트 선택 부분을 개발자가 Brush로 설정하거나 텍스트 선택 부분의 투명도를 설정할 수 있습니다. 또, 현재 커서도 개발자가 Brush로 설정할 수 있습니다.

CaretBrush는 현재 커서의 표시를 Brush로 설정하거나 가져옵니다.
SelectionBrush는 현재 선택 부분의 표시를 Brush로 설정하거나 가져옵니다.
SelectionOpacity는 현재 선택 부분의 표시의 투명도를 설정하거나 가져옵니다.

사용자 삽입 이미지

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
2009/12/30 14:47 2009/12/30 14:47
Posted by 나는산.
TAGS

Leave your greetings here.

[로그인][오픈아이디란?]

POSTSHARP 소개

2009/12/29 10:25 / Programming/.NET
사이트 : http://www.postsharp.org/

PostSharp은 여러분의 .NET 코드의 라인수를 줄이고, 논리적은 관계를 분리시켜 코드를 작성할 수 있도록 해줍니다.

쉽게 얘기하면 일반화할 수 있는 코드를 Attribute로 작성할 수 있습니다.

몇가지 예를 들겠습니다.

(1) Trace : 트래이스할 수 있는 사용자 정의 Attribute

public class TraceAttribute : OnMethodBoundaryAspect
{ 
  public override void OnEntry( MethodExecutionEventArgs eventArgs) 
  { Trace.TraceInformation("Entering {0}.", eventArgs.Method);  }

  public override void OnExit( MethodExecutionEventArgs eventArgs)
  { Trace.TraceInformation("Leaving {0}.", eventArgs.Method);   }
}



(2) Async : 특정 함수를 비동기로 만드는 사용자 정의 Attribute

public class AsyncAttribute : OnMethodInvocationAspect
{
  public override void OnInvocation(MethodInvocationEventArgs eventArgs)
  {
    ThreadPool.QueueUserWorkItem(delegate { eventArgs.Proceed(); });
  }
}



(3) GUI Dispatch : 특정 함수를 GUI 쓰레드에서 실행하게 하는 사용자 정의 Attribute

public class GuiThreadAttribute : OnMethodInvocationAspect
{
  public override void OnInvocation(MethodInvocationEventArgs eventArgs)
  {
    DispatcherObject dispatcherObject = (DispatcherObject)eventArgs.Delegate.Target;

    if (dispatcherObject.CheckAccess())
      eventArgs.Proceed();
    else
      dispatcherObject.Dispatcher.Invoke( DispatcherPriority.Normal,
                                          new
Action(() => eventArgs.Proceed()));
  }
}


(4) Exception : 예외를 처리하는 사용자 정의 Attribute

public class ExceptionDialogAttribute : OnExceptionAspect
{
  public override void OnException(MethodExecutionEventArgs eventArgs)
  {
    string message = eventArgs.Exception.Message;
    Window window = Window.GetWindow((DependencyObject) eventArgs.Instance);
    MessageBox.Show(window, message, "Exception");
   
eventArgs.FlowBehavior = FlowBehavior.Continue;
  }

}



(5) Cache : 캐쉬를 하는 사용자 정의 Attribute

public class CacheAttribute : OnMethodInvocationAspect
{
    public override void OnInvocation(MethodInvocationEventArgs eventArgs)
    {
        object value;
        string key = // Compute the cache key (details omitted).

        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를 사용하면 쉽게 할수 있었습니다.

http://code.google.com/p/propfu/


윈래 이런 코드가

public class PersonLame : INotifyPropertyChanged
   
{
       
private string _name;
       
public string Name
       
{
           
get { return _name; }
           
set
           
{
               
if (value == _name)
                   
return;

                _name
= value;
               
OnPropertyChanged("Name");
           
}
       
}

       
private int _age;
       
public int Age
       
{
           
get { return _age; }
           
set
           
{
               
if (value == _age)
                   
return;

                _age
= value;
               
OnPropertyChanged("Age");
           
}
       
}

       
#region INotifyPropertyChanged Members

       
public event PropertyChangedEventHandler PropertyChanged;

       
#endregion

       
private void OnPropertyChanged(string propertyName)
       
{
           
if (PropertyChanged == null)
               
return;

           
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
       
}
   
}

다음 코드로 정리 됩니다.


[NotifyPropertyChanged]
   
public class PersonAwesome : INotifyPropertyChanged
   
{
       
public string Name { get; set; }

       
public int Age { get; set; }

       
#region INotifyPropertyChanged Members

       
public event PropertyChangedEventHandler PropertyChanged;

       
#endregion

       
[OnPropertyChanged]
       
private void OnPropertyChanged(string propertyName)
       
{
           
if (PropertyChanged == null)
               
return;

           
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
       
}
   
}
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
2009/12/29 10:25 2009/12/29 10:25
Posted by 나는산.
TAGS , , ,

Leave your greetings here.

[로그인][오픈아이디란?]

To install subversion, open a terminal and run the following command:

sudo apt-get install apache2
sudo apt-get install subversion libapache2-svn

We’re going to create the subversion repository in /svn, although you should choose a location that has a good amount of space.

sudo svnadmin create /svn
sudo chown www-data:www-data /svn -R

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:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd <username>

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.

Require valid-user

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
2009/12/02 21:53 2009/12/02 21:53
Posted by 나는산.

Leave your greetings here.

[로그인][오픈아이디란?]
« Previous : 1 : 2 : 3 : 4 : 5 : 6 : ... 184 : Next »