예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public CDPlayerApp()
        {
            stringManager =
                new ResourceManager("SdlDotNetExamples.CDPlayer.Properties.Resources", Assembly.GetExecutingAssembly());
            InitializeComponent();
            this.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Title", CultureInfo.CurrentUICulture);
            this.label1.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "SelectDrive", CultureInfo.CurrentUICulture);
            this.buttonPlay.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Play", CultureInfo.CurrentUICulture);
            this.buttonPause.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Pause", CultureInfo.CurrentUICulture);
            this.buttonStop.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Stop", CultureInfo.CurrentUICulture);
            this.buttonEject.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Eject", CultureInfo.CurrentUICulture);
            this.labelStatus.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Track", CultureInfo.CurrentUICulture);
            this.buttonPrevious.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Previous", CultureInfo.CurrentUICulture);
            this.buttonNext.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                "Next", CultureInfo.CurrentUICulture);
            this.KeyPreview = true;
            surf            =
                new Surface(
                    this.surfaceControl.Width,
                    this.surfaceControl.Height);
            if (File.Exists(Path.Combine(dataDirectory, "marble1.png")))
            {
                filePath = "";
            }
            SurfaceCollection marbleSurfaces = new SurfaceCollection();

            marbleSurfaces.Add(new Surface(Path.Combine(filePath, Path.Combine(dataDirectory, "marble1.png"))), new Size(50, 50));

            for (int i = 0; i < 1; i++)
            {
                //Create a new Sprite at a random location on the screen
                BounceSprite bounceSprite =
                    new BounceSprite(marbleSurfaces,
                                     new Point(rand.Next(0, 350),
                                               rand.Next(0, 200)));
                bounceSprite.Bounds = new Rectangle(new Point(0, 0), this.surfaceControl.Size);

                // Randomize rotation direction
                bounceSprite.AnimateForward = rand.Next(2) == 1 ? true : false;

                //Add the sprite to the SpriteCollection
                master.Add(bounceSprite);
            }

            //The collection will respond to mouse button clicks, mouse movement and the ticker.
            master.EnableMouseButtonEvent();
            master.EnableMouseMotionEvent();
            master.EnableVideoResizeEvent();
            master.EnableKeyboardEvent();
            master.EnableTickEvent();

            SdlDotNet.Core.Events.Fps   = 30;
            SdlDotNet.Core.Events.Tick += new EventHandler <TickEventArgs>(this.Tick);
            SdlDotNet.Core.Events.Quit += new EventHandler <QuitEventArgs>(this.Quit);

            try
            {
                int num = CDRom.NumberOfDrives;
                _drive = CDRom.OpenDrive(0);
                for (int i = 0; i < num; i++)
                {
                    comboBoxDrive.Items.Add(CDRom.DriveName(i));
                }

                if (comboBoxDrive.Items.Count > 0)
                {
                    comboBoxDrive.SelectedIndex = 0;
                }
            }
            catch (SdlException ex)
            {
                Console.WriteLine(ex);
            }
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        public CDPlayerApp()
        {
            stringManager =
                new ResourceManager("SdlDotNetExamples.CDPlayer.Properties.Resources", Assembly.GetExecutingAssembly());
            InitializeComponent();
            this.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Title", CultureInfo.CurrentUICulture);
            this.label1.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                       "SelectDrive", CultureInfo.CurrentUICulture);
            this.buttonPlay.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Play", CultureInfo.CurrentUICulture);
            this.buttonPause.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Pause", CultureInfo.CurrentUICulture);
            this.buttonStop.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Stop", CultureInfo.CurrentUICulture);
            this.buttonEject.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Eject", CultureInfo.CurrentUICulture);
            this.labelStatus.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Track", CultureInfo.CurrentUICulture);
            this.buttonPrevious.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Previous", CultureInfo.CurrentUICulture);
            this.buttonNext.Text = SdlDotNetExamples.CDPlayer.CDPlayerApp.StringManager.GetString(
                        "Next", CultureInfo.CurrentUICulture);
            this.KeyPreview = true;
            surf =
                new Surface(
                this.surfaceControl.Width,
                this.surfaceControl.Height);
            if (File.Exists(Path.Combine(dataDirectory, "marble1.png")))
            {
                filePath = "";
            }
            SurfaceCollection marbleSurfaces = new SurfaceCollection();
            marbleSurfaces.Add(new Surface(Path.Combine(filePath, Path.Combine(dataDirectory, "marble1.png"))), new Size(50, 50));

            for (int i = 0; i < 1; i++)
            {
                //Create a new Sprite at a random location on the screen
                BounceSprite bounceSprite =
                    new BounceSprite(marbleSurfaces,
                    new Point(rand.Next(0, 350),
                    rand.Next(0, 200)));
                bounceSprite.Bounds = new Rectangle(new Point(0, 0), this.surfaceControl.Size);

                // Randomize rotation direction
                bounceSprite.AnimateForward = rand.Next(2) == 1 ? true : false;

                //Add the sprite to the SpriteCollection
                master.Add(bounceSprite);
            }

            //The collection will respond to mouse button clicks, mouse movement and the ticker.
            master.EnableMouseButtonEvent();
            master.EnableMouseMotionEvent();
            master.EnableVideoResizeEvent();
            master.EnableKeyboardEvent();
            master.EnableTickEvent();

            SdlDotNet.Core.Events.Fps = 30;
            SdlDotNet.Core.Events.Tick += new EventHandler<TickEventArgs>(this.Tick);
            SdlDotNet.Core.Events.Quit += new EventHandler<QuitEventArgs>(this.Quit);

            try
            {
                int num = CDRom.NumberOfDrives;
                _drive = CDRom.OpenDrive(0);
                for (int i = 0; i < num; i++)
                {
                    comboBoxDrive.Items.Add(CDRom.DriveName(i));
                }

                if (comboBoxDrive.Items.Count > 0)
                {
                    comboBoxDrive.SelectedIndex = 0;
                }
            }
            catch (SdlException ex)
            {
                Console.WriteLine(ex);
            }
        }