public VoteButton(IVotable votable, bool toUpvote = false) //^dependency { //Delegate deleUpvote = delegate(object o, EventArgs e) //{ votable.TakeBackUpvote(ref toUpvote); } //deleUpvote = delegate void KK(Object o, EventArgs E){ // votable.Upvote(ref toUpvote); //} // deleUpvote = (Object o, EventArgs e) => return votable.Upvote(ref toUpvote); this.BackColor = System.Drawing.Color.MediumSlateBlue; this.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.Margin = new System.Windows.Forms.Padding(2); this.Name = "upvoteButton"; this.Size = new System.Drawing.Size(46, 25); this.TabIndex = 16; this.Text = "Vote++"; this.UseVisualStyleBackColor = false; // // // this.toUpvote = toUpvote; this.previousToUpvote = !toUpvote; this.votable = votable; this.Click += (obj, args) => this.AfterClick(); //^events standard }
private VoteDirections GetUserVote(IVotable item, ObjectId userId) { return(item.Upvoters.Contains(userId) ? VoteDirections.Up : item.Downvoters.Contains(userId) ? VoteDirections.Down : VoteDirections.Cancel); }
public void MergeVotable(IVotable votableThing) { _votableThing = votableThing; originalVoteModifier = (Like ? 1 : 0) + (Dislike ? -1 : 0); RaisePropertyChanged("Like"); RaisePropertyChanged("Dislike"); RaisePropertyChanged("TotalVotes"); RaisePropertyChanged("LikeStatus"); RaisePropertyChanged("SelfRef"); }
public virtual void TimeEnd() { hackEndTimeVote = true; int vote; IVotable iv = this as IVotable; if (iv != null) { iv.Vote(TasSayEventArgs.Default, new string[] {}); } }
public void StopVote() { if (activePoll != null) { activePoll.End(); } if (pollTimer != null) { pollTimer.Enabled = false; } activePoll = null; }
public void RegisterVote(TasSayEventArgs e, bool vote) { if (activePoll != null) { if (activePoll.Vote(e, vote)) { pollTimer.Enabled = false; activePoll = null; } } else { Respond(e, "There is no poll going on, start some first"); } }
public void StartVote(IVotable vote, TasSayEventArgs e, string[] words) { if (vote != null) { if (activePoll != null) { Respond(e, "Another poll already in progress, please wait"); return; } if (vote.Init(e, words)) { activePoll = vote; pollTimer.Interval = PollTimeout * 1000; pollTimer.Enabled = true; } } }
public async Task RemoveMarkAsync(long id) { Vote voteToRemove = await localContext.Votes.FindAsync(id); if (voteToRemove != null) { IVotable relatedObject = null; if (voteToRemove.VotedPost != null) { relatedObject = voteToRemove.VotedPost; } else { relatedObject = voteToRemove.VotedComment; } relatedObject?.RemoveReferenceToVote(voteToRemove.Id); context.Remove(voteToRemove); await context.SaveChangesAsync(); //[Note] - potencjalnie tak, bo inacej EF domyślnie może się wywalić - Czy tutaj usuwając Vote'a muszę też zaktualizować powiązany z nim obiekt, czy EF sam to już ogarnie w context'cie? //TODO: repo vote'ów powinno usuwać zależności wcześniej, a całość ma być wyowłana przez service } }
public void StopVote() { if (activePoll != null) activePoll.End(); if (pollTimer != null) pollTimer.Enabled = false; activePoll = null; }
public void RegisterVote(TasSayEventArgs e, bool vote) { if (activePoll != null) { if (activePoll.Vote(e, vote)) { pollTimer.Enabled = false; activePoll = null; } } else Respond(e, "There is no poll going on, start some first"); }
public void StopVote() { pollTimer.Enabled = false; activePoll = null; }
public void Upvote(IVotable votable) { Badges.Add(Badge.Supporter); votable.Upvote(this); }
protected BaseVotableViewModel(IVotable item, ObjectId userId) { Rating = item.Rating; UserVote = GetUserVote(item, userId); }
// allow current vote status to be injected? public Comment(IVotable voteStatusReference) { this.VoteStatus = voteStatusReference; }
public void StopVote(TasSayEventArgs e = null) { if (e != null) { string name = e.UserName; if (name != null && activePoll != null && name != activePoll.Creator) { if (GetUserLevel(name) < GlobalConst.SpringieBossEffectiveRights) { Respond(e, "Sorry, you do not have rights to end this vote"); return; } } } if (activePoll != null) activePoll.End(); if (pollTimer != null) pollTimer.Enabled = false; activePoll = null; }
public void StartVote(IVotable vote, TasSayEventArgs e, string[] words) { if (vote != null) { if (activePoll != null) { Respond(e, "Another poll already in progress, please wait"); return; } if (vote.Init(e, words)) { activePoll = vote; pollTimer.Interval = PollTimeout*1000; pollTimer.Enabled = true; } } }
public void Downvote(IVotable votable) { Badges.Add(Badge.Critic); votable.Downvote(this); }
public void RemoveDownvote(IVotable votable) { votable.RemoveDownvote(this); }
public VotableViewModel(IVotable votableThing, Action propertyChanged) { _votableThing = votableThing; _propertyChanged = propertyChanged; originalVoteModifier = (Like ? 1 : 0) + (Dislike ? -1 : 0); }