コード例 #1
0
        private void HandlePreviewDropCommand(DataObject droppedObject)
        {
            if (!droppedObject.ContainsFileDropList()) return;

            foreach (var filePath in droppedObject.GetFileDropList())
            {
                LocalPhotos.Add(new SinglePhotoFlickrMatchesViewModel(filePath, _flickrModel));
            }
        }
コード例 #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);
            }
        }
コード例 #3
0
        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);
            }
        }