示例#1
0
        public void ShowDice(Dice dice)
        {
            Rectangle rect = new Rectangle()
            {
                Fill = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255)),
                Stroke = new SolidColorBrush(dice.DiceColor == DiceColor.Red ? Colors.DarkRed : Colors.Black),
                Width = 50,
                Height = 50,
            };

            mainCanvas.Children.Add(rect);
            Canvas.SetLeft(rect, dice.Position.X - 25);
            Canvas.SetTop(rect, dice.Position.Y - 25);

            ScaleTransform trans = new ScaleTransform(1.0, 1.0, 25, 25);
            rect.RenderTransform = trans;

            DoubleAnimation anim = new DoubleAnimation(10.0, 1.0, new Duration(TimeSpan.FromSeconds(0.25)));
            trans.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
            trans.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
        }
 public DiceEventArgs(Dice dice)
 {
     this.Dice = dice;
 }
        private void videoImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (state == WizardOzState.Dice)
            {
                Point vizPos = e.GetPosition(imageCanvas);
                Point actualPos = new Point(vizPos.X * 2.5, vizPos.Y * 2.5);    //TODO: hardcoding!

                DiceColor diceColor = e.RightButton == MouseButtonState.Pressed ? DiceColor.Red : DiceColor.White;
                Dice d = new Dice(dices.Count, actualPos, diceColor);
                dices.Add(d);

                Canvas.SetLeft(diceTextBox, e.GetPosition(imageCanvas).X + 10);
                Canvas.SetTop(diceTextBox, e.GetPosition(imageCanvas).Y + 10);
                //diceTextBox.SelectAll();
                diceTextBox.Text = "";
                diceTextBox.Visibility = Visibility.Visible;
                diceTextBox.IsReadOnly = false;
                diceTextBox.Foreground = diceColor == DiceColor.Red ? Brushes.White : Brushes.Black;
                diceTextBox.Background = diceColor == DiceColor.Red ? Brushes.DarkRed : Brushes.White;
                diceTextBox.Focus();

                if (DiceLocated != null)
                {
                    DiceLocated(this, new DiceEventArgs(d));
                }
            }
        }
示例#4
0
 public DiceEventArgs(Dice dice)
 {
     this.Dice = dice;
 }