-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathStatisticsViewModel.cs
111 lines (101 loc) · 3.61 KB
/
StatisticsViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#region Copyright Syncfusion® Inc. 2001-2025.
// Copyright Syncfusion® Inc. 2001-2025. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using Syncfusion.Windows.Controls.Gantt;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace syncfusion.ganttdemos.wpf.ViewModel
{
public class StatisticsViewModel
{
/// <summary>
/// Initializes a new instance of the <see cref="StatisticsViewModel"/> class.
/// </summary>
/// <param name="prjInfo">The PRJ info.</param>
public StatisticsViewModel(ProjectInfo prjInfo)
{
_projectInformation = prjInfo;
this.SetCostExpenditure(prjInfo);
this.SetDurationExpenditure(prjInfo);
}
private ProjectInfo _projectInformation;
/// <summary>
/// Gets the project information.
/// </summary>
/// <value>The project information.</value>
public ProjectInfo ProjectInformation
{
get
{
return _projectInformation;
}
}
/// <summary>
/// Gets or sets the cost expenditure.
/// </summary>
/// <value>The cost expenditure.</value>
public IList<ProjectStatisticsModel> CostExpenditure
{
get;
set;
}
/// <summary>
/// Gets or sets the duration expenditure.
/// </summary>
/// <value>The duration expenditure.</value>
public IList<ProjectStatisticsModel> DurationExpenditure
{
get;
set;
}
/// <summary>
/// Sets the cost expenditure.
/// </summary>
/// <param name="prjInfo">The PRJ info.</param>
private void SetCostExpenditure(ProjectInfo prjInfo)
{
this.CostExpenditure = new List<ProjectStatisticsModel>();
var temp = Math.Round(((Math.Round(prjInfo.ActualCost) / (Math.Round(prjInfo.Cost))) * 100), 2);
CostExpenditure.Add(new ProjectStatisticsModel() { Name = " Spent ", Amount = temp });
CostExpenditure.Add(new ProjectStatisticsModel() { Name = " Remaining ", Amount = 100 - temp });
}
/// <summary>
/// Sets the duration expenditure.
/// </summary>
/// <param name="prjInfo">The PRJ info.</param>
private void SetDurationExpenditure(ProjectInfo prjInfo)
{
this.DurationExpenditure = new List<ProjectStatisticsModel>();
var t = Math.Round(((Math.Round(prjInfo.ActualDuration.TotalDays, 2) / (Math.Round(prjInfo.Duration.TotalDays))) * 100), 2);
DurationExpenditure.Add(new ProjectStatisticsModel() { Name = " Completed ", Amount = t });
DurationExpenditure.Add(new ProjectStatisticsModel() { Name = " Remaining ", Amount = 100 - t });
}
internal void Dispose()
{
foreach(var cost in CostExpenditure)
{
cost.Dispose();
}
foreach (var duration in DurationExpenditure)
{
duration.Dispose();
}
}
}
}