Пример #1
0
        private void InitialsClicked(object sender, RoutedEventArgs e)
        {
            var unassignedUser = new User
            {
                Id = 0,
                Name = "Unassigned",
                Avatar = @"http://img3.wikia.nocookie.net/__cb20140606001154/watchdogscombined/images/1/1f/Silhouette-question-mark.jpeg"
            };

            var tcvm = (TaskCardViewModel)this.DataContext;
            Button btnClicked = (Button)sender;

            var userSelected = tcvm.Users.Where(u => u.Id == int.Parse(btnClicked.Tag.ToString())).FirstOrDefault();

            var currentTaskUsers = tcvm.StoryTask.TaskUsers;

            if (currentTaskUsers.Contains(unassignedUser))
            {
                currentTaskUsers.Remove(unassignedUser);
            }

            if (!currentTaskUsers.Contains(userSelected))
            {
                currentTaskUsers.Add(userSelected);
            }

            tcvm.StoryTask.TaskUsers = currentTaskUsers;

            users.Visibility = Visibility.Hidden;

            
        }
Пример #2
0
        private void ReadUsers()
        {
            var usersFile = fileStoreLocation + "users.txt";
            if (File.Exists(usersFile))
            {
                var data = File.ReadAllLines(usersFile);
                var headers = data[0];

                foreach (var line in data)
                {
                    if (line != data[0])
                    {
                        var lineSplit = line.Split(',');

                        User user = new User
                        {
                            Id = int.Parse(lineSplit[0]),
                            Name = lineSplit[1],
                            Avatar = lineSplit[2]
                        };

                        users.Add(user);
                    }
                }
            }
        }