コード例 #1
0
        private void UpdateTreeView()
        {
            DateTime startDate = m_startDate.Value;
            DateTime endDate = m_endDate.Value;

            //DateTime timesheetStartDate = new DateTime(startDate.Year, startDate.Month, 1);
            //DateTime timesheetEndDate = endDate.AddMonths(1).AddDays(-endDate.Day);

            RangeTimesheets rangeTimesheets = new RangeTimesheets(startDate, endDate);
            this.RangeTimesheets = rangeTimesheets;

            int totalTimesheets = rangeTimesheets.Count;

            RootTreeNode rootNode = new RootTreeNode("Root", DefaultImageList.Instance.GetRootIconIndex());

            // Monthly Timesheets...
            foreach (MonthlyTimesheets monthlyTimesheets in rangeTimesheets.MonthlyTimesheets) {

                // Timesheets...
                foreach (Timesheet timesheet in monthlyTimesheets.Timesheets) {

                    // TimesheetDates...
                    foreach (TimesheetDate timesheetDate in timesheet.Dates.Where(p=>p.IsValidDate)) {
                        if (timesheetDate.Date < startDate || timesheetDate.Date > endDate) {
                            continue;
                        }

                        Color foreColor = DayTypes.GetDayTypeForeColor(timesheetDate.DayType);

                        TimesheetDateTreeNode treeNode = new TimesheetDateTreeNode(timesheetDate, DefaultImageList.Instance.GetCalendarIconIndex());
                        treeNode.ForeColor = foreColor;

                        AddTimesheetDateTreeNodeDetailNodes(treeNode, timesheetDate, foreColor);

                        rootNode.Nodes.Add(treeNode);
                    }
                }
            }

            rootNode.Expand();
            m_treeView.Nodes.Add(rootNode);
        }
コード例 #2
0
        private void AddTimesheetDateTreeNodeDetailNodes(TimesheetDateTreeNode timesheetDateTreeNode, TimesheetDate timesheetDate, Color foreColor)
        {
            TreeNodeEx treeNode = null;
            int imageIndex = DefaultImageList.Instance.GetPropertyIconIndex();

            // DayType Name...
            treeNode = new TimesheetDateDetailTreeNode(timesheetDate.DayType.Name, imageIndex);
            treeNode.ForeColor = foreColor;
            timesheetDateTreeNode.Nodes.Add(treeNode);

            // Billable Hours...
            treeNode = new TimesheetDateDetailTreeNode(string.Format("Billable Hours: {0}", timesheetDate.GetFormattedBillableHours()), imageIndex);
            treeNode.ForeColor = foreColor;
            timesheetDateTreeNode.Nodes.Add(treeNode);

            // Rate Per Hour...
            treeNode = new TimesheetDateDetailTreeNode(string.Format("Rate Per Hour: {0}", timesheetDate.GetFormattedRatePerHour()), imageIndex);
            treeNode.ForeColor = foreColor;
            timesheetDateTreeNode.Nodes.Add(treeNode);
        }