프로젝트

일반

사용자정보

개정판 670a4be2

ID670a4be2848071ae9ee7a7e181504f1fd199df31
상위 31d64a8c
하위 28c80962

humkyung 이(가) 6년 이상 전에 추가함

Implementing issue #528:Drag Drop하여 심볼 생성

차이점 보기:

KCOM/Controls/Symbol.xaml.cs
467 467
        {
468 468
            IsMouseDown = false;
469 469
        }
470

  
471
        ListBox _dragSource = null;
472
        private void lstSymbolPrivate_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
473
        {
474
            _dragSource = sender as ListBox;
475
            object item = Symbol.GetDataFromListBox(sender as ListBox, e.GetPosition(sender as ListBox));
476
            if (item != null)
477
            {
478
                string _data = string.Empty;
479
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
480
                {
481
                    string id = (item as Symbol_Custom).ID;
482
                    if (RadTab.SelectedIndex == 0)
483
                        _data = Entity.SYMBOL_PRIVATE.Where(data => data.ID == id).FirstOrDefault().DATA;
484
                    else
485
                        _data = Entity.SYMBOL_PUBLIC.Where(data => data.ID == id).FirstOrDefault().DATA;
486
                }
487

  
488
                DragDrop.DoDragDrop(_dragSource, _data, DragDropEffects.Copy);
489
            }
490
        }
491

  
492
        /// <summary>
493
        /// get data from list box where user clicked
494
        /// </summary>
495
        /// <author>humkyung</author>
496
        /// <date>2018.05.30</date>
497
        /// <param name="source"></param>
498
        /// <param name="point"></param>
499
        /// <returns></returns>
500
        private static object GetDataFromListBox(ListBox source, Point point)
501
        {
502
            UIElement element = source.InputHitTest(point) as UIElement;
503
            if (element != null)
504
            {
505
                object data = DependencyProperty.UnsetValue;
506
                while (data == DependencyProperty.UnsetValue)
507
                {
508
                    data = source.ItemContainerGenerator.ItemFromContainer(element);
509

  
510
                    if (data == DependencyProperty.UnsetValue)
511
                    {
512
                        element = VisualTreeHelper.GetParent(element) as UIElement;
513
                    }
514

  
515
                    if (element == source)
516
                    {
517
                        return null;
518
                    }
519
                }
520

  
521
                if (data != DependencyProperty.UnsetValue)
522
                {
523
                    return data;
524
                }
525
            }
526

  
527
            return null;
528
        }
470 529
    }
471 530
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)