private void AddUpdateButtonClick(object sender, RoutedEventArgs e)
        {
            if (updateText != null)
            {
                DataHandling.UpdateTask(selectedTask);
                DataHandling.AddTaskUpdate(selectedTaskID, addUpdateTextBox.Text);

                DataStructures.NotificationStruct notificationStruct = new DataStructures.NotificationStruct();
                notificationStruct.notificationSender     = Application.Current.Properties["username"].ToString();
                notificationStruct.notificationText       = "[" + selectedTask.taskName + "]: " + addUpdateTextBox.Text;
                notificationStruct.taskID                 = selectedTaskID;
                notificationStruct.notificationTime       = DateTime.Now;
                notificationStruct.notificationRecipients = selectedTask.notifyUsers;

                DataHandling.AddNotification(notificationStruct);

                DataHandling.GetTasksFull();

                int taskIndex = 0;

                foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
                {
                    if (task.taskName.Equals(selectedTask.taskName))
                    {
                        taskIndex = DataStructures.taskRows.IndexOf(task);
                    }
                }

                ViewTaskWindow updatedTask = new ViewTaskWindow(DataStructures.taskRows[taskIndex]);
                updatedTask.Show();
                Close();
            }
        }
        //Opens View Task Window for Selected Task
        private void ViewTaskButtonClick(object sender, RoutedEventArgs e)
        {
            DataStructures.TaskRowStruct selectedTask = new DataStructures.TaskRowStruct();

            if ((sender as Button).Name.Equals(ViewTaskButton.Name))
            {
                selectedTask = (DataStructures.TaskRowStruct)TaskList2.SelectedItems[0];
            }
            else if ((sender as Button).Name.Equals(ViewTaskButton_ByYou.Name))
            {
                selectedTask = (DataStructures.TaskRowStruct)AssignedByYouList.SelectedItems[0];
            }
            else if ((sender as Button).Name.Equals(ViewTaskButton_ToYou.Name))
            {
                selectedTask = (DataStructures.TaskRowStruct)AssignedToYouList.SelectedItems[0];
            }
            else
            {
                MessageBox.Show("Please select a task");
            }

            try
            {
                if (selectedTask != null)
                {
                    ViewTaskWindow viewTaskWindow = new ViewTaskWindow(selectedTask);
                    viewTaskWindow.Show();
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please select a task");
            }
        }
        private void AddUpdateKeyPressed(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (Keyboard.Modifiers == ModifierKeys.Shift)
                {
                    int ci = addUpdateTextBox.CaretIndex;
                    addUpdateTextBox.Text      += Environment.NewLine;
                    addUpdateTextBox.CaretIndex = ci + 1;
                }
                else
                {
                    if (updateText != null)
                    {
                        DataHandling.UpdateTask(selectedTask);
                        DataHandling.AddTaskUpdate(selectedTaskID, addUpdateTextBox.Text);

                        DataStructures.NotificationStruct notificationStruct = new DataStructures.NotificationStruct();
                        notificationStruct.notificationSender     = Application.Current.Properties["username"].ToString();
                        notificationStruct.notificationText       = "[" + selectedTask.taskName + "]: " + addUpdateTextBox.Text;
                        notificationStruct.taskID                 = selectedTaskID;
                        notificationStruct.notificationTime       = DateTime.Now;
                        notificationStruct.notificationRecipients = selectedTask.notifyUsers;

                        DataHandling.AddNotification(notificationStruct);

                        DataHandling.GetTasksFull();

                        int taskIndex = 0;

                        foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
                        {
                            if (task.taskName.Equals(selectedTask.taskName))
                            {
                                taskIndex = DataStructures.taskRows.IndexOf(task);
                            }
                        }

                        ViewTaskWindow updatedTask = new ViewTaskWindow(DataStructures.taskRows[taskIndex]);
                        updatedTask.Show();
                        Close();
                    }
                }
            }
        }
Example #4
0
        private void NotificationTextGrid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            int notificationRow = -1;

            foreach (Border border in NotificationsGrid.Children)
            {
                if (((UIElement)e.Source).IsDescendantOf(border))
                {
                    notificationRow = Grid.GetRow(border);
                }
            }


            Console.WriteLine(notificationRow);

            for (int i = DataStructures.notificationRows.Count(); i >= 0; i--)
            {
                if (i == notificationRow)
                {
                    foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
                    {
                        if (task.taskID == taskIDArray[i, 0])
                        {
                            ViewTaskWindow viewTask = new ViewTaskWindow(task);

                            DataHandling.UpdateNotificationReadBy(taskIDArray[i, 1]);
                            //taskIDArray = null;
                            NotificationsGrid.Children.Clear();

                            Close();

                            System.Windows.Application.Current.Resources["BlurEffectRadius"] = (double)0;

                            viewTask.Show();
                        }
                    }
                }
            }
        }
        private void AddFilesButtonClick(object sender, RoutedEventArgs e)
        {
            string taskFilesUpdateString = DataHandling.AddTaskFiles(selectedTask);

            if (selectedTask.taskFiles == null)
            {
                selectedTask.taskFiles = new List <string>();
            }

            string[] taskFilesArray = selectedTask.taskFiles.ToArray();
            string   taskFiles      = String.Join(",", taskFilesArray);

            if (taskFilesUpdateString.Equals("Added File(s): ") == false)
            {
                DataHandling.AddTaskUpdate(selectedTaskID, taskFilesUpdateString);

                DataHandling.GetTasksFull();

                ViewTaskWindow updatedTask = new ViewTaskWindow(selectedTask);
                updatedTask.Show();
                Close();
            }
        }
        private void CalendarTaskClick(object sender, MouseButtonEventArgs e)
        {
            int children = ((e.Source as Rectangle).Parent as Grid).Children.Count;

            for (int i = children - 1; i >= 0; i--)
            {
                if (((e.Source as Rectangle).Parent as Grid).Children[i].GetType() == typeof(Label))
                {
                    if (Grid.GetRow(((e.Source as Rectangle).Parent as Grid).Children[i]) == Grid.GetRow((e.Source as Rectangle)))
                    {
                        string taskname = (((e.Source as Rectangle).Parent as Grid).Children[i] as Label).Content.ToString();

                        foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
                        {
                            if (task.taskName.Equals(taskname))
                            {
                                ViewTaskWindow viewTask = new ViewTaskWindow(task);
                                viewTask.Show();
                            }
                        }
                    }
                }
            }
        }
        //Opens View Task Window for Selected Task
        private void MouseDoubleClickItem(object sender, RoutedEventArgs e)
        {
            DataStructures.TaskRowStruct selectedTask = new DataStructures.TaskRowStruct();

            selectedTask = ((FrameworkElement)e.OriginalSource).DataContext as DataStructures.TaskRowStruct;

            if (selectedTask == null)
            {
                //MessageBox.Show("Please select a task");
            }

            try
            {
                if (selectedTask != null)
                {
                    ViewTaskWindow viewTaskWindow = new ViewTaskWindow(selectedTask);
                    viewTaskWindow.Show();
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                //MessageBox.Show("Please select a task");
            }
        }