Пример #1
0
        /// <summary>
        /// Adding a task to interface application
        /// </summary>
        private void AddTask(DataTask dataTask, Day day)
        {
            day.DataDay.tasks.Add(dataTask);

            day.AddTask(TaskElement(dataTask));

            dataChanged = true;
        }
Пример #2
0
 public bool?ShowDialog(DataTask task, Action ev_complete)
 {
     this.task        = task;
     this.ev_complete = ev_complete;
     taskName.Text    = task.TaskName;
     if (task.Info != string.Empty)
     {
         taskDescription.AppendText(task.Info);
     }
     return(base.ShowDialog());
 }
Пример #3
0
        public Task(DataTask task, Action onCheckBoxClick, Action <Task> onSelect)
        {
            DataTask             = task;
            task.gui             = this;
            this.onCheckBoxClick = onCheckBoxClick;
            this.onSelect        = onSelect;
            InitializeComponent();

            checkBox.Click += delegate(object sender, RoutedEventArgs e) { onCheckBoxClick?.Invoke(); };
            DataContext     = DataTask;
        }
Пример #4
0
        /// <summary>
        /// Function of add a new task
        /// </summary>
        /// <param name="day">Target day</param>
        private void BtnAddTask(Day day)
        {
            TaskWindow window = new TaskWindow();

            window.Owner = this;
            DataTask newTask = new DataTask("New Task", string.Empty, 0, 0);

            /// To open the window of add new task
            if (window.ShowDialog(newTask, () => AddTask(newTask, day)) == true)
            {
            }
        }
Пример #5
0
        static DataWeek LoadWeek(string filePath, DataWeek dataWeek = null)
        {
            if (dataWeek == null)
            {
                dataWeek = new DataWeek();
                dataWeek.FillDefault(
                    GetStartDateForFilePath(filePath));
            }

            // If file of data is exist then read file and fill the array of tasks
            if (File.Exists(filePath))
            {
                string[] dataDays = File.ReadAllLines(filePath);

                foreach (var dataDay in dataDays)
                {
                    if (dataDay == string.Empty)
                    {
                        continue;
                    }

                    // Split the value up half by char '=' (index 0 is a day name, index 1 is data of tasks)
                    var data = Crypt(dataDay).Split('=');

                    DayOfWeek dayOfWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), data[0], true);

                    DataDay day = dataWeek.days[dayOfWeek];

                    // Split the value up on a tasks by char '*'
                    var dataTasks = data[1].Split('*');

                    foreach (var task in dataTasks)
                    {
                        if (task == string.Empty)
                        {
                            continue;
                        }

                        // Split the value up by char '!' and get the array of values of class 'DateTask'
                        var values = task.Split('!');

                        DataTask newTask = new DataTask(values[0], values[1], int.Parse(values[4]), int.Parse(values[2]), bool.Parse(values[3]));

                        day.tasks.Add(newTask);
                    }
                }
            }

            return(dataWeek);
        }
Пример #6
0
        /// <summary>
        /// Invoked when user mark a task as complete or incomplete
        /// </summary>
        private void OnTaskToggleChecked(DataTask task)
        {
            dataChanged = true;
            if (task != currentTask?.DataTask)
            {
                return;
            }

            if (taskStarted)
            {
                StopTimer();
            }
            else
            {
                UpdateButtonsTimer();
            }
        }
Пример #7
0
 public TaskGUI(DataTask task)
 {
     this.task = task;
 }
Пример #8
0
 /// <summary>
 /// Create a task interface element
 /// </summary>
 /// <returns>Created element</returns>
 private Task TaskElement(DataTask dataTask)
 {
     return(new Task(dataTask, () => OnTaskToggleChecked(dataTask), (sender) => SelectTask(sender)));
 }