示例#1
0
 private void Export_Click(object sender, EventArgs e)
 {
     SelectFile.Filter = "Json files (*.json)|*.json|Text files (*.txt)|*.txt";
     if (SelectFile.ShowDialog() == DialogResult.OK)
     {
         service.localItems.ExportAsJSON(SelectFile.FileName, (List <MediaItemDTO>)ItemsTable.DataSource);
     }
 }
示例#2
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     i = 0;
     lblFilePath.Text            = "";
     SelectFile.FilterIndex      = 1;
     SelectFile.RestoreDirectory = true;
     SelectFile.Title            = "Sélectionnez un fichier";
     if (SelectFile.ShowDialog() == DialogResult.OK)
     {
         try
         {
             fileDir  = System.IO.Path.GetDirectoryName(SelectFile.FileName) + "\\";
             fileName = System.IO.Path.GetFileNameWithoutExtension(SelectFile.FileName);
             fileExt  = System.IO.Path.GetExtension(SelectFile.FileName);
             filePath = fileDir + fileName + fileExt;
             ActualLabel();
             btnCopy.Enabled = btnCut.Enabled = btnRename.Enabled = btnDuplicate.Enabled = btnDelete.Enabled = tbxRename.Enabled = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message);
         }
     }
 }
        public static string OpenFile(ThumbItem item)
        {
            string results = String.Empty;

            if (item != null)
            {
                string strPath   = String.Empty;
                bool   bLaunched = false;

                IServices service = Util.GetService(item.EType);

                IMyCollectionsData currentItem = service.Get(item.Id);
                if (currentItem != null)
                {
                    switch (item.EType)
                    {
                    case EntityType.Music:
                        string fullpath = Path.Combine(currentItem.FilePath, currentItem.FileName);
                        strPath = fullpath;
                        if (Directory.Exists(fullpath))
                        {
                            string[] strFiles = Util.GetFiles(fullpath, new List <string> {
                                "*.mp3", "*.flc"
                            });
                            if (strFiles.Any())
                            {
                                string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "play.m3u");
                                //FIX 2.8.9.0
                                using (StreamWriter file = new StreamWriter(filePath, false, Encoding.Default))
                                {
                                    foreach (string music in strFiles)
                                    {
                                        file.WriteLine(music);
                                    }

                                    file.Close();
                                }

                                Process.Start(filePath);

                                bLaunched = true;
                            }
                            else
                            {
                                results = "Can't find any mp3 or flc";
                            }
                        }
                        else if (File.Exists(fullpath))
                        {
                            Process.Start(fullpath);
                            bLaunched = true;
                        }
                        else
                        {
                            results = "Can't find any mp3 or flc";
                        }
                        break;

                    case EntityType.Apps:
                    case EntityType.Books:
                    case EntityType.Games:
                    case EntityType.Nds:
                        if (String.IsNullOrWhiteSpace(currentItem.FilePath) == false || String.IsNullOrWhiteSpace(currentItem.FileName) == false)
                        {
                            if (String.IsNullOrWhiteSpace(currentItem.FilePath) == false && String.IsNullOrWhiteSpace(currentItem.FileName) == false)
                            {
                                strPath = Path.Combine(currentItem.FilePath, currentItem.FileName);
                            }
                            if (String.IsNullOrWhiteSpace(currentItem.FilePath) == true && String.IsNullOrWhiteSpace(currentItem.FileName) == false)
                            {
                                strPath = currentItem.FileName;
                            }
                            if (String.IsNullOrWhiteSpace(currentItem.FilePath) == false && String.IsNullOrWhiteSpace(currentItem.FileName) == true)
                            {
                                strPath = currentItem.FilePath;
                            }

                            if (Directory.Exists(strPath) == true || File.Exists(strPath) == true)
                            {
                                Process.Start(strPath);
                                bLaunched = true;
                            }
                        }
                        break;

                    case EntityType.Movie:
                    case EntityType.XXX:
                        if (String.IsNullOrWhiteSpace(currentItem.FilePath) == false || String.IsNullOrWhiteSpace(currentItem.FileName) == false)
                        {
                            if (String.IsNullOrWhiteSpace(currentItem.FilePath) == false && String.IsNullOrWhiteSpace(currentItem.FileName) == false)
                            {
                                strPath = Path.Combine(currentItem.FilePath, currentItem.FileName);
                            }
                            if (String.IsNullOrWhiteSpace(currentItem.FilePath) == true && String.IsNullOrWhiteSpace(currentItem.FileName) == false)
                            {
                                strPath = currentItem.FileName;
                            }
                            if (String.IsNullOrWhiteSpace(currentItem.FilePath) == false && String.IsNullOrWhiteSpace(currentItem.FileName) == true)
                            {
                                strPath = currentItem.FilePath;
                            }

                            if (Directory.Exists(strPath) == true && File.Exists(strPath) == false)
                            {
                                string[] strFiles = Util.GetFiles(strPath, new List <string> {
                                    "*.avi", "*.mkv", "*.mov", "*.divx"
                                });
                                if (strFiles.Any())
                                {
                                    strPath = Path.Combine(strPath, strFiles[0]);
                                }
                            }
                            if (Directory.Exists(strPath) == true || File.Exists(strPath) == true)
                            {
                                Process.Start(strPath);
                                bLaunched = true;
                            }
                        }
                        break;

                    case EntityType.Series:
                        if (Directory.Exists(currentItem.FilePath))
                        {
                            string[] strFiles = Util.GetFiles(currentItem.FilePath, new List <string> {
                                "*.avi", "*.mkv", "*.mov", "*.divx"
                            });

                            if (strFiles.Any())
                            {
                                SelectFile objWindow = new SelectFile(strFiles);
                                objWindow.ShowDialog();
                                if (String.IsNullOrEmpty(objWindow.SelectedValue) == false)
                                {
                                    Process.Start(objWindow.SelectedValue);
                                }
                                bLaunched = true;
                            }
                            else
                            {
                                results = "Can't find any avi or mkv";
                            }
                        }
                        else
                        {
                            results = "Can't file path : " + currentItem.FilePath;
                        }
                        break;
                    }
                }

                if (bLaunched == false && String.IsNullOrWhiteSpace(results))
                {
                    results = "Can't find path : " + strPath;
                }
            }

            return(results);
        }