Exemple #1
0
        public void drag(double px, double py, cue c)
        {
            if (!c.m_isDragged)
            {
                m_vx = m_vy = 0;

                m_y = px;
                m_x = py;

                setLTWH();
            }
        }
        public billard()
        {
            m_dlg = new startdlg();

            if ((bool)m_dlg.ShowDialog())
            {
                m_name1 = m_dlg.m_name1;
                m_name2 = m_dlg.m_name2;
            }
            else
            {
                Close();
            }

            InitializeComponent();

            spieler1.FontFamily = new FontFamily("Courier New");
            spieler1.FontSize = 20F;
            spieler1.FontWeight = FontWeights.Bold;
            spieler1.Foreground = Brushes.Green;
            spieler2.FontFamily = new FontFamily("Courier New");
            spieler2.FontSize = 20F;
            spieler2.FontWeight = FontWeights.Regular;
            spieler2.Foreground = Brushes.Gray;
            zeit.FontFamily = new FontFamily("Courier New");
            zeit.FontSize = 20F;
            zeit.FontWeight = FontWeights.Bold;
            zeit.Foreground = Brushes.DarkCyan;

            Canvas.SetLeft(m_frame, 135);
            Canvas.SetTop(m_frame, 195);

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.GradientStops.Add(new GradientStop(Colors.Brown, 0.0));
            brush.GradientStops.Add(new GradientStop(Colors.Chocolate, 1.0));

            m_frame.Fill = brush;

            m_frame.Width = 630;          // SetBottom, SetRight reicht nicht ==> kein Rechteck zu sehen
            m_frame.Height = 330;
            m_frame.RadiusX = 15;
            m_frame.RadiusY = 15;
            m_canvas.Children.Add(m_frame);

            Canvas.SetLeft(m_table, 150);
            Canvas.SetTop(m_table, 210);
            m_table.Fill = System.Windows.Media.Brushes.Green;
            m_table.Width = 600;
            m_table.Height = 300;
            m_canvas.Children.Add(m_table);

            m_balls = new ball[3];
            m_balls[0] = new ball(350, 800, m_dlg.m_radius, 0.0005, System.Drawing.Color.White);
            m_balls[1] = new ball(280, 220, m_dlg.m_radius, 0.0005, System.Drawing.Color.Yellow);
            m_balls[2] = new ball(420, 220, m_dlg.m_radius, 0.0005, System.Drawing.Color.Red);

            foreach (ball ball in m_balls)
            {
                m_canvas.Children.Add(ball.m_theball);    // Damit wird der Ball gerendert
            }

            m_cue = new cue();
            m_canvas.Children.Add(m_cue.m_line);
            m_canvas.Children.Add(m_cue.m_laser);
            m_canvas.Children.Add(m_cue.m_knob);

            radius.Value = m_dlg.m_radius;
            impulse.Value = 1000;
        }