Exemplo n.º 1
0
        public BadBoy ExtractBadBoy()
        {
            var badBoy = new BadBoy
            {
                Name                 = Equals(NameTextBox.Foreground, Brushes.Black) ? NameTextBox.Text : "",
                Surname              = Equals(SurnameTextBox.Foreground, Brushes.Black) ? SurnameTextBox.Text : "",
                Nickname             = Equals(NicknameTextBox.Foreground, Brushes.Black) ? NicknameTextBox.Text : "",
                Height               = Equals(HeightTextBox.Foreground, Brushes.Black) ? HeightTextBox.Text : "0",
                EyeColor             = Equals(EyeColorTextBox.Foreground, Brushes.Black) ? EyeColorTextBox.Text : "",
                BirthDate            = dateChanged ? BirthDatePicker.SelectedDate.ToString() : DateTime.Now.ToString(),
                Citizenship          = Equals(CitizenshipTextBox.Foreground, Brushes.Black) ? CitizenshipTextBox.Text : "",
                BirthPlace           = Equals(BirthPlaceTextBox.Foreground, Brushes.Black) ? BirthPlaceTextBox.Text : "",
                DistinguishingTraits = Equals(DistinguishingTraitsTextBox.Foreground, Brushes.Black) ? DistinguishingTraitsTextBox.Text : "",
                Languages            = Equals(LanguagesTextBox.Foreground, Brushes.Black) ? LanguagesTextBox.Text : "",
                HairColor            = Equals(HairColorTextBox.Foreground, Brushes.Black) ? HairColorTextBox.Text : "",
                LastLivingPlace      = Equals(LastLivingPlaceTextBox.Foreground, Brushes.Black) ? LastLivingPlaceTextBox.Text : "",
                Profession           = Equals(ProfessionTextBox.Foreground, Brushes.Black) ? ProfessionTextBox.Text : "",
                LastCase             = Equals(LastCaseTextBox.Foreground, Brushes.Black) ? LastCaseTextBox.Text : ""
            };
            var accomplices = new List <BadBoy>();

            foreach (var i in AccomplicesListBox.SelectedItems)
            {
                accomplices.Add((BadBoy)i);
            }
            badBoy.Accomplices = accomplices;
            badBoy.Crimes      = crimesList;
            return(badBoy);
        }
Exemplo n.º 2
0
        public EditWindow(BadBoy badBoy)
        {
            InitializeComponent();
            current = badBoy;
            var properties = typeof(BadBoy).GetProperties();

            foreach (var property in properties)
            {
                if (property.Name != "Accomplices" && property.Name != "BirthDate" && property.Name != "crimes" && property.Name != "Crimes")
                {
                    var textBox =
                        (TextBox)
                        (this.GetType()
                         .GetField(property.Name + "TextBox", BindingFlags.NonPublic | BindingFlags.Instance)?
                         .GetValue(this));
                    textBox.Text = property.GetValue(badBoy).ToString();
                }
            }
            AccomplicesListBox.ItemsSource = G.BadBoys;
            foreach (var accomplice in badBoy.Accomplices)
            {
                AccomplicesListBox.SelectedItems.Add(accomplice);
            }
            BirthDatePicker.DisplayDate = badBoy._birthDate;
            BirthDatePicker.Text        = BirthDatePicker.DisplayDate.ToString();
            CrimesListBox.ItemsSource   = current.Crimes;
            treeView.Items.Add(Crimes.AllCrimes);
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            BadBoy b = new BadBoy
            {
                Profession = "Comrade Sniper",
                Surname    = "Kozlov",
                Name       = "Vasiliy",
                Nickname   = "Padliva"
            };

            BadBoy c = new BadBoy
            {
                Profession = "Comrade Sniper",
                Surname    = "Kozlov",
                Name       = "Asiliy",
                Nickname   = "Azazaz"
            };

            G.BadBoys.Add(b);
            G.BadBoys.Add(c);
            dataGrid.ItemsSource = G.BadBoys;
        }
Exemplo n.º 4
0
        public void Find(BadBoy toFind, bool isDateChanged)
        {
            var properties = typeof(BadBoy).GetProperties();
            var toDisplay  = new List <BadBoy>();

            foreach (var i in G.BadBoys)
            {
                bool isFine = true;
                foreach (var propertyInfo in properties)
                {
                    if (propertyInfo.Name != "Languages" && propertyInfo.Name != "DistinguishingTraits" &&
                        propertyInfo.Name != "BirthDate" && propertyInfo.Name != "Accomplices")
                    {
                        if (propertyInfo.GetValue(toFind).ToString() != "" && propertyInfo.GetValue(toFind).ToString() != "0" &&
                            !propertyInfo.GetValue(i).ToString().ToLower().Contains(propertyInfo.GetValue(toFind).ToString().ToLower()))
                        {
                            isFine = false;
                            break;
                        }
                    }
                    if (toFind._distinguishingTraits.Count > 0)
                    {
                        foreach (var trait in toFind._distinguishingTraits)
                        {
                            if (trait != "" && i._distinguishingTraits != null && !i._distinguishingTraits.Contains(trait))
                            {
                                isFine = false;
                                break;
                            }
                        }
                    }
                    if (toFind._languages.Count > 0)
                    {
                        foreach (var language in toFind._languages)
                        {
                            if (language != "" && i._languages != null && !i._languages.Contains(language))
                            {
                                isFine = false;
                                break;
                            }
                        }
                    }
                    if (toFind.Accomplices.Count > 0)
                    {
                        foreach (var accomplice in toFind.Accomplices)
                        {
                            if (!i.Accomplices.Contains(accomplice))
                            {
                                isFine = false;
                                break;
                            }
                        }
                    }
                    if (isDateChanged &&
                        i.BirthDate != toFind.BirthDate)
                    {
                        isFine = false;
                        break;
                    }

                    if (toFind.Crimes.Count > 0)
                    {
                        foreach (var crime in toFind.Crimes)
                        {
                            var query = from thisGuyCrime in i.Crimes
                                        where crime.isSuccessor(thisGuyCrime)
                                        select thisGuyCrime;
                            if (!query.Any())
                            {
                                isFine = false;
                            }
                        }
                    }
                }
                if (isFine)
                {
                    toDisplay.Add(i);
                }
            }
            dataGrid.ItemsSource = toDisplay;
        }
Exemplo n.º 5
0
 public void Add(BadBoy toAdd)
 {
     G.BadBoys.Add(toAdd);
     dataGrid.Items.Refresh();
 }