Exemplo n.º 1
0
        }//end 1-arg constructor

        public TimeGrouping(List<TimedInstance> times, string name)
        {
            Times = new List<TimedInstance>();
            foreach (TimedInstance time in times)
            {
                TimedInstance newTime = new TimedInstance(time);
                newTime.CurrentGroup = this;
                Times.Add(newTime);
            }//end copying over times
            GroupName = new StringBuilder(name).ToString();
        }//end 2-arg constructor
Exemplo n.º 2
0
        }//end no-arg constructor

        public TimeGrouping(List<TimedInstance> times)
        {
            Times = new List<TimedInstance>();
            foreach(TimedInstance time in times)
            {
                TimedInstance newTime = new TimedInstance(time);
                newTime.CurrentGroup = this;
                Times.Add(newTime);
            }//end copying over times
            GroupName = "Ungrouped";
        }//end 1-arg constructor
Exemplo n.º 3
0
        }//end uxClockInBtn_Click

        private void uxClockOutBtn_Click(object sender, EventArgs e)
        {
            //update display
            uxElapsedTimeTimer.Enabled = false;
            uxCurrentTimeElapsedTextBox.ResetText();

            //save the new time
            clockOutTime = DateTime.Now;
            TimedInstance time = new TimedInstance(clockInTime, clockOutTime);

            //get the name for that time
            time.InstanceName = uxTimeNameTextBox.Text == "" ? "Unnamed Instance" : uxTimeNameTextBox.Text;
            //reset text in the textbox
            uxTimeNameTextBox.ResetText();

            if (uxGroupsGroup.Visible)
            {
                string groupText = uxGroupNameTextBox.Text;

                //figure out if it's just white space
                bool foundNonSpace = false;
                foreach(char chr in groupText)
                {
                    if (!Char.IsWhiteSpace(chr))
                    {
                        foundNonSpace = true;
                        break;
                    }//end if this is not white space
                }//end foreach

                //make changes if it is just white space
                if (!foundNonSpace) groupText = "Ungrouped";

                //actually add this time to a group
                groupManager.AddTime(time, groupText);
                UpdateListViews(true);
            }//end if we should specify a group
            else
            {
                groupManager.AddTime(time, "Ungrouped");
                UpdateListViews(false);
            }//end else we just do a unspecified group
        }//end uxClockOutBtn Click event handler
Exemplo n.º 4
0
        }//end uxGroupsView_CellEditFinished event handler

        /// <summary>
        /// just make sure to update the views when we edit things
        /// </summary>
        private void uxSavedHoursView_CellEditFinished(object sender, CellEditEventArgs e)
        {
            //grab the instance we're editing out of those args
            TimedInstance time = (TimedInstance)e.RowObject;

            //if we couldn't find it, break out of method
            if (time == null) return;

            if(e.Column == uxInstanceColumn)
            {
                time.InstanceName = (string)e.NewValue;
            }//end if we're editing the name
            else if(e.Column == uxHoursColumn)
            {
                time.Hours = (int)e.NewValue;
            }//end if we're editing the hours
            else if(e.Column == uxMinutesColumn)
            {
                time.Minutes = (int)e.NewValue;
            }//end else if we're editing the minutes
            else if(e.Column == uxStartDateColumn)
            {
                time.Start = (DateTime)e.NewValue;
            }//end else if we're editing the date
            else if(e.Column == uxEndDateColumn)
            {
                time.End = (DateTime)e.NewValue;
            }//end else if we're editing the ending date
            else if(e.Column == uxStartTimeColumn)
            {
                time.Start = (DateTime)e.NewValue;
            }//end else if we're editing the starting time
            else if(e.Column == uxEndTimeColumn)
            {
                time.End = (DateTime)e.NewValue;
            }//end else if we're editing the ending time

            UpdateGroupManager(typedTimeView, groupManager);

            UpdateListViews(true);
        }//end uxGroupView_CellEditFinished event handler
Exemplo n.º 5
0
        public HoursTracker()
        {
            InitializeComponent();
            uxGroupsDefaultLocation = uxGroupsGroup.Location;
            uxHoursDefaultLocation = uxSavedHoursGroup.Location;

            clockInTime = DateTime.Now;
            clockOutTime = DateTime.Now;

            groupManager = new TimeGroupManager();

            SystemTimeTimer.Enabled = true;
            SystemTimeTimer_Tick(null, null);

            //Do some whack ObjectListView things

            //set up the typed olvs
            typedGroupView = new TypedObjectListView<TimeGrouping>(this.uxGroupsView);
            typedTimeView = new TypedObjectListView<TimedInstance>(this.uxSavedHoursView);

            //set up weird delegate things
            for(int i = 0; i < uxSavedHoursView.Columns.Count; i++)
            {
                typedTimeView.GetColumn(i).GroupKeyGetter = delegate (TimedInstance timedInstance)
                {
                    TimedInstance time = timedInstance;
                    return time.CurrentGroup;
                };
            }//end setting all columns to use group name as group key

            for(int i = 0; i < uxSavedHoursView.AllColumns.Count; i++)
            {
                uxSavedHoursView.AllColumns[i].GroupKeyToTitleConverter = delegate (object groupKey)
                {
                    if (groupKey == null) return "No Group Found";
                    TimeGrouping groupObj = (TimeGrouping)groupKey;
                    return groupObj.GroupName;
                };//end setting GroupKeyToTitleConverter
            }//end looping to set groupKeyToTitleConverter for all the columns
            
            // do the group formatters

            uxStartDateColumn.GroupFormatter = (OLVGroup group,
                GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                (
                    (x, y) => (((TimeGrouping)x.Key).EarliestDate.TimeSpan.Ticks.CompareTo(
                        ((TimeGrouping)y.Key).EarliestDate.TimeSpan.Ticks)
                    )
                );//end group comparer definition
            };//end group formatter for start date

            uxEndDateColumn.GroupFormatter = (OLVGroup group,
                GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                (
                    (x, y) => (((TimeGrouping)x.Key).EarliestDate.TimeSpan.Ticks.CompareTo(
                        ((TimeGrouping)y.Key).EarliestDate.TimeSpan.Ticks)
                    )
                );//end group comparer definition
            };//end group formatter for end date

            uxStartTimeColumn.GroupFormatter = (OLVGroup group,
                GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                (
                    (x, y) => (((TimeGrouping)x.Key).EarliestTime.TimeSpan.Ticks.CompareTo(
                        ((TimeGrouping)y.Key).EarliestTime.TimeSpan.Ticks)
                    )
                );//end group comparer definition
            };//end group formatter for start time

            uxEndTimeColumn.GroupFormatter = (OLVGroup group,
                GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                (
                    (x, y) => (((TimeGrouping)x.Key).EarliestTime.TimeSpan.Ticks.CompareTo(
                        ((TimeGrouping)y.Key).EarliestTime.TimeSpan.Ticks)
                    )
                );//end group comparer definition
            };//end group formatter for end time

            uxHoursColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                    (
                        (x, y) => ((TimeGrouping)x.Key).TotalHours.CompareTo(
                        ((TimeGrouping)y.Key).TotalHours)
                    );//end GroupCompareer
            };//end GroupFormatter for Hours

            uxMinutesColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                    (
                        (x, y) => ((TimeGrouping)x.Key).TotalMinutes.CompareTo(
                        ((TimeGrouping)y.Key).TotalMinutes)
                    );//end GroupCompareer
            };//end GroupFormatter for Minutes

            uxInstanceColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) =>
            {
                parms.GroupComparer = Comparer<OLVGroup>.Create
                (
                    (x, y) => ((TimeGrouping)x.Key).GroupName.CompareTo(((TimeGrouping)y.Key).GroupName)
                );//end groupComparer
            };//end GroupFormatter for InstanceName
        }//end constructor
Exemplo n.º 6
0
        }//end constructor

        /// <summary>
        /// handler for adding previous times from the stuff
        /// </summary>
        private void uxAddPrevTimeBtn_Click(object sender, EventArgs e)
        {
            DateTime start;
            DateTime end;

            DateTime startDate;
            DateTime endDate;

            TimeSpan startTime;
            TimeSpan endTime;

            TimedInstance timedInstance;

            

            if (specifyDate)
            {
                //get our stuff from DateTimePickers
                startDate = uxStartDatePicker.Value.Date;
                endDate = uxEndDatePicker.Value.Date;
                startTime = uxStartTimePicker.Value.TimeOfDay;
                endTime = uxEndTimePicker.Value.TimeOfDay;
                
                //put that stuff into start and end DateTimes
                start = startDate.Add(startTime);
                end = endDate.Add(endTime);

                //make sure we don't have a negative
                while (start.Ticks > end.Ticks)
                    end = end.AddDays(1);

                //create our timed instance
                timedInstance = new TimedInstance(start, end)
                {
                    printDate = true
                };
            }//end if we're specifying the date
            else
            {
                if (specifyBeginEnd)
                {
                    //get our stuff from DateTimePickers
                    startDate = DateTime.Now;
                    endDate = DateTime.Now;
                    startTime = uxStartTimePicker.Value.TimeOfDay;
                    endTime = uxEndTimePicker.Value.TimeOfDay;

                    //put that stuff into start and end DateTimes
                    start = startDate.Add(startTime);
                    end = endDate.Add(endTime).AddMinutes(1);

                    //make sure we don't have a negative
                    while (start.Ticks > end.Ticks)
                        end = end.AddDays(1);

                    //create our timed instance
                    timedInstance = new TimedInstance(start, end)
                    {
                        printDate = false
                    };
                }//end if we care about the beginning and end
                else
                {
                    //create our timed instance
                    timedInstance = new TimedInstance((int)uxPrevHourInputNUD.Value, (int)uxPrevMinuteInputNUD.Value)
                    {
                        printDate = false
                    };
                }//end else we don't care about beginning and end
            }//end else we don't care about the date

            //get the name of the instance
            timedInstance.InstanceName = uxTimeNameTextBox.Text == "" ? "Unnamed Instance" : uxTimeNameTextBox.Text;
            //reset text in the textbox
            uxTimeNameTextBox.ResetText();

            if (uxGroupsGroup.Visible)
            {
                string groupText = uxGroupNameTextBox.Text;

                //figure out if it's just white space
                bool foundNonSpace = false;
                foreach (char chr in groupText)
                {
                    if (!Char.IsWhiteSpace(chr))
                    {
                        foundNonSpace = true;
                        break;
                    }//end if this is not white space
                }//end foreach

                //make changes if it is just white space
                if (!foundNonSpace) groupText = "Ungrouped";

                groupManager.AddTime(timedInstance, groupText);

                UpdateListViews(true);
            }//end if we're doing groups right now
            else
            {
                groupManager.AddTime(timedInstance, "Ungrouped");

                UpdateListViews(false);
            }//end else we aren't doing groups rn
        }//end uxAddPrevTimeBtn Click event handler
Exemplo n.º 7
0
        }//end Equals

        public void Remove(TimedInstance time)
        {
            Times.Remove(time);
        }//end Remove(time)