예제 #1
0
        private void SearchFiles(string path, string filename)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            FileInfo[]      fileInfos      = directoryInfo.GetFiles("*" + filename + "*");
            DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories("*" + filename + "*");
            listBox.Items.Clear();
            MyDirectory        myDir      = new MyDirectory(path);
            List <DiscElement> myElements = myDir.GetSubElements();

            foreach (DirectoryInfo directory in directoryInfos)
            {
                foreach (DiscElement myElement in myElements)
                {
                    if (directory.Name == myElement.GetName())
                    {
                        DirectoryView newFolderView = new DirectoryView((MyDirectory)myElement);
                        newFolderView.DirectoryChanged += OnDirectoryChanged;
                        listBox.Items.Add(newFolderView);
                    }
                }
            }
            foreach (FileInfo file in fileInfos)
            {
                foreach (DiscElement myElement in myElements)
                {
                    if (file.Name == myElement.GetName())
                    {
                        FileView newElementView = new FileView((MyFile)myElement);
                        listBox.Items.Add(newElementView);
                    }
                }
            }
        }
예제 #2
0
        public bool RefreshList()
        {
            listView.ItemsSource = "";
            bool               isThrow    = false;
            List <Contr>       controller = new List <Contr>();
            MyDirectory        dirs       = new MyDirectory(mainPath.Text);
            List <DiscElement> elements   = null;

            try
            {
                elements = dirs.GetSubElements();
            }
            catch
            {
                MessageBox.Show("Нет доступа");
                elements = dirs.GetSubElements();
                isThrow  = true;
            }

            foreach (var item in elements)
            {
                controller.Add(new Contr(item));
            }
            listView.ItemsSource = controller;

            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listView.ItemsSource);

            view.Filter = UserFilter;
            return(isThrow);
        }
예제 #3
0
        public FileView(IDiscElement element)
        {
            InitializeComponent();

            if (element is MyFile)
            {
                MyFile file = element as MyFile;
                this.file           = file;
                filename.Text       = file.Name;
                filedate.Text       = file.GetCreationDate().ToString();
                filesize.Text       = file.Size.ToString();
                filetype.Text       = @"<FILE>";
                filetype.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E06C75"));
            }
            else if (element is MyDirectory)
            {
                MyDirectory directory = element as MyDirectory;
                this.file           = directory;
                filename.Text       = directory.Name;
                filedate.Text       = directory.GetCreationDate().ToString();
                filesize.Text       = "--";
                filetype.Text       = @"<DIR>";
                filetype.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD19A66"));
            }
        }
예제 #4
0
 public DirectoryView(MyDirectory discElement)
 {
     InitializeComponent();
     this.discElement = discElement;
     NameBox.Text     = discElement.GetName();
     DateBox.Text     = discElement.GetCreationTime().ToShortDateString();
 }
예제 #5
0
 public DirView(MyDirectory myDir)
 {
     this.myDir = myDir;
     InitializeComponent();
     DirName.Text         = myDir.Name;
     DirCreationTime.Text = myDir.CreationDate.ToString();
 }
예제 #6
0
 public DirectoryView(MyDirectory CurrentDirectory)
 {
     InitializeComponent();
     this.CurrentDirectory  = CurrentDirectory;
     DirectoryDateText.Text = CurrentDirectory.GetCreationDate;
     DirectoryNameText.Text = CurrentDirectory.Name;
 }
예제 #7
0
        private void RefreshLeftList(string path, string sortType = null)
        {
            try
            {
                if (this.backStackLeft.Count == 0)
                {
                    backLeft.IsEnabled = false;
                }
                else
                {
                    backLeft.IsEnabled = true;
                }
                MyDirectory myDirectory = new MyDirectory(path);
                this.currentDirectoryLeft = myDirectory;
                leftList.Children.Clear();

                List <DiscElement> discElementsList = myDirectory.ListDiscElements(sortType);

                foreach (DiscElement discElement in discElementsList)
                {
                    DiscElementView discElementView = new DiscElementView(discElement);

                    leftList.Children.Add(discElementView);

                    discElementView.openDirectory     += OpenLeftDirectory;
                    discElementView.deleteDiscElement += DeleteDiscElementLeft;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        /// <summary>
        /// Wyszukujemy wszyskie pliki których nazwy zawieraja podany przez
        /// nas ciag znakow w textboxie
        /// </summary>

        private void button12_Click(object sender, RoutedEventArgs e)
        {
            MyDirectory myDirectory1 = new MyDirectory(directoryPath.Text);

            listOfUserControls1.Children.Clear();

            List <DiscElement> subElements1 = myDirectory1.GetDiscElements();
            List <DiscElement> results      = subElements1.FindAll(x => x.Name.Contains(textBox.Text));

            foreach (DiscElement discElement in results)
            {
                {
                    ElementsViews discElementViews = new ElementsViews(discElement);

                    listOfUserControls1.Children.Add(discElementViews);
                    discElementViews.checkedChangeEv += CheckedChangeEv;
                }
            }
            //------------------------------------------------------------
            MyDirectory myDirectory2 = new MyDirectory(directoryPath2.Text);

            listOfUserControls2.Children.Clear();

            List <DiscElement> subElements2 = myDirectory2.GetDiscElements();
            List <DiscElement> results2     = subElements2.FindAll(x => x.Name.Contains(textBox.Text));

            foreach (DiscElement discElement in results2)
            {
                ElementsViews discElementViews = new ElementsViews(discElement);

                listOfUserControls2.Children.Add(discElementViews);
                discElementViews.checkedChangeEv += CheckedChangeEv;
            }
        }
예제 #9
0
        public void DirectoryDeleteTest()
        {
            IEntry entry = FileFactory.CreateEntry(@"C:\ForFileManager\ToDeleteByFile1.txt");

            MyDirectory.Delete(entry.FullName);
            Assert.IsFalse(MyDirectory.Exists(@"C:\ForFileManager\ToDeleteByFile1.txt"));
        }
        private FileNodeItem BuildUpdateConfigFile(MyDirectory dir)
        {
            FileNodeItem item = new FileNodeItem();

            item.ListWritDate  = DateTime.Parse(dir.LastUpdate);
            item.Name          = dir.Name;
            item.Version       = dir.Version;
            item.IsCanSelected = false;
            item.ToolTip       = string.Format("文件夹  日期:{0}   版本:{1}", dir.ToString(), dir.Version);
            foreach (FileSimpleInfo file in dir.Files)
            {
                FileNodeItem child = new FileNodeItem();
                child.IsCanSelected = true;
                child.ListWritDate  = file.ModifyDateTime;
                child.Name          = file.Name;
                child.Version       = file.Version;
                child.ToolTip       = string.Format("文件  日期:{0}  版本:{1}", file.ModifyDateTime, file.Version);
                item.Nodes.Add(child);
            }
            foreach (MyDirectory directory in dir.Directories)
            {
                FileNodeItem child = new FileNodeItem();
                item.Nodes.Add(BuildUpdateConfigFile(directory));
            }
            return(item);
        }
예제 #11
0
        public static string GetMyDirectory(MyDirectory directory)
        {
            var folderPath = string.Empty;

            switch (directory)
            {
            //case MyDirectory.PackageDir:
            //    folderPath = GetMyDirectory(MyDirectory.Base) + PackageDirectory;
            //    break;

            case MyDirectory.Project:
                folderPath = GetMyDirectory(MyDirectory.Base) + ProjectDirectory;
                break;

            case MyDirectory.Base:
                folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + ProgramBaseDirectory;
                break;
            }


            if (string.IsNullOrWhiteSpace(folderPath))
            {
                throw new NotImplementedException("GetMyFilepath");
            }

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            return(folderPath);
        }
예제 #12
0
        private void DisplayFiles(string path)
        {
            //Clear the listbox first
            FileList.Items.Clear();

            //Set the current path
            currentPath      = path;
            CurrentPath.Text = path;

            try
            {
                //Initialize FileWatcher
                FileSystemWatcher watcher = new FileSystemWatcher();
                watcher.Path     = currentPath;
                watcher.Changed += new FileSystemEventHandler(OnChanged);
                watcher.Created += new FileSystemEventHandler(OnChanged);
                watcher.Deleted += new FileSystemEventHandler(OnChanged);
                watcher.Renamed += new RenamedEventHandler(OnRenamed);

                watcher.EnableRaisingEvents = true;
            } catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            //Create an DirectoryInfo object to extract child files from it
            DirectoryInfo d         = new DirectoryInfo(path);
            MyDirectory   directory = new MyDirectory(d.Name, d.FullName);

            currentList = directory.GetSubElements();

            Iterate(directory.GetSubElements());
        }
        private void sortFileList(object sender, RoutedEventArgs e)
        {
            string      parentPath  = PanelPath();
            MyDirectory myDirectory = new MyDirectory(parentPath);

            listOfDiscElements.Children.Clear();
            List <DiscElement> allFiles = myDirectory.GetSubDiscElements();

            for (int i = 1; i < allFiles.Count; ++i)
            {
                allFiles.Sort();
            }
            foreach (DiscElement file in allFiles)
            {
                string          prePath         = file.Path;
                string          postPath        = prePath.Replace(parentPath + @"\", "");
                DiscElementView discElementView = new DiscElementView(file);
                listOfDiscElements.Children.Add(discElementView);
                discElementView.openDiscElementClick    += createFileListEventHandler;
                discElementView.checkedDiscElementEvent += checkedDiscElementEventHandler;
            }
            FileSystemWatcher filesystemwatcher = new FileSystemWatcher(parentPath);

            filesystemwatcher.Created            += FileSystemWatcher_Created;
            filesystemwatcher.Deleted            += FileSystemWatcher_Created;
            filesystemwatcher.Renamed            += FileSystemWatcher_Created;
            filesystemwatcher.EnableRaisingEvents = true;
        }
        private void searchForFile()
        {
            string      parentPath  = PanelPath();
            string      destFile    = searchForFiles.Text;
            MyDirectory myDirectory = new MyDirectory(parentPath);

            listOfDiscElements.Children.Clear();
            List <DiscElement> allFiles = myDirectory.GetSubDiscElements();
            var filteredFiles           = allFiles.Where(f => f.Name.Contains(destFile));

            foreach (DiscElement file in filteredFiles)
            {
                string          prePath         = file.Path;
                DiscElementView discElementView = new DiscElementView(file);
                listOfDiscElements.Children.Add(discElementView);
                discElementView.openDiscElementClick    += createFileListEventHandler;
                discElementView.checkedDiscElementEvent += checkedDiscElementEventHandler;
                discElementView.imgPopupMouseEnterEvent += imgPopupMouseEnterEventHandler;
                discElementView.imgPopupMouseLeaveEvent += imgPopupMouseLeaveEventHandler;
                discElementView.imgPopupMouseOverEvent  += imgPopupMouseOverEventHandler;
            }
            FileSystemWatcher filesystemwatcher = new FileSystemWatcher(parentPath);

            filesystemwatcher.Created            += FileSystemWatcher_Created;
            filesystemwatcher.Deleted            += FileSystemWatcher_Created;
            filesystemwatcher.Renamed            += FileSystemWatcher_Created;
            filesystemwatcher.EnableRaisingEvents = true;
        }
예제 #15
0
        public void Binary_Serialization_Deserialization_Equal_Test(string serFileName)
        {
            MySerializer.SerializeBinary(TestCatalog.StandardDir, serFileName);
            _desDir = MySerializer.DeserializeFromFile(serFileName, "-bin");
            File.Delete(serFileName);

            Assert.That(_desDir, Is.EqualTo(TestCatalog.StandardDir));
        }
예제 #16
0
 public WebAssignSettings()
 {
     MyDirectory  = new MyDirectory();
     Institution  = "";
     Username     = WebAssignUserName.First_Name_Initial_plus_Last_Name;
     SEPARATOR    = WebAssignSeperator.Tab;
     UserPassword = WebAssignPassword.LastName;
 }
예제 #17
0
        private void bPathDownloadedArchives_Click(object sender, EventArgs e)
        {
            var path = MyDirectory.Select("directory where you want to save downloaded archives", "dir");

            if (path != null)
            {
                tbDownloadedArchiveLocation.Text = path;
            }
        }
예제 #18
0
        private void bPath7z_Click(object sender, EventArgs e)
        {
            var path = MyDirectory.Select("7z.exe", "7z");

            if (path != null)
            {
                tbPath7z.Text = path;
            }
        }
예제 #19
0
        private void bPathCheatTables_Click(object sender, EventArgs e)
        {
            var path = MyDirectory.Select("Cheat Tables", "dir");

            if (path != null)
            {
                tbPathCheatTables.Text = path;
            }
        }
예제 #20
0
        private void bModPath_Click(object sender, EventArgs e)
        {
            var path = MyDirectory.Select("mod", "arc/dir");

            if (path != null)
            {
                tbModURL.Text = path;
            }
        }
예제 #21
0
        public void LoadFiles(string path, bool sort)
        {
            if (!Directory.Exists(path))
            {
                MessageBox.Show("Błąd Ścieżki!");
                listBox.Items.Clear();
                return;
            }
            MyDirectory        myDir      = new MyDirectory(path);
            List <DiscElement> myElements = myDir.GetSubElements();

            listBox.Items.Clear();
            if (sort == true)
            {
                myElements = myElements.OrderBy(o => o.GetCreationTime()).ToList();
                List <DiscElement> myDirSorted  = new List <DiscElement>();
                List <DiscElement> myFileSorted = new List <DiscElement>();
                foreach (DiscElement orderingElement in myElements)
                {
                    if (orderingElement is MyDirectory)
                    {
                        myDirSorted.Add(orderingElement);
                    }
                    else
                    {
                        myFileSorted.Add(orderingElement);
                    }
                }
                myElements.Clear();
                foreach (DiscElement myDirectory in myDirSorted)
                {
                    myElements.Add(myDirectory);
                }
                foreach (DiscElement myFile in myFileSorted)
                {
                    myElements.Add(myFile);
                }
            }
            foreach (DiscElement myElement in myElements)
            {
                if (myElement is MyDirectory)
                {
                    DirectoryView newFolderView = new DirectoryView((MyDirectory)myElement);
                    newFolderView.DirectoryChanged += OnDirectoryChanged;
                    newFolderView.DirectoryDelete  += OnDeleteDirectory;
                    listBox.Items.Add(newFolderView);
                }
                else
                {
                    FileView newElementView = new FileView((MyFile)myElement);
                    newElementView.filedelete += OnDeleteClick;
                    listBox.Items.Add(newElementView);
                }
            }
        }
예제 #22
0
        public void OnDirectoryChanged(object source, EventArgs e)
        {
            if (!(source is MyDirectory))
            {
                return;
            }
            MyDirectory directory = (MyDirectory)source;

            LoadFiles(directory.GetPath(), false);
            PathBox.Text = directory.GetPath();
        }
예제 #23
0
        private static void DirectoryDemo()
        {
            MyDirectory myDirectory = new MyDirectory();

            //myDirectory.Fun5(Path.Combine(@"D:\迅雷下载", @"ReadMe.txt"), Path.Combine(@"D:\迅雷下载", @"Copy.txt"));
            //Console.Read();
            //string[] array = {"中国第一","美国第一"};
            //myDirectory.Fun7(array);
            //myDirectory.Fun9(Path.Combine(@"D:\迅雷下载", "ReadMe.txt"), Path.Combine(@"D:\迅雷下载", "Compress.txt"));
            Console.Read();
        }
예제 #24
0
 private void bOpenExplorer_Click(object sender, EventArgs e)
 {
     if (Directory.Exists("mods"))
     {
         MyDirectory.OpenInFileManager("mods");
     }
     else
     {
         bOpenExplorer.Enabled = false;
     }
 }
        public static IAuditLogger <TKey, TWorkflowOptions> GetToFileAuditLogger <TKey, TWorkflowOptions>(ToFileAuditLoggerConfig config)
            where TKey : KeyBase
            where TWorkflowOptions : DecryptPlainTextEntryWorkflowOptions
        {
            Contract.Requires <ArgumentNullException>(config != null, "config");
            //
            var myDir  = new MyDirectory();
            var myFile = new MyFile();

            return(new ToFileAuditLogger <TKey, TWorkflowOptions>(config, myDir, myFile, new MyDateTime(),
                                                                  new OldLogCleaner(new ToFileAuditLoggerConfig(), myDir, myFile, new MyFileInfoFactory())));
        }
예제 #26
0
        public void ResharperWarning()
        {
            MyDirectory            myDirectory = new MyDirectory();
            IEnumerable <DataFile> allFiles    = myDirectory
                                                 .GetFiles(@"d:\")
                                                 .Select(fileName => new DataFile(fileName));
            IEnumerable <DataFile> taskFiles = allFiles
                                               .Where(file => !file.FileName.EndsWith("exe"));

            taskFiles.ForEach(file => { Console.WriteLine("[1] file: {0}", file.FileName); });
            taskFiles.ForEach(file => { Console.WriteLine("[2] file: {0}", file); });
        }
예제 #27
0
        private void bIOEp2Visit_Click(object sender, EventArgs e)
        {
            var status = hiWrapper.GetInstallationStatus(GAME.Episode2);

            switch (status.Status)
            {
            case InstallationStatus.NotInstalled: return;

            case InstallationStatus.ImproperlyInstalled: return;
            }
            MyDirectory.OpenInFileManager(status.Location);
        }
예제 #28
0
 /// <summary>
 /// cofanie drugiej strony
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void backPage2_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         MyDirectory mydir = new MyDirectory(textBoxPathNum2.Text);
         RefreshListNum2(mydir.ParentDir);
         textBoxPathNum2.Text = mydir.ParentDir;
     }
     catch (ArgumentNullException)
     {
         RefreshListNum2(textBoxPathNum2.Text);
     }
 }
예제 #29
0
        private void PreviousDirectoryButton_Click(object sender, RoutedEventArgs e)
        {
            string previouspath;

            previouspath = CurrentDirectory.Path.Substring(0, CurrentDirectory.Path.LastIndexOfAny(new char[] { '\\', '/' }));
            if (previouspath.Length < 3)
            {
                previouspath = previouspath + "\\";
            }
            CurrentDirectory = new MyDirectory(previouspath);
            InvokeUpdateEvent();
            ListDirectoriesAndFilesByName();
        }
예제 #30
0
 private void DiscComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         CurrentDirectory = new MyDirectory((DiscComboBox.SelectedItem as DriveView).GetDrive.Path);
         ListDirectoriesAndFilesByDate();
         InvokeUpdateEvent();
     }
     catch
     {
         MessageBox.Show("Cannot open drive");
     }
 }