Esempio n. 1
0
        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]));
        }
Esempio n. 3
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());
            }
        }
Esempio n. 4
0
 private void SetStrokeAndToolTip(MyRectangle rectangle, List <Activity> activity, int index)
 {
     rectangle.SetStroke(Color.FromArgb(100, 255, 255, 255));
     rectangle.ToolTip(activity[index].Name + " - [" + ActionOnTime.GetTimeAndDays(activity[index].ActivityTime) + " / "
                       + ActionOnTime.GetTimeAndDays(activity.Where(x => x.Name == activity[index].Name).Sum(x => x.ActivityTime)) + "] [" +
                       ActionOnNumbers.DivisionI(activity[index].ActivityTime * 100, activity.Where(x => x.Date == activity[index].Date).Sum(x => x.ActivityTime))
                       + "% / " + ActionOnNumbers.DivisionI(activity.Where(x => x.Name == activity[index].Name).Sum(x => x.ActivityTime) * 100, activity.Sum(x => x.ActivityTime)) + "%]");
 }
Esempio n. 5
0
        private void SetScalePercent(int maxValue, int sumValue)
        {
            int minValue = ActionOnNumbers.DivisionI((maxValue * 100), sumValue) / 4;

            for (int i = 0; i < 3; i++)
            {
                scalePercent[i].SetContent((minValue * (i + 1)) + "%");
            }
        }
Esempio n. 6
0
        private void SetStrokeAndToolTip(MyRectangle rectangle, List <ActiveApplication> activeApplication, int index)
        {
            Dictionary <string, string> nameActivity = NameActivity_db.GetAllNameActivityDictionary();

            rectangle.SetStroke(Color.FromArgb(100, 255, 255, 255));
            rectangle.ToolTip(activeApplication[index].Title + " \nAktywność [ " + nameActivity[activeApplication[index].IdNameActivity.ToString()] + " ][" + ActionOnTime.GetTimeAndDays(activeApplication[index].ActivityTime) + " / "
                              + ActionOnTime.GetTimeAndDays(activeApplication.Where(x => x.Title == activeApplication[index].Title).Sum(x => x.ActivityTime)) + "] [" +
                              ActionOnNumbers.DivisionI(activeApplication[index].ActivityTime * 100, activeApplication.Where(x => x.Date == activeApplication[index].Date).Sum(x => x.ActivityTime))
                              + "% / " + ActionOnNumbers.DivisionI(activeApplication.Where(x => x.Title == activeApplication[index].Title).Sum(x => x.ActivityTime) * 100, activeApplication.Sum(x => x.ActivityTime)) + "%]");
        }
        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();
        }
Esempio n. 8
0
        private void DrawDateLabel(string content, int lenghtLabelDate, int positionXLabelDate, List <ActiveApplication> otherActivity, ref int numberDateLabel)
        {
            int     tempNumberDateLabel = numberDateLabel;
            MyLabel l2 = new MyLabel(chartContentCanvas, content, lenghtLabelDate, 22, 9, positionXLabelDate, 326, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 1);

            l2.SetBackgroundColor(Color.FromArgb(60, 255, 255, 255));
            string toolTip = "Wyłączony komputer [" + ActionOnTime.GetTimeAndDays(otherActivity[numberDateLabel].ActivityTime) + " / " + ActionOnTime.GetTimeAndDays(otherActivity.Where(x => x.ID == 1).Sum(x => x.ActivityTime)) + "] [" +
                             ActionOnNumbers.DivisionI(otherActivity[numberDateLabel].ActivityTime * 100, otherActivity.Where(x => x.Date == otherActivity[tempNumberDateLabel].Date).Sum(x => x.ActivityTime))
                             + "% / " + ActionOnNumbers.DivisionI(otherActivity.Where(x => x.ID == 1).Sum(x => x.ActivityTime) * 100, otherActivity.Sum(x => x.ActivityTime)) + "%]"
                             + "\nBrak aktywności [" + ActionOnTime.GetTimeAndDays(otherActivity[++numberDateLabel].ActivityTime) + "/ " + ActionOnTime.GetTimeAndDays(otherActivity.Where(x => x.ID == 2).Sum(x => x.ActivityTime)) + "] [" +
                             ActionOnNumbers.DivisionI(otherActivity[numberDateLabel].ActivityTime * 100, otherActivity.Where(x => x.Date == otherActivity[tempNumberDateLabel].Date).Sum(x => x.ActivityTime))
                             + "% / " + ActionOnNumbers.DivisionI(otherActivity.Where(x => x.ID == 2).Sum(x => x.ActivityTime) * 100, otherActivity.Sum(x => x.ActivityTime)) + "%]";

            l2.ToolTip(toolTip);
            numberDateLabel++;
        }
        public void Update()
        {
            string[,] biggestResults = dailyUseOfApplication_db.GetBiggestResults();
            double[] partOfResults = GetDoubleBiggestResults(biggestResults);

            double sumpartOfResults = 0;

            for (int i = 0; i < 4; i++)
            {
                if (i > 0)
                {
                    sumpartOfResults += partOfResults[i - 1];
                }
                if (partOfResults[i] > 0)
                {
                    UpdateSegment(partOfResults[i], sumpartOfResults, i, biggestResults[i, 0]);
                }
                else
                {
                    labels[i].Opacity(0);
                }
            }

            int sum = 0;

            int[] valueTable = new int[4];
            for (int i = 0; i < 4; i++)
            {
                sum          += Convert.ToInt32(biggestResults[i, 1]);
                valueTable[i] = Convert.ToInt32(biggestResults[i, 1]);
            }
            double allPercent = partOfResults[0] + partOfResults[1] + partOfResults[2] + partOfResults[3];

            if ((1.00 < allPercent || allPercent < 0.99) && sum > 0)
            {
                int[] partOfResultsTableInt = ActionOnNumbers.EqualizePercentages(valueTable, sum);
                for (int i = 0; i < 4; i++)
                {
                    labels[i].SetContent(partOfResultsTableInt[i] + " %");
                }
            }
        }
Esempio n. 10
0
        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]);
                }
            }
        }
Esempio n. 11
0
        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();
                }
            }
        }