Пример #1
0
        public static ICompleteState GenerateState(XDocument xmlDocument)
        {
            var completeState = new CompleteState();
            var rootElement = xmlDocument.Element("CompleteState");

            if(rootElement == null)
            { throw new Exception("Error parsing Xml, there is no root node"); }

            var soundStateNodes = rootElement.Elements("SoundStates");
            foreach (var ambientStateNode in soundStateNodes.Elements("SoundState"))
            {
                var soundTypeAttribute = ambientStateNode.Attribute("SoundTypeIdentifier");
                var soundState = SoundStateFactory.GetState(soundTypeAttribute.Value);
                soundState.PopulateFromXml(ambientStateNode);
                completeState.SoundStates.Add(soundState);
            }

            var quickSoundStateNodes = rootElement.Elements("QuickSoundStates");
            foreach (var quickSoundStateNode in quickSoundStateNodes.Elements("SoundState"))
            {
                var soundTypeAttribute = quickSoundStateNode.Attribute("SoundTypeIdentifier");
                var soundState = SoundStateFactory.GetState(soundTypeAttribute.Value);
                soundState.PopulateFromXml(quickSoundStateNode);
                completeState.QuickSoundStates.Add(soundState);
            }

            return completeState;
        }
Пример #2
0
        private CompleteState CreateState()
        {
            var completeState = new CompleteState();

            var ambientState1 = new AmbientState();
            ambientState1.Filename = ambientPlayerControl1.SelectedFilename;
            ambientState1.Volume = ambientPlayerControl1.Volume;
            ambientState1.isLooping = ambientPlayerControl1.isLooping;
            completeState.AmbientStates.Add(ambientState1);

            var ambientState2 = new AmbientState();
            ambientState2.Filename = ambientPlayerControl2.SelectedFilename;
            ambientState2.Volume = ambientPlayerControl2.Volume;
            ambientState2.isLooping = ambientPlayerControl2.isLooping;
            completeState.AmbientStates.Add(ambientState2);

            var soundState1 = new IntervalSoundState();
            soundState1.Filename = intervalSoundPlayerControl1.SelectedFilename;
            soundState1.Volume = intervalSoundPlayerControl1.Volume;
            soundState1.Interval = intervalSoundPlayerControl1.Interval;
            completeState.SoundStates.Add(soundState1);

            var soundState2 = new IntervalSoundState();
            soundState2.Filename = intervalSoundPlayerControl2.SelectedFilename;
            soundState2.Volume = intervalSoundPlayerControl2.Volume;
            soundState2.Interval = intervalSoundPlayerControl2.Interval;
            completeState.SoundStates.Add(soundState2);

            var soundState3 = new IntervalSoundState();
            soundState3.Filename = intervalSoundPlayerControl3.SelectedFilename;
            soundState3.Volume = intervalSoundPlayerControl3.Volume;
            soundState3.Interval = intervalSoundPlayerControl3.Interval;
            completeState.SoundStates.Add(soundState3);

            var soundState4 = new IntervalSoundState();
            soundState4.Filename = intervalSoundPlayerControl4.SelectedFilename;
            soundState4.Volume = intervalSoundPlayerControl4.Volume;
            soundState4.Interval = intervalSoundPlayerControl4.Interval;
            completeState.SoundStates.Add(soundState4);

            return completeState;
        }
Пример #3
0
        private void PopulateFromState(CompleteState state)
        {
            if(state.AmbientStates[0].Filename != string.Empty)
            {
                ambientPlayerControl1.Volume = state.AmbientStates[0].Volume;
                ambientPlayerControl1.LoadFile(state.AmbientStates[0].Filename);
                ambientPlayerControl1.isLooping = state.AmbientStates[0].isLooping;
            }

            if (state.AmbientStates[1].Filename != string.Empty)
            {
                ambientPlayerControl2.Volume = state.AmbientStates[1].Volume;
                ambientPlayerControl2.LoadFile(state.AmbientStates[1].Filename);
                ambientPlayerControl2.isLooping = state.AmbientStates[1].isLooping;
            }

            if (state.SoundStates[0].Filename != string.Empty)
            {
                intervalSoundPlayerControl1.Volume = state.SoundStates[0].Volume;
                intervalSoundPlayerControl1.Interval = state.SoundStates[0].Interval;
                intervalSoundPlayerControl1.LoadFile(state.SoundStates[0].Filename);
            }

            if (state.SoundStates[1].Filename != string.Empty)
            {
                intervalSoundPlayerControl2.Volume = state.SoundStates[1].Volume;
                intervalSoundPlayerControl2.Interval = state.SoundStates[1].Interval;
                intervalSoundPlayerControl2.LoadFile(state.SoundStates[1].Filename);
            }

            if (state.SoundStates[2].Filename != string.Empty)
            {
                intervalSoundPlayerControl3.Volume = state.SoundStates[2].Volume;
                intervalSoundPlayerControl3.Interval = state.SoundStates[2].Interval;
                intervalSoundPlayerControl3.LoadFile(state.SoundStates[2].Filename);
            }

            if (state.SoundStates[3].Filename != string.Empty)
            {
                intervalSoundPlayerControl4.Volume = state.SoundStates[3].Volume;
                intervalSoundPlayerControl4.Interval = state.SoundStates[3].Interval;
                intervalSoundPlayerControl4.LoadFile(state.SoundStates[3].Filename);
            }
        }
Пример #4
0
        private ICompleteState CreateState()
        {
            var completeState = new CompleteState();
            foreach(var control in tablePanel.Controls)
            {
                if (control is PlaceholderControl) { continue; }

                var soundState = (control as IPlayerControl).GetState();
                completeState.SoundStates.Add(soundState);
            }
            return completeState;
        }