개정판 670a4be2
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