/// <summary> /// Constructor. Generates several Groups of Tasks from an xml document. /// </summary> /// <param name="ATaskGroups"></param> /// <param name="ATaskAppearance" >Initial appearance of the Tasks.</param> public TLstTasks(XmlNode ATaskGroups, TaskAppearance ATaskAppearance) { this.SuspendLayout(); this.Name = "lstTasks" + ATaskGroups.Name; this.AutoScroll = true; // this.HorizontalScroll.Enabled = true; this.Resize += new EventHandler(ListResize); XmlNode TaskGroupNode = ATaskGroups.FirstChild; while (TaskGroupNode != null) { if (TaskGroupNode.Name == "SearchBoxes") { // TODO Search boxes } else { TUcoTaskGroup TaskGroup = new TUcoTaskGroup(); TaskGroup.GroupTitle = TLstFolderNavigation.GetLabel(TaskGroupNode); TaskGroup.Name = TaskGroupNode.Name; TIconCache.TIconSize IconSize = ATaskAppearance == TaskAppearance.staLargeTile ? TIconCache.TIconSize.is32by32 : TIconCache.TIconSize.is16by16; Groups.Add(TaskGroup.Name, TaskGroup); if (TaskGroupNode.FirstChild == null) { // duplicate group node into task; otherwise you would not notice the error in the yml file? TUcoSingleTask SingleTask = new TUcoSingleTask(); SingleTask.TaskTitle = TLstFolderNavigation.GetLabel(TaskGroupNode); SingleTask.TaskDescription = TYml2Xml.HasAttribute(TaskGroupNode, "Description") ? Catalog.GetString(TYml2Xml.GetAttribute(TaskGroupNode, "Description")) : ""; SingleTask.Name = TaskGroupNode.Name; SingleTask.TaskGroup = TaskGroup; SingleTask.Tag = TaskGroupNode; SingleTask.TaskAppearance = ATaskAppearance; SingleTask.TaskImagePath = DetermineIconForTask(TaskGroupNode); SingleTask.TaskImage = TIconCache.IconCache.AddOrGetExistingIcon( SingleTask.TaskImagePath, IconSize); SingleTask.RequestForDifferentIconSize += new TRequestForDifferentIconSize(SingleTask_RequestForDifferentIconSize); if (!FHasAccessPermission(TaskGroupNode, FUserId, false)) { SingleTask.Enabled = false; } TaskGroup.Add(SingleTask.Name, SingleTask); } else { XmlNode TaskNode = TaskGroupNode.FirstChild; while (TaskNode != null) { try { // this item should only be displayed if Tax Deductible Percentage is enable if (TaskNode.Name == "RecipientTaxDeductiblePercentages") { if (!FTaxDeductiblePercentageEnabled) { continue; } } TUcoSingleTask SingleTask = new TUcoSingleTask(); SingleTask.TaskTitle = TLstFolderNavigation.GetLabel(TaskNode); SingleTask.TaskDescription = TYml2Xml.HasAttribute(TaskNode, "Description") ? Catalog.GetString(TYml2Xml.GetAttribute(TaskNode, "Description")) : ""; SingleTask.Name = TaskNode.Name; SingleTask.TaskGroup = TaskGroup; SingleTask.Tag = TaskNode; SingleTask.TaskAppearance = ATaskAppearance; SingleTask.TaskImagePath = DetermineIconForTask(TaskNode); SingleTask.TaskImage = TIconCache.IconCache.AddOrGetExistingIcon( SingleTask.TaskImagePath, IconSize); SingleTask.RequestForDifferentIconSize += new TRequestForDifferentIconSize(SingleTask_RequestForDifferentIconSize); if (TTaskList.IsDisabled(TaskNode) || !FHasAccessPermission(TaskNode, FUserId, false)) { SingleTask.Enabled = false; } TaskGroup.Add(SingleTask.Name, SingleTask); } finally { TaskNode = TaskNode.NextSibling; } } } // Add TaskGroup to this UserControls' Controls TaskGroup.Dock = DockStyle.Top; TaskGroup.Margin = new Padding(3); TaskGroup.AutoSize = true; TaskGroup.AutoSizeMode = AutoSizeMode.GrowAndShrink; TaskGroup.TaskClicked += new EventHandler(SingleTask_ExecuteTask); TaskGroup.TaskSelected += new EventHandler(SingleTask_TaskSelected); this.Controls.Add(TaskGroup); // Make sure Task Groups are shown in correct order and not in reverse order. // (This is needed because we 'stack them up' with 'TaskGroup.Dock = DockStyle.Top') TaskGroup.BringToFront(); } TaskGroupNode = TaskGroupNode.NextSibling; } this.ResumeLayout(); }
private Image SingleTask_RequestForDifferentIconSize(string ATaskImagePath, TIconCache.TIconSize AIconSize) { return(TIconCache.IconCache.AddOrGetExistingIcon(ATaskImagePath, AIconSize)); }