Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        private void Neu_Click(object sender, RoutedEventArgs e)
        {
            m_dlg = new startdlg();

            m_dlg.spieler1.Text = m_name1;
            m_dlg.spieler2.Text = m_name2;

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

                resetScoreEtc();

                // mit new wären die alten objekte weiterhin sichtbar aber nicht dragable ==> besser: nur Attribute  der alten Objekte ändern
                m_balls[0].init(350, 800, m_dlg.m_radius, 0.0005, System.Drawing.Color.White);
                m_balls[1].init(280, 220, m_dlg.m_radius, 0.0005, System.Drawing.Color.Yellow);
                m_balls[2].init(420, 220, m_dlg.m_radius, 0.0005, System.Drawing.Color.Red);

                m_cue.init(420, 800, Math.PI / 4, 140, 1000);

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