다음과 같이 Drag Enter와 DragDrop event를 다루는 메소드를 추가하면 된다.


반드시 AllowDrop속성이 True로 되어있어야 한다.


다음의 예제는 TextBox에 DragEnter와 DragDrop을 추가했을 경우의 코드이다.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
private void textBox_DragEnter(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
        
private void textBox_DragDrop(object sender, DragEventArgs e)
{
    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
    foreach (string file in files) 
        Console.WriteLine(file);
} 


apple developer에서 퍼왔습니다.



'괴발개발 > iOS, Swift' 카테고리의 다른 글

Asynchronous image loading (비동기 이미지 로딩)  (0) 2012.10.26

추가후 사용

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
- (void) loadAsyncImageFromURL:(NSURL *)url  imageBlock:(void (^) (UIImage *image))imageBlock errorBlock:(void(^)(void))errorBlock
{
    dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^(void){
	   NSData * data = [[NSData alloc] initWithContentsOfURL:url];
	   UIImage * image = [[UIImage alloc] initWithData:data];
	   dispatch_async( dispatch_get_main_queue(), ^(void){
		   if( image != nil )
		   {
			   imageBlock( image );
		   } else {
			   errorBlock();
		   }
	   });
   });
}


'괴발개발 > iOS, Swift' 카테고리의 다른 글

iOS7 Window layer (example;Clock app)  (0) 2013.10.03

+ Recent posts