Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        private void QuickPopulate(string str)
        {
            VotableTouchButton2 button = new VotableTouchButton2();
            button.Width = button.Height = 50;

            button.IsVotable = true;
            button.VoteRequestWhen = VoteRequestFlags.OnInterval;
            button.VoteRequestInterval = 30000; //25 seconds
            button.VoteAutoCancelInterval = 15000;

            button.Content = str;

            button.Style = (Style)App.Current.FindResource("BraglButton");

            VotableButtonTray.getInstance().RegisterVotable(button);
        }
Пример #2
0
        /// <summary>
        /// Tells the Tray that a button is canceling their vote.
        /// </summary>
        /// <returns>True if the Vote is canceled.</returns>
        public bool CancelVote(VotableTouchButton2 v)
        {
            if (voteTarget != null && v == voteTarget) //currently voting...
            {
                VotableTouchButton2 temp = voteTarget;
                voteTarget = null;

                RaiseVoteTargetChanged(temp, voteTarget);

                //return the Tray to the starting location
                CornerDockPanel.SetCornerDock(this, CornerDock.TopRightCorner, true);
                _TouchesRemaining = App.TABLE_USERS;

                return true;
            }
            return false;
        }
        void voteHandler_VoteTargetChanged(object src, Events.VotableButtonTrayChangedRoutedEventArgs args)
        {
            IsVotable = (args.to == null || args.to == this);
            bool willVote = args.to == null;

            if (willVote)
            {
                VoteFilterColor = EXITMODECOLOR;

                DoubleAnimation danim = new DoubleAnimation(colorSaturator.ColorSaturation, 0.5, new Duration(TimeSpan.FromMilliseconds(1500)));
                colorSaturator.BeginAnimation(ColorSaturatorEffect.ColorSaturationProperty, null);//
                colorSaturator.BeginAnimation(ColorSaturatorEffect.ColorSaturationProperty, danim);
            }
            else
            {
                VoteFilterColor = CANCELMODECOLOR;

                DoubleAnimation danim = new DoubleAnimation(colorSaturator.ColorSaturation, 0.5, new Duration(TimeSpan.FromMilliseconds(1500)));
                colorSaturator.BeginAnimation(ColorSaturatorEffect.ColorSaturationProperty, null);//
                colorSaturator.BeginAnimation(ColorSaturatorEffect.ColorSaturationProperty, danim);
            }

            currTarget = args.to;
        }
Пример #4
0
        public void UnregisterVotable(VotableTouchButton2 v)
        {
            v.voteHandler = null;
            Buttons.Remove(v);
            Children.Remove(v);

            if (voteTarget == v)
            {
                VotableTouchButton2 temp = voteTarget;
                voteTarget = null;
                RaiseVoteTargetChanged(temp, voteTarget);
            }
        }
Пример #5
0
        /// <summary>
        /// Tells the tray that a button wishes to become the new vote target.
        /// </summary>
        /// <param name="src"></param>
        /// <returns>whether or not the button becomes the new vote target</returns>
        public bool RequestVote(VotableTouchButton2 src)
        {
            if(!src.IsVotable){ return false;  } ////dont waste my time

            if (voteTarget == null || src.CanInterruptVote)
            {
                VotableTouchButton2 temp = voteTarget;
                voteTarget = src;

                RaiseVoteTargetChanged(temp, src);

                //@TODO: Add code that resets all buttons
                int i = 0;
                foreach (VotableTouchButton2 button in Buttons)
                {
                    //force everything to wait.
                    if (button != src)
                    {
                        button.ForceWaiting(button.VoteRequestInterval + 10 * (++i));
                    }
                }

                return true;
            }
            return false;
        }
Пример #6
0
 public void RegisterVotable(VotableTouchButton2 v)
 {
     v.voteHandler = this;
     Buttons.Add(v);
     Children.Add(v);
 }
Пример #7
0
 public void RaiseVoteTargetChanged(VotableTouchButton2 from, VotableTouchButton2 to)
 {
     RaiseEvent(new VotableButtonTrayChangedRoutedEventArgs(VoteTargetChangedEvent, this, from, to));
 }
Пример #8
0
        /// <summary>
        /// Tells the tray that a button is casting a vote.
        /// </summary>
        /// <param name="src"></param>
        /// <returns></returns>
        public bool CastVote(VotableTouchButton2 src)
        {
            if (src == voteTarget) //check validity of vote being cast.
            {
                int currentCorner = (int)CornerDockPanel.GetCornerDock(this);
                //looks better this way i think
                CornerDockPanel.SetCornerDock(this,
                    (CornerDock)((((currentCorner - _CornerDockIncrement) % 4) + 4) % 4), true);

                return --_TouchesRemaining <= 0;
            }
            return false; //stupid >>
        }