From: Taehyub Kim Date: Tue, 21 Feb 2023 07:41:28 +0000 (+0900) Subject: [NUI] DragAndDrop : Add multi-window sample X-Git-Tag: accepted/tizen/unified/20231205.024657~442 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62dec3b268d8f968dbacb900f8ef05f7d2d6d858;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] DragAndDrop : Add multi-window sample --- diff --git a/test/NUIDnDMultiWindow/NUIDnDMultiWindow.cs b/test/NUIDnDMultiWindow/NUIDnDMultiWindow.cs new file mode 100644 index 0000000..3d95b34 --- /dev/null +++ b/test/NUIDnDMultiWindow/NUIDnDMultiWindow.cs @@ -0,0 +1,214 @@ + +using Tizen.NUI; +using Tizen.NUI.Components; +using Tizen.NUI.BaseComponents; + +namespace NUIDnDMultiWindow +{ + class Program : NUIApplication + { + DragAndDrop dnd; + ImageView sourceView; + ImageView shadowView; + ImageView MainWindow_View; + + Window WindowA; + ImageView WindowA_ViewA; + ImageView WindowA_ViewB; + + Window WindowB; + ImageView WindowB_ViewA; + ImageView WindowB_ViewB; + + LongPressGestureDetector longPressed; + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + void Initialize() + { + // Create DnD Instance + dnd = DragAndDrop.Instance; + + Window.Instance.KeyEvent += OnKeyEvent; + Window.Instance.WindowSize = new Size(900, 1080); + Window.Instance.BackgroundColor = Color.White; + + TextLabel text = new TextLabel("Multi-Window Drag And Drop"); + text.Position = new Position(0, 0); + text.TextColor = Color.Black; + text.PointSize = 8.0f; + Window.Instance.GetDefaultLayer().Add(text); + + TextLabel text2 = new TextLabel("Source View"); + text2.Position = new Position(330, 330); + text2.Size = new Size(400, 150); + text2.TextColor = Color.Black; + text2.PointSize = 5.0f; + text2.MultiLine = true; + Window.Instance.GetDefaultLayer().Add(text2); + + TextLabel text3 = new TextLabel("MainWindow View"); + text3.Position = new Position(100, 700); + text3.Size = new Size(400, 150); + text3.TextColor = Color.Black; + text3.PointSize = 5.0f; + text3.MultiLine = true; + Window.Instance.GetDefaultLayer().Add(text3); + + TextLabel text4 = new TextLabel("Window A"); + text4.Position = new Position(400, 650); + text4.Size = new Size(400, 150); + text4.TextColor = Color.Black; + text4.PointSize = 5.0f; + text4.MultiLine = true; + Window.Instance.GetDefaultLayer().Add(text4); + + TextLabel text5 = new TextLabel("Window B"); + text5.Position = new Position(400, 1000); + text5.Size = new Size(400, 150); + text5.TextColor = Color.Black; + text5.PointSize = 5.0f; + text5.MultiLine = true; + Window.Instance.GetDefaultLayer().Add(text5); + + // Create Source View + sourceView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "dragsource.png"); + sourceView.Size = new Size(200, 200); + sourceView.Position = new Position(330, 120); + Window.Instance.GetDefaultLayer().Add(sourceView); + + longPressed = new LongPressGestureDetector(); + longPressed.Attach(sourceView); + longPressed.Detected += (s, e) => + { + if(e.LongPressGesture.State == Gesture.StateType.Started) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "StartDragAndDrop"); + shadowView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png"); + shadowView.Size = new Size(150, 150); + DragData dragData; + dragData.MimeType = "text/uri-list"; + dragData.Data = Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png"; + dnd.StartDragAndDrop(sourceView, shadowView, dragData, OnSourceApp_SourceFunc); + } + }; + + // Create Target MainWindow_View + MainWindow_View = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png"); + MainWindow_View.Size = new Size(200, 200); + MainWindow_View.Position = new Position(100, 500); + Window.Instance.GetDefaultLayer().Add(MainWindow_View); + + // Add Drop Target MainWindow_View + dnd.AddListener(MainWindow_View, OnSourceApp_TargetFunc); + + // Create Target Window A + WindowA = new Window("WindowA", new Rectangle(400, 400, 370, 250), false) + { + BackgroundColor = Color.BlueViolet, + }; + WindowA.Show(); + + // Create Target WindowA_ViewA + WindowA_ViewA = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png"); + WindowA_ViewA.Size = new Size(150, 150); + WindowA_ViewA.Position = new Position(20, 10); + WindowA.GetDefaultLayer().Add(WindowA_ViewA); + + // Add Drop Target WindowA_ViewA + dnd.AddListener(WindowA_ViewA, OnSourceApp_TargetFunc); + + // Create Target View WindowA_ViewB + WindowA_ViewB = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png"); + WindowA_ViewB.Size = new Size(150, 150); + WindowA_ViewB.Position = new Position(180, 50); + WindowA.GetDefaultLayer().Add(WindowA_ViewB); + + // Add Drop Target WindowA_ViewB + dnd.AddListener(WindowA_ViewB, OnSourceApp_TargetFunc); + + // Create Target Window B + WindowB = new Window("WindowB", new Rectangle(400, 750, 370, 250), false) + { + BackgroundColor = Color.LightGoldenRodYellow, + }; + WindowB.Show(); + + // Create Target WindowB_ViewA + WindowB_ViewA = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png"); + WindowB_ViewA.Size = new Size(150, 150); + WindowB_ViewA.Position = new Position(20, 10); + WindowB.GetDefaultLayer().Add(WindowB_ViewA); + + // Add Drop Target WindowB_ViewA + dnd.AddListener(WindowB_ViewA, OnSourceApp_TargetFunc); + + // Create Target WindowB_ViewB + WindowB_ViewB = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png"); + WindowB_ViewB.Size = new Size(150, 150); + WindowB_ViewB.Position = new Position(180, 50); + WindowB.GetDefaultLayer().Add(WindowB_ViewB); + + // Add Drop Target WindowB_ViewB + dnd.AddListener(WindowB_ViewB, OnSourceApp_TargetFunc); + } + + public void OnSourceApp_SourceFunc(DragSourceEventType type) + { + if (type == DragSourceEventType.Start) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Start"); + } + else if (type == DragSourceEventType.Cancel) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Cancel"); + } + else if (type == DragSourceEventType.Accept) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Accept"); + } + else if (type == DragSourceEventType.Finish) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Finish"); + } + } + + public void OnSourceApp_TargetFunc(View targetView, DragEvent dragEvent) + { + if (dragEvent.DragType == DragType.Enter) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Enter]"); + } + else if (dragEvent.DragType == DragType.Leave) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Leave]"); + } + else if (dragEvent.DragType == DragType.Move) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Move]: " + dragEvent.Position.X + " " + dragEvent.Position.Y); + } + else if (dragEvent.DragType == DragType.Drop) + { + Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Drop] MimeType: " + dragEvent.MimeType + " Data: " + dragEvent.Data); + ((ImageView)targetView).ResourceUrl = dragEvent.Data; + } + } + + public void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + } + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/test/NUIDnDMultiWindow/NUIDnDMultiWindow.csproj b/test/NUIDnDMultiWindow/NUIDnDMultiWindow.csproj new file mode 100644 index 0000000..5c97a2a --- /dev/null +++ b/test/NUIDnDMultiWindow/NUIDnDMultiWindow.csproj @@ -0,0 +1,27 @@ + + + + Exe + netcoreapp3.1 + + + + portable + + + None + + + + + + + + + + + True + + + + diff --git a/test/NUIDnDMultiWindow/res/dragsource.png b/test/NUIDnDMultiWindow/res/dragsource.png new file mode 100644 index 0000000..2aaa05c Binary files /dev/null and b/test/NUIDnDMultiWindow/res/dragsource.png differ diff --git a/test/NUIDnDMultiWindow/res/droptarget.png b/test/NUIDnDMultiWindow/res/droptarget.png new file mode 100644 index 0000000..9d1bd7e Binary files /dev/null and b/test/NUIDnDMultiWindow/res/droptarget.png differ diff --git a/test/NUIDnDMultiWindow/shared/res/NUIDnDMultiWindow.png b/test/NUIDnDMultiWindow/shared/res/NUIDnDMultiWindow.png new file mode 100644 index 0000000..62d0dff Binary files /dev/null and b/test/NUIDnDMultiWindow/shared/res/NUIDnDMultiWindow.png differ diff --git a/test/NUIDnDMultiWindow/shared/res/dragsource.png b/test/NUIDnDMultiWindow/shared/res/dragsource.png new file mode 100644 index 0000000..2aaa05c Binary files /dev/null and b/test/NUIDnDMultiWindow/shared/res/dragsource.png differ diff --git a/test/NUIDnDMultiWindow/shared/res/droptarget.png b/test/NUIDnDMultiWindow/shared/res/droptarget.png new file mode 100644 index 0000000..9d1bd7e Binary files /dev/null and b/test/NUIDnDMultiWindow/shared/res/droptarget.png differ diff --git a/test/NUIDnDMultiWindow/tizen-manifest.xml b/test/NUIDnDMultiWindow/tizen-manifest.xml new file mode 100644 index 0000000..25ad830 --- /dev/null +++ b/test/NUIDnDMultiWindow/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + + NUIDnDMultiWindow.png + + +