public Day(DataDay dataDay, Action <Day> eventAddTask) { InitializeComponent(); InitializeListViewDragDropManager(); DataDay = dataDay; this.nameDay.Content = DataDay.dayOfWeek.ToString(); this.eventAddTask = eventAddTask; dragDropDatas.Add(new DragDropData(this, dragMgr)); }
private static TimeSpan CalculateTotalTime(DataDay day) { TimeSpan time = new TimeSpan(); foreach (var t in day.tasks) { time = time.Add(t.TotalTime); } return(time); }
private static int CalculateTomatoes(DataDay day) { int val = 0; foreach (var t in day.tasks) { val += t.Tomatoes; } return(val); }
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); }
private void CreateDayGUI(DataDay dataDay) { Day day = new Day(dataDay, v => BtnAddTask(v)); if (dataDay.tasks.Count > 0) { List <Task> tasks = new List <Task>(); foreach (var t in dataDay.tasks) { tasks.Add(TaskElement(t)); } day.AddTasks(tasks.ToArray()); } days.Add(day); }
private void Load(DateTime dateTime, string path) { if (taskStarted) { StopTimer(); } days.Clear(); Day.dragDropDatas.Clear(); /// Create a tasks from the loaded data selectedDataWeek = FileManager.LoadWeek(dateTime, path); switch (applicationMode) { case ApplicationMode.Day: /// Create the day data selectedDataDay = selectedDataWeek.GetDay(dateTime); CreateDayGUI(selectedDataDay); break; case ApplicationMode.Week: /// Create the week data foreach (var d in selectedDataWeek.days) { CreateDayGUI(d.Value); } break; } /// Update the data of interface labelInfoDay.Content = $"The selected date is {dateTime.Day}.{dateTime.Month}.{dateTime.Year}"; taskDescription.Document.Blocks.Clear(); selectedTasks.Clear(); UpdateTimerInfo(); UpdateTotalTime(); UpdateButtonsTimer(); dataChanged = false; }
public override bool Equals(Object obj) { // Check for null values and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } DataWeek d = (DataWeek)obj; DataDay thisMonday = days[DayOfWeek.Monday]; DataDay otherMonday = d.days[DayOfWeek.Monday]; // Compare only Monday with Monday, because it's easily, than compare all days each other return((thisMonday.date.day == otherMonday.date.day) && (thisMonday.date.month == otherMonday.date.month) && (thisMonday.date.year == otherMonday.date.year)); }
public static DataWeek LoadWeek(DateTime dateTime, string path) { // Getting a days of selected week DateOfWeek[] dates = GetWeek(dateTime); string filePath = $"{path}{dates[0].date.day} {dates[0].date.month} {dates[0].date.year}" + $"-{dates[6].date.day} {dates[6].date.month} {dates[6].date.year}.week"; // Creating a array days of week DataWeek dataWeek = new DataWeek(); // Set default values foreach (var d in dates) { DataDay newDay = new DataDay(d.date); newDay.dayOfWeek = d.dayOfWeek; dataWeek.days.Add(d.dayOfWeek, newDay); } return(LoadWeek(filePath, dataWeek)); }