static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var controllers = new List <Func <AlgorithmControllerBase> >
            {
                () => new MSController(),
                () => new MSShortcutFindingController(),
                () => new SPFController()
            };

            var algoForm = new AlgorithmForm(controllers)
            {
                Text = Resources.Program_Name
            };

            Application.Run(algoForm);
        }
Beispiel #2
0
    bool OpenSoundFile()
    {
        //-----------------------------------------------------------------------------
        // Name: OnOpenSoundFile()
        // Desc: Called when the user requests to open a sound file
        //-----------------------------------------------------------------------------

        OpenFileDialog ofd             = new OpenFileDialog();
        Guid           guid3DAlgorithm = Guid.Empty;

        // Get the default media path (something like C:\WINDOWS\MEDIA)
        if (string.Empty == Path)
        {
            Path = Environment.SystemDirectory.Substring(0, Environment.SystemDirectory.LastIndexOf("\\")) + "\\media";
        }

        ofd.DefaultExt       = ".wav";
        ofd.Filter           = "Wave Files|*.wav|All Files|*.*";
        ofd.FileName         = FileName;
        ofd.InitialDirectory = Path;

        if (null != applicationBuffer)
        {
            applicationBuffer.Stop();
            applicationBuffer.SetCurrentPosition(0);
        }

        // Update the UI controls to show the sound as loading a file
        buttonPlay.Enabled = buttonStop.Enabled = false;
        labelStatus.Text   = "Loading file...";

        // Display the OpenFileName dialog. Then, try to load the specified file
        if (DialogResult.Cancel == ofd.ShowDialog(this))
        {
            labelStatus.Text      = "Load aborted.";
            timerMovement.Enabled = true;
            return(false);
        }
        FileName = ofd.FileName;
        Path     = ofd.FileName.Substring(0, ofd.FileName.LastIndexOf("\\"));

        // Free any previous sound, and make a new one
        if (null != applicationBuffer)
        {
            applicationBuffer.Dispose();
            applicationBuffer = null;
        }

        // Get the software DirectSound3D emulation algorithm to use
        // Ask the user for this sample, so display the algorithm dialog box.
        AlgorithmForm frm = new AlgorithmForm();

        if (DialogResult.Cancel == frm.ShowDialog(this))
        {
            // User canceled dialog box
            labelStatus.Text   = "Load aborted.";
            labelFilename.Text = string.Empty;
            return(false);
        }

        LoadSoundFile(ofd.FileName);
        if (null == applicationBuffer)
        {
            return(false);
        }

        // Get the 3D buffer from the secondary buffer
        try
        {
            applicationBuffer3D = new Buffer3D(applicationBuffer);
        }
        catch (DirectXException)
        {
            labelStatus.Text   = "Could not get 3D buffer.";
            labelFilename.Text = string.Empty;
            return(false);
        }

        // Get the 3D buffer parameters
        application3DSettings = applicationBuffer3D.AllParameters;

        // Set new 3D buffer parameters
        application3DSettings.Mode        = Mode3D.HeadRelative;
        applicationBuffer3D.AllParameters = application3DSettings;

        if (true == applicationBuffer.Caps.LocateInHardware)
        {
            labelStatus.Text = "File loaded using hardware mixing.";
        }
        else
        {
            labelStatus.Text = "File loaded using software mixing.";
        }

        // Update the UI controls to show the sound as the file is loaded
        labelFilename.Text = FileName;
        EnablePlayUI(true);

        // Remember the file for next time
        if (null != applicationBuffer3D)
        {
            FileName = ofd.FileName;
        }
        Path = FileName.Substring(0, FileName.LastIndexOf("\\"));

        // Set the slider positions
        SetSlidersPos(0.0f, 0.0f, maxOrbitRadius, maxOrbitRadius * 2.0f);
        SliderChanged();
        return(true);
    }