Ejemplo n.º 1
0
        private void convertToTimeSpan(TextBox theTextbox, bool canBeNegative)
        {
            TimeSpan time = TimeSpan.Zero;

            // If the timespan is already valid there's no need to do anything more
            if (Skedaddler.parseTimeSpan(theTextbox.Text, out time))
            {
                return;
            }

            if (theTextbox.Text.Length > 0)
            {
                int minutes = 0;
                if (Int32.TryParse(theTextbox.Text, out minutes))
                {
                    time = TimeSpan.FromMinutes(minutes);
                }
            }

            if (time < TimeSpan.Zero && canBeNegative == false)
            {
                time = TimeSpan.Zero;
            }

            theTextbox.Text = (time < TimeSpan.Zero ? "-" : "") + String.Format("{0:h\\:mm}", time);
        }
Ejemplo n.º 2
0
        private void adjustTimeSpan(TextBox theTextbox, int value, bool canBeNegative, string defaultValue = "0:00")
        {
            TimeSpan time;

            if (theTextbox.Text.Length == 0 || !Skedaddler.parseTimeSpan(theTextbox.Text, out time))
            {
                theTextbox.Text = defaultValue;
                return;
            }

            time += TimeSpan.FromMinutes(value);
            if (time < TimeSpan.Zero && canBeNegative == false)
            {
                time = TimeSpan.Zero;
            }

            theTextbox.Text = (time < TimeSpan.Zero ? "-" : "") + String.Format("{0:h\\:mm}", time);
        }
Ejemplo n.º 3
0
        public SettingsForm(Skedaddler parent)
        {
            InitializeComponent();

            this.parent = parent;
        }