예제 #1
0
 static public void VideoFileInfo(ref List<FileTag> arr, Folder Folder, FolderItem FolderItem) {
     FileTag temp = new FileTag();
     int[] index = { 0, 1, 15, 21, 303, 304, 305, 306, 308 };
     string[] name = { "File name", "File size", "Year", "Title", "Data rate", "Frame height", "Frame rate", "Frame width", "Total Bitrate" };
     for (int i = 0; i < 9; i++) {
         temp.TagName = name[i];
         temp.TagValue = Folder.GetDetailsOf(FolderItem, index[i]).ToString();
         arr.Add(temp);
     }
 }
예제 #2
0
 static public void ImageFileInfo(ref List<FileTag> arr, Folder Folder, FolderItem FolderItem) {
     FileTag temp = new FileTag();
     int[] index = { 0, 1, 21, 30, 31, 32, 251, 252, 255, 256, 258, 260 };
     string[] name = { "File name", "File size", "Title", "Camera model", "Dimensions", "Camera maker", "Exposure time", "F-stop", "35mm focal length", "ISO speed", "Lens model", "Max aperture" };
     for (int i = 0; i < 12; i++) {
         temp.TagName = name[i];
         temp.TagValue = Folder.GetDetailsOf(FolderItem, index[i]).ToString();
         arr.Add(temp);
     }
 }
예제 #3
0
 static public void CompressedFileInfo(ref List<FileTag> arr, Folder Folder, FolderItem FolderItem) {
     FileTag temp = new FileTag();
     int[] index = { 0, 1, 2 };
     string[] name = { "File name", "File size", "Item type" };
     for (int i = 0; i < 11; i++) {
         temp.TagName = name[i];
         temp.TagValue = Folder.GetDetailsOf(FolderItem, index[i]).ToString();
         arr.Add(temp);
     }
 }
예제 #4
0
 static public void GeneralFileInfo(ref List<FileTag> arr, Folder Folder, FolderItem FolderItem) {
     FileTag temp = new FileTag();
     int[] index = { 0, 1, 2, 20, 150, 153, 158, 175, 192 };
     string[] name = { "File name", "File size", "Item type", "Authors", "Pages", "Word count", "File version", "Encryption status", "Language" };
     for (int i = 0; i < 9; i++) {
         temp.TagName = name[i];
         temp.TagValue = (Folder.GetDetailsOf(FolderItem, index[i])).ToString();
         arr.Add(temp);
     }
 }
예제 #5
0
 static public void AudioFileInfo(ref List<FileTag> arr, Folder Folder, FolderItem FolderItem) {
     FileTag temp = new FileTag();
     int[] index = { 0, 13, 14, 15, 16, 21, 26, 28, 230 };
     string[] name = { "Name", "Contributing artists", "Album", "Year", "Genre", "Title", "Track number", "Bit rate", "Album artist" };
     for (int i = 0; i < 9; i++) {
         temp.TagName = name[i];
         temp.TagValue = Folder.GetDetailsOf(FolderItem, index[i]).ToString();
         if (i == 7) temp.TagValue = temp.TagValue.Substring(1, temp.TagValue.Length - 1);
         arr.Add(temp);
     }
 }
예제 #6
0
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            // remove previous folders and redisplay (suppressing actual back navigation)
            //  unless at root, at which point let back navigation happen.
            if (previousFolders.Count > 0)
            {
                // lastFolder is parent of current, so make parent the new current
                currentFolder = previousFolders.Last<FolderItem>();
                previousFolders.RemoveAt(previousFolders.Count - 1); // pop it off
                displayFolderContents(currentFolder.ID);

                e.Cancel = true; // suppress back navigation
            }
        }
예제 #7
0
        public async Task <GetFoldersResult> Handle(GetInnerFoldersQuery request, CancellationToken cancellationToken)
        {
            GetFoldersResult Result = new GetFoldersResult();
            string           userId = _caller.GetUserId();

            FolderItem folder = await _unitOfWork.Folders.FirstOrDefaultAsync(s => s.Id == request.ParentId);

            if (folder == null)
            {
                Result.ErrorContent = new ErrorContent("No folder with the provided id was found", ErrorOrigin.Client);
                return(Result);
            }
            // If anonymous user, check if folder is public
            if (userId != folder.UserId && folder.Status != ItemStatus.Visible)
            {
                Result.ErrorContent = new ErrorContent("This folder is not available for public downloads", ErrorOrigin.Client);
                return(Result);
            }

            Result.Folders = await _mediator.Send(new GetFoldersRecursivelyQuery(folder));

            return(Result);
        }
예제 #8
0
        private bool FileRestore(string Item)
        {
            Shell  shell    = new Shell();
            Folder Recycler = shell.NameSpace(10);

            for (int i = 0; i < Recycler.Items().Count; i++)
            {
                FolderItem folderItem = Recycler.Items().Item(i);
                string     FileName   = Recycler.GetDetailsOf(folderItem, 0);
                if (Path.GetExtension(FileName) == "")
                {
                    FileName += Path.GetExtension(folderItem.Path);
                }
                string FilePath = Recycler.GetDetailsOf(folderItem, 1);

                if (Item == Path.Combine(FilePath, FileName))
                {
                    DoVerb(folderItem, "복원(&E)");
                    return(true);
                }
            }
            return(false);
        }
예제 #9
0
        private static string GetShortcutTargetFile(string nomeAtalho)
        {
            string caminhoPasta = Path.GetDirectoryName(nomeAtalho);
            string nomePrograma = Path.GetFileName(nomeAtalho);

            try
            {
                Shell      shell      = new Shell(); //Erro
                Folder     pasta      = shell.NameSpace(caminhoPasta);
                FolderItem folderItem = pasta.ParseName(nomePrograma);
                if (folderItem != null)
                {
                    ShellLinkObject link = (ShellLinkObject)folderItem.GetLink;
                    return(link.Path);
                }
            }
            catch (InvalidCastException)
            {
                return(string.Empty);
            }

            return(string.Empty);
        }
예제 #10
0
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            args.Cancel = true;
            if (string.IsNullOrEmpty(NameBox.Text))
            {
                App._vm.ShowPopup(LanguageName.FieldEmpty, true);
                return;
            }
            FolderItem item = null;

            if (_source == null)
            {
                item = new FolderItem(NameBox.Text, ShowIcon.Symbol);
            }
            else
            {
                item      = _source;
                item.Name = NameBox.Text;
                item.Icon = ShowIcon.Symbol;
            }
            App._vm.AddOrUpdateFolderItem(item);
            Hide();
        }
예제 #11
0
        public async Task RemoveFolder(FolderItem item)
        {
            if (FolderCollection.Count == 1)
            {
                ShowPopup(LanguageName.NeedOneFolder, true);
                return;
            }
            var confirmDialog = new ConfirmDialog(LanguageName.ConfirmRemoveFolder);

            confirmDialog.PrimaryButtonClick += (_s, _e) =>
            {
                FolderCollection.Remove(item);
                AllHistoryList.RemoveAll(p => p.FolderId == item.Id);
                if (CurrentSelectedFolder.Equals(item))
                {
                    var first = FolderCollection.First();
                    CurrentSelectedFolder = first;
                }
                IsFolderListChanged  = true;
                IsHistoryListChanged = true;
            };
            await confirmDialog.ShowAsync();
        }
        private void BuildPartitionStructure(ContentNodeSitecoreItem product)
        {
            var guidAsString = product.Id.Guid.ToString("N").ToUpper(CultureInfo.InvariantCulture);

            FolderItem parent = Root;

            for (int i = 0; i < PartitionDepth; i++)
            {
                var bucketIndex = guidAsString.Substring(0, i + 1);
                if (!_bucketFolders.ContainsKey(bucketIndex))
                {
                    var folder = new BucketFolderItem(new ID(Root.Id.Guid.Derived(bucketIndex)), bucketIndex);
                    _bucketFolders[bucketIndex] = folder;
                    _sitecoreItems[folder.Id]   = folder;

                    parent.AddItem(folder);
                }

                parent = _bucketFolders[bucketIndex];
            }

            parent.AddItem(product);
        }
예제 #13
0
        private bool Restore(string Item)
        {
            Shl = new Shell();
            Folder Recycler = Shl.NameSpace(10);

            for (int i = 0; i < Recycler.Items().Count; i++)
            {
                FolderItem FI       = Recycler.Items().Item(i);
                string     FileName = Recycler.GetDetailsOf(FI, 0);
                if (Path.GetExtension(FileName) == "")
                {
                    FileName += Path.GetExtension(FI.Path);
                }
                //Necessary for systems with hidden file extensions.
                string FilePath = Recycler.GetDetailsOf(FI, 1);
                if (Item == Path.Combine(FilePath, FileName))
                {
                    DoVerb(FI, "ESTORE");
                    return(true);
                }
            }
            return(false);
        }
예제 #14
0
        public static void AssignDiscussionIdIfNeeded(string filePath, FolderItem itemToCheck, string discussionId = null)
        {
            var docFiles        = DeserializeFile(filePath);
            var overwriteNeeded = false;

            var docFilesToUpdate = docFiles.Where(x => x.Name == itemToCheck.Description);

            foreach (var item in docFilesToUpdate)
            {
                if (IsFolder(item) || string.IsNullOrEmpty(item.DiscussionId) == false)
                {
                    continue;
                }

                item.DiscussionId = discussionId ?? Guid.NewGuid().ToString();
                overwriteNeeded   = true;
            }

            if (overwriteNeeded)
            {
                SerializeFile(filePath, docFiles);
            }
        }
        public void WriteFolders_OneOrMoreEmptyPaths()
        {
            FolderItem folderItem = new FolderItem()
            {
                Name = "SSRSMigrate_AW_Tests",
                Path = "",
            };

            List <FolderItem> items = new List <FolderItem>()
            {
                folderItem
            };

            items.AddRange(folderItems);

            InvalidPathException ex = Assert.Throws <InvalidPathException>(
                delegate
            {
                writer.WriteFolders(items.ToArray());
            });

            Assert.That(ex.Message, Is.EqualTo(string.Format("Invalid path '{0}'.", folderItem.Path)));
        }
        /// <summary>
        /// mp3情報の取得
        /// </summary>
        /// <returns></returns>
        public List <string> getInfo(string filePath)
        {
            // mp3情報を取得
            List <string> ret = new List <string>();

            Shell32.Shell shell    = new Shell32.Shell();
            string        fileName = System.IO.Path.GetFileName(filePath);
            string        path     = filePath.Replace(fileName, "");

            Folder     f    = shell.NameSpace(path);
            FolderItem item = f.ParseName(fileName);

            // ※下記の設定は Windows10 のもの
            //
            ret.Add(f.GetDetailsOf(item, 13)); // アーティスト情報
            ret.Add(f.GetDetailsOf(item, 21)); // タイトル情報
            ret.Add(f.GetDetailsOf(item, 16)); // ジャンル情報
            ret.Add(f.GetDetailsOf(item, 24)); // コメント情報
            ret.Add(f.GetDetailsOf(item, 14)); // アルバムタイトル情報
            ret.Add(f.GetDetailsOf(item, 15)); // 年情報

            return(ret);
        }
예제 #17
0
        //매개변수로 전달 받는 파일을 삭제되기 전으로 복원하기 위한 사전 작업
        private bool FileRestore(string Item)
        {
            Shell  shl      = new Shell();
            Folder Recycler = shl.NameSpace(10);

            for (int i = 0; i < Recycler.Items().Count; i++)
            {
                FolderItem FI       = Recycler.Items().Item(i);
                string     FileName = Recycler.GetDetailsOf(FI, 0);
                if (Path.GetExtension(FileName) == "")
                {
                    FileName += Path.GetExtension(FI.Path);
                }
                string FilePath = Recycler.GetDetailsOf(FI, 1);

                if (Item == Path.Combine(FilePath, FileName))
                {
                    DoVerb(FI, "복원(&E)"); //삭제된 파일 및 폴더 정보의 FolderItem 개체와 실행 명령 인자값을 대입하여 호출
                    return(true);
                }
            }
            return(false);
        }
예제 #18
0
        private string GetPathAsText(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return("");
            }
            Folder folder = shell.NameSpace(path);

            if (folder == null)
            {
                return("");
            }
            FolderItem folderItem = (folder as Folder3).Self;

            if (folderItem.IsFileSystem)
            {
                return(folderItem.Path);
            }
            else
            {
                return(folderItem.Name);
            }
        }
예제 #19
0
        private void BundleReaderOnFolderRead(IBundleReader sender, ItemReadEvent itemReadEvent)
        {
            ListViewItem oItem = null;

            if (itemReadEvent.Success)
            {
                ImportStatus status = null;
                FolderItem   item   = this.mFolderItemImporter.ImportItem(itemReadEvent.FileName, out status);

                if (status.Success)
                {
                    oItem = this.AddListViewItem_Success(itemReadEvent, status, item);
                }
                else
                {
                    oItem = this.AddListViewItem_ImportFailed(itemReadEvent, status);
                }
            }
            else
            {
                oItem = this.AddListViewItem_ExtractFailed(itemReadEvent);
            }

            oItem.SubItems.Add(itemReadEvent.Path);
            oItem.SubItems.Add(itemReadEvent.FileName);

            oItem.Group = this.lstSrcReports.Groups["foldersGroup"];

            this.lstSrcReports.Invoke(new Action(() => this.lstSrcReports.Items.Add(oItem)));
            this.lstSrcReports.Invoke(new Action(() => oItem.EnsureVisible()));

            this.lblStatus.Text = string.Format("Refreshing item '{0}'...", itemReadEvent.FileName);

            this.mLogger.Debug("Refreshing item '{0}' in path '{1}'...", itemReadEvent.FileName, itemReadEvent.Path);

            this.mDebugForm.LogMessage(string.Format("Refreshing item '{0}' in path '{1}'...", itemReadEvent.FileName, itemReadEvent.Path));
        }
        private ArrayList GetDetailedFileInfo(string sFile)
        {
            ArrayList aReturn = new ArrayList();

            if (sFile.Length > 0)
            {
                try{
                    // Creating a ShellClass Object from the Shell32
                    ShellClass sh = new ShellClass();
                    // Creating a Folder Object from Folder that inculdes the File
                    Folder dir = sh.NameSpace(Path.GetDirectoryName(sFile));
                    // Creating a new FolderItem from Folder that includes the File
                    FolderItem item = dir.ParseName(Path.GetFileName(sFile));
                    // loop throw the Folder Items
                    for (int i = 0; i < 30; i++)
                    {
                        // read the current detail Info from the FolderItem Object
                        //(Retrieves details about an item in a folder. For example, its size, type, or the time of its last modification.)
                        // some examples:
                        // 0 Retrieves the name of the item.
                        // 1 Retrieves the size of the item.
                        // 2 Retrieves the type of the item.
                        // 3 Retrieves the date and time that the item was last modified.
                        // 4 Retrieves the attributes of the item.
                        // -1 Retrieves the info tip information for the item.

                        string det = dir.GetDetailsOf(item, i);
                        // Create a helper Object for holding the current Information
                        // an put it into a ArrayList
                        DetailedFileInfo oFileInfo = new DetailedFileInfo(i, det);
                        aReturn.Add(oFileInfo);
                    }
                }catch (Exception) {
                }
            }
            return(aReturn);
        }
예제 #21
0
        private static TargetDescriptor GetShortcutTargetDescriptor(string shortcutFilename)
        {
            string pathOnly     = Path.GetDirectoryName(shortcutFilename);
            string filenameOnly = Path.GetFileName(shortcutFilename);

            Shell      shell      = new Shell();
            Folder     folder     = shell.NameSpace(pathOnly);
            FolderItem folderItem = folder.ParseName(filenameOnly);

            TargetDescriptor desc = new TargetDescriptor();

            desc.Type = TargetType.Unknown;

            if (folderItem != null)
            {
                Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;

                if (string.IsNullOrWhiteSpace(link.Path))
                {
                    return(desc);
                }
                else
                {
                    desc.Path             = link.Path;
                    desc.Extension        = Path.GetExtension(desc.Path);
                    desc.Name             = Path.GetFileName(desc.Path);
                    desc.Arguments        = link.Arguments;
                    desc.WorkingDirectory = link.WorkingDirectory;

                    desc.Type = Directory.Exists(link.Path) ? TargetType.Directory : TargetType.File;

                    return(desc);
                }
            }

            return(desc);
        }
예제 #22
0
        public FileHistoryPage(IProjectClient client, FolderItem item)
        {
            this.client = client;
            this.item   = item;

            this.Title = "History";

            this.RefreshAsync();

            var listView = new ListView
            {
                ItemsSource = items,

                ItemTemplate = new DataTemplate(() =>
                {
                    var cell = new ImageCell();
                    cell.SetBinding <NodeVM>(TextCell.TextProperty, _ => _.Name);
                    cell.SetBinding <NodeVM>(TextCell.DetailProperty, _ => _.Details);
                    cell.SetBinding <NodeVM>(ImageCell.ImageSourceProperty, _ => _.ImageSource);
                    return(cell);
                }),
                IsPullToRefreshEnabled = true,
            };

            listView.RefreshCommand = new Command(async() =>
            {
                try
                {
                    await this.RefreshAsync();
                }
                finally
                {
                    listView.IsRefreshing = false;
                }
            });
            this.Content = listView;
        }
예제 #23
0
        private void LoadDrives()
        {
            TreeNode drivesNodes = new TreeNode("Drives");

            foreach (DriveInfo drive in DriveInfo.GetDrives())
            {
                string     iconId = drive.RootDirectory.FullName;
                FolderItem item   = new FolderItem(drive.RootDirectory, iconId);

                if (!_imgTree.Images.ContainsKey(iconId))
                {
                    Icon smallIcon = ShellApi.GetFolderIcon(drive.RootDirectory.FullName);

                    _imgTree.Images.Add(iconId, smallIcon);
                }

                string name = (string.IsNullOrWhiteSpace(drive.VolumeLabel) ? drive.Name : drive.VolumeLabel);
                if (drive.DriveType == DriveType.Removable)
                {
                    name += " (Removable)";
                }

                TreeNode node = drivesNodes.Nodes.Add(name);
                node.Tag              = item;
                node.ImageKey         = iconId;
                node.SelectedImageKey = iconId;
            }

            //if (drivesNodes.Nodes.Count > 0)
            //{
            //    drivesNodes.ImageKey = drivesNodes.Nodes[drivesNodes.Nodes.Count - 1].ImageKey;
            //    drivesNodes.SelectedImageKey = drivesNodes.Nodes[drivesNodes.Nodes.Count - 1].ImageKey;

            //    extendedTreeView1.Nodes.Add(drivesNodes);
            //    drivesNodes.Expand();
            //}
        }
        /// <summary>
        /// Recursively updates all nodes in the treeview, refreshing updated properties.
        /// </summary>
        /// <param name="projectItem">The project item for which to update the corresponding node.</param>
        private void UpdateNodes(ProjectItem projectItem)
        {
            ProjectNode node;

            if (!this.nodeCache.TryGetValue(projectItem, out node))
            {
                return;
            }

            if (projectItem is AddressItem && node != null)
            {
                node.EntryValuePreview = (projectItem as AddressItem).Value?.ToString() ?? String.Empty;
            }

            if (projectItem is FolderItem)
            {
                FolderItem folderItem = projectItem as FolderItem;

                foreach (ProjectItem child in folderItem.Children.ToArray())
                {
                    this.UpdateNodes(child);
                }
            }
        }
예제 #25
0
        /// <summary>
        /// トラック情報の取得
        /// </summary>
        /// <param name="trackfile"></param>
        public void GetTrackInfo(string trackfile)
        {
            // ファイル情報の取得
            string dir  = System.IO.Directory.GetParent(trackfile).ToString();  // ディレクトリ名
            string file = System.IO.Path.GetFileName(trackfile);                // ファイル名

            // ファイルプロパティ(ID3タグ情報)の取得
            ShellClass shell = new ShellClass();
            Folder     f     = shell.NameSpace(dir);
            FolderItem item  = f.ParseName(file);

            //// ID3情報の格納位置確認 (※出力ウィンドウに表示されます)
            //for (int i = 0; i < 100; i++)
            //{
            //    string msg = string.Format("[{0}] {1}", i, f.GetDetailsOf(item, i));
            //    System.Diagnostics.Debug.WriteLine(msg);
            //}

            // トラック情報の取得
            Title  = f.GetDetailsOf(item, (int)TrackIndex.Title);           // タイトル
            Artist = f.GetDetailsOf(item, (int)TrackIndex.Artist);          // アーティスト
            Album  = f.GetDetailsOf(item, (int)TrackIndex.Album);           // アルバム
            Time   = f.GetDetailsOf(item, (int)TrackIndex.Time);            // 時間
        }
예제 #26
0
        /// <summary>
        /// Set the root path of this folder tree. Inializes all internal data and redisplays.
        /// </summary>
        /// <param name="rootPathIn"></param>
        public void SetRootPath(string rootPathIn)
        {
            using (new WaitCursor())
            {
                // Use the correct spelling for the root directory name:
                DirectoryInfo dirInfo  = new DirectoryInfo(rootPathIn);
                string        rootPath = dirInfo.FullName;

                // Store it in the text box if that is empty:
                if (this.folderTextBox.Text.Length == 0)
                {
                    this.folderTextBox.Text = rootPath;
                }
                FolderItem newRootFolder = new FolderItem(null, rootPath, DateTime.Now);
                newRootFolder.Fill(rootPath, true);

                this.rootFolder    = newRootFolder;
                this.currentFolder = this.RootFolder;

                RedisplayFolders();

                // MessageBox.Show("There are currently " + FileSystemItem.ImageList.Images.Count.ToString() + " images in the system image list");
            }
        }
예제 #27
0
        public virtual FolderItem GetFolderItemById(string itemId)
        {
            FolderItem retVal =
                this.ChangeTracker.TrackingEntries.Select(x => x.Entity)
                .OfType <FolderItem>()
                .FirstOrDefault(x => x.FolderItemId == itemId);

            if (retVal == null)
            {
                var cloudBlob = CurrentCloudBlobClient.GetBlobReferenceFromServer(GetUri(itemId)) as CloudBlockBlob;
                if (cloudBlob != null && cloudBlob.Exists())
                {
                    string folderItemTypeName = this._entityFactory.GetEntityTypeStringName(typeof(FolderItem));
                    retVal = this._entityFactory.CreateEntityForType(folderItemTypeName) as FolderItem;
                    this.MapCloudBlob2FolderItem(cloudBlob, retVal);
                }

                if (retVal != null)
                {
                    this.ChangeTracker.Attach(retVal);
                }
            }
            return(retVal);
        }
예제 #28
0
        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            System.Array pathList = (System.Array)e.Data.GetData(DataFormats.FileDrop);
            strList.Clear();
            nameList.Clear();
            durationList.Clear();
            durationTimeList.Clear();
            for (int i = 0; i < pathList.Length; i++)
            {
                var      path     = pathList.GetValue(i).ToString();
                FileInfo file     = new FileInfo(path);
                string   ext      = file.Extension;
                string   fileName = file.Name;
                if (ext == ".mp3")
                {
                    strList.Add(path); //循环添加元素
                    nameList.Add(fileName);
                    Shell  sh  = new Shell();
                    Folder dir = sh.NameSpace(Path.GetDirectoryName(path));

                    FolderItem item = dir.ParseName(Path.GetFileName(path));
                    String     s    = dir.GetDetailsOf(item, 27);
                    durationList.Add(s);
                    durationTimeList.Add(transTimeStr(s));
                }
                else
                {
                    MessageBox.Show(path + "不是mp3格式文件!");
                }
            }

            if (strList.Count > 0)
            {
                InitializeTable();
            }
        }
예제 #29
0
        private double GetSize(FolderItem folderItem)
        {
            //check if it's a folder, if it's not then return it's size
            if (!folderItem.IsFolder)
            {
                return((double)folderItem.Size);
            }

            //create a new Shell32.Folder item
            Folder folder = (Folder)folderItem.GetFolder;

            double size = 0;

            //since we're here we're dealing with a folder, so now we will loop
            //through everything in it and get it's size, thus calculating the
            //overall size of the folder
            foreach (FolderItem2 f in folder.Items())
            {
                size += GetSize(f);
            }

            //return the size
            return(size);
        }
        /// <summary>
        /// Adds the new project item to the project item collection.
        /// </summary>
        /// <param name="addToSelected">Whether or not the items should be added under the selected item.</param>
        /// <param name="projectItems">The project item to add.</param>
        public void AddNewProjectItems(Boolean addToSelected = true, params ProjectItem[] projectItems)
        {
            if (projectItems.IsNullOrEmpty())
            {
                return;
            }

            foreach (ProjectItem projectItem in projectItems)
            {
                if (ProjectRoot.HasNode(projectItem))
                {
                    return;
                }

                ProjectItem target = this.SelectedProjectItems?.FirstOrDefault();

                // Atempt to find the correct folder to place the new item into
                while (target != null && !(target is FolderItem))
                {
                    target = target.Parent as ProjectItem;
                }

                FolderItem targetFolder = target as FolderItem;

                if (target != null)
                {
                    targetFolder.AddChild(projectItem);
                }
                else
                {
                    this.ProjectRoot.AddChild(projectItem);
                }
            }

            this.NotifyObserversStructureChange();
        }
예제 #31
0
        private static string GetShortcutTargetPath(string shortcutPath)
        {
            string directory = Path.GetDirectoryName(shortcutPath);
            string filename  = Path.GetFileName(shortcutPath);

            try
            {
                Shell      shell      = new ShellClass();
                Folder     folder     = shell.NameSpace(directory);
                FolderItem folderItem = folder.ParseName(filename);

                if (folderItem != null)
                {
                    ShellLinkObject link = (ShellLinkObject)folderItem.GetLink;
                    return(link.Path);
                }
            }
            catch (Exception e)
            {
                DebugHelper.WriteException(e);
            }

            return(null);
        }
예제 #32
0
        /// <summary>
        /// 获取MP3之类的音乐文件的属性
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static MusicInfo GetFileInfo(string filePath)
        {
            ShellClass sh = new ShellClass();

            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(filePath));
            FolderItem item = dir.ParseName(Path.GetFileName(filePath));

            //StringBuilder sb = new StringBuilder();
            //for (int i = -1; i < 87; i++)
            //{
            //    sb.AppendFormat("{0}:{1}\n", i, dir.GetDetailsOf(item, i));
            //}
            //sb.ToString();
            return(new MusicInfo
            {
                Album = dir.GetDetailsOf(item, 14),
                Artists = dir.GetDetailsOf(item, 13),
                BitRate = Said.Helper.ConvertHelper.StringToInt(dir.GetDetailsOf(item, 28)),
                Length = dir.GetDetailsOf(item, 27),
                //Size = dir.GetDetailsOf(item, 1),
                Title = dir.GetDetailsOf(item, 21),
                Type = dir.GetDetailsOf(item, 2)
            });
        }
예제 #33
0
        public static Dictionary <int, string> getMediaField(string targetFolderPath, string fileName)
        {
            Dictionary <int, string> metaInfo = new Dictionary <int, string>();

            ShellClass shell = new ShellClass();
            Folder     f     = shell.NameSpace(targetFolderPath);
            FolderItem item  = f.ParseName(fileName);

            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.ARTIST)); // 参加アーティスト
            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.TITLE)); // タイトル
            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.GENRE)); // ジャンル
            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.ALBUMTITLE)); // アルバムのタイトル
            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.YEAR)); // 年
            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.TRACKNO)); // トラック番号
            //Console.WriteLine(f.GetDetailsOf(item, MediaMetaNo.COMMENT)); // コメント

            metaInfo.Add(MediaMetaNo.ARTIST, f.GetDetailsOf(item, MediaMetaNo.ARTIST));
            metaInfo.Add(MediaMetaNo.TITLE, f.GetDetailsOf(item, MediaMetaNo.TITLE));
            metaInfo.Add(MediaMetaNo.GENRE, f.GetDetailsOf(item, MediaMetaNo.GENRE));
            metaInfo.Add(MediaMetaNo.ALBUMTITLE, f.GetDetailsOf(item, MediaMetaNo.ALBUMTITLE));
            metaInfo.Add(MediaMetaNo.YEAR, f.GetDetailsOf(item, MediaMetaNo.YEAR));
            metaInfo.Add(MediaMetaNo.TRACKNO, f.GetDetailsOf(item, MediaMetaNo.TRACKNO));
            metaInfo.Add(MediaMetaNo.COMMENT, f.GetDetailsOf(item, MediaMetaNo.COMMENT));
            metaInfo.Add(MediaMetaNo.RELEASE, f.GetDetailsOf(item, MediaMetaNo.RELEASE));

            //for (int i = 0; i < 10000; i++)
            //{ // 10000は適当な大きな値
            //    string name = f.GetDetailsOf(null, i);
            //    if (!string.IsNullOrEmpty(name))
            //    {
            //        Console.WriteLine("{0} : {1}", i, name);
            //    }
            //}

            return(metaInfo);
        }
        protected DocumentationPage CompileDocumentationPage(FolderItem page, string directory,
                                                             string documentationVersion, List <DocumentationMapping> mappings,
                                                             string sourceDocumentationVersion = null)
        {
            var path = FileExtensionHelper.GetMarkdownFilePath(directory, page);

            var fileInfo = new FileInfo(path);

            if (fileInfo.Exists == false)
            {
                throw new FileNotFoundException($"Documentation file '{path}' not found.");
            }

            var compilationParams = new CompilationUtils.Parameters
            {
                File = fileInfo,
                Page = page,
                DocumentationVersion       = documentationVersion,
                SourceDocumentationVersion = sourceDocumentationVersion ?? documentationVersion,
                Mappings = mappings
            };

            return(_documentCompiler.Compile(compilationParams));
        }
예제 #35
0
        private static bool PinUnpinTaskBar(string filePath, bool pin)
        {
            bool success = false;

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(filePath);
            }

            // create the shell application object
            Shell shellApplication = new Shell();

            string path     = Path.GetDirectoryName(filePath);
            string fileName = Path.GetFileName(filePath);

            Folder     directory = shellApplication.NameSpace(path);
            FolderItem link      = directory.ParseName(fileName);

            FolderItemVerbs verbs = link.Verbs();

            for (int i = 0; i < verbs.Count; i++)
            {
                FolderItemVerb verb     = verbs.Item(i);
                string         verbName = verb.Name.Replace(@"&", string.Empty).ToLower();

                System.Diagnostics.Trace.WriteLine(string.Format("Verb:{0}", verbName));
                if ((pin && verbName.Equals("pin to taskbar")) || (!pin && verbName.Equals("unpin from taskbar")))
                {
                    verb.DoIt();
                    success = true;
                }
            }

            shellApplication = null;
            return(success);
        }
예제 #36
0
        public static IEnumerable <File> ToFiles(this FolderItem folderItem)
        {
            var extensionStrategy = new FileExtensionExtractStrategyFactory()
                                    .GetStrategy(folderItem.Document);

            if (folderItem.Document is DesktopDocument desktopDoc)
            {
                return(new List <File>()
                {
                    new File
                    {
                        InputStream = desktopDoc.DesktopFileData,
                        ContentType = desktopDoc.DocumentExtension,
                        ContentLength = (int)folderItem.Document.Size,
                        FileName = $"{folderItem.Description}.{extensionStrategy.GetExtension()}"
                    }
                });
            }
            else if (folderItem.Document is ImageDocument imageDoc)
            {
                return(imageDoc.Pages.Select(p =>
                                             new File
                {
                    InputStream = p.ImageData,
                    FileName = $"{p.ImageFileName}.{extensionStrategy.GetExtension()}",
                    ContentLength = p.ImageData.Length,
                    ContentType = p.DocumentExtension
                }
                                             ));
            }
            else
            {
                Log.Warning($"Calling function with unsupported document type for folder item, {nameof(folderItem)}.");
                return(new List <File>());
            }
        }
 private bool FilterOtherProgramFolderItems(FolderItem arg)
 {
     return true;
 }
 protected virtual void FillMyComputer(FolderItem folderItem, TreeNodeCollection parentCollection,
     TreeViewFolderBrowserHelper helper)
 {
     _rootCollection = parentCollection;
       Logicaldisk.LogicaldiskCollection logicalDisks = null;
       // get wmi logical disk's if we have to
       if (helper.TreeView.DriveTypes != DriveTypes.All)
     logicalDisks = Logicaldisk.GetInstances(null, GetWMIQueryStatement(helper.TreeView));
       //
       foreach (FolderItem fi in ((Folder)folderItem.GetFolder).Items())
       {
     // only File System shell objects ?
     if (!_showAllShellObjects && !fi.IsFileSystem) continue;
     // check drive type
     if (fi.IsFileSystem && logicalDisks != null)
     {
       bool skipDrive = true;
       foreach (Logicaldisk lg in logicalDisks)
       {
     if (lg.Name + "\\" == fi.Path)
     {
       skipDrive = false;
       break;
     }
       }
       if (skipDrive) continue;
     }
     // create new node
     TreeNodePath node = CreateTreeNode(helper, fi.Name, fi.Path, IsFolderWithChilds(fi), false, true);
     node.Tag = fi;
     parentCollection.Add(node);
       }
 }
예제 #39
0
 private bool DoVerb(FolderItem Item, string Verb) {
   var Found = Item.Verbs().OfType<FolderItemVerb>().FirstOrDefault(FIVerb => FIVerb.Name.ToUpper().Contains(Verb.ToUpper()));
   Found?.DoIt();
   return Found != null;
 }
 /**
 * 读取目录列表
 * @param $path 目录路径
 * return array 数组 或 null
 */
 private ArrayList readDir(string bucketname, string url)
 {
     Hashtable headers = new Hashtable();
     byte[] a = null;
     HttpWebResponse resp = newWorker("GET", DL + bucketname + url, a, headers);
     StreamReader sr = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
     string strhtml = sr.ReadToEnd();
     resp.Close();
     strhtml = strhtml.Replace("\t", "\\");
     strhtml = strhtml.Replace("\n", "\\");
     string[] ss = strhtml.Split('\\');
     int i = 0;
     ArrayList AL = new ArrayList();
     while (i < ss.Length)
     {
         FolderItem fi = new FolderItem(ss[i], ss[i + 1], int.Parse(ss[i + 2]), int.Parse(ss[i + 3]));
         AL.Add(fi);
         i += 4;
     }
     return AL;
 }
 /// <summary>
 ///   Do we have to add a dummy node (+ sign)
 /// </summary>
 protected virtual bool IsFolderWithChilds(FolderItem fi)
 {
     return _showAllShellObjects || (fi.IsFileSystem && fi.IsFolder && !fi.IsBrowsable);
 }