public void OnClickFileType(FileItem.FileType filetype)
    {
        FileItem.FileType lastType = FileListControl.Instance().SelectedType;
        FileListControl.Instance().SelectedType = filetype;
        for (int i = 0; i < tabArray.Length; ++i)
        {
            if (tabArray [i].btnTpye == filetype)
            {
                tabArray [i].HighColor();
            }

            if (tabArray [i].btnTpye == lastType)
            {
                tabArray [i].ReSetColor();
            }
        }

        if (filetype == FileItem.FileType.FileType_Web)
        {
            webObject.SetActive(true);
            videoObject.SetActive(false);
        }
        else if (filetype == FileItem.FileType.FileType_Video)
        {
            webObject.SetActive(false);
            videoObject.SetActive(true);
        }
    }
Пример #2
0
 internal void Init(FileListControl flc)
 {
     ParentFileListControl              = flc;
     ParentFileListControl.ExFilters    = true;
     ParentFileListControl.ExFileFilter = filter;
     ParentFileListControl.ExDirFilter  = filter;
 }
Пример #3
0
    //filter字段: Video: mov, .mpg, .mpeg, .mp4,.avi, .asf, wmv, webm格式...
    //https://baike.baidu.com/item/OPENFILENAME/1166193?fr=aladdin...
    public void WebUrlConfirm()
    {
        // StartCoroutine(WaitLoad(ofn.file));//加载图片到panle ..
        string strurl   = url.text;
        string strtitle = title.text;

        //string filename = "file:///" + Utility.StrictLinuxStyle(ofn.file);
        Debug.Log("Selected file with full path: " + strurl);
        //ofn.file = filename;

        //must not duplicate...
        string shortUrl = FileListModel.GetUrlShortName(strurl);

        if (FileListControl.Instance().GetFileListView(shortUrl) != null)
        {
            return;
        }

        FileItem item = new FileItem();

        item._fileInfo = null;
        item._title    = strtitle;
        item._webUrl   = strurl;
        item._fileType = FileItem.FileType.FileType_Web;
        FileListControl.Instance().AddFile(item);

        //file path must convert for url path...
        //VideoPreviewer.Instance().StartPreview  ("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4", PreViewDone);
        WebPreviewer.Instance().StartPreview(strurl, PreViewDone);
        //StartCoroutine ( WaitLoadTexture(ofn.file) );

        merialDlg.Hide();
    }
Пример #4
0
 private void FileListControl1_DeleteFileAction(FileListControl arg1, IFileInfo arg2)
 {
     foreach (var item in PreviewExtensions)
     {
         item.Release(arg2);
     }
 }
Пример #5
0
    /// <summary>
    /// Inits the file list and init textures preview...
    /// </summary>
    public void InitFileList()
    {
        //
        DeserializeAndRead();

        //get texture...
        if (null == dicFileItems)
        {
            dicFileItems = new FileList();
        }
        List <FileItem> dicFileList = dicFileItems.lstFileItems;
        List <FileItem> deleteList  = new List <FileItem>();

        foreach (var item in dicFileList)
        {
            //if ( countIndex < item.Key )
            //countIndex = item.Key;

            //FileItem file
            if (item._fileType == FileItem.FileType.FileType_Video)
            {
                //string filePath = "file://" + item.Value.
                OpenFileNameEx fileinfo = item._fileInfo;
                string         filePath = "file:///" + fileinfo.file;
                Texture2D      texture  = VideoPreviewer.Instance().LoadTexture(filePath);
                if (texture == null)
                {
                    deleteList.Add(item);
                    continue;
                }

                Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                string key    = GetFileShortName(filePath);
                FileListControl.Instance().AddPreViewSprite(key, sprite);
            }
            else if (item._fileType == FileItem.FileType.FileType_Web)
            {
                string    weburl  = item._webUrl;
                Texture2D texture = WebPreviewer.Instance().LoadTexture(weburl);
                if (texture == null)
                {
                    deleteList.Add(item);
                    continue;
                }

                Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                string key    = GetUrlShortName(weburl);
                FileListControl.Instance().AddPreViewWeb(key, sprite);
            }
        }

        foreach (var itemDel in deleteList)
        {
            dicFileList.Remove(itemDel);
        }

        Save();
    }
Пример #6
0
    //filter字段: Video: mov, .mpg, .mpeg, .mp4,.avi, .asf, wmv, webm格式...
    //https://baike.baidu.com/item/OPENFILENAME/1166193?fr=aladdin...
    public void VideoFileSelect()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        //三菱(*.gxw)\0*.gxw\0西门子(*.mwp)\0*.mwp\0All Files\0*.*\0\0
        ofn.filter = "All Files\0*.mp4;*.mpg\0\0";

        ofn.file = new string(new char[256]);

        ofn.maxFile = ofn.file.Length;

        ofn.fileTitle = new string(new char[64]);

        ofn.maxFileTitle = ofn.fileTitle.Length;

        ofn.initialDir = objectThread.UnityFullpath;        //默认路径

        ofn.title = "Open Video";

        ofn.defExt = "mp4";                                                         //显示文件的类型
        //注意 一下项目不一定要全选 但是0x00000008项不要缺少
        ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR

        if (DllComdlg.GetOpenFileName(ofn))
        {
            // StartCoroutine(WaitLoad(ofn.file));//加载图片到panle
            //string filename = "file:///" + Utility.StrictLinuxStyle(ofn.file);
            string filename = Utility.StrictLinuxStyle(ofn.file);
            ofn.file = filename;

            //must not duplicate...
            string shortName = FileListModel.GetFileShortName(filename);
            //Debug.Log( "Selected file with full path: " + filename + " : shortName:" + shortName);
            if (FileListControl.Instance().GetFileListView(shortName) != null)
            {
                return;
            }

            FileItem item = new FileItem();
            item._fileInfo = new OpenFileNameEx(ofn);
            item._fileType = FileItem.FileType.FileType_Video;

            lock ( objectThread ) {
                FileListControl.Instance().AddFile(item);
                objectThread.BUnityWorkMutex = true;
                objectThread.UnityFullpath   = filename;
            }
            //file path must convert for url path...
            //VideoPreviewer.Instance().StartPreview  ("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4", PreViewDone);
            //StartCoroutine ( WaitLoadTexture(ofn.file) );

            /*VideoPreviewer.Instance().StartPreview  (filename, PreViewDone);
             * merialDlg.Hide ();*/
        }
        Thread.CurrentThread.Abort();
    }
Пример #7
0
 public void PreViewDone(WebPreviewer.PreViewEvent e)
 {
     //previewImage.sprite = e.PreViewSprite;
     Log.debug(this, "PreViewDone: =========" + e.webUrl);
     //add sprite...
     //Get file name..
     //videoImage.sprite = e.PreViewSprite;
     FileListControl.Instance().CreatePreviewWeb(e.webUrl, e.PreViewSprite);
 }
Пример #8
0
 private void followAction(FileListControl fc, IFileInfo f)
 {
     if (fc == fileListControl1)
     {
         fileListControl2.FollowToFile(f);
     }
     else
     {
         fileListControl1.FollowToFile(f);
     }
 }
Пример #9
0
        private void InsertClipboardAsFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RenameDialog rdl = new RenameDialog();

            rdl.StartPosition = FormStartPosition.CenterParent;

            if (rdl.ShowDialog() == DialogResult.OK)
            {
                FileListControl flc = fileListControl1;
                if (fileListControl2.ContainsFocus)
                {
                    flc = fileListControl2;
                }

                var img = Clipboard.GetImage();
                img.Save(Path.Combine(flc.CurrentDirectory.FullName, rdl.Value));
            }
        }
Пример #10
0
    //init to set ..

    /*
     * public void SetSprite(int index, Sprite previewSprite)
     * {
     *      this.index = index;
     *      previewImage.sprite = previewSprite;
     * }*/

    public void OnClick(GameObject objSender)
    {
        switch (objSender.name)
        {
        case "PreviewBtn":         //Open Material Window..
            if (fileListModel._fileType == FileItem.FileType.FileType_Video)
            {
                SCMainWinController.Instance().TopLeftVw.DisplayVideo(fileListModel._fileInfo.file, title);
            }
            else if (fileListModel._fileType == FileItem.FileType.FileType_Web)
            {
                SCMainWinController.Instance().TopLeftVw.DisplayWeb(fileListModel._webUrl, title);
            }
            break;

        case "ProjectBtn":         //..
            if (fileListModel._fileType == FileItem.FileType.FileType_Video)
            {
                SCMainWinController.Instance().TopRhtVw.DisplayVideo(fileListModel._fileInfo.file, title,
                                                                     SCMainWinController.Instance().TopLeftVw.GetVideoFrameCount());
            }
            else if (fileListModel._fileType == FileItem.FileType.FileType_Web)
            {
                SCMainWinController.Instance().TopRhtVw.DisplayWeb(fileListModel._webUrl, title);
            }
            break;

        case "RemoveBtn":         //移除...
            string key = "";
            if (fileListModel._fileType == FileItem.FileType.FileType_Video)
            {
                key = FileListModel.GetFileShortName(fileListModel._fileInfo.file);
            }
            else if (fileListModel._fileType == FileItem.FileType.FileType_Web)
            {
                key = FileListModel.GetUrlShortName(fileListModel._webUrl);
            }
            FileListControl.Instance().ClickRemovePreview(key);
            break;

        default:
            break;
        }
    }
Пример #11
0
    //
    public static FileListView Create(string name, string title, Sprite sprite, FileItem.FileType filetype = FileItem.FileType.FileType_Video)
    {
        if (sprite == null)
        {
            Debug.Log("FileListView.Create(), sprite can not be null !");
            return(null);
        }

        GameObject go;

        if (FileItem.FileType.FileType_Video == filetype)
        {
            go = Instantiate(FileListControl.Instance().VideoViewPrefab) as GameObject;
        }
        else if (FileItem.FileType.FileType_Web == filetype)
        {
            go = Instantiate(FileListControl.Instance().WebViewPrefab) as GameObject;
        }
        else
        {
            Log.error("FileListView", "Unknown file type:" + filetype);
            return(null);
        }

        go.transform.SetParent(FileListControl.Instance().GetTempRoot());
        go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, 0);
        go.transform.localScale    = Vector3.one;
        go.name = name;

        //set title and sprite
        //RectTransform rect = go.GetComponent<RectTransform> ();
        //rect.rect.height = 100;
        //rect.rect.width = 100;
        FileListView instance = go.GetComponent <FileListView>();

        if (null == instance)
        {
            instance = go.AddComponent <FileListView>();
        }
        instance.title         = title;
        instance.preview       = sprite;
        instance.fileListModel = null;
        return(instance);
    }
Пример #12
0
        private void mouseIsoAction(FileListControl sender, IFileInfo obj, IDirectoryInfo target)
        {
            var t = fileListControl1;

            if (target == null)
            {
                if (t == sender)
                {
                    t = fileListControl2;
                }
                target = t.CurrentDirectory;
            }
            if (Stuff.Question("Mount: " + obj.FullName + " to " + target.FullName + "?") == DialogResult.Yes)
            {
                var minf = new MountInfo();
                minf.IsoPath   = obj;
                minf.Path      = target.FullName;
                minf.IsMounted = true;
                if (minf.Reader == null)
                {
                    IsoReader reader = new IsoReader();
                    reader.Parse(minf.IsoPath.FullName);
                    minf.Reader = reader;
                }
                var r = new IsoDirectoryInfoWrapper(minf, minf.Reader.WorkPvd.RootDir);
                r.Parent         = new DirectoryInfoWrapper(minf.Path);
                minf.MountTarget = r;
                r.Filesystem     = new IsoFilesystem(minf)
                {
                    IsoFileInfo = minf.IsoPath
                };

                Stuff.MountIso(minf);
                if (target == null)
                {
                    t.UpdateList(target.FullName);
                }
            }
        }
Пример #13
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                /*FileListControl fc = null;
                 * if (fileListControl1.ContainsFocus)
                 * {
                 *  fc = fileListControl1;
                 * }
                 * if (fileListControl2.ContainsFocus)
                 * {
                 *  fc = fileListControl2;
                 * }
                 *
                 * if (fc != null && fc.ListView.Focused && fc.SelectedFile != null)
                 * {
                 *  ProcessStartInfo psi = new ProcessStartInfo();
                 *  psi.WorkingDirectory = fc.SelectedFile.DirectoryName;
                 *  psi.FileName = fc.SelectedFile.FullName;
                 *
                 *  Process.Start(psi);
                 *
                 * }*/
            }

            //if (e.KeyCode == Keys.Delete)
            //{
            //    FileListControl fc = null;
            //    if (fileListControl1.ContainsFocus)
            //    {
            //        fc = fileListControl1;
            //    }
            //    if (fileListControl2.ContainsFocus)
            //    {
            //        fc = fileListControl2;
            //    }

            //    if (fc != null && fc.ListView.Focused)
            //    {
            //        if (Stuff.Question("Delete file: " + fc.SelectedFile.FullName + "?") == DialogResult.Yes)
            //        {
            //            var attr = File.GetAttributes(fc.SelectedFile.FullName);
            //            bool allow = true;
            //            if (attr.HasFlag(FileAttributes.ReadOnly))
            //            {
            //                if (Stuff.Question("File is read-only, do you want to delete it anyway?") != DialogResult.Yes)
            //                {
            //                    allow = false;
            //                }
            //                else
            //                {
            //                    File.SetAttributes(fc.SelectedFile.FullName, FileAttributes.Normal);
            //                }
            //            }
            //            if (allow)
            //            {
            //                File.Delete(fc.SelectedFile.FullName);
            //            }
            //        }
            //    }
            //}

            if (e.KeyCode == Keys.F2)
            {//rename
                FileListControl fc = null;
                if (fileListControl1.ContainsFocus)
                {
                    fc = fileListControl1;
                }
                if (fileListControl2.ContainsFocus)
                {
                    fc = fileListControl2;
                }
                if (fc != null)
                {
                    fc.Rename();
                }
            }

            if (Stuff.Hotkeys.Any(z => z.Hotkey == e.KeyCode && z.IsEnabled))
            {
                var cc = Stuff.Hotkeys.First(z => z.Hotkey == e.KeyCode);

                IFileListControl fl = fileListControl1;
                if (fileListControl2.ContainsFocus)
                {
                    fl = fileListControl2;
                }
                cc.Execute(fl);
            }


            if (e.KeyCode == Keys.F5)
            {//copy
                if (fileListControl1.Mode == ViewModeEnum.Filesystem && fileListControl2.Mode == ViewModeEnum.Filesystem)
                {
                    var from = fileListControl1;
                    var to   = fileListControl2;
                    if (fileListControl2.ContainsFocus)
                    {
                        from = fileListControl2;
                        to   = fileListControl1;
                    }

                    /*if (from.SelectedFiles != null)
                     * {
                     *  bool allow = true;
                     *  var p1 = Path.Combine(to.CurrentDirectory.FullName,
                     *      from.SelectedFile.Name);
                     *  if (File.Exists(p1))
                     *  {
                     *      if (MessageBox.Show(
                     *              "File " + p1 + " already exist. replace?", Text,
                     *              MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                     *      {
                     *          allow = false;
                     *      }
                     *  }
                     *
                     *  if (allow)
                     *  {
                     *      File.Copy(from.SelectedFile.FullName, p1, true);
                     *      to.UpdateList(to.CurrentDirectory.FullName);
                     *  }
                     * }*/
                    var self = from.SelectedFiles;
                    var seld = from.SelectedDirectories;
                    if (seld != null || self != null)
                    {
                        //copy recursively all files and dirs
                        var prnt = from.CurrentDirectory;
                        List <IFileInfo>      list = new List <IFileInfo>();
                        List <IDirectoryInfo> dirs = new List <IDirectoryInfo>();
                        if (self != null)
                        {
                            list.AddRange(self);
                        }
                        if (seld != null)
                        {
                            foreach (var item in seld)
                            {
                                Stuff.GetAllFiles(item, list);
                                Stuff.GetAllDirs(item, dirs);
                            }
                        }


                        CopyDialog cpd = new CopyDialog();
                        cpd.Init(list.ToArray(), dirs.ToArray(), to.CurrentDirectory, prnt);
                        cpd.ShowDialog();
                    }
                }

                if ((fileListControl1.Mode == ViewModeEnum.Filesystem || fileListControl1.Mode == ViewModeEnum.Libraries) &&
                    fileListControl2.Mode == ViewModeEnum.Tags)
                {
                    if (fileListControl1.SelectedFile != null && fileListControl2.CurrentTag != null)
                    {
                        var fn = fileListControl1.SelectedFile;
                        if (!fileListControl2.CurrentTag.ContainsFile(fn))
                        {
                            fileListControl2.CurrentTag.AddFile(fn);
                            MessageBox.Show(Path.GetFileName(fn.FullName) + " tagged as " + fileListControl2.CurrentTag.Name);
                            fileListControl2.UpdateTagsList();
                        }
                    }
                }
            }
            base.OnKeyDown(e);
        }
Пример #14
0
        private void isoExtractAction(FileListControl arg1, IFileInfo arg2)
        {
            var target = arg1;

            if (target == fileListControl1)
            {
                target = fileListControl2;
            }
            else
            {
                target = fileListControl1;
            }
            using (var fs = new FileStream(arg2.FullName, FileMode.Open, FileAccess.Read))
            {
                IsoReader reader = new IsoReader();
                reader.Parse(fs);
                var pvd = reader.WorkPvd;

                string savePath = Path.Combine(target.CurrentDirectory.FullName, Path.GetFileNameWithoutExtension(arg2.Name));
                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }
                var ret = DirectoryRecord.GetAllRecords(pvd.RootDir);

                foreach (var directoryRecord in ret)
                {
                    if (!directoryRecord.IsDirectory)
                    {
                        continue;
                    }
                    if (directoryRecord.LBA == pvd.RootDir.LBA)
                    {
                        continue;
                    }
                    if (directoryRecord.Parent != null && directoryRecord.Parent.LBA == directoryRecord.LBA)
                    {
                        continue;
                    }
                    if (directoryRecord.Parent != null &&
                        directoryRecord.Parent.Parent != null &&
                        directoryRecord.Parent.Parent.LBA == directoryRecord.LBA)
                    {
                        continue;
                    }

                    var pp = Path.Combine(savePath, directoryRecord.FullPath);
                    if (!Directory.Exists(pp))
                    {
                        Directory.CreateDirectory(pp);
                    }
                }


                foreach (var directoryRecord in ret)
                {
                    if (!directoryRecord.IsFile)
                    {
                        continue;
                    }
                    var data = directoryRecord.GetFileData(fs, pvd);
                    var pp   = Path.Combine(savePath, directoryRecord.FullPath);
                    File.WriteAllBytes(pp, data);
                }

                Stuff.Info("Extraction complete!");
            }
        }
Пример #15
0
 public void Init(FileListControl fc)
 {
     parent             = fc;
     listView1.KeyDown += ListView1_KeyDown;
     tuc.Init();
 }