3 using Tizen.NUI.Components;
4 using Tizen.NUI.BaseComponents;
8 class Program : NUIApplication
10 ImageView targetViewA;
11 ImageView targetViewB;
13 protected override void OnCreate()
21 // Create DnD Instance
22 dnd = DragAndDrop.Instance;
24 Window.Instance.KeyEvent += OnKeyEvent;
25 Window.Instance.WindowPosition = new Position(1020, 0);
26 Window.Instance.WindowSize = new Size(900, 1080);
27 Window.Instance.BackgroundColor = Color.White;
29 TextLabel text = new TextLabel("DropTarget Application");
30 text.Position = new Position(0, 0);
31 text.TextColor = Color.Black;
32 text.PointSize = 10.0f;
33 Window.Instance.GetDefaultLayer().Add(text);
35 TextLabel text2 = new TextLabel("This sample demonstrates NUI DnD functionality and is the 'target' app for this sample.");
36 text2.Position = new Position(0, 70);
37 text2.TextColor = Color.Black;
38 text2.PointSize = 7.0f;
39 text2.MultiLine = true;
40 Window.Instance.GetDefaultLayer().Add(text2);
42 // Create Target View A
43 targetViewA = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
44 targetViewA.Size = new Size(300, 300);
45 targetViewA.Position = new Position(100, 235);
46 Window.Instance.GetDefaultLayer().Add(targetViewA);
49 dnd.AddListener(targetViewA, OnTargetAppDnDFuncA);
51 // Create Target View B
52 targetViewB = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "droptarget.png");
53 targetViewB.Size = new Size(300, 300);
54 targetViewB.Position = new Position(100, 585);
55 Window.Instance.GetDefaultLayer().Add(targetViewB);
58 dnd.AddListener(targetViewB, OnTargetAppDnDFuncB);
60 TextLabel text3 = new TextLabel("Drop your image here.");
61 text3.Position = new Position(500, 355);
62 text3.TextColor = Color.Black;
63 text3.PointSize = 7.0f;
64 Window.Instance.GetDefaultLayer().Add(text3);
67 public void OnTargetAppDnDFuncA(View targetView, DragEvent dragEvent)
69 if (dragEvent.DragType == DragType.Enter)
71 Tizen.Log.Error("NUIDnDTarget", "Target App Target A [Enter]");
73 else if (dragEvent.DragType == DragType.Leave)
75 Tizen.Log.Error("NUIDnDTarget", "Target App Target A [Leave]");
77 else if (dragEvent.DragType == DragType.Move)
79 Tizen.Log.Error("NUIDnDTarget", "Target App Target A [Move]: " + dragEvent.Position.X + " " + dragEvent.Position.Y);
81 else if (dragEvent.DragType == DragType.Drop)
83 Tizen.Log.Error("NUIDnDTarget", "Target App Target A [Drop] MimeType: " + dragEvent.MimeType + " Data: " + dragEvent.Data);
84 targetViewA.ResourceUrl = dragEvent.Data;
88 public void OnTargetAppDnDFuncB(View targetView, DragEvent dragEvent)
90 if (dragEvent.DragType == DragType.Enter)
92 Tizen.Log.Error("NUIDnDTarget", "Target App Target B [Enter]");
94 else if (dragEvent.DragType == DragType.Leave)
96 Tizen.Log.Error("NUIDnDTarget", "Target App Target B [Leave]");
98 else if (dragEvent.DragType == DragType.Move)
100 Tizen.Log.Error("NUIDnDTarget", "Target App Target B [Move]: " + dragEvent.Position.X + " " + dragEvent.Position.Y);
102 else if (dragEvent.DragType == DragType.Drop)
104 Tizen.Log.Error("NUIDnDTarget", "Target App Target B [Drop] MimeType: " + dragEvent.MimeType + " Data: " + dragEvent.Data);
105 targetViewB.ResourceUrl = dragEvent.Data;
109 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
111 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
117 static void Main(string[] args)
119 var app = new Program();