public void SavePerson(string name, Sex sex, DateTime birthDateUtc, string biography) { // Let's also practice exception handling. if (String.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); var person = _personRepository.Fetch(record => record.Name == name).FirstOrDefault(); if (person == null) { person = new PersonRecord(); _personRepository.Create(person); } person.Name = name; person.Sex = sex; person.BirthDateUtc = birthDateUtc; person.Biography = biography; // Running filters // Normally we don't persist the result of filters though. foreach (var filter in _filters) { person.Biography = filter.FilterBiography(person.Biography); } }
public Person(string name, DateTime birthday, Sex gender) { this.Name = name; this.Birthday = birthday; this.Gender = gender; this.Id = NEXT_ID++; }
public Result(Age a, Sex s, Profession p, Education e, YesNo cit, List<Technology> tech, Frequency pub, Frequency home, NumPass single, List<PassType> passType, Frequency pChange, YesNo sharePass,YesNo pSecure, YesNo passHome,YesNo pMobile, YesNo hWifiPass, YesNo hWifiFire, YesNo hVirusSoftware, YesNo softUpdate, SecureLevel sLevel, SharePersonalInfo postPersonal, Frequency pWifi) { m_age = a; m_sex = s; m_profession = p; m_education = e; m_usCitizen = cit; m_technologyList = tech; m_publicComputer = pub; m_homeComputer = home; m_singlePass = single; m_passType = passType; m_passChangeFreq = pChange; m_sharePassword = sharePass; m_passSecure = pSecure; m_passHomePC = passHome; m_passForMobile = pMobile; m_homeWifiPass = hWifiPass; m_homeWifiFirewall = hWifiFire; m_homeVirusSoftware = hVirusSoftware; m_softwareUpdates = softUpdate; m_securityLevel = sLevel; m_postPersonalInfo = postPersonal; m_publicWifi = pWifi; }
/// <summary> /// /// </summary> /// <param name="info"></param> /// <param name="ctxt"></param> public Person(SerializationInfo info, StreamingContext ctxt) { _full_name = info.GetString("full_name"); _sex = (Sex)info.GetValue("sex", typeof(Sex)); _birth_date = info.GetDateTime("birth_date"); _photo_path = info.GetString("photo_path"); }
//constructor public Dog(string name, int age, Sex sex, FurColour furColour) { this.Name = name; this.Age = age; this.Sex = sex; this.FurColour = furColour; }
Human CreatePair(Human human, Sex gender) { if (human == null) { throw new ArgumentNullException(); } Human newHuman; if (human is Botan) { newHuman = CreateCoolParentPair(human as Botan); } else if (human is CoolParent) { newHuman = CreateBotanPair(human as CoolParent, gender); } else if (human is Student) { newHuman = CreateParentPair(human as Student); } else if (human is Parent) { newHuman = CreateStudentPair(human as Parent, gender); } else { throw new ArgumentNullException(); } Humans.Add(newHuman); return newHuman; }
public Animal(string name, Sex sex, byte age, string type) { this.Name = name; this.Sex = sex; this.Age = age; this.Type = type; }
public IList<string> GetSearchableCountries(Sex gender) { using (var session = _documentStore.OpenSession()) { try { var query = (from item in session.Query<CountryCityCountResult, CountryCityCountIndex>().Where(p => p.Gender == (byte) gender).ToList() group item by new {item.CountryName} into g let o = new {g.Key.CountryName} orderby o.CountryName select g.Key.CountryName); return query.ToList(); //(from item in session.Query<CountryCityCountResult, CountryCityCountIndex>().Where(p => p.Gender == (byte)gender).ToList() // group item by new {item.CountryCode, item.CountryName} // into g // let o = new {Sum = g.Sum(x => x.Count), g.Key.CountryCode, g.Key.CountryName} // orderby o.Sum descending // select new {g.Key.CountryCode, g.Key.CountryName}); //var dictionary = new Dictionary<string, string>(); //foreach (var item in query) // if(item != null && !String.IsNullOrWhiteSpace(item.CountryCode) && !dictionary.ContainsKey(item.CountryCode)) // dictionary.Add(item.CountryCode, item.CountryName); //return dictionary; } catch(InvalidOperationException) { return new List<string>(); } } }
public static void SetRecomendedCalories(int age, Sex sex) { if (sex == Sex.Female) { if (age == 12) { DailyRecomendedCalories = 1800; } else if (age > 12 && age < 15) { DailyRecomendedCalories = 2000; } else if (age == 15) { DailyRecomendedCalories = 2200; } else if (age > 16 && age < 19) { DailyRecomendedCalories = 2400; } else if (age > 18 && age < 21) { DailyRecomendedCalories = 2600; } else { DailyRecomendedCalories = 2400; } } if (sex == Sex.Male) { if (age < 14) { DailyRecomendedCalories = 1600; } else if (age > 13 && age < 19) { DailyRecomendedCalories = 1800; } else { DailyRecomendedCalories = 2000; } } }
public AnnualPolicy(Age age, Sex gender, Destination destination, Tax tax) { this.age = age; this.gender = gender; this.destination = destination; this.tax = tax; }
public Animals(string name, byte age, Sex sex) { this.Name = name; this.Age = age; Sex gender = sex; this.Sound = ""; }
Entity(long date, Sex sex, int motherId, int fatherId) { _birthday = date; _sex = sex; _motherId = motherId; _fatherId = fatherId; }
//constructor public Frog(string name, int age, Sex sex, int greenSpots) { this.Name = name; this.Age = age; this.Sex = sex; this.greenSpots = greenSpots; }
//Constructor public CorporateCustomer(string customerID, string companyName, Address companyAddress, string regNumber, string firstName, string middleName, string lastName, Sex sex, decimal pin) : base(customerID, firstName, middleName, lastName, sex, companyAddress, pin) { this.CompanyName = companyName; this.RegNumber = regNumber; }
/// <summary> /// 创建玩家 /// </summary> /// <param name="netstate"></param> /// <param name="playerName"></param> /// <param name="sex"></param> public void OnCreatePlayer(NetState netstate, string playerName, Sex sex) { // 如果已经创建过(例如玩家连续点了两次创建角色) var player = WorldEntityManager.PlayerCache.GetEntity(netstate.BizId); if (player != null) { ClientProxy.Login.CreatePlayerResult(netstate, CraetePlayerResult.Fail); return; } player = new Player { Id = netstate.BizId, AccountId = netstate.BizId, Name = playerName, Sex = sex, NetState = netstate }; DB.GameDB.InsertEntity(player); WorldEntityManager.PlayerCache.AddOrReplace(player); Logs.Info("角色 {0}({1}) 创建成功", playerName, player.Id); netstate.Player = player; PlayerEnterGame(player); ClientProxy.Login.CreatePlayerResult(netstate, CraetePlayerResult.Success); }
internal static string NameFromPatronymic(Sex sex, string patronymic) { if ((patronymic == null) || (patronymic.Length <= 4)) { throw new ArgumentException(Properties.Resources.InvalidPatronymic); } var substringToRemove = patronymic.Substring(patronymic.Length - AdditionalPatronymicLength, AdditionalPatronymicLength); switch (sex) { case Sex.Male: { if (!substringToRemove.Equals(ManPatronymicAddition)) { throw new ArgumentException(Properties.Resources.InvalidParentNameFromPatronymic); } break; } case Sex.Female: { if (!substringToRemove.Equals(WomanPatronymicAddition)) { throw new ArgumentException(Properties.Resources.InvalidParentNameFromPatronymic); } break; } default: throw new NotSupportedException(Properties.Resources.InvalidSex); } return patronymic.Substring(0, patronymic.Length - AdditionalPatronymicLength); }
// We'll need this later for PersonListPart. public IEnumerable<PersonRecord> GetPersons(Sex sex, int maxCount) { // _personRepository.Fetch(record => record.Sex == sex).Take(maxCount) would produce the same result. However // since Fetch() returns an IEnumerable, not an IQueryable, Take() would run on objects, not translated to SQL. // Hence the below version can perform better. return _personRepository.Table.Where(record => record.Sex == sex).Take(maxCount); }
public Animals(float age, string name, Sex sex) { this.Age = age; this.Name = name; this.Sex = sex; if (this.GetType().Name == "Tomcat") { this.Sex = Sex.male; } else if (this.GetType().Name == "Kitten") { this.Sex = Sex.female; } if (this.GetType().Name == "Dog") { this.Sound = "Woof-Woof"; } else if (this.GetType().Name == "Kitten") { this.Sound = "Meooow"; } else if (this.GetType().Name == "Tomcat") { this.Sound = "Meow"; } else if (this.GetType().Name == "Frog") { this.Sound = "Ribbit-ribbit"; } }
public IEntity Build() { if (_sex == Sex.UNDEFINED) _sex = GetRandomSex(); return new Entity(_birthday, _sex, _motherId, _fatherId); }
private static Player CreatePlayer(string name, PlayerColor color, Sex sex, int n) { var player = new Player(name, color, sex); int i = 0; StuffManager stuffManager = StuffManager.Instance; foreach (IDxMCard dxMCard in stuffManager.DxMCards) { if (dxMCard is ICheatCard) continue; if (dxMCard is IRaceCard && player.RaceCards.Count < 2) player.RaceCards.Add((IRaceCard)dxMCard); else if (dxMCard is IClassCard && player.ClassCards.Count < 2) player.ClassCards.Add((IClassCard)dxMCard); else if (dxMCard is IHalfBreededCard) player.HalfBreededCard = (IHalfBreededCard)dxMCard; else if (dxMCard is ISuperManchkinCard) player.SuperManchkinCard = (ISuperManchkinCard)dxMCard; else player.HandCards.Add(dxMCard); } foreach (ITreasureCard treasureCard in stuffManager.TreasureCards) { ICheatCard cheatCard = i++ == 4 ? stuffManager.DxMCards.OfType<ICheatCard>().Single() : null; player.WornItems.Add(Tuple.Create(treasureCard, cheatCard)); } /* for (int j = 0; j < n * 2; j++) player.HandCards.Add(cardManager.TreasureCards.First()); */ return player; }
public Person(string name,int age, Sex sex, Race race, String favoriteCar ) { Name = name; Age = age; Sex = sex; Race = race; FavoriteCar = favoriteCar; }
internal Character(World world, string firstName, string lastName, Sex gender, Date birthDate) : base(world) { FirstName = firstName; LastName = lastName; BirthDate = birthDate; Gender = gender; }
public Human CreateHuman(Sex sex) { var human = sex == Sex.Male ? _maleGenerator[_rnd.Next(_maleGenerator.Count)](sex) : _femaleGenerator[_rnd.Next(_femaleGenerator.Count)](sex); _humans.Add(human); return human; }
public Parent(string name, int age, Sex gender, int amountChildren) : base(name, age, gender) { if (amountChildren < 0) { throw new ArgumentOutOfRangeException(); } AmountChildren = amountChildren; }
public Person() { Sex = Sex.Female; Age = Age.ThirtyOneToForty; EducationLevel = EducationLevel.primary; Type = AgentType.Person; myID = idCounter++; }
protected Animal(string name, int age, Sex sex) { // I've made the Animal constructor, because an Animal should not be created anyway. // It's descendents can still use this constructor when creating their instances. this.Age = age; this.Name = name; this.Sex = sex; }
public Person(string name, Sex sex, Style style) { _name = name; _sex = sex; _style = style; StyleField = _style; }
public Kitten(string name, double age, Sex sex) : base(name, age, sex) { if (base.Sex != Sex.Female) { throw new ArgumentException("Kittens can be only female!!!"); } }
public TomCat(string name, int age, Sex sex) : base(name, age,sex) { if(sex == Sex.female) { throw new ArgumentException("TomCat must be male!"); // to check if it works } }
// Constructors public Student(string firstName, string middleName, string lastName, Sex sex, DateTime birthDate, long pin, int schClass, char schSubClass) : base(firstName, middleName, lastName, sex, birthDate, pin) { base.Password = pin.ToString(); this.SchClass = schClass; this.SchSubClass = schSubClass; }
// public MedicalFile MedicalFile { get; set; } public Patient(string id, string fNamen, string lName, Sex sex, string phone, string email, string address, DateTime birthDate) : base(id, fNamen, lName, sex, phone, email, address, birthDate) { }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as FamilyMemberHistory; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (InstantiatesCanonicalElement != null) { dest.InstantiatesCanonicalElement = new List <Hl7.Fhir.Model.Canonical>(InstantiatesCanonicalElement.DeepCopy()); } if (InstantiatesUriElement != null) { dest.InstantiatesUriElement = new List <Hl7.Fhir.Model.FhirUri>(InstantiatesUriElement.DeepCopy()); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.FamilyMemberHistory.FamilyHistoryStatus>)StatusElement.DeepCopy(); } if (DataAbsentReason != null) { dest.DataAbsentReason = (Hl7.Fhir.Model.CodeableConcept)DataAbsentReason.DeepCopy(); } if (Patient != null) { dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy(); } if (DateElement != null) { dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy(); } if (NameElement != null) { dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy(); } if (Relationship != null) { dest.Relationship = (Hl7.Fhir.Model.CodeableConcept)Relationship.DeepCopy(); } if (Sex != null) { dest.Sex = (Hl7.Fhir.Model.CodeableConcept)Sex.DeepCopy(); } if (Born != null) { dest.Born = (Hl7.Fhir.Model.DataType)Born.DeepCopy(); } if (Age != null) { dest.Age = (Hl7.Fhir.Model.DataType)Age.DeepCopy(); } if (EstimatedAgeElement != null) { dest.EstimatedAgeElement = (Hl7.Fhir.Model.FhirBoolean)EstimatedAgeElement.DeepCopy(); } if (Deceased != null) { dest.Deceased = (Hl7.Fhir.Model.DataType)Deceased.DeepCopy(); } if (ReasonCode != null) { dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy()); } if (ReasonReference != null) { dest.ReasonReference = new List <Hl7.Fhir.Model.ResourceReference>(ReasonReference.DeepCopy()); } if (Note != null) { dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy()); } if (Condition != null) { dest.Condition = new List <Hl7.Fhir.Model.FamilyMemberHistory.ConditionComponent>(Condition.DeepCopy()); } return(dest); }
public Cat(string name, int age, Sex sex) : base(name, age, sex) { this.Purpose = "I am the terror of mice!"; }
public DataOwner(Guid staffUserId, string fullName, string displayName, string email, DateTimeOffset registrationDate, int birthYear, Sex sex, Guid nationalSociety, Language preferredLanguage, string position, string dutyStation) : base(staffUserId, fullName, displayName, email, registrationDate) { BirthYear = birthYear; Sex = sex; NationalSociety = nationalSociety; PreferredLanguage = preferredLanguage; Position = position; DutyStation = dutyStation; PhoneNumbers = new List <PhoneNumber>(); AssignedNationalSocieties = new List <Guid>(); }
public void Should_Return_Enum_Description(Sex sex, string expectedValue) { var enumValue = EnumExtension.GetDescription(sex); Assert.Equal(enumValue, expectedValue); }
public void SetSex(Sex value) { this._sex = value; }
public Frog(string name, int age, Sex sex) : base(name, age, sex) { }
public Person(string name, Sex sex) { Name = name; Sex = sex; }
private void buttonSex_Click(object sender, EventArgs e) { sex = Utils.NextSex(sex); buttonSex.Text = Utils.SexSymbol(sex); }
protected abstract void ChangeSex(Sex sex);
public void Clone(Gene source) { val = source.val; carrier = source.carrier; }
public void drawBestParents(BreedingMode breedingMode, bool updateBreedingData = false) { SuspendLayout(); Cursor.Current = Cursors.WaitCursor; ClearControls(); // chosen Creature (only consider this one for its gender) bool considerChosenCreature = chosenCreature != null; Sex chosenCS = (considerChosenCreature ? chosenCreature.gender : Sex.Unknown); labelTitle.Text = currentSpecies + (considerChosenCreature ? " (only pairings with \"" + chosenCreature.name + "\")" : ""); if (considerChosenCreature && (chosenCreature.neutered || chosenCreature.status != CreatureStatus.Available)) { labelTitle.Text += "! Breeding not possible ! (" + (chosenCreature.neutered ? "neutered" : "not available") + ")"; } if (females != null && males != null && females.Count > 0 && males.Count > 0) { combinedTops[0].Clear(); combinedTops[1].Clear(); comboScore.Clear(); comboOrder.Clear(); double t = 0, tt = 0, pTS = 1; int o = 0, nrTS = 0; Int16[] bestPossLevels = new Int16[7]; // best possible levels for (int f = 0; f < females.Count; f++) { if (considerChosenCreature && chosenCS == Sex.Female && females[f] != chosenCreature) { continue; } for (int m = 0; m < males.Count; m++) { if (considerChosenCreature && chosenCS == Sex.Male && males[m] != chosenCreature) { continue; } combinedTops[0].Add(f); combinedTops[1].Add(m); t = 0; nrTS = 0; // number of possible top-stats pTS = 1; for (int s = 0; s < 7; s++) { bestPossLevels[s] = 0; tt = statWeights[s] * (0.7 * Math.Max(females[f].levelsWild[s], males[m].levelsWild[s]) + 0.3 * Math.Min(females[f].levelsWild[s], males[m].levelsWild[s])) / 40; if (tt <= 0) { tt = 0; } else if (breedingMode == BreedingMode.TopStatsLucky) { if (females[f].topBreedingStats[s] || males[m].topBreedingStats[s]) { if (females[f].topBreedingStats[s] && males[m].topBreedingStats[s]) { tt *= 1.142; } } else if (bestLevels[s] > 0) { tt *= .01; } } else if (breedingMode == BreedingMode.TopStatsConservative && bestLevels[s] > 0) { bestPossLevels[s] = (Int16)Math.Max(females[f].levelsWild[s], males[m].levelsWild[s]); tt *= .01; if (females[f].topBreedingStats[s] || males[m].topBreedingStats[s]) { nrTS++; pTS *= ((females[f].topBreedingStats[s] && males[m].topBreedingStats[s]) ? 1 : 0.7); } } t += tt; } if (breedingMode == BreedingMode.TopStatsConservative) { if (females[f].topStatsCountBP < nrTS && males[m].topStatsCountBP < nrTS) { t += nrTS * pTS; } else { t += .1 * nrTS * pTS; } // check if the best possible stat outcome already exists in a male bool maleExists = false; foreach (Creature cr in males) { maleExists = true; for (int s = 0; s < 7; s++) { if (cr.levelsWild[s] != bestPossLevels[s]) { maleExists = false; break; } } if (maleExists) { break; } } if (maleExists) { t *= .2; // another male with the same stats is not worth much } else { // check if the best possible stat outcome already exists in a female bool femaleExists = false; foreach (Creature cr in females) { femaleExists = true; for (int s = 0; s < 7; s++) { if (cr.levelsWild[s] != bestPossLevels[s]) { femaleExists = false; break; } } if (femaleExists) { break; } } if (femaleExists) { t *= .5; // another female with the same stats may be useful, but not so much in conservative breeding } } t *= 2; // scale conservative mode as it rather displays improvement, but only scarcely } comboScore.Add(t * 1.25); comboOrder.Add(o++); } } comboOrder = comboOrder.OrderByDescending(c => comboScore[c]).ToList(); // draw best parents int row = 0; // scrolloffsets int xS = AutoScrollPosition.X; int yS = AutoScrollPosition.Y; PedigreeCreature pc; Bitmap bm; Graphics g; PictureBox pb; for (int i = 0; i < maxSuggestions && i < comboOrder.Count; i++) { pc = new PedigreeCreature(females[combinedTops[0][comboOrder[i]]], enabledColorRegions, comboOrder[i]); pc.Location = new Point(10 + xS, 5 + 35 * row + yS); pc.CreatureClicked += new PedigreeCreature.CreatureChangedEventHandler(CreatureClicked); pc.CreatureEdit += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit); pc.BPRecalc += new BPRecalcEventHandler(BPRecalc); pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners); pc.exportToClipboard += new PedigreeCreature.ExportToClipboardEventHandler(exportToClipboard); panelCombinations.Controls.Add(pc); pcs.Add(pc); pc = new PedigreeCreature(males[combinedTops[1][comboOrder[i]]], enabledColorRegions, comboOrder[i]); pc.Location = new Point(397 + xS, 5 + 35 * row + yS); pc.CreatureClicked += new PedigreeCreature.CreatureChangedEventHandler(CreatureClicked); pc.CreatureEdit += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit); pc.BPRecalc += new BPRecalcEventHandler(BPRecalc); pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners); pc.exportToClipboard += new PedigreeCreature.ExportToClipboardEventHandler(exportToClipboard); panelCombinations.Controls.Add(pc); pcs.Add(pc); // draw score pb = new PictureBox(); pbs.Add(pb); panelCombinations.Controls.Add(pb); pb.Size = new Size(87, 15); pb.Location = new Point(308 + xS, 19 + 35 * row + yS); bm = new Bitmap(pb.Width, pb.Height); g = Graphics.FromImage(bm); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; Brush br = new SolidBrush(Utils.getColorFromPercent((int)(comboScore[comboOrder[i]] * 12.5), 0.5)); Brush brd = new SolidBrush(Utils.getColorFromPercent((int)(comboScore[comboOrder[i]] * 12.5), -.2)); g.FillRectangle(brd, 0, 5, 87, 5); g.FillRectangle(brd, 20, 0, 47, 15); g.FillRectangle(br, 1, 6, 85, 3); g.FillRectangle(br, 21, 1, 45, 13); g.DrawString(comboScore[comboOrder[i]].ToString("N4"), new System.Drawing.Font("Microsoft Sans Serif", 8.25f), new System.Drawing.SolidBrush(System.Drawing.Color.Black), 24, 2); pb.Image = bm; g.Dispose(); row++; } if (updateBreedingData) { setBreedingData(currentSpecies); } if (comboOrder.Count > 0) { setParents(comboOrder[0]); } else { setParents(-1); } } else { labelInfo.Text = "No possible pairings found for " + currentSpecies + ". Make sure at least one female and male are available in your library."; labelInfo.Visible = true; if (updateBreedingData) { setBreedingData(currentSpecies); } } Cursor.Current = Cursors.Default; ResumeLayout(); }
public Student(string name, int age, Sex sex, decimal salary) : base(name, age, sex, salary) { }
/// <summary> /// Constructor /// </summary> public RuminantFemale(double setAge, Sex setGender, double setWeight, RuminantType setParams) : base(setAge, setGender, setWeight, setParams) { SucklingOffspringList = new List <Ruminant>(); }
public Student(string name, Sex sex, int id) : base(name, sex) { ID = id; }
public Animal(string name, Sex sex, int age) { this.name = name; this.sex = sex; this.age = age; }
public HumanoidCharacterProfile WithSex(Sex sex) { return(new(Name, Age, sex, Appearance, _jobPriorities, PreferenceUnavailable, _antagPreferences)); }
public string this[string name] { get { CanSave = true; var validate = new Validation(); var db = new DataAccess(); string validationMessage = string.Empty; if (name == nameof(PersonalNo)) { if (!validate.IsValidPersonalNoFormat(PersonalNo)) { validationMessage = "Invalid personal number format!"; CanSave = false; } if (!validate.IsUniquePersonalNo(PersonalNo, db.LoadPersonalNumbers())) { validationMessage = "Personal number must be unique!"; CanSave = false; } //if peronal number is valid we can check the age of user if (validationMessage == string.Empty) { EmployeeAge = GeneratingData.CalculateAge(GeneratingData.GenerateBirthdate(PersonalNo)); if (EmployeeAge < 16) { validationMessage = "Persons younger than 16 years old can not be employed."; CanSave = false; } } } else if (name == nameof(Sex)) { if (!string.IsNullOrWhiteSpace(Sex)) { var sexToLower = Sex.ToLower(); if (sexToLower != "m" && sexToLower != "f" && sexToLower != "x") { validationMessage = "Please use letter 'm' for male,'f' for female sex or 'x' for other!"; CanSave = false; } } } else if (name == nameof(RegistrationNumber)) { if (RegistrationNumber.Length != 9 || !validate.IsDigitsOnly(RegistrationNumber)) { validationMessage = "Invalid registration number format!"; CanSave = false; } if (!validate.IsUniqueRegistrationNo(RegistrationNumber, db.LoadRegistrationNumbers())) { validationMessage = "Registartion number must be unique!"; CanSave = false; } } if (string.IsNullOrEmpty(validationMessage)) { CanSave = true; } return(validationMessage); } }
public async Task <Sex> SetSex(Sex sex) { return(await Task.FromResult(sex)); }
public void SetSex(string value) { this._sex = (value == "female") ? Sex.Female : (value == "male" ? Sex.Male : Sex.NotSpecified); }
public Worker(string name, Sex sex, int salary) : base(name, sex) { Salary = salary; }
public Frog(string name, byte age, Sex sex) : base(name, age, sex) { }
public Kitten(string name, int age, Sex gender) : base(name, age, Sex.Female) { }
public Raccoon(int _x, int _y, Sex _sex, int _range, int _rollBack, int _deadUntil, OrganismSentry _organismSentry) : base(_x, _y, _sex, _range, _rollBack, _deadUntil, _organismSentry) { }
// todo not used, remove? //private static Rectangle letterRect(Bitmap source, int hStart, int hEnd) //{ // int startWhite = -1, endWhite = -1; // for (int j = 0; j < source.Height; j++) // { // for (int i = hStart; i < hEnd; i++) // { // if (startWhite == -1 && source.GetPixel(i, j).R == 255) // { // startWhite = j; // } // if (endWhite == -1 && source.GetPixel(i, (source.Height - j) - 1).R == 255) // { // endWhite = (source.Height - j); // } // if (startWhite != -1 && endWhite != -1) // return new Rectangle(hStart, startWhite, hEnd - hStart, endWhite - startWhite); // } // } // return Rectangle.Empty; //} public double[] doOCR(out string OCRText, out string dinoName, out string species, out string ownerName, out string tribeName, out Sex sex, string useImageFilePath = "", bool changeForegroundWindow = true) { string finishedText = ""; dinoName = ""; species = ""; ownerName = ""; tribeName = ""; sex = Sex.Unknown; double[] finalValues = new double[1] { 0 }; if (ocrConfig == null) { OCRText = "Error: no ocr configured"; return(finalValues); } Bitmap screenshotbmp; ocrControl.debugPanel.Controls.Clear(); ocrControl.ClearLists(); if (System.IO.File.Exists(useImageFilePath)) { screenshotbmp = (Bitmap)Image.FromFile(useImageFilePath); } else { // grab screenshot from ark screenshotbmp = Win32Stuff.GetSreenshotOfProcess(screenCaptureApplicationName, waitBeforeScreenCapture, true); } if (screenshotbmp == null) { OCRText = "Error: no image for OCR. Is ARK running?"; return(finalValues); } if (!setResolution(screenshotbmp)) { OCRText = "Error while calibrating: The game-resolution is not supported by the currently loaded OCR-configuration.\n" + $"The tested image has a resolution of {screenshotbmp.Width.ToString()} × {screenshotbmp.Height.ToString()} px,\n" + $"the resolution of the loaded ocr-config is {ocrConfig.resolutionWidth} × {ocrConfig.resolutionHeight} px.\n\n" + "Load a ocr-config file with the resolution of the game to make it work."; return(finalValues); } // TODO resize image according to resize-factor. used for large screenshots if (ocrConfig.resize != 1 && ocrConfig.resize > 0) { Bitmap resized = new Bitmap((int)(ocrConfig.resize * ocrConfig.resolutionWidth), (int)(ocrConfig.resize * ocrConfig.resolutionHeight)); using (var graphics = Graphics.FromImage(resized)) { graphics.CompositingMode = CompositingMode.SourceCopy; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; using (var wrapMode = new ImageAttributes()) { wrapMode.SetWrapMode(WrapMode.TileFlipXY); graphics.DrawImage(screenshotbmp, new Rectangle(0, 0, 1920, 1080), 0, 0, screenshotbmp.Width, screenshotbmp.Height, GraphicsUnit.Pixel, wrapMode); } screenshotbmp?.Dispose(); screenshotbmp = resized; } } if (enableOutput) { AddBitmapToDebug(screenshotbmp); ocrControl.SetScreenshot(screenshotbmp); } finalValues = new double[ocrConfig.labelRectangles.Count]; finalValues[8] = -1; // set imprinting to -1 to mark it as unknown and to set a difference to a creature with 0% imprinting. if (changeForegroundWindow) { Win32Stuff.SetForegroundWindow(Application.OpenForms[0].Handle); } bool wild = false; // todo: set to true and find out if the creature is wild in the first loop int stI = -1; for (int lbI = 0; lbI < ocrConfig.labelNames.Count; lbI++) { stI++; if (lbI == 8) { stI = 8; } string statName = ocrConfig.labelNames[stI]; Rectangle rec = ocrConfig.labelRectangles[lbI]; // wild creatures don't have the xp-bar, all stats are moved one row up if (wild && stI < 9) { rec.Offset(0, ocrConfig.labelRectangles[0].Top - ocrConfig.labelRectangles[1].Top); } Bitmap testbmp = SubImage(screenshotbmp, rec.X, rec.Y, rec.Width, rec.Height); //AddBitmapToDebug(testbmp); string statOCR = ""; if (statName == "NameSpecies") { statOCR = readImage(testbmp, true, false); } else if (statName == "Level") { statOCR = readImage(testbmp, true, true); } else if (statName == "Tribe" || statName == "Owner") { statOCR = readImage(testbmp, true, false); } else { statOCR = readImage(testbmp, true, true); // statvalues are only numbers } if (statOCR == "" && (statName == "Health" || statName == "Imprinting" || statName == "Tribe" || statName == "Owner")) { if (wild && statName == "Health") { stI--; wild = false; } continue; // these can be missing, it's fine } lastLetterPositions[statName] = new Point(rec.X + lastLetterPosition(removePixelsUnderThreshold(GetGreyScale(testbmp), whiteThreshold)), rec.Y); finishedText += (finishedText.Length == 0 ? "" : "\r\n") + statName + ":\t" + statOCR; // parse the OCR String Regex r; r = new Regex(@"^[_\/\\]*(.*?)[_\/\\]*$"); // trim. often the background is misinterpreted as underscores or slash/backslash statOCR = r.Replace(statOCR, "$1"); if (statName == "NameSpecies") { r = new Regex(@".*?([♂♀])?[_.,-\/\\]*([^♂♀]+?)(?:[\(\[]([^\[\(\]\)]+)[\)\]]$|$)"); } else if (statName == "Owner" || statName == "Tribe") { r = new Regex(@"(.*)"); } else if (statName == "Level") { r = new Regex(@".*\D(\d+)"); } else { r = new Regex(@"(?:[\d.,%\/]*\/)?(\d+[\.,']?\d?)(%)?"); // only the second numbers is interesting after the current weight is not shown anymore //if (onlyNumbers) //r = new Regex(@"((\d*[\.,']?\d?\d?)\/)?(\d*[\.,']?\d?\d?)"); //else // r = new Regex(@"([a-zA-Z]*)[:;]((\d*[\.,']?\d?\d?)\/)?(\d*[\.,']?\d?\d?)"); } MatchCollection mc = r.Matches(statOCR); if (mc.Count == 0) { if (statName == "NameSpecies" || statName == "Owner" || statName == "Tribe") { continue; } if (statName == "Torpor" && false) { // probably it's a wild creature // todo } else { finishedText += "error reading stat " + statName; finalValues[stI] = 0; continue; } } if (statName == "NameSpecies" || statName == "Owner" || statName == "Tribe") { if (statName == "NameSpecies" && mc[0].Groups.Count > 0) { if (mc[0].Groups[1].Value == "♀") { sex = Sex.Female; } else if (mc[0].Groups[1].Value == "♂") { sex = Sex.Male; } dinoName = mc[0].Groups[2].Value; species = mc[0].Groups[3].Value; if (species.Length == 0) { species = dinoName; } // remove non-letter chars r = new Regex("[^a-zA-Z]"); species = r.Replace(species, ""); // replace capital I with lower l (common misrecognition) r = new Regex("(?<=[a-z])I(?=[a-z])"); species = r.Replace(species, "l"); // readd spaces before capital letters r = new Regex("(?<=[a-z])(?=[A-Z])"); species = r.Replace(species, " "); finishedText += "\t→ " + sex.ToString() + ", " + species; } else if (statName == "Owner" && mc[0].Groups.Count > 0) { ownerName = mc[0].Groups[0].Value; finishedText += "\t→ " + ownerName; } else if (statName == "Tribe" && mc[0].Groups.Count > 0) { tribeName = mc[0].Groups[0].Value.Replace("Tobe", "Tribe").Replace("Tdbe", "Tribe").Replace("Tribeof", "Tribe of "); finishedText += "\t→ " + tribeName; } continue; } if (mc[0].Groups.Count > 2 && mc[0].Groups[2].Value == "%" && statName == "Weight") { // first stat with a '%' is damage, if oxygen is missing, shift all stats by one finalValues[4] = finalValues[3]; // shift food to weight finalValues[3] = finalValues[2]; // shift oxygen to food finalValues[2] = 0; // set oxygen (which wasn't there) to 0 stI++; } double.TryParse(mc[0].Groups[1].Value.Replace('\'', '.').Replace(',', '.').Replace('O', '0'), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out double v); // common substitutions: comma and apostrophe to dot, finishedText += $"\t→ {v}"; // TODO: test here that the read stat name corresponds to the stat supposed to be read finalValues[stI] = v; } OCRText = finishedText; // TODO reorder stats to match 12-stats-order return(finalValues); /* * Bitmap grab = Win32Stuff.GetSreenshotOfProcess(screenCaptureApplicationName); * AddBitmapToDebug(grab); * * //grab.Save("E:\\Temp\\Calibration8.png", ImageFormat.Png); * if (changeForegroundWindow) * Win32Stuff.SetForegroundWindow(Application.OpenForms[0].Handle); */ }
public Employee(Sex sex) { _sex = sex; }
public FitTorso(int numberOfArms, Sex sex, Colors color) : base(numberOfArms, sex, color, "OMG, so fit. It's lit.") { }
public Dog(string name, uint age, Sex sex) : base(name, age, sex) { }
public Animal(string name, byte age, Sex sex) { this.Name = name; this.Age = age; this.Sex = sex; }
public Gene(byte b, Sex s = Sex.Either) { val = b; carrier = s; }