Ejemplo n.º 1
0
        /// <summary>
        /// Private method to load taskItems of a masterXmlNode
        /// This method is also used to reload task items when style has been changed or a node has been disabled, etc
        /// </summary>
        /// <param name="Node"></param>
        /// <param name="NumberingLevel"></param>
        /// <param name="ParentNumberText"></param>
        /// <param name="ARebuildXmlNodeToLinkLabelMapping"/>
        private void LoadTaskItems(XmlNode Node, int NumberingLevel, String ParentNumberText,
                                   bool ARebuildXmlNodeToLinkLabelMapping = false)
        {
            this.SuspendLayout();

            if (ARebuildXmlNodeToLinkLabelMapping)
            {
                FXmlNodeToLinkLabelMapping = new Dictionary <XmlNode, LinkLabel>();
            }

            //If this is the base case, reset number of Tasks and clear previously painted Task Items
            if (NumberingLevel == 0)
            {
                NumTasks = 0;
                this.tPnlGradient1.Controls.Clear();

                // Set the 'Padding'
                this.tPnlGradient1.AutoScrollMargin = new Size(VisualStyle.ContentPaddingRight, VisualStyle.ContentPaddingBottom);
            }

            this.tPnlGradient1.Resize += new EventHandler(TTaskList_Resize);
            int CurrentNumbering = 1;

            NumberingLevel++;

            XmlNode TaskNode = Node.FirstChild;

            //Iterate through all children nodes of the node
            while (TaskNode != null)
            {
                if (SkipThisLevel(TaskNode))
                {
                    TaskNode = TaskNode.FirstChild;
                }

                LinkLabel lblTaskItem = new LinkLabel();
                lblTaskItem.Tag = TaskNode;

                if (TaskNode != FActiveTaskItem)
                {
                    SetCommonNonActivatedLinkAppearance(lblTaskItem);
                }
                else
                {
                    SetCommonActivatedLinkAppearance(lblTaskItem);
                }

                lblTaskItem.Name     = TaskNode.Name;
                lblTaskItem.AutoSize = true;
                lblTaskItem.Font     = VisualStyle.ContentFont;

                //@TODO: This line specifies the indentation by setting the location, however each level is indented the same amount
                // Should allow the first level to be indented a different amount than the rest of the levels
                lblTaskItem.Location = new System.Drawing.Point(VisualStyle.ContentPaddingLeft + (NumberingLevel * this.TaskIndentation),
                                                                VisualStyle.ContentPaddingTop + (NumTasks * TaskHeight));

                lblTaskItem.LinkClicked      += new LinkLabelLinkClickedEventHandler(lblTaskItem_LinkClicked);
                lblTaskItem.Links[0].LinkData = TaskNode;

                lblTaskItem.MouseEnter += new System.EventHandler(this.LinkLabelMouseEnter);
                lblTaskItem.MouseLeave += new System.EventHandler(this.LinkLabelMouseLeave);

                if (IsDisabled(TaskNode))
                {
                    lblTaskItem.Links[0].Enabled  = false;
                    lblTaskItem.DisabledLinkColor = VisualStyle.ContentDisabledFontColour;
                    lblTaskItem.LinkBehavior      = LinkBehavior.NeverUnderline;
                }

                if (IsVisible(TaskNode))
                {
                    //Automatic Numbering
                    String NumberText = ParentNumberText + (CurrentNumbering).ToString() + ".";

                    if (!this.InternalAutomaticNumbering)
                    {
                        lblTaskItem.Text = TLstFolderNavigation.GetLabel(TaskNode);
                    }
                    else
                    {
                        lblTaskItem.Text = NumberText + " " + TLstFolderNavigation.GetLabel(TaskNode);
                        CurrentNumbering++;
                    }

                    this.tPnlGradient1.Controls.Add(lblTaskItem);

                    FXmlNodeToLinkLabelMapping[TaskNode] = lblTaskItem;

                    NumTasks++;

                    //If the TaskNode has Children, do subtasks
                    if ((TaskNode.HasChildNodes) &&
                        (!DontShowNestedTasksAsLinks(TaskNode)))
                    {
                        LoadTaskItems(TaskNode, NumberingLevel, NumberText, false);
                    }
                }

                TaskNode = TaskNode.NextSibling;
            }

            FTaskListMaxHeight = tPnlGradient1.GetPreferredSize(new Size()).Height;
            this.ResumeLayout();
        }
Ejemplo n.º 2
0
        private void InstantiateCollapsiblePanels()
        {
            this.SuspendLayout();

            this.Controls.Clear();
            FCollPanelCount = 0;

            if (FMasterXmlNode == null)
            {
                throw new Exception("MasterXmlNode Property not set to an instance of XmlNode");
            }

            XmlNode TaskNode = FMasterXmlNode.FirstChild;

            //Iterate through all children nodes of the node
            while (TaskNode != null)
            {
                // Create a wrapper Panel. This is only needed to be able to set a distance between Collapsible Panels.
                Panel WrapperPanel = new Panel();
                WrapperPanel.AutoSize     = true;
                WrapperPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                WrapperPanel.BackColor    = Color.Transparent;
                WrapperPanel.Dock         = DockStyle.Top;
                WrapperPanel.Padding      = new Padding(0, 0, 0, FDistanceBetweenCollapsiblePanels);
                WrapperPanel.TabIndex     = FCollPanelCount;
                WrapperPanel.Tag          = TaskNode;
                WrapperPanel.Name         = TaskNode.Name;

                // Create a Collapsible Panel
                TPnlCollapsible CollPanel = new TPnlCollapsible(THostedControlKind.hckTaskList,
                                                                TaskNode,
                                                                TCollapseDirection.cdVertical,
                                                                10,
                                                                false,
                                                                FVisualStyle);
                CollPanel.Tag      = WrapperPanel;
                CollPanel.Name     = TaskNode.Name;
                CollPanel.Text     = TLstFolderNavigation.GetLabel(TaskNode);
                CollPanel.Dock     = DockStyle.Top;
                CollPanel.TabIndex = 0;

                if ((TaskNode.Attributes["Visible"] != null) &&
                    (TaskNode.Attributes["Visible"].Value.ToLower() == "false"))
                {
                    CollPanel.Visible = false;
                }

                if ((TaskNode.Attributes["Enabled"] != null) &&
                    (TaskNode.Attributes["Enabled"].Value.ToLower() == "false"))
                {
                    CollPanel.Enabled = false;
                }
                else
                {
                    CollPanel.ItemActivation += delegate(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked, object AOtherData)
                    {
                        OnItemActivation(ATaskList, ATaskListNode, AItemClicked);
                    };
                }

                WrapperPanel.Height = CollPanel.ExpandedSize + FDistanceBetweenCollapsiblePanels;
                WrapperPanel.Controls.Add(CollPanel);
                this.Controls.Add(WrapperPanel);

                // Make sure the Collapsible Panels' Wrapper Panels are shown in correct order and not in reverse order.
                // (This is needed because we 'stack them up' with '.Controls.Dock = DockStyle.Top')
                WrapperPanel.BringToFront();

                TaskNode = TaskNode.NextSibling;

                FCollPanelCount++;
            }

            this.ResumeLayout();
        }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Private method to load taskItems of a masterXmlNode
        /// This method is also used to reload task items when style has been changed or a node has been disabled, etc
        /// </summary>
        /// <param name="Node"></param>
        /// <param name="NumberingLevel"></param>
        /// <param name="ParentNumberText"></param>
        /// <param name="ARebuildXmlNodeToLinkLabelMapping"/>
        private void LoadTaskItems(XmlNode Node, int NumberingLevel, String ParentNumberText,
                                   bool ARebuildXmlNodeToLinkLabelMapping = false)
        {
            this.SuspendLayout();

            if (ARebuildXmlNodeToLinkLabelMapping)
            {
                FXmlNodeToLinkLabelMapping = new Dictionary <XmlNode, LinkLabel>();
            }

            //If this is the base case, reset number of Tasks and clear previously painted Task Items
            if (NumberingLevel == 0)
            {
                NumTasks = 0;
                this.tPnlGradient1.Controls.Clear();

                // Set the 'Padding'
                this.tPnlGradient1.AutoScrollMargin = new Size(VisualStyle.ContentPaddingRight, VisualStyle.ContentPaddingBottom);
            }

            this.tPnlGradient1.Resize += new EventHandler(TTaskList_Resize);
            int CurrentNumbering = 1;

            NumberingLevel++;

            XmlNode TaskNode = Node.FirstChild;

            //Iterate through all children nodes of the node
            while (TaskNode != null)
            {
                if (SkipThisLevel(TaskNode))
                {
                    TaskNode = TaskNode.FirstChild;
                }

                LinkLabel lblTaskItem = new LinkLabel();
                lblTaskItem.Tag = TaskNode;

                if (TaskNode != FActiveTaskItem)
                {
                    SetCommonNonActivatedLinkAppearance(lblTaskItem);
                }
                else
                {
                    SetCommonActivatedLinkAppearance(lblTaskItem);
                }

                lblTaskItem.Name     = TaskNode.Name;
                lblTaskItem.AutoSize = true;
                lblTaskItem.Font     = VisualStyle.ContentFont;

                //@TODO: This line specifies the indentation by setting the location, however each level is indented the same amount
                // Should allow the first level to be indented a different amount than the rest of the levels
                lblTaskItem.Location = new System.Drawing.Point(VisualStyle.ContentPaddingLeft + (NumberingLevel * this.TaskIndentation),
                                                                VisualStyle.ContentPaddingTop + (NumTasks * TaskHeight));

                lblTaskItem.LinkClicked      += new LinkLabelLinkClickedEventHandler(lblTaskItem_LinkClicked);
                lblTaskItem.Links[0].LinkData = TaskNode;

                lblTaskItem.MouseEnter += new System.EventHandler(this.LinkLabelMouseEnter);
                lblTaskItem.MouseLeave += new System.EventHandler(this.LinkLabelMouseLeave);

                if (IsDisabled(TaskNode))
                {
                    lblTaskItem.Links[0].Enabled  = false;
                    lblTaskItem.DisabledLinkColor = VisualStyle.ContentDisabledFontColour;
                    lblTaskItem.LinkBehavior      = LinkBehavior.NeverUnderline;
                }

                if (IsVisible(TaskNode))
                {
                    //Automatic Numbering
                    String NumberText = ParentNumberText + (CurrentNumbering).ToString() + ".";

                    if (!this.InternalAutomaticNumbering)
                    {
                        lblTaskItem.Text = TLstFolderNavigation.GetLabel(TaskNode);
                    }
                    else
                    {
                        lblTaskItem.Text = NumberText + " " + TLstFolderNavigation.GetLabel(TaskNode);
                        CurrentNumbering++;
                    }

                    long conferenceCode;

                    if (TaskNode.Name.StartsWith("Conference") && Int64.TryParse(TaskNode.Name.Substring(10), out conferenceCode))
                    {
                        // This covers the Selected Conference panel.
                        // NOTE: We have to set the tab stop for 'this' to false.  It is not enough to just set the lblTaskItem property
                        // because, bizarrely, only setting the link label allows the tab key to select the user control but that does not
                        // have any focused control!
                        this.TabStop = false;
                    }
                    else
                    {
                        // This covers the Current ledger panel where some ledgers are inaccessible to the user.
                        // NOTE: setting TabStop to false for a LinkLabel must be done AFTER setting the links and setting the text
                        //  otherwise .NET will always set TabStop to true!
                        lblTaskItem.TabStop = !IsDisabled(TaskNode);
                    }

                    this.tPnlGradient1.Controls.Add(lblTaskItem);

                    FXmlNodeToLinkLabelMapping[TaskNode] = lblTaskItem;

                    NumTasks++;

                    //If the TaskNode has Children, do subtasks
                    if ((TaskNode.HasChildNodes) &&
                        (!DontShowNestedTasksAsLinks(TaskNode)))
                    {
                        LoadTaskItems(TaskNode, NumberingLevel, NumberText, false);
                    }
                }

                TaskNode = TaskNode.NextSibling;
            }

            FTaskListMaxHeight = tPnlGradient1.GetPreferredSize(new Size()).Height;
            this.ResumeLayout();
        }