public void AddActivityControl(String name, SolidColorBrush color)
        {
            ActivityControl activityControl = new ActivityControl();

            activityControl.ActivityName         = name;
            activityControl.ActivityColor        = color;
            activityControl.MouseLeftButtonDown += _actionHandler.ActivityControl_Click;
            _activitiesPanel.Children.Add(activityControl);
        }
 public void HandleActivityControlClick(object sender)
 {
     if (_selectedAC != null)
     {
         _selectedAC.BorderThickness = new Thickness(0);
     }
     if (_selectedAC != sender as ActivityControl)
     {
         _selectedAC = sender as ActivityControl;
         _selectedAC.BorderThickness = new Thickness(2);
     }
     else
     {
         _selectedAC = null;
     }
 }
        /// <summary>
        /// Prepare new label for Statistics field of Statistic window.
        /// </summary>
        /// <param name="content">Content of label. Its type should be Activity or integer.</param>
        /// <param name="firstActivity">Determine if label should be label concerning first activity.</param>
        /// <returns></returns>
        private object PrepareLabel(object content, bool firstActivity)
        {
            if (content is Activity)
            {
                Activity        givenActivity = content as Activity;
                ActivityControl activityLabel = new ActivityControl();
                activityLabel.ActivityName  = givenActivity.Name;
                activityLabel.ActivityColor = givenActivity.SquareColor;

                Thickness borderThickness;
                if (firstActivity)
                {
                    borderThickness = new Thickness(0, 2, 0, 1);
                }
                else
                {
                    borderThickness = new Thickness(0, 0, 0, 1);
                }
                activityLabel.BorderThickness = borderThickness;
                return(activityLabel);
            }
            else
            {
                Label newLabel = new Label();
                newLabel.Content = content;
                newLabel.Width   = Double.NaN;
                newLabel.HorizontalContentAlignment = HorizontalAlignment.Center;
                newLabel.BorderBrush = new SolidColorBrush(Colors.Black);

                Thickness borderThickness;
                if (firstActivity)
                {
                    borderThickness = new Thickness(0, 2, 0, 1);
                    newLabel.Height = 31;
                }
                else
                {
                    borderThickness = new Thickness(0, 0, 0, 1);
                    newLabel.Height = 29;
                }
                newLabel.BorderThickness = borderThickness;
                return(newLabel);
            }
        }
        public RemovingActivityCtrlErr RemoveSelectedActivity()
        {
            if (_selectedAC == null)
            {
                return(RemovingActivityCtrlErr.NoneActivitySelected);
            }
            if (_selectedAC.ActivityName.Equals("Nothing"))
            {
                return(RemovingActivityCtrlErr.NothingActivityRemovingAttmpt);
            }

            Activity selectedActivity = GetActivity(_selectedAC.ActivityName);

            _activitiesPanel.Children.Remove(_selectedAC);
            _activities.Remove(selectedActivity);
            _selectedAC = null;

            return(RemovingActivityCtrlErr.NoError);
        }
        /// <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);
            }
        }