private void LoadGroup() { addFiltrPlus.Visibility = System.Windows.Visibility.Visible; addFiltrButton.Visibility = System.Windows.Visibility.Visible; int allInGroup = Convert.ToInt32(Membership_db.GetNumberApplicationInGroup(selectGroupId)); int inGroupWithFilter = Convert.ToInt32(Membership_db.GetNumberApplicationInGroupWithFilter(selectGroupId)); applicationInGroup.SetContent(allInGroup.ToString()); addingByFilter.SetContent(inGroupWithFilter.ToString()); effectivenessFilter.SetContent((ActionOnNumbers.DivisionD(inGroupWithFilter, allInGroup) * 100).ToString("0.00") + " %"); CommandParameters parameters = new CommandParameters(); parameters.ID.Add(selectGroupId); List <Membership> groups = Membership_db.GetAllGroups(parameters); if (!string.IsNullOrEmpty(groups[0].Filter)) { contentsOfFilter.Text = groups[0].Filter; contentsOfFilter.Visibility = System.Windows.Visibility.Visible; } if (groups[0].IfActiveConfiguration) { ifActivity.Visibility = System.Windows.Visibility.Visible; buttonChangeActivity.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 155, 0)); } if (groups[0].IfAsOneApplication) { treatAsOne.Visibility = System.Windows.Visibility.Visible; buttonTreatAsOne.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 155, 0)); } }
private void UpdateTableWithInformation() { AllData_db allData_db = new AllData_db(); List <int> activityID = new List <int>(); activityID.Add(viewActivityID); double[, ,] valueQuery = new double[2, 2, 2]; valueQuery[0, 0, 0] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-7).ToShortDateString(), DateTime.Now.ToShortDateString()); valueQuery[1, 0, 0] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-30).ToShortDateString(), DateTime.Now.ToShortDateString()); valueQuery[0, 1, 0] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-14).ToShortDateString(), DateTime.Now.AddDays(-7).ToShortDateString()); valueQuery[1, 1, 0] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-60).ToShortDateString(), DateTime.Now.AddDays(-30).ToShortDateString()); activityID.Clear(); activityID.Add(-1); activityID.Add(-2); valueQuery[0, 0, 1] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-7).ToShortDateString(), DateTime.Now.ToShortDateString(), true); valueQuery[1, 0, 1] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-30).ToShortDateString(), DateTime.Now.ToShortDateString(), true); valueQuery[0, 1, 1] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-14).ToShortDateString(), DateTime.Now.AddDays(-7).ToShortDateString(), true); valueQuery[1, 1, 1] = allData_db.GetTimeForNumberActivity(activityID, DateTime.Now.AddDays(-60).ToShortDateString(), DateTime.Now.AddDays(-30).ToShortDateString(), true); average[0].SetContent((ActionOnNumbers.DivisionD(valueQuery[0, 0, 0], valueQuery[0, 0, 1]) * 100).ToString("0.00") + " %"); average[1].SetContent((ActionOnNumbers.DivisionD(valueQuery[1, 0, 0], valueQuery[1, 0, 1]) * 100).ToString("0.00") + " %"); growth[0].SetContent(((ActionOnNumbers.DivisionD(valueQuery[0, 1, 0], valueQuery[0, 1, 1]) - ActionOnNumbers.DivisionD(valueQuery[0, 0, 0], valueQuery[0, 0, 1])) * 100 * -1).ToString("0.00") + " %"); growth[1].SetContent(((ActionOnNumbers.DivisionD(valueQuery[1, 1, 0], valueQuery[1, 1, 1]) - ActionOnNumbers.DivisionD(valueQuery[1, 0, 0], valueQuery[1, 0, 1])) * 100 * -1).ToString("0.00") + " %"); time[0].SetContent(ActionOnTime.GetTimeAndDays((int)valueQuery[0, 0, 0])); time[1].SetContent(ActionOnTime.GetTimeAndDays((int)valueQuery[1, 0, 0])); }
private void CreateChartActiveApplication(List <ActiveApplication> activeApplication, List <ActiveApplication> otherActivity) { if (activeApplication.Any()) { activeApplication = activeApplication.OrderBy(x => x.Date).ToList(); int maxValue = activeApplication.Max(x => x.ActivityTime); List <Tuple <int, string> > activeApplicationTupleList = GetTupleList(activeApplication); List <int> sumDateList = GetSumTimeList(activeApplicationTupleList); double scaleMultiplier = ActionOnNumbers.DivisionD(300, maxValue); int width = 10; int space = 0; int lenghtLabelDate = 0; int positionXLabelDate = 16; int numberElement = 0; int numberDateLabel = 0; chartContentCanvas.Width = 0; for (int i = 0; i < activeApplication.Count; i++) { if (i > 0) { if (!activeApplication[i].Date.Equals(activeApplication[i - 1].Date)) { space += 10; lenghtLabelDate += 11; DrawDateLabel(activeApplication[i - 1].Date.Remove(10), lenghtLabelDate, positionXLabelDate, otherActivity, ref numberDateLabel); positionXLabelDate += lenghtLabelDate - 1; lenghtLabelDate = 0; } } if (!string.IsNullOrEmpty(searchingNames.Text) && !searchingNames.Text.Equals("Wpisz nazwę aktywności") && indexResultFilter > -1) { if (activeApplication[i].ID == Convert.ToInt32(foundList.ElementAt(indexResultFilter).Key)) { MyRectangle r = new MyRectangle(chartContentCanvas, width, (int)(activeApplication[i].ActivityTime * scaleMultiplier), colorTable[i % 4], 40 + space + ((width + 40) * numberElement) + 2, 320 - activeApplication[i].ActivityTime * scaleMultiplier, 1); SetStrokeAndToolTip(r, activeApplication, i); chartContentCanvas.Width += width * 5; lenghtLabelDate += width * 5; numberElement++; } } else { MyRectangle r = new MyRectangle(chartContentCanvas, width, (int)(activeApplication[i].ActivityTime * scaleMultiplier), colorTable[i % 4], 20 + space + ((width + 2) * i) + 2, 320 - activeApplication[i].ActivityTime * scaleMultiplier, 1); SetStrokeAndToolTip(r, activeApplication, i); chartContentCanvas.Width += (width + 2); lenghtLabelDate += width + 2; } } lenghtLabelDate += 21; DrawDateLabel(activeApplication[activeApplication.Count - 1].Date.Remove(10), lenghtLabelDate, positionXLabelDate, otherActivity, ref numberDateLabel); chartContentCanvas.Width += space + 50; SetScalePercent(maxValue, sumDateList.Max()); countTitleApplication.SetContent(activeApplication.Select(x => x.Title).Distinct().Count().ToString()); countActivityApplication.SetContent(activeApplication.Select(x => x.IdNameActivity).Distinct().Count().ToString()); } }
private void UpdateChart() { AllData_db allData_db = new AllData_db(); DailyUseOfApplication_db dailyUseOfApplication_db = new DailyUseOfApplication_db(); List <int> activityID = new List <int>(); int[] timeActivity = new int[7]; DateTime dateTime = DateTime.Now; activityID.Add(viewActivityID); for (int i = 0; i < 7; i++) { if (i < 6) { timeActivity[i] = allData_db.GetTimeForNumberActivity(activityID, dateTime.AddDays(-(7 - (i + 1))).ToShortDateString()); } else { timeActivity[i] = dailyUseOfApplication_db.GetTimeForNumberActivity(activityID); } } double maxValue = ActionOnNumbers.DivisionD((timeActivity.Max() > 2) ? timeActivity.Max() : 3, 60); for (int i = 0; i < 4; i++) { scaleLabel[i].SetContent((((maxValue / 3.0) * 3) - ((maxValue / 3.0) * i)).ToString("0.0") + " h"); } if (timeActivity.Max() > 0) { double scale = maxValue / Convert.ToDouble(scaleLabel[0].GetContent().Replace(" h", "")); for (int i = 0; i < 7; i++) { charts[i].Resize((int)(timeActivity[i] * (120 * scale) / timeActivity.Max()), 16); charts[i].Position(y: 200 - timeActivity[i] * (120 * scale / timeActivity.Max())); charts[i].ToolTip(ActionOnTime.GetTime(timeActivity[i])); } } else { for (int i = 0; i < 7; i++) { charts[i].Resize(0, 16); charts[i].ToolTip(ActionOnTime.GetTime(timeActivity[i])); } } SetVisibleScale(); }
public void Update() { int[] tableTime = new int[4]; int[] tableTime_copy = new int[4]; List <int> numbers = new List <int>(); numbers.Add(2); for (int i = 0; i < 4; i++) { tableTime[i] = 0; } tableTime[0] = dailyUseOfApplication_db.GetTimeForTitle("'Wył. komputer'"); tableTime[1] = dailyUseOfApplication_db.GetTimeForTitle("'Brak Aktyw.'"); tableTime[2] = dailyUseOfApplication_db.GetTimeForNumberActivity(numbers); numbers.Add(-2); numbers.Add(-1); tableTime[3] = dailyUseOfApplication_db.GetTimeForNumberActivity(numbers, true); int sum = 0; for (int i = 0; i < 4; i++) { sum += tableTime[i]; } for (int i = 0; i < 4; i++) { tableTime_copy[i] = tableTime[i]; if (sum > 0) { tableTime[i] = Convert.ToInt32(Math.Round(ActionOnNumbers.DivisionD(tableTime[i], sum) * 100)); } UpdateSegment(i, tableTime[i]); } if (tableTime[0] + tableTime[1] + tableTime[2] + tableTime[3] != 100 && sum > 0) { tableTime = ActionOnNumbers.EqualizePercentages(tableTime_copy, sum); for (int i = 0; i < 4; i++) { UpdateSegment(i, tableTime[i]); } } }
private void CreateChartActivity(List <Activity> activity, CommandParameters parameters, List <ActiveApplication> otherActivity) { if (activity.Any()) { activity = activity.OrderBy(x => x.Date).ToList(); int maxValue = activity.Max(x => x.ActivityTime); List <Tuple <int, string> > activityTupleList = GetTupleList(activity); List <int> sumDateList = GetSumTimeList(activityTupleList); double scaleMultiplier = ActionOnNumbers.DivisionD(300, maxValue); int width = 18; int space = 0; int lenghtLabelDate = 0; int positionXLabelDate = 12; int numberElement = 0; int numberDateLabel = 0; chartContentCanvas.Width = 0; for (int i = 0; i < activity.Count; i++) { if (i > 0) { if (!activity[i].Date.Equals(activity[i - 1].Date)) { space += 20; lenghtLabelDate += 21; DrawDateLabel(activity[i - 1].Date.Remove(10), lenghtLabelDate, positionXLabelDate, otherActivity, ref numberDateLabel); positionXLabelDate += lenghtLabelDate - 1; lenghtLabelDate = 0; } } if (((searchingNames != null) ? !string.IsNullOrEmpty(searchingNames.Text) : true) && ((searchingNames != null) ? !searchingNames.Text.Equals("Wpisz nazwę aktywności") : true) && indexResultFilter > -1) { if (activity[i].ID == Convert.ToInt32(foundList.ElementAt(indexResultFilter).Key)) { MyRectangle r = new MyRectangle(chartContentCanvas, width, (int)(activity[i].ActivityTime * scaleMultiplier), colorTable[i % 4], 40 + space + ((width + 36) * numberElement) + 2, 320 - activity[i].ActivityTime * scaleMultiplier, 1); SetStrokeAndToolTip(r, activity, i); chartContentCanvas.Width += width * 3; lenghtLabelDate += width * 3; numberElement++; } } else { MyRectangle r = new MyRectangle(chartContentCanvas, width, (int)(activity[i].ActivityTime * scaleMultiplier), colorTable[i % 4], 20 + space + ((width + 4) * i) + 4, 320 - activity[i].ActivityTime * scaleMultiplier, 1); SetStrokeAndToolTip(r, activity, i); chartContentCanvas.Width += (width + 4); lenghtLabelDate += width + 4; } } lenghtLabelDate += 21; DrawDateLabel(activity[activity.Count - 1].Date.Remove(10), lenghtLabelDate, positionXLabelDate, otherActivity, ref numberDateLabel); chartContentCanvas.Width += space + 50; SetScalePercent(maxValue, sumDateList.Max()); if (countTitleApplication != null) { countTitleApplication.SetContent(allData_db.CountApplicationInInterwalTime(parameters.StartDate, parameters.EndDate)); countActivityApplication.SetContent(activity.Select(x => x.Name).Distinct().Count().ToString()); } else { tempDateCount = new string[2]; tempDateCount[0] = allData_db.CountApplicationInInterwalTime(parameters.StartDate, parameters.EndDate); tempDateCount[1] = activity.Select(x => x.Name).Distinct().Count().ToString(); } } }