Ejemplo n.º 1
0
        public Task(int number, string description, long timeSpentInSeconds, TaskTimeTracker form)
        {
            TaskNumber = number;

            Tracker = new TaskTracker(timeSpentInSeconds);

            UI = new TaskControl(number, description, timeSpentInSeconds, form);
        }
Ejemplo n.º 2
0
 public TaskManager(TaskTimeTracker form)
 {
     Form = form;
 }
Ejemplo n.º 3
0
        public TaskControl(int taskNumber, string taskDescription, long timeSpentInSeconds, TaskTimeTracker form)
        {
            // TODO: move this somewhere (e.g. to constants?)
            int descriptionWidth  = 450;
            int timeWidth         = 95;
            int buttonWidth       = 50;
            int removeButtonWidth = 50;
            int lineHeight        = 30;
            int horizontalSpace   = 5;

            // ----------------------------------------------------------------
            // Construct Panel control
            // ----------------------------------------------------------------
            ConfigurePanelByTaskNumber(taskNumber);

            // ----------------------------------------------------------------
            // Construct Task Description control
            // ----------------------------------------------------------------
            TaskDescription = new TextBox
            {
                Location = new Point(0, 0),
                Size     = new Size(descriptionWidth, lineHeight),
                Text     = taskDescription,
                TabIndex = 0
            };
            TaskDescription.TextChanged +=
                new EventHandler(form.AnyInputChanges);

            // ----------------------------------------------------------------
            // Construct Task Time control
            // ----------------------------------------------------------------
            int taskTimeLeftCoordinate =
                descriptionWidth + horizontalSpace;

            TaskTime = new TextBox
            {
                ReadOnly  = false,
                BackColor = timeSpentInSeconds == 0 ? Color.LightCoral : Color.Khaki,
                ForeColor = Color.Black,
                Location  = new Point(taskTimeLeftCoordinate, 0),
                Size      = new Size(timeWidth, lineHeight),
                TabIndex  = 1,
                Text      = GetFormattedTime(timeSpentInSeconds),
                TextAlign = HorizontalAlignment.Center
            };
            TaskTime.LostFocus +=
                new EventHandler(form.AnyInputChanges);
            TaskTime.LostFocus +=
                new EventHandler(form.UserChangedTime);

            // ----------------------------------------------------------------
            // Construct Task Button control
            // ----------------------------------------------------------------
            int buttonLeftCoordinate =
                taskTimeLeftCoordinate + timeWidth + horizontalSpace;

            ToggleButton = new Button
            {
                Location = new Point(buttonLeftCoordinate, 0),
                Size     = new Size(buttonWidth, lineHeight),
                TabIndex = 2,
                Text     = "GO",
                UseVisualStyleBackColor = true
            };
            ToggleButton.Click +=
                new EventHandler(form.ToogleTimer_Click);

            // ----------------------------------------------------------------
            // Construct Remove Button control
            // ----------------------------------------------------------------
            int removeButtonLeftCoordinate =
                buttonLeftCoordinate + buttonWidth + horizontalSpace;

            RemoveButton = new Button
            {
                Location = new Point(removeButtonLeftCoordinate, 0),
                Size     = new Size(removeButtonWidth, lineHeight),
                TabIndex = 3,
                Text     = "DEL",
                UseVisualStyleBackColor = true
            };
            RemoveButton.Click +=
                new EventHandler(form.RemoveTask_Click);

            // ----------------------------------------------------------------
            // Update Panel with inner contents
            // ----------------------------------------------------------------
            AdjustPanel();
        }