示例#1
0
        /// <summary>
        /// Select the first task in the group before the current group and focus the control
        /// </summary>
        public void SelectPreviousGroupWithFocus()
        {
            if (FCurrentTaskList != null)
            {
                bool foundThisGroup = false;

                for (int i = 0; i < FCurrentTaskList.Controls.Count; i++)
                {
                    TUcoTaskGroup group = (TUcoTaskGroup)FCurrentTaskList.Controls[i];

                    if (group.Name == FCurrentTaskList.CurrentGroupName)
                    {
                        foundThisGroup = true;
                    }
                    else if (foundThisGroup)
                    {
                        for (int k = 0; k < group.Controls[0].Controls.Count; k++)
                        {
                            TUcoSingleTask task = (TUcoSingleTask)group.Controls[0].Controls[k];

                            if (task.Enabled)
                            {
                                task.FocusTask();
                                return;
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Finds the task at the specified row and column.  Returns null if there is no task at the location requested.
        /// </summary>
        /// <param name="ARow">A 0-based row number.  If the value is int.MaxValue then the last task in the group in the specified column is returned.</param>
        /// <param name="AColumn">A 0-based column number</param>
        /// <returns></returns>
        private TUcoSingleTask FindTaskAtLocation(int ARow, int AColumn)
        {
            int            maxRow       = -1;
            TUcoSingleTask taskAtMaxRow = null;

            foreach (TUcoSingleTask task in FTasks.Values)
            {
                int tryRow, tryColumn;
                GetTaskLocation(task, out tryRow, out tryColumn);

                if (ARow == int.MaxValue)
                {
                    // we are looking for the last task in the group
                    if ((tryRow > maxRow) && (tryColumn == AColumn))
                    {
                        maxRow       = tryRow;
                        taskAtMaxRow = task;
                    }
                }
                else if ((tryRow == ARow) && (tryColumn == AColumn))
                {
                    return(task);
                }
            }

            if (taskAtMaxRow != null)
            {
                return(taskAtMaxRow);
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// Removes all Tasks from the Task Group.
        /// </summary>
        public void Clear()
        {
            FTasks.Clear();

            flpTaskGroup.Controls.Clear();
            FirstTaskInGroup = null;
        }
示例#4
0
        /// <summary>
        /// Get the location (row and column) of a specified task.  The values will be -1 if no task is specified
        /// </summary>
        public void GetTaskLocation(TUcoSingleTask ATask, out int ARow, out int AColumn)
        {
            ARow    = -1;
            AColumn = -1;

            if (ATask == null)
            {
                return;
            }

            ARow = ATask.Top / ATask.Height;

            if (FTaskAppearance == TaskAppearance.staLargeTile)
            {
                AColumn = ATask.Left / ATask.Width;
            }
            else
            {
                // it is list entry which does not have a fixed width
                foreach (TUcoSingleTask task in FTasks.Values)
                {
                    if ((task.Top == ATask.Top) && (task.Left <= ATask.Left))
                    {
                        AColumn++;
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Adds a Task to the Task Group.
        /// </summary>
        /// <param name="ATaskname">Name of the Task to be added.</param>
        /// <param name="ATask">Instance of the Task to be added.</param>
        public void Add(string ATaskname, TUcoSingleTask ATask)
        {
            FTasks.Add(ATaskname, ATask);

            //	Add Task to this UserControls' Controls
            ATask.Margin = new Padding(5);
            flpTaskGroup.Controls.Add(ATask);

            ATask.TaskClicked  += new EventHandler(FireTaskClicked);
            ATask.TaskSelected += new EventHandler(FireTaskSelected);
        }
示例#6
0
        private void FireTaskSelected(object sender, EventArgs e)
        {
            // An individual task has been selected
            FCurrentTask = (TUcoSingleTask)sender;

            // This line makes sure it is completely visible
            ((TLstTasks)this.Parent).ScrollControlIntoView(FCurrentTask);

            if (TaskSelected != null)
            {
                TaskSelected(sender, null);
            }
        }
示例#7
0
        /// <summary>
        /// Select the next enabled task in the group in the direction specified.  Returns true if a task could be selected.
        /// Returns false if there is no task or if there is a task but it is disabled.  Disabled tasks are skipped if there is an enabled task beyond.
        /// </summary>
        /// <param name="ADirection"></param>
        /// <returns></returns>
        public bool SelectNextTask(Keys ADirection)
        {
            if (FCurrentTask == null)
            {
                return(false);
            }

            // Start by discovering the row and column of the current task in the group
            int currentRow, currentColumn;

            GetTaskLocation(out currentRow, out currentColumn);

            TUcoSingleTask nextTask    = null;
            bool           keepLooking = true;

            while (keepLooking)
            {
                // Find the next task at a specific location
                switch (ADirection)
                {
                case Keys.Right:
                    nextTask = FindTaskAtLocation(currentRow, ++currentColumn);
                    break;

                case Keys.Left:
                    nextTask = FindTaskAtLocation(currentRow, --currentColumn);
                    break;

                case Keys.Up:
                    nextTask = FindTaskAtLocation(--currentRow, currentColumn);
                    break;

                case Keys.Down:
                    nextTask = FindTaskAtLocation(++currentRow, currentColumn);
                    break;
                }

                if ((nextTask != null) && nextTask.Enabled)
                {
                    // we found one and it is enabled
                    nextTask.FocusTask();
                    return(true);
                }

                // if we found a task that was disabled we can go round again
                keepLooking = (nextTask != null);
            }

            return(false);
        }
示例#8
0
        /// <summary>
        /// Select the next enabled task in the group in the direction specified and starting with the task in a specific row and column.
        /// Returns true if a task could be selected.
        /// Returns false if there is no task or if there is a task but it is disabled.  Disabled tasks are skipped if there is an enabled task beyond.
        /// </summary>
        /// <param name="ARow"></param>
        /// <param name="AColumn"></param>
        /// <param name="ADirection"></param>
        /// <returns></returns>
        public bool SelectNextTask(int ARow, int AColumn, Keys ADirection)
        {
            TUcoSingleTask nextTask    = null;
            bool           keepLooking = true;

            while (keepLooking)
            {
                // get the task at the location
                nextTask = FindTaskAtLocation(ARow, AColumn);

                if (nextTask != null)
                {
                    if (nextTask.Enabled)
                    {
                        // we found one and it is enabled
                        nextTask.FocusTask();
                        return(true);
                    }

                    // we found one but it was disabled - so try again in the specified direction
                    switch (ADirection)
                    {
                    case Keys.Up:
                        ARow--;
                        break;

                    case Keys.Down:
                        ARow++;
                        break;

                    case Keys.Left:
                        AColumn--;
                        break;

                    case Keys.Right:
                        AColumn++;
                        break;
                    }
                }

                keepLooking = (nextTask != null);
            }

            return(false);
        }
示例#9
0
        /// <summary>
        /// Select the last task in the specified task list and set focus to the control
        /// </summary>
        private void SelectLastTaskWithFocus(TLstTasks ATaskList)
        {
            for (int i = 0; i < ATaskList.Controls.Count; i++)
            {
                TUcoTaskGroup group = (TUcoTaskGroup)ATaskList.Controls[i];

                for (int k = group.Controls[0].Controls.Count - 1; k >= 0; k--)
                {
                    TUcoSingleTask task = (TUcoSingleTask)group.Controls[0].Controls[k];

                    if (task.Enabled)
                    {
                        task.FocusTask();
                        return;
                    }
                }
            }
        }
示例#10
0
        /// <summary>
        /// Select the first task in the specified task list and set focus to the control
        /// </summary>
        private void SelectFirstTaskWithFocus(TLstTasks ATaskList)
        {
            if (ATaskList == null)
            {
                return;
            }

            for (int i = ATaskList.Controls.Count - 1; i >= 0; i--)
            {
                TUcoTaskGroup group = (TUcoTaskGroup)ATaskList.Controls[i];

                for (int k = 0; k < group.Controls[0].Controls.Count; k++)
                {
                    TUcoSingleTask task = (TUcoSingleTask)group.Controls[0].Controls[k];

                    if (task.Enabled)
                    {
                        task.FocusTask();
                        return;
                    }
                }
            }
        }
示例#11
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();
        }
示例#12
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();

                    // Select (highlight) first Task in the first Group
                    if (Groups.Count == 1)
                    {
                        TaskGroup.SelectFirstTask();
                    }
                }

                TaskGroupNode = TaskGroupNode.NextSibling;
            }

            this.ResumeLayout();
        }
示例#13
0
        /// <summary>
        /// Removes all Tasks from the Task Group.
        /// </summary>
        public void Clear()
        {
            FTasks.Clear();

            flpTaskGroup.Controls.Clear();
            FirstTaskInGroup = null;
        }
示例#14
0
        /// <summary>
        /// Adds a Task to the Task Group.
        /// </summary>
        /// <param name="ATaskname">Name of the Task to be added.</param>
        /// <param name="ATask">Instance of the Task to be added.</param>
        public void Add(string ATaskname, TUcoSingleTask ATask)
        {
            FTasks.Add(ATaskname, ATask);

            //	Add Task to this UserControls' Controls
            ATask.Margin = new Padding(5);
            flpTaskGroup.Controls.Add(ATask);

            ATask.TaskClicked += new EventHandler(FireTaskClicked);
            ATask.TaskSelected += new EventHandler(FireTaskSelected);

            if (FTasks.Count == 1)
            {
                FirstTaskInGroup = ATask;
            }
        }