Exemple #1
0
        protected async override void OnDrop(System.Windows.DragEventArgs e)
        {
            double currMapX = 0;
            double currMapY = 0;

            System.Windows.DataObject d = (System.Windows.DataObject)e.Data;

            string[] dataFormats = d.GetFormats();
            string   dataText    = d.GetText();

            Point position = e.GetPosition(this);

            GMap.NET.PointLatLng curPosition = FromLocalToLatLng((int)position.X, (int)position.Y);
            currMapX = curPosition.Lng;
            currMapY = curPosition.Lat;

            for (int i = 0; i < dataFormats.Length; i++)
            {
                string dragFormat = dataFormats[i];

                if (dragFormat.Contains("FormationTree") && dataText == "Actor")
                {
                    object dragObject = d.GetData(dragFormat);

                    FormationTree formation = dragObject as FormationTree;
                    if (formation == null)
                    {
                        continue;
                    }

                    enOSMhighwayFilter highwayFilter = enOSMhighwayFilter.Undefined;
                    SetHighwayFilter(highwayFilter);
                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, currMapX, currMapY);

                    if (PointId != null)
                    {
                        shPoint           pnt             = PointId.point;
                        DeployedFormation deployFormation = new DeployedFormation();
                        deployFormation.x         = pnt.x;
                        deployFormation.y         = pnt.y;
                        deployFormation.formation = formation;

                        AtomData atom = await TDSClient.SAGInterface.SAGSignalR.DeployFormationFromTree(VMMainViewModel.Instance.SimulationHubProxy, deployFormation);

                        if (atom != null)
                        {
                            AtomDeployedEventArgs args = new AtomDeployedEventArgs();
                            args.atom = atom;
                            if (AtomDeployedEvent != null)
                            {
                                AtomDeployedEvent(this, args);
                            }
                        }
                    }

                    return;
                }
            }
        }
        private static string GetImageFilename(DragDropInfo info)
        {
            DataObject data = new DataObject(info.Data);

            if (info.Data.GetDataPresent("FileDrop"))
            {
                // The drag and drop operation came from the file system
                StringCollection files = data.GetFileDropList();

                if (files != null && files.Count == 1)
                    return files[0];
            }
            else if (info.Data.GetDataPresent("CF_VSSTGPROJECTITEMS"))
            {
                return data.GetText(); // The drag and drop operation came from the VS solution explorer
            }
            else if (info.Data.GetDataPresent("MultiURL"))
            {
                return data.GetText();
            }

            return null;
        }
        /// <summary>
        /// Get the dropped filename
        /// </summary>
        /// <param name="Info"></param>
        /// <returns></returns>
        private static string GetFilename(DragDropInfo Info)
        {
            DataObject Data = new DataObject(Info.Data);

            if (Info.Data.GetDataPresent(DragDropHandlerProvider.FileDropDataFormat))
            {
                // The drag and drop operation came from the file system
                StringCollection Files = Data.GetFileDropList();

                if (Files != null && Files.Count == 1)
                {
                    return Files[0];
                }
            }
            else if (Info.Data.GetDataPresent(DragDropHandlerProvider.VSProjectStorageItemDataFormat))
            {
                // The drag and drop operation came from the VS solution explorer as a storage item
                return Data.GetText();
            }
            else if (Info.Data.GetDataPresent(DragDropHandlerProvider.VSProjectReferenceItemDataFormat))
            {
                // The drag and drop operation came from the VS solution explorer as a reference item have to
                // get the selected item from the solution explorer
                DTE2 dte = Package.GetGlobalService(typeof(DTE)) as DTE2;

                UIHierarchy solutionExplorer = dte.ToolWindows.SolutionExplorer;

                var SolutionExplorerSeclectedItems = solutionExplorer.SelectedItems as System.Array;

                if (SolutionExplorerSeclectedItems != null && SolutionExplorerSeclectedItems.Length == 1)
                {
                    foreach (UIHierarchyItem SolutionExplorerSelectedItem in SolutionExplorerSeclectedItems)
                    {
                        ProjectItem SolutionExplorerSelectedObject = SolutionExplorerSelectedItem.Object as ProjectItem;

                        return SolutionExplorerSelectedObject.Properties.Item("FullPath").Value.ToString();
                    }

                }
            }

            return null;
        }
        private static string GetImageFilename(DragDropInfo info)
        {
            DataObject data = new DataObject(info.Data);

            if (info.Data.GetDataPresent(ImageInsertionDropHandlerProvider.FileDropDataFormat))
            {
                // The drag and drop operation came from the file system
                StringCollection files = data.GetFileDropList();

                if (files != null && files.Count == 1)
                {
                    return files[0];
                }
            }
            else if (info.Data.GetDataPresent(ImageInsertionDropHandlerProvider.VSProjectItemDataFormat))
            {
                // The drag and drop operation came from the VS solution explorer
                return data.GetText();
            }

            return null;
        }