public string getFormattedFabricPopularity() { List <Networking.SingleDependable.Fabric> fabrics = Networking.SingleDependable.FabricNetworkProxy.GetAll(); List <Networking.MultipleDependable.Booking> bookings = Networking.MultipleDependable.BookingNetworkProxy.GetAll(); List <Popularity <Networking.SingleDependable.Fabric> > fabricalPopularities = new List <Popularity <Networking.SingleDependable.Fabric> >(); foreach (Networking.SingleDependable.Fabric fabric in fabrics) { Popularity <Networking.SingleDependable.Fabric> fabricalPopularity = new Popularity <Networking.SingleDependable.Fabric>(fabric); foreach (Networking.MultipleDependable.Booking booking in bookings) { if (booking.fabric.id == fabric.id) { fabricalPopularity.priorityCounter += 1; } } fabricalPopularities.Add(fabricalPopularity); } fabricalPopularities.Sort(); string resultString = "Fabric Popularity:\r"; resultString += $"{Consts.lineBraker}\r"; foreach (Popularity <Networking.SingleDependable.Fabric> fabricalPopularity in fabricalPopularities) { if (fabricalPopularity.priorityCounter > 0) { resultString += $"{fabricalPopularity.popularityObject.name}: "; resultString += $"popularity = {fabricalPopularity.priorityCounter}\r"; resultString += $"{Consts.lineBraker}\r"; } } return(resultString); }
public string getFormattedModelPopularity() { List <Networking.Independent.Model> models = Networking.Independent.ModelNetworkProxy.GetAll(); List <Networking.MultipleDependable.Booking> bookings = Networking.MultipleDependable.BookingNetworkProxy.GetAll(); List <Popularity <Networking.Independent.Model> > modelPopularities = new List <Popularity <Networking.Independent.Model> >(); foreach (Networking.Independent.Model model in models) { Popularity <Networking.Independent.Model> modelPopularity = new Popularity <Networking.Independent.Model>(model); foreach (Networking.MultipleDependable.Booking booking in bookings) { if (booking.model.id == model.id) { modelPopularity.priorityCounter += 1; } } modelPopularities.Add(modelPopularity); } modelPopularities.Sort(); string resultString = "Model Popularity:\r"; resultString += $"{Consts.lineBraker}\r"; foreach (Popularity <Networking.Independent.Model> modelPopularity in modelPopularities) { if (modelPopularity.priorityCounter > 0) { resultString += $"{modelPopularity.popularityObject.name}: "; resultString += $"popularity = {modelPopularity.priorityCounter}\r"; resultString += $"{Consts.lineBraker}\r"; } } return(resultString); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Nazov")] Popularity popularity) { if (id != popularity.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(popularity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PopularityExists(popularity.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(popularity)); }
public string getFormattedManufacturerPopularity() { List <Networking.SingleDependable.Fabric> fabrics = Networking.SingleDependable.FabricNetworkProxy.GetAll(); List <Networking.Independent.Manufacturer> manufacturers = Networking.Independent.ManufacturerNetworkProxy.GetAll(); List <Popularity <Networking.Independent.Manufacturer> > fabricalManufacturers = new List <Popularity <Networking.Independent.Manufacturer> >(); foreach (Networking.Independent.Manufacturer manufacturer in manufacturers) { Popularity <Networking.Independent.Manufacturer> fabricalManufacturer = new Popularity <Networking.Independent.Manufacturer>(manufacturer); foreach (Networking.SingleDependable.Fabric fabric in fabrics) { if (fabric.manufacturer.id == manufacturer.id) { fabricalManufacturer.priorityCounter += 1; } } fabricalManufacturers.Add(fabricalManufacturer); } fabricalManufacturers.Sort(); string resultString = "Manufacturer Popularity:\r"; resultString += $"{Consts.lineBraker}\r"; foreach (Popularity <Networking.Independent.Manufacturer> fabricalManufacturer in fabricalManufacturers) { resultString += $"{fabricalManufacturer.popularityObject.firmName}: "; resultString += $"popularity = {fabricalManufacturer.priorityCounter}\r"; resultString += $"{Consts.lineBraker}\r"; } return(resultString); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { Random rnd = new Random(); Color[,] color = null; if (algorithm == AlgorithmEnum.ditheringAverage) { color = Average.ComputeAlgorithm(currentImage, Kr, Kg, Kb, backgroundWorker1); } else if (algorithm == AlgorithmEnum.ditheringOrderedVersion1) { color = Ordered.ComputeAlgorithmVersion1(currentImage, Kr, Kg, Kb, rnd, backgroundWorker1); } else if (algorithm == AlgorithmEnum.ditheringOrderedVersion2) { color = Ordered.ComputeAlgorithmVersion2(currentImage, Kr, Kg, Kb, rnd, backgroundWorker1); } else if (algorithm == AlgorithmEnum.ditheringFloydSteinberg) { color = ErrorDiffusion.FloydSteinberg(currentImage, Kr, Kg, Kb, backgroundWorker1); } else if (algorithm == AlgorithmEnum.ditheringBurkes) { color = ErrorDiffusion.Burkes(currentImage, Kr, Kg, Kb, backgroundWorker1); } else if (algorithm == AlgorithmEnum.ditheringStucky) { color = ErrorDiffusion.Stucky(currentImage, Kr, Kg, Kb, backgroundWorker1); } else if (algorithm == AlgorithmEnum.popularityAlgorythm) { color = Popularity.ComputeAlgorithm(currentImage, K, backgroundWorker1); } e.Result = color; }
public ScenicNode(string name, string description, Popularity welcomedegree, bool canrest, bool iswc) { this.name = name; this.description = description; welcomeDegree = welcomedegree; CanRest = canrest; IsWC = iswc; }
private void Popularity_Form_Load(object sender, EventArgs e) { this.dgw_popularity.Size = new Size(568, 220); this.dgw_popularity.DataSource = Popularity.Show_All_Popularities(); this.pnl_operation.Hide(); this.lbl_msg1.Text = ""; this.lbl_msg2.Text = ""; }
private void InitPopularityIfAbsent(int userId, Course course) { if (course.PopularityStats.Count(p => p.UserDetailsId == userId) == 0) { Popularity newPopularityStat = new Popularity { UserDetailsId = userId, CourseId = course.Id, Votes = 0 }; course.PopularityStats.Add(newPopularityStat); } }
/// <summary> /// Override GetHashCode for dish /// </summary> /// <returns></returns> public override int GetHashCode() { int hashCode = 256195580; hashCode = hashCode * -1521134295 + Id.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name); hashCode = hashCode * -1521134295 + Popularity.GetHashCode(); hashCode = hashCode * -1521134295 + IdType.GetHashCode(); return(hashCode); }
public async Task <IActionResult> Create([Bind("ID,Nazov")] Popularity popularity) { if (ModelState.IsValid) { _context.Add(popularity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(popularity)); }
private void btn_ok_Click(object sender, EventArgs e) { this.lbl_msg1.Text = ""; this.lbl_msg2.Text = ""; if (tb_name.Text.Trim() == "") { lbl_msg1.Text = "*Invalid"; lbl_msg1.ForeColor = Color.Red; return; } if (tb_score.Text.Trim() == "") { lbl_msg2.Text = "*Invalid"; lbl_msg2.ForeColor = Color.Red; return; } this.name = tb_name.Text.Trim(); this.score = int.Parse(tb_score.Text.Trim()); if (Popularity.Contains_Name(name) != this.id && Popularity.Contains_Name(name) != -1) { lbl_msg1.Text = "*Exist"; lbl_msg1.ForeColor = Color.Red; return; } if (Popularity.Contains_Score(score) != this.id && Popularity.Contains_Score(score) != -1) { lbl_msg2.Text = "*Exist"; lbl_msg2.ForeColor = Color.Red; return; } if (opr == OPERATION.ADD) { Popularity new_pop = new Popularity(0, name, score); new_pop.Add(); dgw_popularity.DataSource = Popularity.Show_All_Popularities(); new_pop = null; } else if (opr == OPERATION.EDIT) { Popularity curr_pop = new Popularity(id, name, score); curr_pop.Edit(); dgw_popularity.DataSource = Popularity.Show_All_Popularities(); curr_pop = null; } }
/// <summary> /// Converts an object into its XML representation. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> stream to which the object is serialized.</param> public void WriteXml(XmlWriter writer) { writer.WriteAttributeString(nameof(Base), Base.AbsoluteUri); writer.WriteAttributeString(nameof(Popularity), Popularity.ToString(CultureInfo.InvariantCulture)); if (Profiles != null) { writer.WriteStartElement(nameof(ProfileRefList)); writer.WriteAttributeString("Key", nameof(Profiles)); Profiles.WriteXml(writer); writer.WriteEndElement(); } }
public Genetic(int popuSize, int chromosomeLength, Func <Chromosome, double> score, double crossoverRatio = 0.1, double mutateRatio = 0.05) { MutateRatio = mutateRatio; CrossoverRatio = crossoverRatio; ChromosomeLength = chromosomeLength; PopuSize = popuSize; split = 1.0 / chromosomeLength; Score = score; GetCrossOverHead = prob => (int)(prob / split); Popularity = Enumerable.Range(0, popuSize).Select(i => ChromosomeLength).Select(GenChromosome).ToList(); }
public int CompareTo(object obj) { Popularity <T> popularity = obj as Popularity <T>; if (popularity.priorityCounter > priorityCounter) { return(1); } else if (popularity.priorityCounter < priorityCounter) { return(-1); } else { return(0); } }
public IHttpActionResult PostCommentLike(int id) { Comment comment = db.Comments.Find(id); if (comment == null) { var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent( string.Format("Comment with ID = {0} doesn't exist", id) ) }; throw new HttpResponseException(resp); } comment.Likes++; Popularity.CommentLiked(comment.Post.CourseId, comment.UserDetails.UserDetailsId, db); db.SaveChanges(); return(Ok(comment)); }
public IHttpActionResult PostPostDislike(int postId) { Post post = db.Posts.Find(postId); if (post == null) { var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent( string.Format("Cannot dislike post. Post with ID = {0} doesn't exist", postId) ) }; throw new HttpResponseException(resp); } post.Dislikes++; Popularity.PostDisliked(post.CourseId, post.UserDetailsId, db); db.SaveChanges(); return(Ok()); }
private void btn_remove_Click(object sender, EventArgs e) { Microwave main_page = (Microwave)Application.OpenForms["Microwave"]; string msg = "Are you sure to delete a popularity type?"; main_page.Create_Warning_Form(msg, Color.DarkRed); if (main_page.Warning_form.Result) { main_page.Warning_form.Refresh_Form(); this.id = int.Parse(dgw_popularity.SelectedRows[0].Cells[0].Value.ToString()); if (this.id == -1) { return; } if (this.id == 0) { MessageBox.Show("Default cannot be deleted.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Popularity pop_delete = new Popularity(id, name, score); pop_delete.Delete(); this.dgw_popularity.DataSource = Popularity.Show_All_Popularities(); } main_page.Warning_form.Refresh_Form(); return; }
public bool Equals(PostResponse input) { if (input == null) { return(false); } return (( LastReplyTimestamp == input.LastReplyTimestamp || (LastReplyTimestamp != null && LastReplyTimestamp.Equals(input.LastReplyTimestamp)) ) && ( IsPinned == input.IsPinned || (IsPinned != null && IsPinned.Equals(input.IsPinned)) ) && ( UrlMediaType == input.UrlMediaType || (UrlMediaType != null && UrlMediaType.Equals(input.UrlMediaType)) ) && ( Thumbnail == input.Thumbnail || (Thumbnail != null && Thumbnail.Equals(input.Thumbnail)) ) && ( Popularity == input.Popularity || (Popularity != null && Popularity.Equals(input.Popularity)) ) && ( IsActive == input.IsActive || (IsActive != null && IsActive.Equals(input.IsActive)) ) && ( IsAnnouncement == input.IsAnnouncement || (IsAnnouncement != null && IsAnnouncement.Equals(input.IsAnnouncement)) ) && ( UserRating == input.UserRating || (UserRating.Equals(input.UserRating)) ) && ( UserHasRated == input.UserHasRated || (UserHasRated != null && UserHasRated.Equals(input.UserHasRated)) ) && ( UserHasMutedPost == input.UserHasMutedPost || (UserHasMutedPost != null && UserHasMutedPost.Equals(input.UserHasMutedPost)) ) && ( LatestReplyPostId == input.LatestReplyPostId || (LatestReplyPostId.Equals(input.LatestReplyPostId)) ) && ( LatestReplyAuthorId == input.LatestReplyAuthorId || (LatestReplyAuthorId.Equals(input.LatestReplyAuthorId)) ) && ( IgnoreStatus == input.IgnoreStatus || (IgnoreStatus != null && IgnoreStatus.Equals(input.IgnoreStatus)) ) && ( Locale == input.Locale || (Locale != null && Locale.Equals(input.Locale)) )); }
public override int GetHashCode() { int hash = 1; if (CardId != 0) { hash ^= CardId.GetHashCode(); } if (Player != 0) { hash ^= Player.GetHashCode(); } if (Credit != 0) { hash ^= Credit.GetHashCode(); } if (Singing != 0) { hash ^= Singing.GetHashCode(); } if (Dancing != 0) { hash ^= Dancing.GetHashCode(); } if (Composing != 0) { hash ^= Composing.GetHashCode(); } if (Popularity != 0) { hash ^= Popularity.GetHashCode(); } if (Charm != 0) { hash ^= Charm.GetHashCode(); } if (Perseverance != 0) { hash ^= Perseverance.GetHashCode(); } if (Puzzle != 0) { hash ^= Puzzle.GetHashCode(); } if (CardName.Length != 0) { hash ^= CardName.GetHashCode(); } if (Gold != 0) { hash ^= Gold.GetHashCode(); } if (GrowthRateS != 0F) { hash ^= GrowthRateS.GetHashCode(); } if (GrowthRateD != 0F) { hash ^= GrowthRateD.GetHashCode(); } if (GrowthRateC != 0F) { hash ^= GrowthRateC.GetHashCode(); } if (GrowthRatePo != 0F) { hash ^= GrowthRatePo.GetHashCode(); } if (GrowthRateCh != 0F) { hash ^= GrowthRateCh.GetHashCode(); } if (GrowthRatePe != 0F) { hash ^= GrowthRatePe.GetHashCode(); } hash ^= gainSceneIds_.GetHashCode(); hash ^= evoSceneIds_.GetHashCode(); if (NewViewEvo != 0) { hash ^= NewViewEvo.GetHashCode(); } if (MemoriesItem != 0) { hash ^= MemoriesItem.GetHashCode(); } if (Used != 0) { hash ^= Used.GetHashCode(); } return(hash); }
/// <summary> /// Filter by the number of users with this media on their list /// </summary> public GraphQueryArgument <int> PopularityArgument(int value) { return(Popularity.GetQueryArgumentAndSetValue(value)); }
public void HandlePositiveEvents(EventScriptableObj eventObj) { string numberText = ""; switch (eventObj.m_PositiveEventType) { case PositiveEventTypes.DECREASE_TEMPERATURE: { Temperature temperature = GameStats.Instance.m_Temperature; if (temperature == null) { return; } float decreaseAmt = 0; if (eventObj.m_AffectedByPercentage) { decreaseAmt = ((float)temperature.m_CurrTemperatureAmt * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { decreaseAmt = Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } temperature.AddToTemperatureOffset(decreaseAmt); numberText = "Temperature slightly decreased."; } break; case PositiveEventTypes.GET_MONEY: { Money money = GameStats.Instance.m_Money; if (money == null) { return; } int increaseAmt = 0; if (eventObj.m_AffectedByPercentage) { increaseAmt = (int)((float)money.m_CurrMoney * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { increaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = "$" + increaseAmt.ToString(); money.IncreaseMoney(increaseAmt); } break; case PositiveEventTypes.INCREASE_POPULARITY: { Popularity popularity = GameStats.Instance.m_Popularity; if (popularity == null) { return; } int increaseAmt = 0; if (eventObj.m_AffectedByPercentage) { increaseAmt = (int)((float)popularity.m_CurrentPopularity * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { increaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = increaseAmt.ToString(); popularity.UpdatePopularityOffset(increaseAmt); } break; } ++m_EventNumberInAMonth; UpdateUI(eventObj, numberText); SoundManager.Instance.Play("successfulFund"); }
public ImageItem(string name, double sizeFile, DateTime creationDate, Popularity popularity, ScreenResolution screenResolution) : base(name, sizeFile, creationDate, popularity) { this.ScreenResolution = screenResolution; }
public void HandleNegativeEvent(EventScriptableObj eventObj) { string numberText = ""; switch (eventObj.m_NegativeEventType) { case NegativeEventTypes.INCREASE_TEMPERATURE: { Temperature temperature = GameStats.Instance.m_Temperature; if (temperature == null) { return; } float increaseAmt = 0; if (eventObj.m_AffectedByPercentage) { increaseAmt = ((float)temperature.m_CurrTemperatureAmt * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { increaseAmt = Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } temperature.AddToTemperatureOffset(-increaseAmt); numberText = "Temperature slightly increased."; } break; case NegativeEventTypes.DECREASE_POPULARITY: { Popularity popularity = GameStats.Instance.m_Popularity; if (popularity == null) { return; } int decreaseAmt = 0; if (eventObj.m_AffectedByPercentage) { decreaseAmt = (int)((float)popularity.m_CurrentPopularity * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { decreaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = decreaseAmt.ToString(); popularity.UpdatePopularityOffset(-decreaseAmt); } break; case NegativeEventTypes.LOSE_MONEY: { Money money = GameStats.Instance.m_Money; if (money == null) { return; } int decreaseAmt = 0; if (eventObj.m_AffectedByPercentage) { decreaseAmt = (int)((float)money.m_CurrMoney * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { decreaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = "$" + decreaseAmt.ToString(); money.ReduceMoney(decreaseAmt); } break; case NegativeEventTypes.EVIL_COOPERATE: { //THIS EVENT CAN ONLY HAPPEN WHEN THERE ARE TREES if (MapManager.Instance.GetTotalAmtOfTreeOnMap() == 0) { return; } int numberToSpawn = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); for (int i = 0; i < numberToSpawn; ++i) { NPCManager.Instance.SpawnEvilPeople(); } } break; } ++m_EventNumberInAMonth; ++m_NumberOfBadEventsInAMonth; UpdateUI(eventObj, numberText); SoundManager.Instance.Play("UnsuccessfulFund"); }