3 using Tizen.NUI.Components;
4 using Tizen.NUI.BaseComponents;
6 namespace NUIDnDMultiWindow
8 class Program : NUIApplication
13 ImageView MainWindow_View;
16 ImageView WindowA_ViewA;
17 ImageView WindowA_ViewB;
20 ImageView WindowB_ViewA;
21 ImageView WindowB_ViewB;
23 LongPressGestureDetector longPressed;
24 protected override void OnCreate()
32 // Create DnD Instance
33 dnd = DragAndDrop.Instance;
35 Window.Instance.KeyEvent += OnKeyEvent;
36 Window.Instance.WindowSize = new Size(900, 1080);
37 Window.Instance.BackgroundColor = Color.White;
39 TextLabel text = new TextLabel("Multi-Window Drag And Drop");
40 text.Position = new Position(0, 0);
41 text.TextColor = Color.Black;
42 text.PointSize = 8.0f;
43 Window.Instance.GetDefaultLayer().Add(text);
45 TextLabel text2 = new TextLabel("Source View");
46 text2.Position = new Position(330, 330);
47 text2.Size = new Size(400, 150);
48 text2.TextColor = Color.Black;
49 text2.PointSize = 5.0f;
50 text2.MultiLine = true;
51 Window.Instance.GetDefaultLayer().Add(text2);
53 TextLabel text3 = new TextLabel("MainWindow View");
54 text3.Position = new Position(100, 700);
55 text3.Size = new Size(400, 150);
56 text3.TextColor = Color.Black;
57 text3.PointSize = 5.0f;
58 text3.MultiLine = true;
59 Window.Instance.GetDefaultLayer().Add(text3);
61 TextLabel text4 = new TextLabel("Window A");
62 text4.Position = new Position(400, 650);
63 text4.Size = new Size(400, 150);
64 text4.TextColor = Color.Black;
65 text4.PointSize = 5.0f;
66 text4.MultiLine = true;
67 Window.Instance.GetDefaultLayer().Add(text4);
69 TextLabel text5 = new TextLabel("Window B");
70 text5.Position = new Position(400, 1000);
71 text5.Size = new Size(400, 150);
72 text5.TextColor = Color.Black;
73 text5.PointSize = 5.0f;
74 text5.MultiLine = true;
75 Window.Instance.GetDefaultLayer().Add(text5);
78 sourceView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "dragsource.png");
79 sourceView.Size = new Size(200, 200);
80 sourceView.Position = new Position(330, 120);
81 Window.Instance.GetDefaultLayer().Add(sourceView);
83 longPressed = new LongPressGestureDetector();
84 longPressed.Attach(sourceView);
85 longPressed.Detected += (s, e) =>
87 if(e.LongPressGesture.State == Gesture.StateType.Started)
89 Tizen.Log.Debug("NUIDnDMultiWindow", "StartDragAndDrop");
90 shadowView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png");
91 shadowView.Size = new Size(150, 150);
93 dragData.MimeType = "text/uri-list";
94 dragData.Data = Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png";
95 dnd.StartDragAndDrop(sourceView, shadowView, dragData, OnSourceApp_SourceFunc);
99 // Create Target MainWindow_View
100 MainWindow_View = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
101 MainWindow_View.Size = new Size(200, 200);
102 MainWindow_View.Position = new Position(100, 500);
103 Window.Instance.GetDefaultLayer().Add(MainWindow_View);
105 // Add Drop Target MainWindow_View
106 dnd.AddListener(MainWindow_View, OnSourceApp_TargetFunc);
108 // Create Target Window A
109 WindowA = new Window("WindowA", new Rectangle(400, 400, 370, 250), false)
111 BackgroundColor = Color.BlueViolet,
115 // Create Target WindowA_ViewA
116 WindowA_ViewA = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
117 WindowA_ViewA.Size = new Size(150, 150);
118 WindowA_ViewA.Position = new Position(20, 10);
119 WindowA.GetDefaultLayer().Add(WindowA_ViewA);
121 // Add Drop Target WindowA_ViewA
122 dnd.AddListener(WindowA_ViewA, OnSourceApp_TargetFunc);
124 // Create Target View WindowA_ViewB
125 WindowA_ViewB = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
126 WindowA_ViewB.Size = new Size(150, 150);
127 WindowA_ViewB.Position = new Position(180, 50);
128 WindowA.GetDefaultLayer().Add(WindowA_ViewB);
130 // Add Drop Target WindowA_ViewB
131 dnd.AddListener(WindowA_ViewB, OnSourceApp_TargetFunc);
133 // Create Target Window B
134 WindowB = new Window("WindowB", new Rectangle(400, 750, 370, 250), false)
136 BackgroundColor = Color.LightGoldenRodYellow,
140 // Create Target WindowB_ViewA
141 WindowB_ViewA = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
142 WindowB_ViewA.Size = new Size(150, 150);
143 WindowB_ViewA.Position = new Position(20, 10);
144 WindowB.GetDefaultLayer().Add(WindowB_ViewA);
146 // Add Drop Target WindowB_ViewA
147 dnd.AddListener(WindowB_ViewA, OnSourceApp_TargetFunc);
149 // Create Target WindowB_ViewB
150 WindowB_ViewB = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
151 WindowB_ViewB.Size = new Size(150, 150);
152 WindowB_ViewB.Position = new Position(180, 50);
153 WindowB.GetDefaultLayer().Add(WindowB_ViewB);
155 // Add Drop Target WindowB_ViewB
156 dnd.AddListener(WindowB_ViewB, OnSourceApp_TargetFunc);
159 public void OnSourceApp_SourceFunc(DragSourceEventType type)
161 if (type == DragSourceEventType.Start)
163 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Start");
165 else if (type == DragSourceEventType.Cancel)
167 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Cancel");
169 else if (type == DragSourceEventType.Accept)
171 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Accept");
173 else if (type == DragSourceEventType.Finish)
175 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App DragSourceEventType: " + "Finish");
179 public void OnSourceApp_TargetFunc(View targetView, DragEvent dragEvent)
181 if (dragEvent.DragType == DragType.Enter)
183 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Enter]");
185 else if (dragEvent.DragType == DragType.Leave)
187 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Leave]");
189 else if (dragEvent.DragType == DragType.Move)
191 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Move]: " + dragEvent.Position.X + " " + dragEvent.Position.Y);
193 else if (dragEvent.DragType == DragType.Drop)
195 Tizen.Log.Debug("NUIDnDMultiWindow", "Source App Target A [Drop] MimeType: " + dragEvent.MimeType + " Data: " + dragEvent.Data);
196 ((ImageView)targetView).ResourceUrl = dragEvent.Data;
200 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
202 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
208 static void Main(string[] args)
210 var app = new Program();