protected override ProjectTreeItem CreateTreeItemForItem(ScriptAndHeader item) { ProjectTree treeController = _guiController.ProjectTree; ProjectTreeItem newItem = (ProjectTreeItem)treeController.AddTreeBranch(this, GetNodeID(item), item.Name, ICON_KEY); newItem.AllowDoubleClickWhenExpanding = true; const string editHeaderText = "Edit Header"; const string editScriptText = "Edit Script"; if (item.Name != Path.GetFileNameWithoutExtension(Script.GLOBAL_HEADER_FILE_NAME)) { newItem.AllowLabelEdit = true; newItem.LabelTextProperty = item.Header.GetType().GetProperty("NameForLabelEdit"); newItem.LabelTextDataSource = item.Header; treeController.AddTreeLeaf(this, GetNodeID(item.Header), editHeaderText, ICON_KEY); treeController.AddTreeLeaf(this, GetNodeID(item.Script), editScriptText, ICON_KEY); } else { treeController.AddTreeLeaf(this, GetNodeID(item.Header), editHeaderText, "MenuIconGlobalHeader"); treeController.AddTreeLeaf(this, GetNodeID(item.Script), editScriptText, "MenuIconGlobalScript"); } return(newItem); }
protected void BindTree() { ProjectTree projectTree = new ProjectTree(); projectTree.BindTreeNodes(this.tvBudget, this.Session["PmSet"], base.UserCode, base.Request["prjId"], this.ddlYear.SelectedItem.Text, this.ddlYear.SelectedValue); TreeNode arg_64_0 = this.tvBudget.Nodes[0]; }
/// <summary> /// Saves the project to another location on disk, leaving the old location intact /// </summary> /// <param name="projectTree">Project to be saved</param> /// <param name="projectFileName">New location</param> /// <returns></returns> public virtual MagitekResult SaveProjectAs(ProjectTree projectTree, string projectFileName) { if (projectTree is null) { throw new InvalidOperationException($"{nameof(SaveProjectAs)} parameter '{nameof(projectTree)}' was null"); } if (string.IsNullOrWhiteSpace(projectFileName)) { throw new ArgumentException($"{nameof(SaveProjectAs)} cannot have a null or empty value for '{nameof(projectFileName)}'"); } try { var serializer = _serializerFactory.CreateWriter(projectTree); var result = serializer.WriteProject(projectFileName); if (result.Value is MagitekResult.Success) { projectTree.Root.DiskLocation = Path.GetFullPath(projectFileName); } return(result); } catch (Exception ex) { return(new MagitekResult.Failed($"Failed to save project: {ex.Message}")); } }
public static ImportResult ImportImage(ProjectTree projectTree, string imageFileName, string arrangerKey) { Console.Write($"Importing '{imageFileName}' to '{arrangerKey}'..."); if (!File.Exists(imageFileName)) { Console.WriteLine($"File does not exist"); return(ImportResult.MissingFile); } if (!projectTree.TryGetItem(arrangerKey, out ScatteredArranger arranger)) { Console.WriteLine($"Resource key does not exist or is not a {nameof(ScatteredArranger)}"); return(ImportResult.BadResourceKey); } if (arranger.ColorType == PixelColorType.Indexed) { var image = new IndexedImage(arranger); image.ImportImage(imageFileName, new ImageSharpFileAdapter(), ColorMatchStrategy.Exact); image.SaveImage(); } else if (arranger.ColorType == PixelColorType.Direct) { var image = new DirectImage(arranger); image.ImportImage(imageFileName, new ImageSharpFileAdapter()); image.SaveImage(); } Console.WriteLine("Completed successfully"); return(ImportResult.Success); }
/// <summary> /// Creates a new project /// </summary> /// <param name="projectFileName">File name for the specified project</param> /// <returns></returns> public virtual MagitekResult <ProjectTree> CreateNewProject(string projectFileName) { if (_projects.Any(x => string.Equals(x.Name, projectFileName, StringComparison.OrdinalIgnoreCase))) { return(new MagitekResult <ProjectTree> .Failed($"{projectFileName} already exists in the solution")); } var projectName = Path.GetFileNameWithoutExtension(projectFileName); var project = new ImageProject(projectName); var root = new ProjectNode(project.Name, project) { DiskLocation = Path.GetFullPath(projectFileName), BaseDirectory = Path.GetDirectoryName(projectFileName) }; var tree = new ProjectTree(root); var contents = _serializerFactory.CreateWriter(tree).SerializeResource(root); File.WriteAllText(root.DiskLocation, contents); _projects.Add(tree); UpdateNodeModel(tree, root); return(new MagitekResult <ProjectTree> .Success(tree)); }
public Editor() { UpdateSerialize(); Instance = this; InitializeComponent(); DataContext = Project = new ProjectTree(); }
public void BindDrop() { ProjectTree projectTree = new ProjectTree(); projectTree.BindDlistYears(this.ddlYear, this.Session["PmSet"], base.UserCode, base.Request["year"]); if (!string.IsNullOrEmpty(base.Request["year"])) { this.ddlYear.SelectedValue = base.Request["year"]; } }
private void Signal_NewModMenuActivated(int index) { var controller = ContentPackController.GetControllerForMod(ContentPackController.GetRegisteredControllerTypes()[index]); var mod = ProjectTree.CreateItem(ProjectRoot); mod.SetText(0, $"[{controller.ModAbbreviation}] {ModProject.Name}"); mod.AddButton(0, RemoveIcon, REMOVE_BUTTON_INDEX, tooltip: "Remove this mod"); mod.SetMeta(Meta.CorrespondingController, controller.ModUniqueId); ModProject.Mods.Add(controller.OnModCreated(this, mod)); }
public void AddChild() { this.Children = this.Children.Add(this.NewNode()); // children must be non-empty for the collection to be used in the node. this.node = this.NewTree(Caption, children: this.Children); var newChild = this.NewNode(); var newNode = this.node.AddChildren(newChild); Assert.Same(this.Children, this.node.Children); Assert.Equal(2, newNode.Children.Count); Assert.Same(newChild, newNode.Children[1]); }
public void BindDrop() { ProjectTree projectTree = new ProjectTree(); projectTree.BindDlistYears(this.ddlYear, this.Session["PmSet"], base.UserCode, base.Request["year"]); this.ddlYear.Items.Add(new ListItem("组织机构", "zzjg")); if (base.Request["year"] != null) { this.ddlYear.SelectedValue = base.Request["year"]; } }
protected void BindTree() { if (this.ddlYear.SelectedValue == "zzjg") { this.BindZZJGTree(); } else { ProjectTree projectTree = new ProjectTree(); projectTree.BindTreeNodes(this.tvBudget, this.Session["PmSet"], base.UserCode, base.Request["id"], this.ddlYear.SelectedItem.Text, this.ddlYear.SelectedValue); } this.tvBudget.ExpandAll(); }
public XmlProjectWriter(ProjectTree tree, IColorFactory colorFactory, IEnumerable <IProjectResource> globalResources) { if (tree is null) { throw new ArgumentNullException($"{nameof(WriteProject)} parameter '{nameof(tree)}' was null"); } _tree = tree; _colorFactory = colorFactory; _globalResources = globalResources.ToList(); _globalDefaultPalette = globalResources.OfType <Palette>().FirstOrDefault(); _baseDirectory = Path.GetDirectoryName(Path.GetFullPath(tree.Root.DiskLocation)); }
/// <summary> /// Generate Tree View /// </summary> private void PopulateTreeView() { var xlApp = new Excel.Application(); var xlWorkbook = OpennessHelper.GetExcelFile(networkListPath, xlApp); foreach (Excel.Worksheet xlWorksheet in xlWorkbook.Worksheets) { string sheetName = xlWorksheet.Name; var matrix = OpennessHelper.ExcelToMatrix(xlWorksheet); if (OpennessHelper.IsNetworkList(matrix)) { Worksheets.Add(sheetName); } } xlWorkbook.Close(0); xlApp.Quit(); var projectTreeView = new TreeView(); foreach (var ws in Worksheets) { TreeViewItem tvi = new TreeViewItem { Tag = ws, Header = new CheckBox() { Content = new TextBlock() { Text = ws }, Tag = ws } }; projectTreeView.Items.Add(tvi); } if (projectTreeView.Items.Count == 0) { TreeViewItem tvi = new TreeViewItem { Header = "Excel does not contain a valid Worksheet" }; projectTreeView.Items.Add(tvi); BtnEnabled = false; } ProjectTree.Refresh(projectTreeView); }
protected void BindTree() { if (this.ddlYear.SelectedValue == "zzjg") { this.BindZZJGTree(); return; } ProjectTree projectTree = new ProjectTree(); projectTree.BindTreeNodes(this.tvBudget, this.Session["PmSet"], base.UserCode, base.Request["prjGuid"], this.ddlYear.SelectedItem.Text, this.ddlYear.SelectedValue); TreeNode treeNode = this.tvBudget.Nodes[0]; this.DisabledBtnAdd(treeNode.ChildNodes.Count); }
public static string Locate(ProjectTree tree, ResourceNode node) { var baseDirectory = (tree.Root as ProjectNode).BaseDirectory; var pathKey = tree.CreatePathKey(node, Path.DirectorySeparatorChar.ToString()).TrimStart(Path.DirectorySeparatorChar); if (node.Item is ResourceFolder) { return(Path.Combine(baseDirectory, pathKey)); } else { return(Path.Combine(baseDirectory, $"{pathKey}.xml")); } }
public static string LocateByParent(ProjectTree tree, ResourceNode parentNode, ResourceNode childNode) { var baseDirectory = (tree.Root as ProjectNode).BaseDirectory; var pathKey = tree.CreatePathKey(parentNode, Path.DirectorySeparatorChar.ToString()).TrimStart(Path.DirectorySeparatorChar); if (childNode is not ResourceFolderNode) { return(Path.Combine(baseDirectory, pathKey, $"{childNode.Name}.xml")); } else { return(Path.Combine(baseDirectory, pathKey, childNode.Name)); } }
private void Signal_TreeButtonPressed(TreeItem item, int column, int id) { if (id == REMOVE_BUTTON_INDEX) { pendingRemoval = item; var confirm = GetNode <ConfirmationDialog>("PendingRemovalDialog"); confirm.PopupCenteredClamped(); } else if (id == ADD_BUTTON_INDEX) { if (item == depsRoot) { Dependency dep; ModProject.Dependencies.Add(dep = new Dependency() { UniqueID = "mod.id" }); var depItem = ProjectTree.CreateItem(depsRoot); depItem.SetText(0, dep.UniqueID); depItem.AddButton(0, RemoveIcon, REMOVE_BUTTON_INDEX, tooltip: "Remove this dependency"); deps.Add(depItem, dep); } else if (item == updateKeysRoot) { UpdateKey updateKey; ModProject.UpdateKeys.Add(updateKey = new UpdateKey() { Platform = "Nexus" }); var updateKeyItem = ProjectTree.CreateItem(updateKeysRoot); updateKeyItem.SetText(0, "Nexus:"); updateKeyItem.AddButton(0, RemoveIcon, REMOVE_BUTTON_INDEX, tooltip: "Remove this update key"); updateKeys.Add(updateKeyItem, updateKey); } else if (item == resourcesRoot) { var import = GetNode <FileDialog>("ResourceImportDialog"); import.PopupCenteredClamped(); } else if (item.GetMeta(Meta.CorrespondingController) != null) { var controller = ContentPackController.GetControllerForMod((string)item.GetParent().GetMeta(Meta.CorrespondingController)); var data = ModProject.Mods.Find(md => md.ContentPackFor == controller.ModUniqueId); controller.OnAdded(this, data, item); } } }
private void gettopprojecttree(HttpContext context) { int CompanyID = 0; int.TryParse(context.Request.Params["CompanyID"], out CompanyID); int MsgID = 0; int.TryParse(context.Request.Params["MsgID"], out MsgID); string ProjectIDs = context.Request["ProjectIDs"]; int UserID = WebUtil.GetUser(context).UserID; int ContactID = WebUtil.GetIntValue(context, "ContactID"); List <int> ProjectIDList = new List <int>(); if (!string.IsNullOrEmpty(ProjectIDs)) { ProjectIDList = JsonConvert.DeserializeObject <List <int> >(ProjectIDs); } var list = ProjectTree.GetProjectTreeListByMsgID(CompanyID, MsgID, UserID).ToArray(); List <Dictionary <string, object> > items = null; items = list.Select(p => { bool ischecked = MsgID != 0 && p.MsgID == MsgID; if (ProjectIDList.Count > 0 && ProjectIDList.Contains(p.ID)) { ischecked = true; } var dic = p.ToJsonObject(); if (p.ID == 1) { var company = Company.GetCompany(CompanyID); dic["name"] = company.CompanyName; } else { dic["name"] = p.Name; } dic["id"] = p.ID; dic["pId"] = p.ParentID; dic["iconSkin"] = "Icon_" + p.IconID; dic["open"] = true; dic["checked"] = ischecked; return(dic); }).ToList(); string result = JsonConvert.SerializeObject(items); context.Response.Write(result); }
/// <summary> /// Closes the specified project that is active in the service and frees associated resources /// </summary> /// <param name="projectTree">Project to be closed</param> public virtual void CloseProject(ProjectTree projectTree) { if (projectTree is null) { throw new InvalidOperationException($"{nameof(CloseProject)} parameter '{nameof(projectTree)}' was null"); } if (_projects.Contains(projectTree)) { foreach (var resource in projectTree.EnumerateBreadthFirst().Select(x => x.Item).OfType <IDisposable>()) { resource.Dispose(); } _projects.Remove(projectTree); } }
private void CreateNewProject(bool loading = false) { if (ProjectRoot != null) { ProjectRoot.GetParent().RemoveChild(ProjectRoot); } if (projectDirWatcher != null) { projectDirWatcher.EnableRaisingEvents = false; projectDirWatcher = null; } if (!loading) { ModProject = new Project(); } ProjectRoot = ProjectTree.CreateItem(); ProjectRoot.SetText(0, "My Project 1.0.0"); ProjectRoot.DisableFolding = true; depsRoot = ProjectTree.CreateItem(ProjectRoot); depsRoot.SetText(0, "Dependencies"); depsRoot.AddButton(0, AddIcon, ADD_BUTTON_INDEX, tooltip: "Add a dependency"); updateKeysRoot = ProjectTree.CreateItem(ProjectRoot); updateKeysRoot.SetText(0, "Update Keys"); updateKeysRoot.AddButton(0, AddIcon, ADD_BUTTON_INDEX, tooltip: "Add an update key"); resourcesRoot = ProjectTree.CreateItem(ProjectRoot); resourcesRoot.SetText(0, "Resources"); resourcesRoot.AddButton(0, AddIcon, ADD_BUTTON_INDEX, tooltip: "Import a resource"); fileMenu.GetPopup().SetItemDisabled(1, false); fileMenu.GetPopup().SetItemDisabled(3, false); fileMenu.GetPopup().SetItemDisabled(6, false); fileMenu.GetPopup().SetItemDisabled(7, false); if (!loading) { SaveProject(); InitFileSystemWatcher(); } }
public MagitekResult AddProject(ImageProjectModel projectModel, string baseDirectory, string projectFileName) { if (Tree?.Root is not null) { return(new MagitekResult.Failed($"Attempted to add a new project '{projectModel?.Name}' to an existing project")); } var root = new ProjectNode(projectModel.Name, projectModel.MapToResource()) { BaseDirectory = baseDirectory, DiskLocation = projectFileName, Model = projectModel }; Tree = new ProjectTree(root); return(MagitekResult.SuccessResult); }
public virtual MagitekResult <ProjectTree> CreateNewProjectWithExistingFile(string projectFileName, string dataFileName) { if (_projects.Any(x => string.Equals(x.Name, projectFileName, StringComparison.OrdinalIgnoreCase))) { return(new MagitekResult <ProjectTree> .Failed($"{projectFileName} already exists in the solution")); } if (File.Exists(projectFileName)) { return(new MagitekResult <ProjectTree> .Failed($"Project file '{projectFileName}' already exists")); } if (!File.Exists(dataFileName)) { return(new MagitekResult <ProjectTree> .Failed($"Data file '{dataFileName}' does not exist")); } var projectName = Path.GetFileNameWithoutExtension(projectFileName); var project = new ImageProject(projectName); var root = new ProjectNode(project.Name, project) { DiskLocation = Path.GetFullPath(projectFileName), BaseDirectory = Path.GetDirectoryName(projectFileName) }; var tree = new ProjectTree(root); var dataFile = new FileDataSource(Path.GetFileNameWithoutExtension(dataFileName), dataFileName); var dataNode = new DataFileNode(dataFile.Name, dataFile); tree.AttachNodeToPath("", dataNode); _projects.Add(tree); var result = SaveProject(tree); if (result.HasSucceeded) { UpdateNodeModel(tree, root); return(new MagitekResult <ProjectTree> .Success(tree)); } else { return(new MagitekResult <ProjectTree> .Failed(result.AsError.Reason)); } }
private void Signal_TreeItemEdited() { var edited = ProjectTree.GetSelected(); if (edited.GetParent() == resourcesRoot) { var oldFilename = resourcesNames[edited]; string newFilename = edited.GetText(0); justRenamedInUi = newFilename; System.IO.File.Move(System.IO.Path.Combine(ModProjectDir, oldFilename), System.IO.Path.Combine(ModProjectDir, newFilename)); resourcesNames[edited] = newFilename; foreach (var mod in ModProject.Mods) { var controller = ContentPackController.GetControllerForMod(mod.ContentPackFor); controller.OnResourceRenamed(this, mod, oldFilename, newFilename); } } }
public static ProjectTree[] GetMyProjectsByLevel(int level, int UserID) { var cache = HttpRuntime.Cache; ProjectTree[] projectlist = null; string self_projectlevellist_key = projectlevellist_key + "_" + UserID; if (cache.Get(self_projectlevellist_key) != null) { projectlist = cache.Get(self_projectlevellist_key) as ProjectTree[]; return(projectlist); } projectlist = ProjectTree.GetProjectTreeListByID(0, string.Empty, UserID, IconID: level).ToArray(); if (projectlist != null) { cache.Insert(self_projectlevellist_key, projectlist); } return(projectlist); }
public static ProjectTree[] GetMyProjectDetailsTree(int UserID) { var cache = HttpRuntime.Cache; ProjectTree[] projectdetailstree = null; string self_projectdetailstree_key = projectdetailstree_key + "_" + UserID; if (cache.Get(self_projectdetailstree_key) != null) { projectdetailstree = cache.Get(self_projectdetailstree_key) as ProjectTree[]; return(projectdetailstree); } projectdetailstree = ProjectTree.GetProjectTreeListByID(0, string.Empty, UserID).ToArray(); if (projectdetailstree != null) { cache.Insert(self_projectdetailstree_key, projectdetailstree); } return(projectdetailstree); }
public void BindDrop() { ProjectTree projectTree = new ProjectTree(); string text = base.Request["prjId"]; this.hfldTreeSelVale.Value = text; string selectedYearValue = string.Empty; if (!string.IsNullOrEmpty(text)) { DataTable projectDate = ProjectInfo.GetProjectDate(text); if (projectDate != null && projectDate.Rows.Count > 0) { object obj = projectDate.Rows[0]["StartDate"]; string value = (obj == null) ? string.Empty : obj.ToString(); selectedYearValue = Convert.ToDateTime(value).Year.ToString(); } } projectTree.BindDlistYears(this.ddlYear, this.Session["PmSet"], base.UserCode, selectedYearValue); }
private void WatchProjectDir_Create(object sender, FileSystemEventArgs e) { var filename = System.IO.Path.GetFileName(e.Name); if (filename == justRenamedInUi) { justRenamedInUi = null; return; } var ext = System.IO.Path.GetExtension(filename); if (ext == ".png" || ext == ".tbin" || ext == ".tmx" || ext == ".json" || ext == ".xnb") { var resItem = ProjectTree.CreateItem(resourcesRoot); resItem.SetText(0, filename); resItem.SetEditable(0, true); resItem.AddButton(0, RemoveIcon, REMOVE_BUTTON_INDEX, tooltip: "Delete this resource"); resourcesNames.Add(resItem, filename); } }
public static bool ExportArranger(ProjectTree projectTree, string arrangerKey, string projectRoot, bool forceOverwrite) { if (!projectTree.TryGetNode(arrangerKey, out var node)) { Console.WriteLine($"Exporting '{arrangerKey}'...Resource key not found in project"); return(false); } var relativeFile = Path.Combine(projectTree.CreatePaths(node).ToArray()); var exportFileName = Path.Combine(projectRoot, $"{relativeFile}.png"); var arranger = node.Item as ScatteredArranger; Console.Write($"Exporting '{arrangerKey}' to '{exportFileName}'..."); if (!Directory.Exists(Path.GetDirectoryName(exportFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(exportFileName)); } if (File.Exists(exportFileName) && forceOverwrite == false) { Console.WriteLine($"File already exists and was skipped to not overwrite it"); return(false); } if (arranger.ColorType == PixelColorType.Indexed) { var image = new IndexedImage(arranger); image.ExportImage(exportFileName, new ImageSharpFileAdapter()); } else if (arranger.ColorType == PixelColorType.Direct) { var image = new DirectImage(arranger); image.ExportImage(exportFileName, new ImageSharpFileAdapter()); } Console.WriteLine("Completed successfully"); return(true); }
/// <summary> /// Saves the project /// </summary> /// <param name="projectTree">Project to be saved</param> /// <returns></returns> public virtual MagitekResult SaveProject(ProjectTree projectTree) { if (projectTree is null) { throw new InvalidOperationException($"{nameof(SaveProject)} parameter '{nameof(projectTree)}' was null"); } string projectFileLocation = projectTree.Root.DiskLocation; if (string.IsNullOrWhiteSpace(projectFileLocation)) { throw new InvalidOperationException($"{nameof(SaveProject)} cannot have a null or empty value for the project's file location"); } try { var writer = _serializerFactory.CreateWriter(projectTree); return(writer.WriteProject(projectFileLocation)); } catch (Exception ex) { return(new MagitekResult.Failed($"Failed to save project: {ex.Message}")); } }
private void ShowProjectContextMenu(MouseEventArgs e) { var p = new Point(e.X, e.Y); TreeNode selectedNode = ProjectTree.GetNodeAt(p); if (selectedNode == null) { return; } ProjectTree.SelectedNode = selectedNode; var currentElement = (Element)selectedNode.Tag; IList <Type> childTypes = Engine.GetChildTypes(currentElement.GetType()); ProjectContextMenu.Items.Clear(); var addNewLabel = new ToolStripLabel("Elements:") { Font = BoldFont.Font }; ProjectContextMenu.Items.Add(addNewLabel); foreach (Type childType in childTypes) { bool allowNew = true; var allowMultipleAttrib = childType.GetAttribute <AllowMultipleAttribute>(); if (allowMultipleAttrib != null && allowMultipleAttrib.Allow == false) { foreach (Element childElement in currentElement.AllChildren) { if (childElement.GetType() == childType) { allowNew = false; break; } } } string itemText = string.Format("Add {0}", childType.GetElementName()); var item = new ToolStripMenuItem(itemText) { Tag = childType }; item.Click += NewElement_Click; item.Enabled = allowNew; item.Image = childType.GetElementIcon(); if (allowNew) { } else { item.ToolTipText = "Only one instance of this item is allowed"; } ProjectContextMenu.Items.Add(item); } var separator1 = new ToolStripSeparator(); ProjectContextMenu.Items.Add(separator1); var verbLabel = new ToolStripLabel("Verbs:") { Font = BoldFont.Font }; ProjectContextMenu.Items.Add(verbLabel); List <MethodInfo> elementVerbs = currentElement.GetType().GetElementVerbs(); foreach (MethodInfo method in elementVerbs) { string verbName = method.GetVerbName(); var item = new ToolStripMenuItem(verbName) { Tag = method }; item.Click += ElementVerb_Click; ProjectContextMenu.Items.Add(item); } ProjectContextMenu.Show(ProjectTree, e.Location); }
public ProjectTree CloneProjectTreeLeafToRoot(ProjectTree templateTree) { var clone = ProjectTree.Create(templateTree.Caption).AddChildren(templateTree.Children.Select(this.CloneProjectTreeLeafToRoot)); return clone; }
private static RootedProjectTree RecursiveAddChildren(ProjectTree template, RootedProjectTree receiver) { RootedProjectTree latest = receiver; foreach (var templateChild in template) { var clonedTemplateChild = ProjectTree.Create(templateChild.Caption); var asChild = latest.AddChild(clonedTemplateChild).Value; var childWithChildren = RecursiveAddChildren(templateChild, asChild); latest = childWithChildren.Parent; } return latest; }
private static void RecursiveAddChildren(ProjectTree template, ProjectTree.Builder receiver) { foreach (var templateChild in template) { var clonedTemplateChild = ProjectTree.Create(templateChild.Caption).ToBuilder(); RecursiveAddChildren(templateChild, clonedTemplateChild); receiver.Children.Add(clonedTemplateChild.ToImmutable()); } }
internal ProjectTree NewTree(string caption, ProjectTree singleChild) { return this.NewTree(caption, new[] { singleChild }); }
private void GetProjectOrderNumberTree(HttpContext context) { int CompanyID = 0; int.TryParse(context.Request.Params["CompanyID"], out CompanyID); int ID = 0; int.TryParse(context.Request.Params["ID"], out ID); string Keywords = context.Request.Params["Keywords"]; int OrderNumberID = 0; int.TryParse(context.Request.Params["OrderNumberID"], out OrderNumberID); int Level = 0; int.TryParse(context.Request.Params["Level"], out Level); if (Level <= 0) { Level = 2; } int UserID = WebUtil.GetUser(context).UserID; ProjectTree[] list = ProjectTree.GetProjectTreeListByOrderNumberID(ID, Keywords, OrderNumberID, Level, UserID).ToArray(); List <Dictionary <string, object> > items = null; if (string.IsNullOrEmpty(Keywords)) { items = list.Select(p => { var dic = p.ToJsonObject(); if (p.ID == 1) { var company = Company.GetCompany(CompanyID); dic["name"] = company.CompanyName; } else { dic["name"] = p.Name; } dic["id"] = p.ID; dic["pId"] = p.ParentID; dic["iconSkin"] = "Icon_" + p.IconID; dic["open"] = true; dic["checked"] = OrderNumberID != 0 && p.OrderNumberID == OrderNumberID; if (p.IconID == Level) { dic["isParent"] = false; } return(dic); }).ToList(); } else { items = list.Select(p => { var dic = p.ToJsonObject(); if (p.ID == 1) { var company = Company.GetCompany(CompanyID); dic["name"] = company.CompanyName; } else { dic["name"] = p.FullName + p.Name; } dic["id"] = p.ID; dic["pId"] = p.ParentID; dic["iconSkin"] = "Icon_" + p.IconID; dic["open"] = true; dic["checked"] = OrderNumberID != 0 && p.OrderNumberID == OrderNumberID; if (p.IconID == Level) { dic["isParent"] = false; } return(dic); }).ToList(); } string result = JsonConvert.SerializeObject(items); context.Response.Write(result); }
public void ImmutableNodeConstructorTest() { this.Children = this.Children.Add(this.NewNode()); // children must be non-empty for the collection to be used in the node. this.node = (ProjectTree)this.NewTree(Caption, children: this.Children); Assert.Same(Caption, this.node.Caption); Assert.Same(Children, this.node.Children); }
public UnattachedProjectTreeNodeTest2() { this.node = (ProjectTree)this.NewTree(Caption, children: this.Children); }
public void ReplaceNodeWithChildrenAndChangeIdentity() { var grandchild = this.NewTree("grandchild"); var child = this.NewTree("child", new[] { grandchild }); this.node = this.node.AddChildren(child); // Ensure we exercise our lookup table update code by filling the tree with enough nodes. for (int i = 0; i < RecursiveTypeExtensions.InefficiencyLoadThreshold; i++) { this.node = this.node.AddChildren(this.NewTree("child " + i)); } // Verify that we can find the interesting child. var spine = this.node.GetSpine(child.Identity); Assert.Same(this.node, spine.Peek()); Assert.Same(child, spine.Pop().Peek()); // Now replace the child with one of a different identity. var newChild = this.NewTree("newChild", child.Children); this.node = this.node.ReplaceDescendent(child, newChild); spine = this.node.GetSpine(newChild.Identity); Assert.Same(this.node, spine.Peek()); Assert.Same(newChild, spine.Last()); spine = this.node.GetSpine(grandchild.Identity); Assert.Same(this.node, spine.Peek()); Assert.Same(newChild, spine.Pop().Peek()); Assert.Same(grandchild, spine.Last()); }