public static System.Drawing.Icon GetFolderIcon(string name, IconSize size, FolderType folderType) { Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) { flags += Shell32.SHGFI_OPENICON; } //if (true == linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY; /* Check the size specified for return. */ if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } Shell32.SHGetFileInfo(name, Shell32.FILE_ATTRIBUTE_DIRECTORY, ref shfi, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags); // Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(shfi.hIcon).Clone(); User32.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
private void FolderSelectionChanged(object sender, EventArgs e) { if (inboxRadioButton.Checked) { this.folderSelectionLabel.Text = "Look in Inbox Folder"; folderTypeSelection = FolderType.Inbox; } else if (sentRadioButton.Checked) { this.folderSelectionLabel.Text = "Look in Sent Items Folder"; folderTypeSelection = FolderType.Sent; } else if (outboxRadioButton.Checked) { this.folderSelectionLabel.Text = "Look in Outbox Folder"; folderTypeSelection = FolderType.Outbox; } else { this.folderSelectionLabel.Text = string.Empty; folderTypeSelection = FolderType.None; } BuildWorkflow(WizardStep.None); ResetButtons(); }
/// <summary> /// Obtains system folder icon</summary> /// <param name="size">Specifies large or small icons</param> /// <param name="folderType">Specifies open or closed FolderType</param> /// <returns>System folder icon</returns> public static Icon GetFolderIcon(IconSize size, FolderType folderType) { // Need to add size check, although errors generated at present! uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) { flags += Shell32.SHGFI_OPENICON; } if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } // Get the folder icon Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); Shell32.SHGetFileInfo(null, Shell32.FILE_ATTRIBUTE_DIRECTORY, ref shfi, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags); Icon.FromHandle(shfi.hIcon); // Load the icon from an HICON handle // Now clone the icon, so that it can be successfully stored in an ImageList Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); User32.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
/// <summary> /// The current Windows default Folder Icon in the given Size (Large/Small) as System.Drawing.Icon. /// </summary> /// <param name="size">The Size of the Icon (Small or Large).</param> /// <param name="folderType">The folderTypeIcon (closed or Open).</param> /// <returns>The Folder Icon as System.Drawing.Icon.</returns> public static Icon GetDefaultDirectoryIcon(IconSize size, FolderType folderType) { var flags = ShgfiIcon | ShgfiUsefileattributes; if (FolderType.Open == folderType) { flags += ShgfiOpenicon; } if (IconSize.Small == size) { flags += ShgfiSmallicon; } else { flags += ShgfiLargeicon; } var shfi = new Structs.Shfileinfo(); var res = DllImports.SHGetFileInfo(@"C:\Windows", FileAttributeDirectory, out shfi, (uint) Marshal.SizeOf(shfi), flags); if (res == IntPtr.Zero) { throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); } Icon.FromHandle(shfi.hIcon); var icon = (Icon) Icon.FromHandle(shfi.hIcon).Clone(); DllImports.DestroyIcon(shfi.hIcon); return icon; }
public int AddFolderIcon(FolderType type) { string text = "folder_" + type.ToString(); int result; if (this._extensionList.ContainsKey(text)) { result = (int)this._extensionList[text]; } else { int count = ((ImageList)this._imageLists[0]).Images.Count; if (this._manageBothSizes) { ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(IconSize.Small, type)); ((ImageList)this._imageLists[1]).Images.Add(IconReader.GetFolderIcon(IconSize.Large, type)); } else { ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(this._iconSize, type)); } this.AddExtension(text, count); result = count; } return result; }
public ChunithmFile(string name, FileType file, FolderType parentFolder, string[] potentialPaths, bool mandatory = true) { Name = name; File = file; PotentialPaths = potentialPaths; ParentFolder = parentFolder; Mandatory = mandatory; }
public Folder(string id, string title, string courseId, FolderType type = FolderType.General) { Id = id; Title = title; CourseId = courseId; Type = type; ApplicationType = ApplicationType.None; }
public static string GetPathAbsolut(FolderType type, string photoPath = "") { if (string.IsNullOrWhiteSpace(photoPath)) { return(GetPathAbsolut(PhotoFoldersPath[type])); } return(GetPathAbsolut(PhotoFoldersPath[type]) + photoPath); }
//_____________ public static string GetPath(FolderType type, string photoPath, bool isForAdministration) { if (string.IsNullOrWhiteSpace(photoPath)) { return(GetPath(PhotoFoldersPath[type], isForAdministration)); } return(GetPath(PhotoFoldersPath[type], isForAdministration) + photoPath); }
public IFolderService GetFolderService(Guid folderId) { int folderTypeId = GetFolderTypeId(folderId); FolderType folderType = GetFolderType(folderTypeId); return((IFolderService)Activator.CreateInstance(Type.GetType(folderType.TypeFolderService), DatabaseService)); }
/// <summary> /// Validates the name of the file. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="folderType">Type of the folder.</param> /// <returns></returns> public bool ValidateFileName(string fileName, FolderType folderType) { if (!IsValidFileName(fileName)) { throw new ArgumentException("File name has invalid characters \\ / : ? <> | * _ .", "fileName"); } return(GetFile(fileName, folderType) != null); }
public TreeNode MakeHierarchy(ref IEnumerable <Folder> allFolders, ref Dictionary <string, TreeNode> existFoldersInTree, Folder folder, FolderType folderType, ref StringBuilder path, ref Dictionary <string, Folder> currentFoldersInTree) { TreeNode n = new TreeNode(); Folder fParent = new Folder(); foreach (Folder f in allFolders) { if (f.Id == folder.ParentId) { fParent = f; FolderType newFolderType = ClientRequests.GetFolderType(f.Type); n = MakeHierarchy(ref allFolders, ref existFoldersInTree, f, newFolderType, ref path, ref currentFoldersInTree); break; } } path.Append(folder.Name + "\\"); foreach (var temp in existFoldersInTree) { if (temp.Key == path.ToString()) { return(temp.Value); } } TreeNode newNode = new TreeNode(folder.Name); existFoldersInTree.Add(path.ToString(), newNode); int count = 0; try { count = ClientRequests.GetCountLetterInFolder(folder.Id, ((ApplicationState)ServiceProvider.GetService(typeof(ApplicationState))).Worker.Id); } catch (Exception ex) { NLogger.Logger.Trace(ex.ToString()); } if (count > 0) { newNode.Text += " (" + count.ToString() + ")"; newNode.NodeFont = new Font(foldersTV.Font, FontStyle.Bold);; } if (folder.ParentId == Guid.Empty) { foldersTV.Nodes.Add(newNode); } else { n.Nodes.Add(newNode); } currentFoldersInTree.Add(newNode.FullPath, folder); return(newNode); }
public void SetConversationsFolder(List <int> ids, FolderType folder, uint?userFolderId = null) { if (!ids.Any()) { throw new ArgumentNullException("ids"); } var engine = new EngineFactory(Tenant, User, Log); List <MailInfo> listObjects; using (var daoFactory = new DaoFactory()) { listObjects = GetChainedMessagesInfo(daoFactory, ids); if (!listObjects.Any()) { return; } using (var tx = daoFactory.DbManager.BeginTransaction(IsolationLevel.ReadUncommitted)) { engine.MessageEngine.SetFolder(daoFactory, listObjects, folder, userFolderId); tx.Commit(); } } if (folder == FolderType.Inbox || folder == FolderType.Sent || folder == FolderType.Spam) { engine.OperationEngine.ApplyFilters(listObjects.Select(o => o.Id).ToList()); } if (!FactoryIndexer <MailWrapper> .Support) { return; } var data = new MailWrapper { Folder = (byte)folder, UserFolders = userFolderId.HasValue ? new List <UserFolderWrapper> { new UserFolderWrapper { Id = (int)userFolderId.Value } } : new List <UserFolderWrapper>() }; Expression <Func <Selector <MailWrapper>, Selector <MailWrapper> > > exp = s => s.In(m => m.Id, listObjects.Select(o => o.Id).ToArray()); engine.IndexEngine.Update(data, exp, w => w.Folder); engine.IndexEngine.Update(data, exp, UpdateAction.Replace, w => w.UserFolders); }
public static Icon GetFolderIcon( string directoryPath, FolderType folderType, bool linkOverlay, IconSize size = IconSize.Small) { Icon icon = null; // Need to add size check, although errors generated at present! // uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; // MH: Removed SHGFI_USEFILEATTRIBUTES, otherwise was wrong folder icon uint flags = DllImports.NativeMethods.ShgfiIcon; // | Shell32.SHGFI_USEFILEATTRIBUTES; if (linkOverlay) { flags += DllImports.NativeMethods.ShgfiLINKOVERLAY; } if (folderType == FolderType.Open) { flags += DllImports.NativeMethods.ShgfiOPENICON; } if (size == IconSize.Small) { flags += DllImports.NativeMethods.ShgfiSMALLICON; } else { flags += DllImports.NativeMethods.ShgfiLARGEICON; } // Get the folder icon DllImports.NativeMethods.SHFILEINFO shfi = default; IntPtr success = DllImports.NativeMethods.Shell32SHGetFileInfo( directoryPath, DllImports.NativeMethods.FileAttributeDirectory, ref shfi, (uint)Marshal.SizeOf(shfi), flags); if (success != IntPtr.Zero && shfi.hIcon != IntPtr.Zero) { try { icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); DllImports.NativeMethods.User32DestroyIcon(shfi.hIcon); } catch (Exception ex) { Log.Error($"directoryPath:'{directoryPath}'", ex); } } return(icon); }
/// <summary> /// Gets an icon in the specified size representing a folder of the specified type. /// </summary> /// <param name="size">The size of icon to get.</param> /// <param name="folderType">The type of folder icon to get.</param> /// <returns>The requested folder icon.</returns> public static SDIcon GetFolderIcon(Size size, FolderType folderType) { // Need to add size check, although errors generated at present! uint flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | (size == Size.Small ? SHGFI_SMALLICON : SHGFI_LARGEICON) | (folderType == FolderType.Open ? SHGFI_OPENICON : 0); return(GetIcon(Directory.GetCurrentDirectory(), flags, FileAttributes.Directory)); }
public PagedList<TravelerMessage> ListMessages(Guid travelerID, FolderType folder, int index = 0, int count = 10) { Traveler traveler = _repository.FindBy<Traveler>(t => t.TravelerID == travelerID); if (traveler == null) throw new TravelerNotFoundException(); if (traveler.HasMessagesInFolder(folder)) return traveler.Messages.Where(m => m.FolderID == (int)folder).ToPagedList(index, count); else return new PagedList<TravelerMessage>(); }
private JobAdFolder CreateSpecialFolder(Guid memberId, FolderType folderType) { var folder = new JobAdFolder { MemberId = memberId, FolderType = folderType }; _jobAdListsCommand.CreateList(folder); return(folder); }
private CandidateFolder CreateSpecialFolder(Guid employerId, FolderType folderType) { var folder = new CandidateFolder { RecruiterId = employerId, FolderType = folderType }; _contenderListsCommand.CreateList(folder); return(folder); }
public static Icon GetFolderIcon(string directoryPath, FolderType folderType, bool linkOverlay, IconSize size = IconSize.Small) { Icon icon = null; // Need to add size check, although errors generated at present! //uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; //MH: Removed SHGFI_USEFILEATTRIBUTES, otherwise was wrong folder icon uint flags = DllImports.NativeMethods.ShgfiIcon; // | Shell32.SHGFI_USEFILEATTRIBUTES; if (true == linkOverlay) { flags += DllImports.NativeMethods.ShgfiLINKOVERLAY; } if (FolderType.Open == folderType) { flags += DllImports.NativeMethods.ShgfiOPENICON; } if (IconSize.Small == size) { flags += DllImports.NativeMethods.ShgfiSMALLICON; } else { flags += DllImports.NativeMethods.ShgfiLARGEICON; } // Get the folder icon DllImports.NativeMethods.SHFILEINFO shfi = new DllImports.NativeMethods.SHFILEINFO(); IntPtr Success = DllImports.NativeMethods.Shell32SHGetFileInfo(directoryPath, DllImports.NativeMethods.FileAttributeDirectory, ref shfi, (uint)Marshal.SizeOf(shfi), flags); if (Success != IntPtr.Zero) // got valid handle? { try { Icon.FromHandle(shfi.hIcon); icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); DllImports.NativeMethods.User32DestroyIcon(shfi.hIcon); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { Log.Error($"directoryPath:'{directoryPath}'", ex); } } return(icon); }
/// <summary> /// Deletes the folder. /// </summary> /// <param name="folderType">Type of the folder.</param> public void DeleteFolder(FolderType folderType) { var path = PathBuilder.GetFolderPath(folderType); if (Directory.Exists(path)) { Directory.Delete(PathBuilder.GetFolderPath(folderType), true); } }
public IEnumerable <FolderInfoDto> GetSubsiteRootFolders(FolderType folderType) { using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CMSDataStoreKey)) { FolderFacade facade = new FolderFacade(uow); List <FolderInfoDto> folderList = facade.GetSubsiteRootFolders(new FolderInfoConverter()); return(folderList); } }
private static FileInfo GetFolderIcon(FolderType folderType) { var fileInfo = GetFolderIconInternal(IconSize.Small, folderType); var fileInfo2 = GetFolderIconInternal(IconSize.Large, folderType); fileInfo.LargeIcon = fileInfo2.LargeIcon; return(fileInfo); }
private async Task <IFolder> _GetWorkflowFolder(Workflow workflow, FolderType type, bool suppressLogging = false) { IFolder folder; string typeName = Enum.GetName(typeof(FolderType), type); if (type == FolderType.Archive) { IFolder sourceFolder = await _GetWorkflowFolder(workflow, FolderType.Source, true); folder = await sourceFolder.CreateOrGetFolder($"{_ArchiveFolderName}_{workflow.Id}"); } else if (type == FolderType.Failed) { IFolder sourceFolder = await _GetWorkflowFolder(workflow, FolderType.Source, true); folder = await sourceFolder.CreateOrGetFolder($"{_FailedFolderName}_{workflow.Id}"); } else if (type == FolderType.Staging) { IFolder sourceFolder = await _GetWorkflowFolder(workflow, FolderType.Source, true); folder = await sourceFolder.CreateOrGetFolder($"{_ProcessingFolderName}_{workflow.Id}"); } else if ((type == FolderType.Source && workflow.Direction == WorkflowDirection.Inbound) || (type == FolderType.Destination && workflow.Direction == WorkflowDirection.Outbound)) { Server server = workflow.Server; FtpClient ftpClient = new FtpClient(server.Host, server.Port, server.Username, server.Password); if (_log.IsEnabled(LogLevel.Trace)) { _log.LogTrace("Using {FtpUsername} / {FtpPassword} to connect to {FtpHost}:{FtpPort}.", server.Username, server.Password, server.Host, server.Port); } else { _log.LogDebug("Using {FtpUsername} to connect to {FtpHost}:{FtpPort}. Enable trace-level logging to see password.", server.Username, server.Host, server.Port); } folder = new FtpFolder(ftpClient, PathUtil.CombineFragments(server.Path, workflow.RemotePath)); } else { folder = new LocalFolder(workflow.LocalPath); } if (!suppressLogging) { _log.LogDebug(string.Concat(typeName, " Folder: {", typeName, "folderName}"), folder.FullName); } return(folder); }
public static string PathCombine(string basePath, FolderType appendFolderType) { switch (appendFolderType) { case FolderType.Models: return(Path.Combine(basePath, "Models")); case FolderType.Controllers: return(Path.Combine(basePath, "Controllers")); case FolderType.Components: return(Path.Combine(basePath, "Components")); case FolderType.DataControllers: return(Path.Combine(basePath, "DataControllers")); case FolderType.Managers: return(Path.Combine(basePath, "Managers")); case FolderType.Views: return(Path.Combine(basePath, "Views")); case FolderType.ViewModels: return(Path.Combine(basePath, "ViewModels")); case FolderType.ViewEntities: return(Path.Combine(basePath, "ViewEntities")); case FolderType.Attributes: return(Path.Combine(basePath, "Attributes")); case FolderType.Inputs: return(Path.Combine(basePath, "Inputs")); case FolderType.Animators: return(Path.Combine(basePath, "Animators")); case FolderType.Audio: return(Path.Combine(basePath, "Audio")); case FolderType.AI: return(Path.Combine(basePath, "AI")); case FolderType.Network: return(Path.Combine(basePath, "Network")); case FolderType.Editor: return(Path.Combine(basePath, "Editor")); case FolderType.Editor_Drawers: return(Path.Combine(Path.Combine(basePath, "Editor"), "Drawers")); default: return(string.Empty); } }
private JobAdFolder GetSpecialFolder(Guid memberId, FolderType folderType) { // If it doesn't exist then create it. var folders = _jobAdListsQuery.GetLists <JobAdFolder>(memberId, (int)folderType); return(folders.Count == 0 ? CreateSpecialFolder(memberId, folderType) : folders[0]); }
public static FolderType CreateFolder(TreeView t) { // Create root folder then get all children FolderType f = new FolderType(); f.Name = "/"; f.Items = GetChildren(t.Nodes[0]); return(f); }
private CandidateFolder GetSpecialFolder(Guid employerId, FolderType folderType) { // If it doesn't exist then create it. var folders = _contenderListsQuery.GetLists <CandidateFolder>(employerId, (int)folderType); return(folders.Count == 0 ? CreateSpecialFolder(employerId, folderType) : folders[0]); }
public static string ToFolderId(this FolderType type) { return(type switch { FolderType.Inbox => ExchangeMailService.SpecialFolders.INBOX, FolderType.DeletedItems => ExchangeMailService.SpecialFolders.DELETED_ITEMS, FolderType.Archive => ExchangeMailService.SpecialFolders.ARCHIVE, FolderType.Junk => ExchangeMailService.SpecialFolders.JUNK, _ => throw new NotSupportedException($"Folder type {type} is not supported."), });
public FolderMapping(string folderName, FolderType folderType, string folderClass) { base.FolderRec.FolderName = folderName; base.FolderRec.FolderType = folderType; base.FolderRec.FolderClass = folderClass; this.WKFType = WellKnownFolderType.None; this.Flags = FolderMappingFlags.None; this.SourceFolder = null; this.TargetFolder = null; }
public static Icon AddFolderIcon(FolderType type) { var key = $"folder_{type}"; if (!_cache.ContainsKey(key)) { _cache.Add(key, GetFolderIcon(IconSize.Small, type)); } return(_cache[key]); }
public virtual int UpdateProviderInfo(int linkId, string customerTitle, FolderType folderType) { var queryUpdate = new SqlUpdate(TableTitle) .Set("customer_title", customerTitle) .Set("folder_type", (int)folderType) .Where("id", linkId) .Where("tenant_id", TenantID); return(DbManager.ExecuteNonQuery(queryUpdate) == 1 ? linkId : default(int)); }
/// <summary> /// 获取文件夹下文件 /// </summary> /// <param name="directory">目录</param> /// <param name="folderType">文件类型</param> /// <param name="searchOption">搜索参数</param> /// <returns></returns> public static IList <string> GetFileList(string directory, FolderType folderType = FolderType.Bin, SearchOption searchOption = SearchOption.AllDirectories) { var path = folderType.GetPath(); if (!Directory.Exists(path)) { return(new List <string>()); } return(Directory.GetFiles(path, directory, searchOption)); }
/// <summary> /// Gets or creates the storage folder from the given path. /// </summary> /// <param name="path">The path.</param> /// <param name="folderType">The folder type.</param> /// <returns>A storage folder representing the path.</returns> public async static Task <StorageFolder> GetCreateFolder(string path, FolderType folderType) { StorageFolder storageFolder = ApplicationData.Current.LocalFolder; path = path.Replace(storageFolder.Path, ""); string[] folders = path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries); string folder; string folderPrefix; for (int i = 0; i < folders.Length; i++) { folder = folders[i]; folderPrefix = null; if (folder.StartsWith(MailClient.MailboxFolderPrefix.ToString()) || folder.StartsWith(MailClient.MessageFolderPrefix.ToString())) { goto Create; } switch (i) { case 0: break; default: if (i == folders.Length - 1) { switch (folderType) { case FolderType.Mailbox: folderPrefix = MailClient.MailboxFolderPrefix.ToString(); break; case FolderType.Message: folderPrefix = MailClient.MessageFolderPrefix.ToString(); break; default: break; } } else { folderPrefix = MailClient.MailboxFolderPrefix.ToString(); } break; } Create: storageFolder = await GetCreateFolder(storageFolder, folderPrefix + folder); } return(storageFolder); }
public FolderClass(string FullName, FolderType type, DirectoryInfo info, string DVDCDname) { Name = FullName; FolderType = type; DirectoryInfo = info; FullPath = info.FullName; DVD_CDname = DVDCDname; PopulateFolderList(); PopulateFileList(); }
public Folder GetFolder(FolderType folder) { var query = Query() .Where(FolderCountersTable.Columns.Folder, (int)folder) .Where(FolderCountersTable.Columns.Tenant, Tenant) .Where(FolderCountersTable.Columns.User, CurrentUserId); return(Db.ExecuteList(query) .ConvertAll(ToFolder) .SingleOrDefault()); }
public MailFolder(FolderType folder, string name, string[] tags = null) { if (!IsIdOk(folder)) { throw new ArgumentException(@"Incorrect folder id", "folder"); } Folder = folder; Name = name; Tags = tags ?? new string[] {}; }
/// <summary> /// http://apidocs.mailchimp.com/api/2.0/folders/del.php /// </summary> /// <returns></returns> public Task<MailChimpServiceResponse> Delete(string name, int id, FolderType type) { var url = Urls.Folder + "/del.json"; var request = new { fid = id, type = type }; return Execute(url, request); }
public GoogleDriveProviderInfo(int id, string providerKey, string customerTitle, string token, Guid owner, FolderType rootFolderType, DateTime createOn) { if (string.IsNullOrEmpty(providerKey)) throw new ArgumentNullException("providerKey"); if (string.IsNullOrEmpty(token)) throw new ArgumentException("Token can't be null"); ID = id; CustomerTitle = customerTitle; Owner = owner == Guid.Empty ? SecurityContext.CurrentAccount.ID : owner; ProviderKey = providerKey; _token = OAuth20Token.FromJson(token); _rootFolderType = rootFolderType; _createOn = createOn; }
/// <summary> /// 以 FolderType 查詢實體存放資料夾 /// </summary> /// <param name="folderType">資料夾類型</param> /// <param name="isCreate">是否建立資料夾</param> /// <returns>實體存放資料夾(絕對路徑)</returns> public DirectoryInfo GetStorageDirectory(FolderType folderType, bool isCreate) { string rootPath = GetStoragePath(FolderType.ROOT); string storagePath = GetStoragePath(folderType); m_Log.Debug("rootPath = " + rootPath); m_Log.Debug("storagePath = " + storagePath); DirectoryInfo dir = new DirectoryInfo(Path.Combine(rootPath, storagePath)); if (isCreate && !dir.Exists) { dir.Create(); } return dir; }
public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) { Dictionary<FolderType, InventoryFolderBase> ff = null; if (m_FolderTypes.TryGetValue(userID, out ff)) { InventoryFolderBase f = null; lock (ff) { if (ff.TryGetValue(type, out f)) return f; } } return null; }
public SharePointProviderInfo(int id, string providerKey, string customerTitle, AuthData authData, Guid owner, FolderType rootFolderType, DateTime createOn) { if (string.IsNullOrEmpty(providerKey)) throw new ArgumentNullException("providerKey"); if (!string.IsNullOrEmpty(authData.Login) && string.IsNullOrEmpty(authData.Password)) throw new ArgumentNullException("password", "Password can't be null"); ID = id; ProviderKey = providerKey; CustomerTitle = customerTitle; Owner = owner == Guid.Empty ? SecurityContext.CurrentAccount.ID : owner; RootFolderType = rootFolderType; CreateOn = createOn; RootFolderId = MakeId(); InitClientContext(authData); }
public void Cache(UUID userID, FolderType type, InventoryFolderBase folder) { Dictionary<FolderType, InventoryFolderBase> ff = null; if (!m_FolderTypes.TryGetValue(userID, out ff)) { ff = new Dictionary<FolderType, InventoryFolderBase>(); m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS); } // We need to lock here since two threads could potentially retrieve the same dictionary // and try to add a folder for that type simultaneously. Dictionary<>.Add() is not described as thread-safe in the SDK // even if the folders are identical. lock (ff) { if (!ff.ContainsKey(type)) ff.Add(type, folder); } }
public SharpBoxProviderInfo(int id, string providerKey, string customerTitle, AuthData authData, Guid owner, FolderType rootFolderType, DateTime createOn) { if (string.IsNullOrEmpty(providerKey)) throw new ArgumentNullException("providerKey"); if (string.IsNullOrEmpty(authData.Token) && string.IsNullOrEmpty(authData.Password)) throw new ArgumentNullException("token", "Both token and password can't be null"); if (!string.IsNullOrEmpty(authData.Login) && string.IsNullOrEmpty(authData.Password) && string.IsNullOrEmpty(authData.Token)) throw new ArgumentNullException("password", "Password can't be null"); ID = id; CustomerTitle = customerTitle; Owner = owner == Guid.Empty ? SecurityContext.CurrentAccount.ID : owner; _providerKey = (nSupportedCloudConfigurations) Enum.Parse(typeof (nSupportedCloudConfigurations), providerKey, true); _authData = authData; _rootFolderType = rootFolderType; _createOn = createOn; }
/// <summary> /// http://apidocs.mailchimp.com/api/2.0/folders/add.php /// </summary> /// <returns></returns> public Task<MailChimpServiceResponse> AddAsync(string name, FolderType type) { var url = Urls.Folder + "/add.json"; var request = new { name = name, type = Enum.GetName(typeof(FolderType), type).ToLowerInvariant() }; return Execute(url, request).ContinueWith(t => { // add an extra level of validation if (t.Result.IsSuccesful) t.Result.IsSuccesful = t.Result.Json["complete"] .ToObject<bool>(); return t.Result; }); }
public static Icon GetFolderIcon(IconSize size, FolderType folderType) { uint num = 272u; if (FolderType.Open == folderType) { num |= 2u; } if (IconSize.Small == size) { num |= 1u; } else { num = num; } Shell32.SHFILEINFO sHFILEINFO = default(Shell32.SHFILEINFO); Shell32.SHGetFileInfo(Environment.CurrentDirectory, 16u, ref sHFILEINFO, (uint)Marshal.SizeOf(sHFILEINFO), num); Icon.FromHandle(sHFILEINFO.hIcon); Icon result = (Icon)Icon.FromHandle(sHFILEINFO.hIcon).Clone(); User32.DestroyIcon(sHFILEINFO.hIcon); return result; }
public static Icon GetFolderIcon(string path, IconSize size, FolderType folderType) { // Need to add size check, although errors generated at present! uint flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) { flags += SHGFI_OPENICON; } if (IconSize.Small == size) { flags += SHGFI_SMALLICON; } else { flags += SHGFI_LARGEICON; } // Get the folder icon var shfi = new SHFILEINFO(); var res = SHGetFileInfo(path, FILE_ATTRIBUTE_DIRECTORY, out shfi, (uint)Marshal.SizeOf(shfi), flags); if (res == IntPtr.Zero) throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); // Load the icon from an HICON handle Icon.FromHandle(shfi.hIcon); // Now clone the icon, so that it can be successfully stored in an ImageList var icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); DestroyIcon(shfi.hIcon); // Cleanup return icon; }
/// <summary> /// Obtains system folder icon</summary> /// <param name="size">Specifies large or small icons</param> /// <param name="folderType">Specifies open or closed FolderType</param> /// <returns>System folder icon</returns> public static Icon GetFolderIcon(IconSize size, FolderType folderType) { // Need to add size check, although errors generated at present! uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) { flags += Shell32.SHGFI_OPENICON; } if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } // Get the folder icon Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); // Flag SHGFI_USEFILEATTRIBUTES prevents SHGetFileInfo() from attempting // to access the path specified by the first argument. However, passing // some sort of non-null string is still required, or the call will fail. Shell32.SHGetFileInfo("C:\\Windows", Shell32.FILE_ATTRIBUTE_DIRECTORY, ref shfi, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags); Icon.FromHandle(shfi.hIcon); // Load the icon from an HICON handle // Now clone the icon, so that it can be successfully stored in an ImageList Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); User32.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
public static Icon ForGenericFolder(IconSize size, FolderType folderType) { // Need to add size check, although errors generated at present! NativeMethods.FileInfoFlags flags = NativeMethods.FileInfoFlags.SHGFI_ICON | NativeMethods.FileInfoFlags.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) flags |= NativeMethods.FileInfoFlags.SHGFI_OPENICON; flags |= (IconSize.Small == size) ? NativeMethods.FileInfoFlags.SHGFI_SMALLICON : NativeMethods.FileInfoFlags.SHGFI_LARGEICON; NativeMethods.SHFILEINFO shfi = new NativeMethods.SHFILEINFO(); NativeMethods.SHGetFileInfo( null, NativeMethods.FILE_ATTRIBUTE_DIRECTORY, out shfi, (uint)Marshal.SizeOf(shfi), flags ); Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); NativeMethods.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
/// <summary> /// Update folder properties /// </summary> /// <param name="folderID"><seealso cref="UUID"/> of the folder to update</param> /// <param name="parentID">Sets folder's parent to <seealso cref="UUID"/></param> /// <param name="name">Folder name</param> /// <param name="type">Folder type</param> public void UpdateFolderProperties(UUID folderID, UUID parentID, string name, FolderType type) { lock (Store) { if (_Store.Contains(folderID)) { InventoryFolder inv = (InventoryFolder)Store[folderID]; inv.Name = name; inv.ParentUUID = parentID; inv.PreferredType = type; _Store.UpdateNodeFor(inv); } } UpdateInventoryFolderPacket invFolder = new UpdateInventoryFolderPacket(); invFolder.AgentData.AgentID = Client.Self.AgentID; invFolder.AgentData.SessionID = Client.Self.SessionID; invFolder.FolderData = new UpdateInventoryFolderPacket.FolderDataBlock[1]; invFolder.FolderData[0] = new UpdateInventoryFolderPacket.FolderDataBlock(); invFolder.FolderData[0].FolderID = folderID; invFolder.FolderData[0].ParentID = parentID; invFolder.FolderData[0].Name = Utils.StringToBytes(name); invFolder.FolderData[0].Type = (sbyte)type; Client.Network.SendPacket(invFolder); }
public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type) { Dictionary<string,object> ret = MakeRequest("GETFOLDERFORTYPE", new Dictionary<string,object> { { "PRINCIPAL", principalID.ToString() }, { "TYPE", ((int)type).ToString() } }); if (!CheckReturn(ret)) return null; return BuildFolder((Dictionary<string, object>)ret["folder"]); }
public IEnumerable<Folder> Search(string text, FolderType folderType) { return TryGetFolderDao().Search(text, folderType); }
/// <summary> /// Return a normal folder icon /// </summary> public static Icon GetFolderIcon(IconSize size, FolderType folderType) { return GetFolderIcon(null, size, folderType); }
/// <summary> /// Retrieve a folder icon with specific path /// </summary> public static Icon GetFolderIcon(string folderPath, IconSize size, FolderType folderType) { FileInfoFlags flags = FileInfoFlags.SHGFI_ICON | FileInfoFlags.SHGFI_USEFILEATTRIBUTES; flags |= (size == IconSize.Small) ? FileInfoFlags.SHGFI_SMALLICON : FileInfoFlags.SHGFI_LARGEICON; if (folderType == FolderType.Opened) { flags |= FileInfoFlags.SHGFI_OPENICON; } ShellFileInfo shellFileInfo = new ShellFileInfo(); SHGetFileInfo(folderPath, FILE_ATTRIBUTE_DIRECTORY, ref shellFileInfo, (uint) Marshal.SizeOf(shellFileInfo), (uint) flags); // Deep copy Icon icon = (Icon) Icon.FromHandle(shellFileInfo.hIcon).Clone(); // Release icon handle DestroyIcon(shellFileInfo.hIcon); return icon; }
/// <summary> /// Constructor /// </summary> /// <param name="itemID">UUID of the folder</param> public InventoryFolder(UUID itemID) : base(itemID) { PreferredType = FolderType.None; Version = 1; DescendentCount = 0; }
/// <summary> /// Construct an InventoryFolder object from a serialization stream /// </summary> public InventoryFolder(SerializationInfo info, StreamingContext ctxt) : base(info, ctxt) { PreferredType = (FolderType)info.GetValue("PreferredType", typeof(FolderType)); Version = (int)info.GetValue("Version", typeof(int)); DescendentCount = (int)info.GetValue("DescendentCount", typeof(int)); }
public IEnumerable<File> Search(String searchText, FolderType folderType) { if (FullTextSearch.SupportModule(FullTextSearch.FileModule)) { var ids = FullTextSearch.Search(FullTextSearch.FileModule.Match(searchText)); using (var dbManager = GetDb()) { return dbManager .ExecuteList(GetFileQuery(Exp.In("id", ids) & Exp.Eq("current_version", true))) .ConvertAll(ToFile) .Where( f => folderType == FolderType.BUNCH ? f.RootFolderType == FolderType.BUNCH : f.RootFolderType == FolderType.USER | f.RootFolderType == FolderType.COMMON) .ToList(); } } else { var keywords = searchText .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Where(k => 3 <= k.Trim().Length) .ToArray(); if (keywords.Length == 0) return Enumerable.Empty<File>(); var q = GetFileQuery(Exp.Eq("f.current_version", true) & BuildLike(new[] { "f.title" }, keywords)); using (var dbManager = GetDb()) { return dbManager .ExecuteList(q) .ConvertAll(ToFile) .Where(f => folderType == FolderType.BUNCH ? f.RootFolderType == FolderType.BUNCH : f.RootFolderType == FolderType.USER | f.RootFolderType == FolderType.COMMON) .ToList(); } } }
public IEnumerable<Folder> Search(string text, FolderType folderType) { if (string.IsNullOrEmpty(text)) return new List<Folder>(); if (FullTextSearch.SupportModule(FullTextSearch.FileModule)) { var ids = FullTextSearch.Search(FullTextSearch.FileFolderModule.Match(text)); using (var dbManager = GetDb()) { return dbManager .ExecuteList(GetFolderQuery(Exp.In("id", ids))) .ConvertAll(ToFolder) .Where( f => folderType == FolderType.BUNCH ? f.RootFolderType == FolderType.BUNCH : f.RootFolderType == FolderType.USER | f.RootFolderType == FolderType.COMMON); } } else { var keywords = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Where(k => 3 <= k.Trim().Length) .ToList(); if (keywords.Count == 0) return new List<Folder>(); var where = Exp.Empty; keywords.ForEach(k => where &= Exp.Like("title", k)); using (var dbManager = GetDb()) { return dbManager .ExecuteList(GetFolderQuery(where)) .ConvertAll(ToFolder) .Where( f => folderType == FolderType.BUNCH ? f.RootFolderType == FolderType.BUNCH : f.RootFolderType == FolderType.USER | f.RootFolderType == FolderType.COMMON); } } }
public IEnumerable<Folder> Search(string text, FolderType folderType) { return null; }
/// <summary> /// Used to access system folder icons. /// </summary> /// <param name="size">Specify large or small icons.</param> /// <param name="folderType">Specify open or closed FolderType.</param> /// <param name="shfi">Return Folder Information</param> /// <returns>System.Drawing.Icon</returns> public static Icon GetFolderIcon(IconSize size, FolderType folderType, ref Shell32.SHFILEINFO shfi) { // Need to add size check, although errors generated at present! Shell32.SHGetFileInfoConstants flags = Shell32.SHGetFileInfoConstants.SHGFI_TYPENAME | Shell32.SHGetFileInfoConstants.SHGFI_DISPLAYNAME | Shell32.SHGetFileInfoConstants.SHGFI_ICON | Shell32.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) flags |= Shell32.SHGetFileInfoConstants.SHGFI_OPENICON; if (IconSize.Small == size) flags |= Shell32.SHGetFileInfoConstants.SHGFI_SMALLICON; else flags |= Shell32.SHGetFileInfoConstants.SHGFI_LARGEICON; IntPtr hIml; // Get the folder icon shfi = new Shell32.SHFILEINFO(); if (IconHelper.Utils.IsSevenOrAbove()) // Windows 7 FIX { hIml = Shell32.SHGetFileInfo(Environment.GetFolderPath(Environment.SpecialFolder.System), Shell32.FILE_ATTRIBUTE.DIRECTORY, ref shfi, (uint)Marshal.SizeOf(shfi), flags); } else { hIml = Shell32.SHGetFileInfo(null, Shell32.FILE_ATTRIBUTE.DIRECTORY, ref shfi, (uint)Marshal.SizeOf(shfi), flags); } if (shfi.hIcon == IntPtr.Zero) return null; if (!IconHelper.Utils.IsXpOrAbove()) return GetManagedIcon(shfi.hIcon); // Get the System IImageList object from the Shell: Guid iidImageList = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950"); Shell32.IImageList iImageList = null; int ret = Shell32.SHGetImageList( (int)size, ref iidImageList, ref iImageList ); // the image list handle is the IUnknown pointer, but // using Marshal.GetIUnknownForObject doesn't return // the right value. It really doesn't hurt to make // a second call to get the handle: Shell32.SHGetImageListHandle((int)size, ref iidImageList, ref hIml); IntPtr hIcon = IntPtr.Zero; if (iImageList == null) { hIcon = Comctl32.ImageList_GetIcon( hIml, shfi.iIcon, (int)Comctl32.ImageListDrawItemConstants.ILD_TRANSPARENT); } else { iImageList.GetIcon( shfi.iIcon, (int)Comctl32.ImageListDrawItemConstants.ILD_TRANSPARENT, ref hIcon); } return hIcon == IntPtr.Zero ? GetManagedIcon(shfi.hIcon) : GetManagedIcon(hIcon); }
private void EmptySystemFolder(FolderType folderType) { List<InventoryBase> items = _Store.GetContents(_Store.RootFolder); UUID folderKey = UUID.Zero; foreach (InventoryBase item in items) { if ((item as InventoryFolder) != null) { InventoryFolder folder = item as InventoryFolder; if (folder.PreferredType == folderType) { folderKey = folder.UUID; break; } } } items = _Store.GetContents(folderKey); List<UUID> remItems = new List<UUID>(); List<UUID> remFolders = new List<UUID>(); foreach (InventoryBase item in items) { if ((item as InventoryFolder) != null) { remFolders.Add(item.UUID); } else { remItems.Add(item.UUID); } } Remove(remItems, remFolders); }