Ejemplo n.º 1
0
        private void HandlePreviewDropCommand(DataObject droppedObject)
        {
            if (!droppedObject.ContainsFileDropList()) return;

            foreach (var filePath in droppedObject.GetFileDropList())
            {
                LocalPhotos.Add(new SinglePhotoFlickrMatchesViewModel(filePath, _flickrModel));
            }
        }
Ejemplo n.º 2
0
        //Handle filedrop to GUI
        private void Window_Drop(object sender, System.Windows.DragEventArgs e)
        {
            XMlControler xmlcon = new XMlControler();
            EDIControler Edicon = new EDIControler();

            LWFilepatchtoFinich.Items.Clear();
            System.Windows.DataObject dataObject = e.Data as System.Windows.DataObject;
            LbResultat.Visibility = System.Windows.Visibility.Hidden;
            List <string> imageFiles = new List <string>();

            try
            {
                if (dataObject.ContainsFileDropList())
                {
                    System.Collections.Specialized.StringCollection fileNames =
                        dataObject.GetFileDropList();
                    foreach (string fileName in fileNames)
                    {
                        string extension = System.IO.Path.GetExtension(fileName).ToString().ToLower();
                        switch (extension)
                        {
                        case ".xml":

                            imageFiles.Add(fileName);
                            xmlcon.DecodeBase64(fileName, folman.GetUserFilePatch());
                            LWFilepatchtoFinich.Items.Add(fileName.ToString());
                            break;

                        case ".fnx":
                            imageFiles.Add(fileName);
                            xmlcon.DecodeBase64(fileName, folman.GetUserFilePatch());
                            LWFilepatchtoFinich.Items.Add(fileName.ToString());
                            break;

                        case ".edi":
                            imageFiles.Add(fileName);
                            Edicon.ExtractEDIFIle(fileName, folman.GetUserFilePatch());
                            LWFilepatchtoFinich.Items.Add(fileName.ToString());
                            break;

                        default:
                            LWFilepatchtoFinich.Items.Add("forkert fil format");
                            break;
                        }
                    }
                }
                LbResultat.Visibility = System.Windows.Visibility.Visible;
                LbResultat.Content    = "Færdig";
                LbResultat.Foreground = new SolidColorBrush(Colors.Green);
            }
            catch
            {
                LbResultat.Visibility = System.Windows.Visibility.Visible;
                LbResultat.Content    = "Ingen output";
                LbResultat.Foreground = new SolidColorBrush(Colors.Red);
            }
        }
        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;
        }
Ejemplo n.º 4
0
        /// <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;
        }
        private void ClipboardReceived(object sender, RunWorkerCompletedEventArgs eventArgs)
        {
            if (!eventArgs.Cancelled && eventArgs.Error == null)
            {
                ArrayList data = (ArrayList)eventArgs.Result;
                if (data != null)
                {
                    DataObject dataObj = new DataObject();
                    Console.WriteLine("Count: " + data.Count);
                    for (int i = 0; i < data.Count; i++)
                    {
                        string format = (string)data[i++];
                        Console.WriteLine(format);
                        dataObj.SetData(format, data[i]);
                    }

                    if (dataObj.ContainsFileDropList())
                    {
                        StringCollection files = dataObj.GetFileDropList();
                        dataObj = new DataObject();
                        StringCollection adjusted = new StringCollection();
                        foreach (string f in files)
                        {
                            if (!f.StartsWith("\\"))
                            {
                                string toadd = "\\\\" + Ip + "\\" + f.Replace(":", "");
                                Console.WriteLine(toadd);
                                adjusted.Add(toadd);
                            }
                            else
                            {
                                adjusted.Add(f);
                            }
                        }
                        dataObj.SetFileDropList(adjusted);
                    }
                    Clipboard.SetDataObject(dataObj);

                }
            }
        }
        public void SetClipboard(string Ip, Object obj)
        {
            try
            {
                ArrayList data = (ArrayList)obj;
                if (data != null)
                {
                    DataObject dataObj = new DataObject();
                    Console.WriteLine("Count: " + data.Count);
                    for (int i = 0; i < data.Count; i++)
                    {
                        string format = (string)data[i++];
                        Console.WriteLine(format);
                        dataObj.SetData(format, data[i]);
                    }
                    if (dataObj.ContainsFileDropList())
                    {
                        StringCollection files = dataObj.GetFileDropList();
                        dataObj = new DataObject();
                        StringCollection adjusted = new StringCollection();
                        foreach (string f in files)
                        {
                            if (!f.StartsWith("\\"))
                            {
                                string toadd = "\\\\" + Ip + "\\" + f.Replace(":", "");
                                Console.WriteLine(toadd);
                                adjusted.Add(toadd);
                            }
                            else
                            {
                                adjusted.Add(f);
                            }
                        }
                        dataObj.SetFileDropList(adjusted);
                    }
                    Clipboard.SetDataObject(dataObj);

                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }