public void Execute(Stream stream) { var p = "/"; foreach (var f in ParentFolder.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)) { folderService.Create(f, p); p += p == "/" ? f: "/" + f; } var xmlDoc = new XmlDocument(); using (StreamReader reader = new StreamReader(stream)) xmlDoc.Load(reader); var root = xmlDoc.FirstChild.NextSibling; foreach (var childParser in ChildParsers) { childParser.Root = this; childParser.Parent = null; childParser.ParentPath = ParentFolder; if (childParser is IParserPathable) { ((IParserPathable)childParser).RootPath = RootPath; } childParser.Execute(root); } }
private void OpenFolder() { BeFolderOpen = !BeFolderOpen; int flag = BeFolderOpen ? -1 : 1; TreeItem item = null; for (int i = 0; i < SubItemNums; i++) { item = ItemList [i]; if (BeFolderOpen) { item.gameObject.SetActive(true); } else { item.gameObject.SetActive(false); } //显示(隐藏)子项,这里没必要计算,显示和隐藏不会改变子Item相对于父Folder的相对位置 //float _h = ((i + 1) * FolderH)*flag; //item.ChangeY(_h); } //计算增长缩小高度 float h = this.CurSubItemH * flag; //通知父文件夹排序 if (!BeRootFolder) { ParentFolder.ParentYOrder(h, IndexInParentFolder); } }
public virtual void RefreshType() { var videos = SubItems.View.OfType <FolderViewModel <TFileViewModel> >().Any(x => x.FolderType == FolderType.Video) || SubItems.View.OfType <TFileViewModel>().Any(x => x.FileType == FileType.Video); var sounds = SubItems.View.OfType <FolderViewModel <TFileViewModel> >().Any(x => x.FolderType == FolderType.Sound) || SubItems.View.OfType <TFileViewModel>().Any(x => x.FileType == FileType.Sound); if (videos && sounds) { FolderType = FolderType.Mixed; } else if (sounds) { FolderType = FolderType.Sound; } else if (videos) { FolderType = FolderType.Video; } else { FolderType = FolderType.Other; } ParentFolder?.RefreshType(); }
/// <summary> /// Dissociate child folder from this (parent) folder, changes will be saved immediately /// </summary> public void RemoveChildFolder(PSTFolder childFolder) { TableContext hierarchyTable = GetHierarchyTable(); int rowIndex = hierarchyTable.GetRowIndex(childFolder.NodeID.Value); if (rowIndex >= 0) { if (this.ChildFolderCount == 1) { PropertyContext pc = this.PC; pc.SetBooleanProperty(PropertyID.PidTagSubfolders, false); pc.SaveChanges(NodeID); // update hierarchy table of parent (set PidTagSubfolders of current folder to false): TableContext parentHierarchyTable = ParentFolder.GetHierarchyTable(); int rowIndexOfFolder = parentHierarchyTable.GetRowIndex(NodeID.Value); parentHierarchyTable.SetBooleanProperty(rowIndexOfFolder, PropertyID.PidTagSubfolders, false); parentHierarchyTable.SaveChanges(ParentFolder.GetHierarchyTableNodeID()); } hierarchyTable.DeleteRow(rowIndex); hierarchyTable.SaveChanges(GetHierarchyTableNodeID()); } }
public void RefreshItemNum() { StringBuilder sb = new StringBuilder(); sb.Append(Name); sb.Append('('); sb.Append(SubAllItemNums); sb.Append(')'); ItemNameText.text = sb.ToString(); ItemNameText.fontSize = UIEnum.FontSize; var textRt = ItemNameText.gameObject.GetComponent <RectTransform>(); float w = Tools.GetStringW(ItemNameText.text, UIEnum.FontSize); textRt.sizeDelta = new Vector2(w, UIEnum.ItmeH); //重新设置下Folder的边框宽度 float w1 = UIEnum.FolderBtnW + UIEnum.FolderImageW + w; _RectTransform.sizeDelta = new Vector2(w1, UIEnum.FolderH); if (!BeRootFolder) { ParentFolder.RefreshItemNum(); } }
public virtual void Release() { Reg(false); if (ParentFolder != null) { ParentFolder.Remove(this); } }
internal void NotifyItemAddedToFolder(object sender, SolutionItemChangeEventArgs e, bool newToSolution) { if (ParentFolder != null) { ParentFolder.NotifyItemAddedToFolder(sender, e, newToSolution); } else if (ParentSolution != null && newToSolution) { ParentSolution.OnSolutionItemAdded(e); } DescendantItemAdded?.Invoke(sender, e); }
internal void NotifyItemRemovedFromFolder(object sender, SolutionItemChangeEventArgs e, bool removedFromSolution) { DescendantItemRemoved?.Invoke(sender, e); if (ParentFolder != null) { ParentFolder.NotifyItemRemovedFromFolder(sender, e, removedFromSolution); } else if (ParentSolution != null && removedFromSolution) { ParentSolution.OnSolutionItemRemoved(e); } }
private static Shell32.IContextMenu GetContextMenuObject(params string[] PathArray) { if (PathArray.Count() > 1) { ShellItem[] Items = PathArray.Select((Path) => new ShellItem(Path)).ToArray(); ShellFolder[] ParentFolders = Items.Select((Item) => Item.Parent).ToArray(); try { if (ParentFolders.Skip(1).All((Folder) => Folder == ParentFolders[0])) { return(ParentFolders[0].GetChildrenUIObjects <Shell32.IContextMenu>(null, Items)); } else { throw new ArgumentException("All items must have the same parent"); } } finally { Array.ForEach(Items, (It) => It.Dispose()); Array.ForEach(ParentFolders, (It) => It.Dispose()); } } else { using (ShellItem Item = new ShellItem(PathArray.First())) { if (Item is ShellFolder Folder) { return(Folder.IShellFolder.CreateViewObject <Shell32.IContextMenu>(HWND.NULL)); } else { if (Item.Parent is ShellFolder ParentFolder) { try { return(ParentFolder.GetChildrenUIObjects <Shell32.IContextMenu>(null, Item)); } finally { ParentFolder?.Dispose(); } } else { return(Item.GetHandler <Shell32.IContextMenu>(Shell32.BHID.BHID_SFUIObject)); } } } } }
public override XmlElement Export(XmlDocument doc, XmlElement parent) { XmlElement current = base.Export(doc, parent); if (JobName != null) { current.SetAttribute("JOBNAME", JobName.ToString()); } if (ParentFolder != null) { current.SetAttribute("PARENT_FOLDER", ParentFolder.ToString()); } return(current); }
public string GetFullFolderName(string delimiter = ".") { var folderName = string.Empty; if (ParentFolder != null) { folderName += ParentFolder.GetFullFolderName(delimiter) + delimiter + Name; } else { folderName += Name; } return(folderName); }
private void DelFolder() { //TODO 这里还要Folder中所有的item OKDialog.Open( delegate() { //先做删除文件夹后的排序 ParentFolder.ParentYOrder(CurFolderH, IndexInParentFolder); //然后把folder从父类ListItem中去掉 ParentFolder.ItemList.Remove(this); //再删除folder节点 Destroy(gameObject); }, "确定删除文件夹?" ); }
/// <summary> /// 重要方法,用于向上一级文件夹汇报H变换 /// h为正式变大,h为负为变小 /// /// 描述下具体逻辑 /// 当一个item(folder)要发生变化(被删除,折叠,打开折叠,剪切) /// 要通知上一级folder,把自己在上一级folder中的序号和要改变的h的大小通知上一级MenuListItem.ChildYReport /// /// 上一级folder中的进一步处理MenuListFolder.ParentYOrder /// 拿到子item传来的消息后,先判断子Item的Index是不是自己folder中所有Item中的最后一个 /// 如果不是,那么从这个index往后的所有控件(Item)都要执行一次位置移动 /// /// </summary> public void ParentYOrder(float h, int index) { for (int i = index + 1; i < SubItemNums; i++) { ItemList [i].ChangeY(h); } if (BeRootFolder) //如果已经执行到根部,就不要再向上传递了 { return; } else { ParentFolder.ParentYOrder(h, IndexInParentFolder); } }
public override void SaveChanges() { if (m_contentCount.HasValue) { TableContext parentHierarchyTable = ParentFolder.GetHierarchyTable(); int rowIndexOfFolder = parentHierarchyTable.GetRowIndex(NodeID.Value); parentHierarchyTable.SetInt32Property(rowIndexOfFolder, PropertyID.PidTagContentCount, m_contentCount.Value); parentHierarchyTable.SaveChanges(ParentFolder.GetHierarchyTableNodeID()); } if (m_contentsTable != null) { m_contentsTable.SaveChanges(GetContentsTableNodeID()); } base.SaveChanges(); }
/// <summary> /// Changes will be saved immediately /// </summary> public PSTFolder CreateChildFolder(string folderName, FolderItemTypeName folderItemType) { PSTFolder childFolder = CreateNewFolder(this.File, folderName, folderItemType, this.NodeID); PropertyContext pc = this.PC; if (!pc.GetBooleanProperty(PropertyID.PidTagSubfolders).Value) { pc.SetBooleanProperty(PropertyID.PidTagSubfolders, true); pc.SaveChanges(NodeID); } // update hierarchy table of parent (set PidTagSubfolders of current folder to true): TableContext parentHierarchyTable = ParentFolder.GetHierarchyTable(); int rowIndexOfFolder = parentHierarchyTable.GetRowIndex(NodeID.Value); if (!parentHierarchyTable.GetBooleanProperty(rowIndexOfFolder, PropertyID.PidTagSubfolders).Value) { parentHierarchyTable.SetBooleanProperty(rowIndexOfFolder, PropertyID.PidTagSubfolders, true); parentHierarchyTable.SaveChanges(ParentFolder.GetHierarchyTableNodeID()); } // update hierarchy table: TableContext hierarchyTable = GetHierarchyTable(); hierarchyTable.AddRow(childFolder.NodeID.Value); int rowIndex = hierarchyTable.RowCount - 1; // Template properties (assured to be present) hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagContentCount, 0); hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagContentUnreadCount, 0); hierarchyTable.SetBooleanProperty(rowIndex, PropertyID.PidTagSubfolders, false); hierarchyTable.SetStringProperty(rowIndex, PropertyID.PidTagDisplayName, folderName); hierarchyTable.SetStringProperty(rowIndex, PropertyID.PidTagContainerClass, GetContainerClass(folderItemType)); hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagLtpRowId, (int)childFolder.NodeID.Value); // PidTagLtpRowVer uses dwUnique int rowVersion = (int)File.Header.AllocateNextUniqueID(); hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagLtpRowVer, rowVersion); hierarchyTable.SaveChanges(GetHierarchyTableNodeID()); this.File.SearchManagementQueue.AddFolder(childFolder.NodeID, this.NodeID); return(childFolder); }
public virtual DynamicContentFolder ToModel(DynamicContentFolder folder) { if (folder == null) { throw new NullReferenceException(nameof(folder)); } folder.Id = Id; folder.CreatedBy = CreatedBy; folder.CreatedDate = CreatedDate; folder.Description = Description; folder.ModifiedBy = ModifiedBy; folder.ModifiedDate = ModifiedDate; folder.Name = Name; folder.ParentFolderId = ParentFolderId; if (ParentFolder != null) { folder.ParentFolder = ParentFolder.ToModel(AbstractTypeFactory <DynamicContentFolder> .TryCreateInstance()); } return(folder); }
private bool ValidateFolderName(string foldername) { foldername = foldername.Trim(); if (string.IsNullOrWhiteSpace(foldername)) { MessageBox.Show(this, "The name cannot be empty.", "Validation"); return(false); } if (!FileHelper.IsValidDirectoryName(foldername)) { MessageBox.Show(this, "The name contains invalid characters.", "Validation"); return(false); } if (ParentFolder.ContainsEntryName(foldername)) { MessageBox.Show(this, "An entry with the same name already exist.", "Validation"); return(false); } return(true); }
public void Create() { if (wizardProvider.HasWizard) { wizardProvider.BeforeProjectIsCreated(); } if (!CreateProject()) { return; } Solution parentSolution = null; if (ParentFolder == null) { //NOTE: we can only create one solution, so if the first item is a solution, it's the only item parentSolution = processedTemplate.WorkspaceItems.FirstOrDefault() as Solution; if (parentSolution != null) { if (parentSolution.RootFolder.Items.Count > 0) { currentEntries = new List <SolutionItem> (parentSolution.GetAllSolutionItems()); } ParentFolder = parentSolution.RootFolder; } } else { parentSolution = ParentFolder.ParentSolution; currentEntries = processedTemplate.WorkspaceItems.OfType <SolutionItem> ().ToList(); } // New combines (not added to parent combines) already have the project as child. if (!projectConfiguration.CreateSolution) { // Make sure the new item is saved before adding. In this way the // version control add-in will be able to put it under version control. foreach (SolutionItem currentEntry in currentEntries) { var eitem = currentEntry as SolutionEntityItem; if (eitem != null) { // Inherit the file format from the solution eitem.FileFormat = ParentFolder.ParentSolution.FileFormat; // Remove any references to other projects and add them back after the // project is saved because a project reference cannot be resolved until // the project has a parent solution. List <ProjectReference> projectReferences = GetProjectReferences(eitem); if (projectReferences.Any()) { eitem.Items.RemoveRange(projectReferences); } IdeApp.ProjectOperations.Save(eitem); if (projectReferences.Any()) { eitem.Items.AddRange(projectReferences); } } ParentFolder.AddItem(currentEntry, true); } } if (ParentFolder != null) { IdeApp.ProjectOperations.Save(ParentFolder.ParentSolution); } else { IdeApp.ProjectOperations.Save(processedTemplate.WorkspaceItems); } CreateVersionControlItems(); if (OpenSolution) { DisposeExistingNewItems(); TemplateWizard wizard = wizardProvider.CurrentWizard; var op = OpenCreatedSolution(processedTemplate); op.Completed += delegate { if (op.Success) { var sol = IdeApp.Workspace.GetAllSolutions().FirstOrDefault(); if (sol != null) { if (wizard != null) { wizard.ItemsCreated(new [] { sol }); } InstallProjectTemplatePackages(sol); } } }; } else { // The item is not a solution being opened, so it is going to be added to // an existing item. In this case, it must not be disposed by the dialog. disposeNewItem = false; RunTemplateActions(processedTemplate); if (wizardProvider.HasWizard) { wizardProvider.CurrentWizard.ItemsCreated(processedTemplate.WorkspaceItems); } if (ParentFolder != null) { InstallProjectTemplatePackages(ParentFolder.ParentSolution); } } IsNewItemCreated = true; UpdateDefaultSettings(); dialog.CloseDialog(); wizardProvider.Dispose(); imageProvider.Dispose(); }
public async Task Create() { Runtime.AssertMainThread(); OnProjectCreating(); projectCreated = new TaskCompletionSource <bool> (); if (wizardProvider.HasWizard) { wizardProvider.BeforeProjectIsCreated(); } if (!await CreateProject()) { projectCreated.SetResult(false); OnProjectCreationFailed(); return; } Solution parentSolution = null; if (ParentFolder == null) { //NOTE: we can only create one solution, so if the first item is a solution, it's the only item parentSolution = processedTemplate.WorkspaceItems.FirstOrDefault() as Solution; if (parentSolution != null) { if (parentSolution.RootFolder.Items.Count > 0) { currentEntries = new List <SolutionItem> (parentSolution.GetAllSolutionItems()); } ParentFolder = parentSolution.RootFolder; } } else { parentSolution = ParentFolder.ParentSolution; currentEntries = processedTemplate.WorkspaceItems.OfType <SolutionItem> ().ToList(); } // New combines (not added to parent combines) already have the project as child. if (!projectConfiguration.CreateSolution) { // Make sure the new item is saved before adding. In this way the // version control add-in will be able to put it under version control. foreach (SolutionItem currentEntry in currentEntries) { var eitem = currentEntry as SolutionItem; if (eitem != null) { // Inherit the file format from the solution eitem.ConvertToFormat(ParentFolder.ParentSolution.FileFormat); var project = eitem as Project; if (project != null) { // Remove any references to other projects and add them back after the // project is saved because a project reference cannot be resolved until // the project has a parent solution. List <ProjectReference> projectReferences = GetProjectReferences(project); if (projectReferences.Any()) { project.Items.RemoveRange(projectReferences); } await IdeApp.ProjectOperations.SaveAsync(eitem); if (projectReferences.Any()) { project.Items.AddRange(projectReferences); } } } ParentFolder.AddItem(currentEntry, true); } } else { string solutionFileName = Path.Combine(projectConfiguration.SolutionLocation, finalConfigurationPage.SolutionFileName); if (File.Exists(solutionFileName)) { if (!MessageService.Confirm(GettextCatalog.GetString("File {0} already exists. Overwrite?", solutionFileName), AlertButton.OverwriteFile)) { ParentFolder = null; //Reset process of creating solution projectCreated.SetResult(false); return; } File.Delete(solutionFileName); } } dialog.CloseDialog(); try { if (ParentFolder != null) { await IdeApp.ProjectOperations.SaveAsync(ParentFolder.ParentSolution); } else { await IdeApp.ProjectOperations.SaveAsync(processedTemplate.WorkspaceItems); } CreateVersionControlItems(); if (OpenSolution) { DisposeExistingNewItems(); TemplateWizard wizard = wizardProvider.CurrentWizard; if (await OpenCreatedSolution(processedTemplate)) { var sol = IdeApp.Workspace.GetAllSolutions().FirstOrDefault(); if (sol != null) { if (wizard != null) { wizard.ItemsCreated(new [] { sol }); } InstallProjectTemplatePackages(sol); } } } else { // The item is not a solution being opened, so it is going to be added to // an existing item. In this case, it must not be disposed by the dialog. RunTemplateActions(processedTemplate); if (wizardProvider.HasWizard) { wizardProvider.CurrentWizard.ItemsCreated(processedTemplate.WorkspaceItems); } if (ParentFolder != null) { InstallProjectTemplatePackages(ParentFolder.ParentSolution); } } wizardProvider.Dispose(); IsNewItemCreated = true; UpdateDefaultSettings(); projectCreated.SetResult(true); OnProjectCreated(); } catch (Exception ex) { projectCreated.SetException(ex); throw; } }
/// <summary> /// Prepare the result string value by template and custom tags /// </summary> public string ToString(Dictionary <string, string> CustomTags) { var clientContext = this.Item.Context; Dictionary <string, string> CustomTagsInternalDictionary = CustomTags; string CheckTag = null; bool NeedLoading = false; Web oWeb = this.Item.ParentList.ParentWeb; if (!oWeb.IsObjectPropertyInstantiated("Url") || !oWeb.IsObjectPropertyInstantiated("ServerRelativeUrl") || !oWeb.IsObjectPropertyInstantiated("Language")) { clientContext.Load(oWeb, web => web.Url, web => web.ServerRelativeUrl, web => web.Language ); NeedLoading = true; } if (!this.Item.ParentList.IsObjectPropertyInstantiated("DefaultDisplayFormUrl") || !this.Item.ParentList.IsObjectPropertyInstantiated("Fields")) { clientContext.Load(this.Item.ParentList, list => list.DefaultDisplayFormUrl, list => list.Fields ); NeedLoading = true; } this.ParentFolders.ForEach(ParentFolder => { if (!ParentFolder.IsObjectPropertyInstantiated("ListItemAllFields")) { clientContext.Load(ParentFolder, folder => folder.ListItemAllFields ); NeedLoading = true; } }); if (NeedLoading) { clientContext.ExecuteQuery(); } CheckTag = null; CustomTagsInternalDictionary.TryGetValue("/{Url}", out CheckTag); if (String.IsNullOrEmpty(CheckTag)) { CustomTagsInternalDictionary.Add("/{Url}", oWeb.Url.Replace(oWeb.ServerRelativeUrl, "") + this.Item.ParentList.DefaultDisplayFormUrl + "?ID=" + this.Item.Id); } CheckTag = null; CustomTagsInternalDictionary.TryGetValue("{Url}", out CheckTag); if (String.IsNullOrEmpty(CheckTag)) { CustomTagsInternalDictionary.Add("{Url}", oWeb.Url.Replace(oWeb.ServerRelativeUrl, "") + this.Item.ParentList.DefaultDisplayFormUrl + "?ID=" + this.Item.Id); } var InTemplate = ""; foreach (KeyValuePair <string, string> CustomTag in CustomTagsInternalDictionary) { string Tag = CustomTag.Key; string Value = CustomTag.Value; //processing text InTemplate = this.Template.Replace(Tag, Value); //processing html if (IsHtml) { Tag = Tag.Replace("{", "{"); Tag = Tag.Replace("}", "}"); Tag = Tag.Replace(":", ":"); InTemplate = InTemplate.Replace(Tag, Value); } } //processing text InTemplate = ProcessingInternalNameTags(InTemplate, StartString, EndString, PropertySeparator); //processing html InTemplate = ProcessingInternalNameTags(InTemplate, "{", "}", ":"); return(InTemplate); }