示例#1
0
        /// <summary>
        /// Fetches the contents of Content\Index.html and formats it using dummy values when requests to DummyIndex.
        /// This allows testing of the module without affecting volume or any audio devices.
        /// </summary>
        /// <returns>Content\Index.html with dummy values.</returns>
        public Negotiator DummyIndex()
        {
            AudioDeviceList devices = new AudioDeviceList
            {
                new AudioDevice
                {
                    Id = "1",
                    IsCurrentDevice = true,
                    Name            = "Speaker"
                },
                new AudioDevice
                {
                    Id = "2",
                    IsCurrentDevice = false,
                    Name            = "Headphones"
                },
                new AudioDevice
                {
                    Id = "3",
                    IsCurrentDevice = false,
                    Name            = "Monitor"
                }
            };

            string  file  = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\ng-knob-options.json"));
            dynamic model = new IndexModel
            {
                Volume      = "75",
                Devices     = $"[{string.Join(",", devices.Select(MakeJavaScriptObjectString))}]",
                KnobOptions = $"{JsonToJavaScriptObject(file)}"
            };

            return(View["Index", model]);
        }
示例#2
0
        /// <summary>
        /// Fetches the contents of Content\Index.html and formats it using the current volume and available audio devices
        /// found on the host machine using classes and methods defined in the referenced Audio library.
        /// </summary>
        /// <returns>Content\Index.html with live values.</returns>
        public Negotiator Index()
        {
            if (_AuthenticateUser)
            {
                this.RequiresAuthentication();
            }

            float           volume  = GetCurrentVolume();
            AudioDeviceList devices = GetAudioDeviceList();
            string          file    = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\ng-knob-options.json"));
            dynamic         model   = new IndexModel
            {
                Volume      = volume.ToString(),
                Devices     = $"[{string.Join(",", devices.Select(MakeJavaScriptObjectString))}]",
                KnobOptions = $"{JsonToJavaScriptObject(file)}"
            };

            return(View["Index", model]);
        }