Ejemplo n.º 1
0
        public bool IsDir(int index)
        {
            string dir = Path.Combine(DirName, FileNameList[index]);

            return(CheckFileType.IsDir(dir));
        }
Ejemplo n.º 2
0
        // -----------------------------------------------------------
        // 成員函式
        // -----------------------------------------------------------

        #region 成員函式

        // 處理傳入的參數
        private void RunArgs()
        {
            // 有三種方式:
            // 1. 不傳參數, 開啟目前目錄
            // 2. 傳入一個參數, 可為目錄、壓縮檔或圖檔
            // 3. 傳入二個參數, 第二個通常是壓縮檔中的圖檔

            if (args.Length == 1)
            {
                // 沒有參數
                GetImageFileListByDir(Directory.GetCurrentDirectory());
            }
            else if (args.Length >= 2)
            {
                // 處理 1 個參數
                if (CheckFileType.IsDir(args[1]))
                {
                    // 傳入目錄
                    GetImageFileListByDir(args[1]);
                }
                else if (CheckFileType.IsZip(args[1]))
                {
                    // 傳入壓縮檔
                    GetZipFileList(args[1]);
                }
                else if (CheckFileType.IsImage(args[1]))
                {
                    // 傳入圖檔
                    string filename = args[1];
                    string dir      = Path.GetDirectoryName(filename);
                    if (dir == "")
                    {
                        // 沒有傳入目錄, 目錄是目前目錄
                        filename = Path.Combine(Directory.GetCurrentDirectory(), filename);
                    }
                    GetImageFileListByFile(filename);

                    string file  = Path.GetFileName(filename);
                    int    index = lbImageFileName.FindString(file);
                    if (index != ListBox.NoMatches)
                    {
                        lbImageFileName.SelectedIndex = index;
                    }
                    else
                    {
                        MessageBox.Show($"找不到指定的圖檔 {file}");
                    }
                }
            }

            if (args.Length >= 3)
            {
                // 第二個參數是圖檔,有指定解開的檔名
                int index = lbImageFileName.FindString(args[2]);
                if (index != ListBox.NoMatches)
                {
                    lbImageFileName.SelectedIndex = index;
                }
                else
                {
                    MessageBox.Show($"找不到指定的圖檔 {args[2]}");
                }
            }
        }