public static string ToLabelString(
            this DurationSeparator format,
            DateTimeSettings currentSettings,
            TimeSpan sampleTime
            )
        {
            string label;

            if (format == DurationSeparator.ColonAndLetters)
            {
                label = "Colons and Letters";
            }
            else if (format == DurationSeparator.LettersOnly)
            {
                label = "Letters Only";
            }
            else // Colons only is the default.
            {
                label = "Colons Only";
            }

            DateTimeSettings settings = currentSettings with {
                DurationSeparator = format
            };

            return($"{label} ({sampleTime.ToSettingsString( settings )})");
        }
    }
        /// <summary>
        /// Reads in the settings, and returns a string representation
        /// of the <see cref="TimeSpan"/> object based on the settings.
        /// </summary>
        public static string ToSettingsString(this TimeSpan timespan, DateTimeSettings settings)
        {
            ArgumentNullException.ThrowIfNull(settings, nameof(settings));

            DurationFormat    duration  = settings.DurationFormat;
            DurationSeparator separator = settings.DurationSeparator;

            string formatString;

            if (duration == DurationFormat.HourMinuteSecond)
            {
                if (separator == DurationSeparator.LettersOnly)
                {
                    formatString = @"'H 'mm'M 'ss'S'";
                }
                else if (separator == DurationSeparator.ColonAndLetters)
                {
                    formatString = @"'H'\:mm'M'\:ss'S'";
                }
                else // ColonOnly is the default.
                {
                    formatString = @"\:mm\:ss";
                }
            }
            else // HourMinute (and any others) are the default.
            {
                if (separator == DurationSeparator.LettersOnly)
                {
                    formatString = @"'H 'mm'M'";
                }
                else if (separator == DurationSeparator.ColonAndLetters)
                {
                    formatString = @"'H'\:mm'M'";
                }
                else // ColonOnly is the default.
                {
                    formatString = @"\:mm";
                }
            }

            // For total hours, need to use the TotalHours property instead of using
            // a format string.  Otherwise, if the time is more than a day,
            // it won't report the correct number of hours.
            //
            // Need to Math.Floor it as well, otherwise if we have more than half an hour
            // in the minutes section, it will round up.
            return
                (Math.Floor(timespan.TotalHours).ToString("00") +
                 timespan.ToString(formatString));
        }
示例#3
0
        void ReleaseDesignerOutlets()
        {
            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

            if (AddProjectTaskLabel != null)
            {
                AddProjectTaskLabel.Dispose();
                AddProjectTaskLabel = null;
            }

            if (AddTagsLabel != null)
            {
                AddTagsLabel.Dispose();
                AddTagsLabel = null;
            }

            if (AddTagsView != null)
            {
                AddTagsView.Dispose();
                AddTagsView = null;
            }

            if (BillableLabel != null)
            {
                BillableLabel.Dispose();
                BillableLabel = null;
            }

            if (BillableSwitch != null)
            {
                BillableSwitch.Dispose();
                BillableSwitch = null;
            }

            if (BillableView != null)
            {
                BillableView.Dispose();
                BillableView = null;
            }

            if (CategorizeWithProjectsBubbleView != null)
            {
                CategorizeWithProjectsBubbleView.Dispose();
                CategorizeWithProjectsBubbleView = null;
            }

            if (CategorizeWithProjectsLabel != null)
            {
                CategorizeWithProjectsLabel.Dispose();
                CategorizeWithProjectsLabel = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (ConfirmButton != null)
            {
                ConfirmButton.Dispose();
                ConfirmButton = null;
            }

            if (ConfirmButtonBottomConstraint != null)
            {
                ConfirmButtonBottomConstraint.Dispose();
                ConfirmButtonBottomConstraint = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (DeleteButtonBottomConstraint != null)
            {
                DeleteButtonBottomConstraint.Dispose();
                DeleteButtonBottomConstraint = null;
            }

            if (DescriptionTextView != null)
            {
                DescriptionTextView.Dispose();
                DescriptionTextView = null;
            }

            if (DurationDescriptionLabel != null)
            {
                DurationDescriptionLabel.Dispose();
                DurationDescriptionLabel = null;
            }

            if (DurationLabel != null)
            {
                DurationLabel.Dispose();
                DurationLabel = null;
            }

            if (DurationSeparator != null)
            {
                DurationSeparator.Dispose();
                DurationSeparator = null;
            }

            if (StartDateSeparator != null)
            {
                StartDateSeparator.Dispose();
                StartDateSeparator = null;
            }

            if (DurationView != null)
            {
                DurationView.Dispose();
                DurationView = null;
            }

            if (EndDescriptionLabel != null)
            {
                EndDescriptionLabel.Dispose();
                EndDescriptionLabel = null;
            }

            if (EndTimeLabel != null)
            {
                EndTimeLabel.Dispose();
                EndTimeLabel = null;
            }

            if (EndTimeView != null)
            {
                EndTimeView.Dispose();
                EndTimeView = null;
            }

            if (ErrorMessageLabel != null)
            {
                ErrorMessageLabel.Dispose();
                ErrorMessageLabel = null;
            }

            if (ErrorMessageTitleLabel != null)
            {
                ErrorMessageTitleLabel.Dispose();
                ErrorMessageTitleLabel = null;
            }

            if (ErrorView != null)
            {
                ErrorView.Dispose();
                ErrorView = null;
            }

            if (GroupDuration != null)
            {
                GroupDuration.Dispose();
                GroupDuration = null;
            }

            if (ProjectTaskClientLabel != null)
            {
                ProjectTaskClientLabel.Dispose();
                ProjectTaskClientLabel = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (ScrollViewContent != null)
            {
                ScrollViewContent.Dispose();
                ScrollViewContent = null;
            }

            if (StartDateDescriptionLabel != null)
            {
                StartDateDescriptionLabel.Dispose();
                StartDateDescriptionLabel = null;
            }

            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }

            if (StartDateView != null)
            {
                StartDateView.Dispose();
                StartDateView = null;
            }

            if (StartDescriptionLabel != null)
            {
                StartDescriptionLabel.Dispose();
                StartDescriptionLabel = null;
            }

            if (StartTimeLabel != null)
            {
                StartTimeLabel.Dispose();
                StartTimeLabel = null;
            }

            if (StartTimeView != null)
            {
                StartTimeView.Dispose();
                StartTimeView = null;
            }

            if (StopButton != null)
            {
                StopButton.Dispose();
                StopButton = null;
            }

            if (TagsContainerView != null)
            {
                TagsContainerView.Dispose();
                TagsContainerView = null;
            }

            if (TagsSeparator != null)
            {
                TagsSeparator.Dispose();
                TagsSeparator = null;
            }

            if (TagsTextView != null)
            {
                TagsTextView.Dispose();
                TagsTextView = null;
            }

            if (TimeEntryTimes != null)
            {
                TimeEntryTimes.Dispose();
                TimeEntryTimes = null;
            }

            if (TimeEntryTimesSeparator != null)
            {
                TimeEntryTimesSeparator.Dispose();
                TimeEntryTimesSeparator = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }

            if (SelectProject != null)
            {
                SelectProject.Dispose();
                SelectProject = null;
            }
        }