Beispiel #1
0
        public void ChangeLocation(string Location)
        {
            string RealLocation;

            switch (Location.ToLower())
            {
            case "alldrives":
            case "all drives":
                RealLocation = "All Drives";
                break;

            case "desktop":
                RealLocation = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                break;

            case "documents":
                RealLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                break;

            case "downloads":
                RealLocation = GetDownloadPath();
                break;

            case "music":
            case "mymusic":
            case "my music":
                RealLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
                break;

            case "picture":
            case "mypicture":
            case "my picture":
                RealLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                break;

            default:
                RealLocation = Location;
                break;
            }
            if (File.Exists(RealLocation))
            {
                MsgBox("파일은 열 수 없습니다!", "파일 경로 선택 불가"); return;
            }
            if (!Directory.Exists(RealLocation) && RealLocation != "All Drives")
            {
                MsgBox("존재하지 않는 경로입니다!", "경로 오류!", Globals.MessageBoxStyle.OK); locTB.Text = LastLocation; return;
            }
            PART_File.Items.Clear();

            if (RealLocation == "All Drives")
            {
                foreach (DriveInfo di in DriveInfo.GetDrives())
                {
                    AddImageItem(di.Name, ImageType.Folder, PART_File, "FileItmStyle", di.RootDirectory.FullName);
                }
            }
            else
            {
                string        UpperLoc;
                DirectoryInfo dirinfo = new DirectoryInfo(RealLocation).Parent;
                if (dirinfo == null)
                {
                    UpperLoc = "All Drives";
                }
                else
                {
                    UpperLoc = dirinfo.FullName;
                }

                AddImageItem(".. (상위 폴더)", ImageType.None, PART_File, "FileItmStyle", UpperLoc);
                foreach (DirectoryInfo di in new DirectoryInfo(RealLocation).GetDirectories())
                {
                    if (di.Attributes.HasFlag(FileAttributes.Hidden))
                    {
                        continue;
                    }
                    AddImageItem(di.Name, ImageType.Folder, PART_File, "FileItmStyle", di.FullName);
                }

                if (!IsDirMode)
                {
                    foreach (FileInfo fi in new DirectoryInfo(RealLocation).GetFiles())
                    {
                        if (FilterExtensions != null && (fi.Attributes.HasFlag(FileAttributes.Hidden) || !FilterExtensions.Contains(fi.Extension)))
                        {
                            continue;
                        }
                        string      exs = fi.Extension;
                        ImageType   it  = ImageType.Document;
                        ImageSource img = null;
                        switch (exs)
                        {
                        case ".jpg":
                        case ".png":
                        case ".jpeg":
                        case ".gif":
                        case ".bmp": it = ImageType.Picture;
                            break;

                        case ".mp3":
                        case ".wav":
                        case ".ogg":
                        case ".m4a":
                        case ".flac": it = ImageType.Music;
                            break;

                        case ".xaml":
                        case ".cs":
                        case ".vb":
                        case ".txt":
                        case ".log":
                        case ".xml": it = ImageType.Text;
                            break;

                        case ".xls":
                        case ".xlsx":
                        case ".pptx":
                        case ".ppsx":
                        case ".docx": it = ImageType.Presentation;
                            break;

                        case ".zip":
                        case ".7z":
                        case ".egg":
                        case ".cab": it = ImageType.Zip;
                            break;

                        case ".mp4":
                        case ".wmv":
                        case ".avi":
                        case ".flv": it = ImageType.Video;
                            break;

                        case ".lnk":
                        case ".appref-ms": it = ImageType.Link;
                            break;

                        default:
                            it  = ImageType.Custom;
                            img = GetIcon(fi.FullName);
                            break;
                        }

                        AddImageItem(fi.Name, it, PART_File, "FileItmStyle", fi.FullName, img);
                    }
                }
            }

            locTB.Text = RealLocation;
            bool Flag = false;

            foreach (object itm in PART_Drive.Items)
            {
                if (itm.GetType() == typeof(ImageItem))
                {
                    if (((ImageItem)itm).Tag.ToString() == RealLocation)
                    {
                        PART_Drive.SelectedItem = itm; Flag = true;
                    }
                }
            }

            if (!Flag)
            {
                PART_Drive.SelectedIndex = -1;
            }

            LastLocation  = RealLocation;
            searchTB.Text = string.Empty;

            AllItems = CopyArray(PART_File.Items).Select(x => (ImageItem)x).ToArray();
        }
Beispiel #2
0
 public void MatchFirst_ShouldReturnEmptyStringIfNoMatch()
 {
     Assert.That(FilterExtensions.MatchFirst("Foo: Shakalaka\nFoo: ShakalakaBar", "(?m)^Foos: .+$"), Is.EqualTo(""));
 }
Beispiel #3
0
 public void MatchFirst_ShouldRegexMatchFirstWithCaptureGroup()
 {
     Assert.That(FilterExtensions.MatchFirst("Foo: Shakalaka\nFoo: ShakalakaBar", "(?m)^Foo: (.+)$"), Is.EqualTo("Shakalaka"));
 }
Beispiel #4
0
 partial void FilterQuery_PreprocessQuery(string Parameter, ref IQueryable <Lab> query)
 {
     query = FilterExtensions.Filter(query, Parameter, this.Application);
 }