コード例 #1
0
        // ============================================
        // PROTECTED (Methods) Event Handlers
        // ============================================
        protected void OnDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            // Get Drop Paths
            object[] filesPath = Dnd.GetDragReceivedPaths(args);

            if (this.userInfo == MyInfo.GetInstance())
            {
                // Copy Selected Files Into Directory
                foreach (string filePath in filesPath)
                {
                    FileUtils.CopyAll(filePath, currentDirectory.FullName);
                }

                // Refresh Icon View
                Refresh();
            }
            else
            {
                // Send Files
                foreach (string filePath in filesPath)
                {
                    PeerSocket peer   = (PeerSocket)P2PManager.KnownPeers[userInfo];
                    bool       fisDir = FileUtils.IsDirectory(filePath);

                    Debug.Log("Send To '{0}' URI: '{1}'", userInfo.Name, filePath);
                    if (FileSend != null)
                    {
                        FileSend(peer, filePath, fisDir);
                    }
                }
            }

            Drag.Finish(args.Context, true, false, args.Time);
        }
コード例 #2
0
        // ============================================
        // PROTECTED (Methods) Event Handlers
        // ============================================
        protected void OnDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            IconViewDropPosition pos;
            TreePath             path;

            // Get Dest Item Position
            if (iconView.GetDestItemAtPos(args.X, args.Y, out path, out pos) == false)
            {
                Drag.Finish(args.Context, false, false, args.Time);
                return;
            }

            // Select Item (Change Icon To Activate it)
            UserInfo userInfo = store.GetUserInfo(path);

            // Get Drop Paths
            object[] filesPath = Dnd.GetDragReceivedPaths(args);
            foreach (string filePath in filesPath)
            {
                Debug.Log("Send To '{0}' URI: '{1}'", userInfo.Name, filePath);
                if (SendFile != null)
                {
                    SendFile(this, userInfo, filePath);
                }
            }

            Drag.Finish(args.Context, true, false, args.Time);
        }
コード例 #3
0
ファイル: GtkTypeDisplayer.cs プロジェクト: retahc/old-code
        private void OnDropFiles(object o, DragDataReceivedArgs args)
        {
            string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);

            string[] urls  = Regex.Split(data, "\r\n");
            int      count = 0;

            foreach (string s in urls)
            {
                if (s != null && s.Length > 0)
                {
                    ++count;
                }
            }
            string[] files = new string[count];
            count = 0;
            foreach (string s in urls)
            {
                if (s != null && s.Length > 0)
                {
                    files[count++] = s;
                }
            }

            OpenAssembly(files);

            Drag.Finish(args.Context, true, false, args.Time);
        }
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: yunatoomi/DGLE
        private void SetDestDnD()
        {
            Drag.DestSet(
                packTreeView,
                DestDefaults.All,
                new TargetEntry[] { new TargetEntry("text/uri-list", TargetFlags.OtherApp, 0) },
                Gdk.DragAction.Copy);

            packTreeView.DragDataReceived += (o, args) =>
            {
                string data = Encoding.UTF8.GetString(args.SelectionData.Data, 0, args.SelectionData.Length - 1);
                data = Uri.UnescapeDataString(data);
                Drag.Finish(args.Context, true, false, args.Time);

                string[] files = data.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                // try to open pack
                if (fileSystem == null)
                {
                    if (files.Length == 1)
                    {
                        OpenPack(files.Select(
                                     path => path.StartsWith("file:///") ? path.Substring(8) : path).First());
                    }

                    return;
                }

                packTreeView.Selection.UnselectAll();

                files.Select(path => path.StartsWith("file:///") ? path.Substring(8) : path).ToList()
                .ForEach(path =>
                {
                    if (Directory.Exists(path))
                    {
                        Packer.Item folderItem = NewItem(currentFolder, path);
                        TreeIter folderIter    = AppendItem(currentFolder, folderItem);
                        AppendFolders(folderIter, path);
                    }
                    else
                    if (File.Exists(path))
                    {
                        AppendFile(currentFolder, path);
                    }
                });
            };
        }
コード例 #5
0
ファイル: ExperimentCanvasPad.cs プロジェクト: thbin/TraceLab
        /// <summary>
        /// Handles the drag data received.
        /// See the EnableDrag and HandleDragDataGet in the ComponentLibraryPad where the drag
        /// has started and drag source is set
        /// </summary>
        /// <param name='o'>
        /// O.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        private void HandleDragDataReceived(object o, DragDataReceivedArgs args)
        {
            Widget   source   = Drag.GetSourceWidget(args.Context);
            TreeView treeView = source as TreeView;
            TreeIter selectedItem;

            if (treeView != null && treeView.Selection.GetSelected(out selectedItem))
            {
                ComponentsLibraryNode selectedNode = treeView.Model.GetValue(selectedItem, 0) as ComponentsLibraryNode;

                Cairo.PointD   translation = m_experimentCanvasWidget.ExperimentCanvas.View.ViewToDrawing(args.X, args.Y);
                ExperimentNode node        = m_applicationViewModel.Experiment.AddComponentFromDefinition(selectedNode.Data,
                                                                                                          translation.X, translation.Y);
                m_experimentDrawer.DrawComponent(node, true);
            }

            Drag.Finish(args.Context, true, false, args.Time);
        }
コード例 #6
0
        // ============================================
        // PROTECTED (Methods) Event Handlers
        // ============================================
        protected void OnDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            if (this.userInfo == MyInfo.GetInstance())
            {
                return;
            }

            // Get Drop Paths
            object[] filesPath = Dnd.GetDragReceivedPaths(args);
            foreach (string filePath in filesPath)
            {
                PeerSocket peer   = (PeerSocket)P2PManager.KnownPeers[userInfo];
                bool       fisDir = FileUtils.IsDirectory(filePath);

                Debug.Log("Send To '{0}' URI: '{1}'", userInfo.Name, filePath);
                if (FileSend != null)
                {
                    FileSend(peer, filePath, fisDir);
                }
            }

            Drag.Finish(args.Context, true, false, args.Time);
        }
 private void lstStyles_DragDataReceived_Drop(object sender, DragDataReceivedArgs e)
 {
     if (e.SelectionData.Length > 0 && e.SelectionData.Format == 8)
     {
         byte[] data    = e.SelectionData.Data;
         string encoded = System.Text.Encoding.UTF8.GetString(data);
         System.Collections.Generic.List <string> paths = new System.Collections.Generic.List <string>(encoded.Split('\r', '\n'));
         paths.RemoveAll(string.IsNullOrEmpty);
         foreach (string sTP in paths)
         {
             if (sTP.StartsWith("file://"))
             {
                 string StylePath = sTP.Substring(7);
                 string sTitle    = System.IO.Path.GetFileNameWithoutExtension(StylePath);
                 string sExt      = System.IO.Path.GetExtension(StylePath).ToLower();
                 while (!string.IsNullOrEmpty(System.IO.Path.GetExtension(sTitle)))
                 {
                     sExt   = System.IO.Path.GetExtension(sTitle).ToLower() + sExt;
                     sTitle = System.IO.Path.GetFileNameWithoutExtension(sTitle);
                 }
                 if (sExt == ".tgz" | sExt == ".tar.gz" | sExt == ".tar")
                 {
                     File.Copy(StylePath, System.IO.Path.Combine(modFunctions.AppData, sTitle + sExt), true);
                     TreeIter iter;
                     lstStyles.Model.GetIterFirst(out iter);
                     bool Add = true;
                     do
                     {
                         GLib.Value val = new GLib.Value();
                         lstStyles.Model.GetValue(iter, 0, ref val);
                         if ((string)val.Val == sTitle)
                         {
                             Add = false;
                             break;
                         }
                     } while (lstStyles.Model.IterNext(ref iter));
                     if (Add)
                     {
                         lstStyles.AddItem(sTitle);
                     }
                     if (paths.Count == 1)
                     {
                         TreeIter iterSel;
                         lstStyles.Model.GetIterFirst(out iterSel);
                         do
                         {
                             GLib.Value val = new GLib.Value();
                             lstStyles.Model.GetValue(iterSel, 0, ref val);
                             if ((string)val.Val == sTitle)
                             {
                                 lstStyles.Selection.SelectIter(iterSel);
                                 break;
                             }
                         } while (lstStyles.Model.IterNext(ref iterSel));
                     }
                 }
             }
         }
         Drag.Finish(e.Context, true, false, e.Time);
     }
     lstStyles.DragDataReceived -= lstStyles_DragDataReceived_Drop;
 }