public Day(StackPanel dayStackPanel, string name, string[] plan, string[] report, byte id) { _dayStackPanel = dayStackPanel; _id = id; _activitiesManager = ActivitiesManager.GetInstance(); //Creating all quarters: //When some data was taken from database. if (plan != null) { for (byte i = 0; i < 96; i++) { Activity plannedActivity = _activitiesManager.GetActivity(plan[i]); Activity reportedActivity = _activitiesManager.GetActivity(report[i]); _quarters[i] = new Quarter(PrepareQuartersArea(), plannedActivity, reportedActivity, new QuarterIdentifier(_id, i)); } } else // When any data wasn't taken from database. { for (byte i = 0; i < 96; i++) { Activity activity = ActivitiesManager.NullActivity; _quarters[i] = new Quarter(PrepareQuartersArea(), activity, activity, new QuarterIdentifier(_id, i)); } } }
public static ActivitiesManager GetInstance() { if (_instance == null) { _instance = new ActivitiesManager(); } return(_instance); }
//-------------------------- START METHOD ------------------------------------------------------------------------------------------- public void Start(ActivitiesManager activitiesManager) { _activitiesManager = activitiesManager; _week = Week.GetInstance(); _defaultState = new States.Default(activitiesManager); _QSstate = new States.QuartersSelected(); _SIPstate = new States.SelectionInProgress(); _currentState = _defaultState; }
public MainWindow() { InitializeComponent(); ActionHandler actionHandler = ActionHandler.GetInstance(); ActivitiesManager activitiesManager = ActivitiesManager.GetInstance(); _week = Week.GetInstance(); _dbAccess = DBAccess.GetInstance(); activitiesManager.Start(ActivitiesPanel, actionHandler, _week); actionHandler.Start(activitiesManager); _week.ActualInitialisation(WeekGrid, WeekComboBox); StatsBtn.Click += actionHandler.StatsBtn_Click; WeekComboBox.SelectionChanged += actionHandler.WeekComboBox_SelectionChanged; PlanningRB.Checked += actionHandler.PlanningRB_Checked; ReportingRB.Checked += actionHandler.ReportingRB_Checked; AddActivityBtn.Click += actionHandler.AddActivityBtn_Click; RemoveActivityBtn.Click += actionHandler.RemoveActivityBtn_Click; MouseLeftButtonDown += actionHandler.Window_MouseLeftButtonDown; MouseLeftButtonUp += actionHandler.Window_MouseLeftButtonUp; }
/// <summary> /// Updates part of content of StatisticsWindow according to chosen values of ComboBoxes. /// </summary> public void UpdateStatisticsVisualisation() { int firstQuarter = 0; int lastQuarter = 1; Period selectedPeriod = (Period)PeriodComboBox.SelectedIndex; switch (selectedPeriod) { case Period.Day: { firstQuarter = VariousTools.NumberOfFirstQuarterOfFirstWeekInMonth(CurrSlctdMonth); firstQuarter += StatWindWeekComboBox.SelectedIndex * 7 * 96 + DayComboBox.SelectedIndex * 96; lastQuarter = firstQuarter + 96 - 1; break; } case Period.Week: { firstQuarter = VariousTools.NumberOfFirstQuarterOfFirstWeekInMonth(CurrSlctdMonth); firstQuarter += StatWindWeekComboBox.SelectedIndex * 7 * 96; lastQuarter = firstQuarter + 96 * 7 - 1; break; } case Period.Month: { firstQuarter = VariousTools.NumberOfFirstQuarterOfFirstWeekInMonth(CurrSlctdMonth); lastQuarter = firstQuarter + 96 * 7 * StatWindWeekComboBox.Items.Count - 1; break; } default: { break; } } List <Activity> activities = ActivitiesManager.GetInstance().Activities; ClearStatisticsVisualisation(); foreach (Activity activity in activities) { bool firstActivity = activity == activities.First(); short numOfQrtsAccToPlan = (short)_dbAccess.CountActivityAppearences(activity, QrtrsMrkngMode.Planning, firstQuarter, lastQuarter); short numOfQrtsAccToReport = (short)_dbAccess.CountActivityAppearences(activity, QrtrsMrkngMode.Reporting, firstQuarter, lastQuarter); double rltyToPlan = (double)numOfQrtsAccToReport / numOfQrtsAccToPlan; ActivityControl activityLabel = PrepareLabel(activity, firstActivity) as ActivityControl; Label QrtQntAccToPln = (Label)PrepareLabel(numOfQrtsAccToPlan, firstActivity); Label QrtsQnttInRlty = (Label)PrepareLabel(numOfQrtsAccToReport, firstActivity); Label RltyToPlan = (Label)PrepareLabel(Double.IsNaN(rltyToPlan) || Double.IsInfinity(rltyToPlan) ? "Not planned" : Math.Round(rltyToPlan * 100, 2).ToString(), firstActivity); ActivityName.Children.Add(activityLabel); QrtsQnttyPlnnd.Children.Add(QrtQntAccToPln); QrtsQnttyRlty.Children.Add(QrtsQnttInRlty); RltyToPlanSP.Children.Add(RltyToPlan); } }