Exemplo n.º 1
0
        public AudioControlViewModel()
        {
            //var tt = Application.Current.Resources["InfoButton"] as Style;
            AudioTitle = new TextBoxTip()
            {
                TitleText = new TipMessageItem()
                {
                    MenuName  = AudioControlStrings.Volume.ToString(),
                    MenuStyle = Application.Current.Resources["BaseTextBoxStyle"] as Style
                },
                TipItem = new TipViewItem()
                {
                    TipViewItemVisibility = true,
                    TipButton             = new TipMessageItem()
                    {
                        MenuName    = "I",
                        MenuStyle   = Application.Current.Resources["InfoButton"] as Style,
                        MenuCommand = OnTipButtonClickEvent,
                        MenuData    = AudioControlStrings.Volume.ToString()
                    },
                    TipInfo = new TipMessageItem()
                    {
                        MenuName    = "Tip String is here",
                        MenuStyle   = Application.Current.Resources["ToolTipStyle"] as Style,
                        MenuCommand = OnTipCloseClickEvent,
                        MenuData    = AudioControlStrings.Volume.ToString()
                    }
                }
            };

            MonitorTitle = new TextBoxTip()
            {
                TitleText = new TipMessageItem()
                {
                    MenuName  = "Monitor Audio",
                    MenuStyle = Application.Current.Resources["BaseTextBoxStyle"] as Style
                },
                TipItem = new TipViewItem()
                {
                    TipViewItemVisibility = true,
                    TipButton             = new TipMessageItem()
                    {
                        MenuName    = "I",
                        MenuStyle   = Application.Current.Resources["InfoButton"] as Style,
                        MenuCommand = OnTipButtonClickEvent,
                        MenuData    = AudioControlStrings.Monitor_Speaker.ToString()
                    },
                    TipInfo = new TipMessageItem()
                    {
                        MenuName    = "Tip String is here",
                        MenuStyle   = Application.Current.Resources["ToolTipStyle"] as Style,
                        MenuCommand = OnTipCloseClickEvent,
                        MenuData    = AudioControlStrings.Monitor_Speaker.ToString()
                    }
                }
            };
        }
        public AdvanceControlViewModel(IAudioDemoControlModel model)
        {
            _model = model;
            _localResourceDictionary = new ResourceDictionary()
            {
                Source = new Uri("pack://application:,,,/AudioDemoModule;component/Styles/AudioDemoStyle.xaml", UriKind.RelativeOrAbsolute)
            };

            //Force EQ enabled
            //if (!_model.GetEQEnabled())
            //{
            //    _model.SetEQEnabled();
            //}
            //Get Cmedia EQ presets
            using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("AudioDemoModule.JSON.EqualizerPreset.json"))
            {
                System.IO.TextReader tr = new System.IO.StreamReader(stream);
                string fileContents     = tr.ReadToEnd();
                _presetDictionary = JsonConvert.DeserializeObject <Dictionary <EqualizerPresets, List <int> > >(fileContents);
            }

            AudioTitle = new TextBoxTip()
            {
                TitleText = new TipMessageItem()
                {
                    MenuName  = "Audio Mode",
                    MenuStyle = Application.Current.Resources["BaseTextBoxStyle"] as Style
                },
                TipItem = new TipViewItem()
                {
                    TipViewItemVisibility = true,
                    TipButton             = new TipMessageItem()
                    {
                        MenuName    = "I",
                        MenuStyle   = Application.Current.Resources["InfoButton"] as Style,
                        MenuCommand = OnTipButtonClickEvent,
                        MenuData    = EQModesStrings.Audio_Modes.ToString()
                    },
                    TipInfo = new TipMessageItem()
                    {
                        MenuName    = "Tip String is here",
                        MenuStyle   = Application.Current.Resources["ToolTipStyle"] as Style,
                        MenuCommand = OnTipCloseClickEvent,
                        MenuData    = EQModesStrings.Audio_Modes.ToString()
                    }
                }
            };

            CustomEQPreset = new TextBoxTip()
            {
                TitleText = new TipMessageItem()
                {
                    MenuName  = "Custom EQ Presets",
                    MenuStyle = Application.Current.Resources["BaseTextBoxStyle"] as Style
                },
                TipItem = new TipViewItem()
                {
                    TipViewItemVisibility = true,
                    TipButton             = new TipMessageItem()
                    {
                        MenuName    = "I",
                        MenuStyle   = Application.Current.Resources["InfoButton"] as Style,
                        MenuCommand = OnTipButtonClickEvent,
                        MenuData    = EQModesStrings.Custom_EQ_Presets.ToString()
                    },
                    TipInfo = new TipMessageItem()
                    {
                        MenuName    = "Custom EQ Tip String is here",
                        MenuStyle   = Application.Current.Resources["ToolTipStyle"] as Style,
                        MenuCommand = OnTipCloseClickEvent,
                        MenuData    = EQModesStrings.Custom_EQ_Presets.ToString()
                    }
                }
            };

            EQModeCollection       = GetEQModeCollection();
            EQPresetModeCollection = GetEQPresetModeCollection();
            EQBandCollection       = GetEQBandeCollection();
            //SetFiveBands();
            BandClarity = new EQBandItem()
            {
                EQBandSlider = new AudioSliderItem()
                {
                    MenuName           = AudioControlStrings.Headphone.ToString(),
                    MenuStyle          = _localResourceDictionary["CustomAudioSlider"] as Style,
                    MaxValue           = SliderMax,
                    MinValue           = SliderMin,
                    Step               = SliderStep,
                    SliderValue        = "0",
                    SliderValueChanged = OnEQBandValueChangedEvent
                },
                EQBandName = new ViewItem()
                {
                    MenuName = "Dialog Clarity", MenuStyle = _localResourceDictionary["VerticalBandStyle"] as Style, MenuVisibility = true
                }
            };
            EQBandsCollection       = GetEQBandsCollection();
            PresetControlCollection = GetPreSetControlCollection();
            ControlButtonCollection = new ObservableCollection <IViewItem>()
            {
                new ViewItem()
                {
                    MenuName  = "Restore Default",
                    MenuStyle = _localResourceDictionary["BaseOMENButtonStyle"] as Style,
                    MenuData  = "Restore Default"
                }
            };
            //_model.RegisterSpeakerFeatrueCallBack(OnSpeakerFeatureChanged);
        }