コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: xxu1021/Mp2Editor
        private void LoadConfig()
        {
            try
            {
                suppressMidiUpdate  = true;
                AutoUpdate          = config.AutoUpdate;
                MidiChannel         = config.MidiChannel;
                LoadOnProgramSelect = config.LoadOnProgramSelect;

                if (config.MidiInput.HasValue)
                {
                    // match by key and name
                    var midiInputMatch = MidiInputs.SingleOrDefault(x => x.Key == config.MidiInput.Value.Key && x.Value == config.MidiInput.Value.Value);
                    if (midiInputMatch.Value != null)
                    {
                        SelectedMidiInput = midiInputMatch;
                    }
                    else
                    {
                        // keys can change, match by name, if only 1 match, use it
                        var midiInputMatches = MidiInputs.Where(x => x.Value == config.MidiInput.Value.Value).ToArray();
                        if (midiInputMatches.Length == 1)
                        {
                            SelectedMidiInput = midiInputMatches[0];
                        }
                    }
                }

                if (config.MidiOutput.HasValue)
                {
                    // match by key and name
                    var midiOutputMatch = MidiOutputs.SingleOrDefault(x => x.Key == config.MidiInput.Value.Key && x.Value == config.MidiOutput.Value.Value);
                    if (midiOutputMatch.Value != null)
                    {
                        SelectedMidiOutput = midiOutputMatch;
                    }
                    else
                    {
                        // keys can change, match by name, if only 1 match, use it
                        var midiOutputMatches = MidiOutputs.Where(x => x.Value == config.MidiOutput.Value.Value).ToArray();
                        if (midiOutputMatches.Length == 1)
                        {
                            SelectedMidiOutput = midiOutputMatches[0];
                        }
                    }
                }
            }
            finally
            {
                suppressMidiUpdate = false;
            }
        }
コード例 #2
0
        public MainViewModel()
        {
            VersionString = _programVersion.ToString();

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/ianespana/ShawzinBot/releases/latest");

            request.UserAgent = "request";
            try
            {
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                        using (JsonReader reader = new JsonTextReader(sr))
                        {
                            JsonSerializer serializer = new JsonSerializer();
                            GitVersion     p          = serializer.Deserialize <GitVersion>(reader);
                            if (!(p.draft || p.prerelease) && p.tag_name != _programVersion.ToString())
                            {
                                VersionString = _programVersion.ToString() + " - Update available!";
                            }
                        }
            }
            catch (WebException ex)
            {
                Console.WriteLine(ex);
            }

            MidiInputs.Add(new MidiInputModel("None"));

            foreach (var device in InputDevice.GetAll())
            {
                MidiInputs.Add(new MidiInputModel(device.Name));
            }

            SelectedMidiInput = MidiInputs[0];

            MidiSpeeds.Add(new MidiSpeedModel("0.25", 0.25));
            MidiSpeeds.Add(new MidiSpeedModel("0.5", 0.5));
            MidiSpeeds.Add(new MidiSpeedModel("0.75", 0.75));
            MidiSpeeds.Add(new MidiSpeedModel("Normal", 1));
            MidiSpeeds.Add(new MidiSpeedModel("1.25", 1.25));
            MidiSpeeds.Add(new MidiSpeedModel("1.5", 1.5));
            MidiSpeeds.Add(new MidiSpeedModel("1.75", 1.75));
            MidiSpeeds.Add(new MidiSpeedModel("2", 2));

            SelectedMidiSpeed = MidiSpeeds[3];

            EnableVibrato       = Properties.Settings.Default.EnableVibrato;
            TransposeNotes      = Properties.Settings.Default.TransposeNotes;
            PlayThroughSpeakers = Properties.Settings.Default.PlayThroughSpeakers;
            PlaybackCurrentTimeWatcher.Instance.PollingInterval = TimeSpan.FromSeconds(1);
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: xSimone/ShawzinBot
        public MainViewModel()
        {
            MidiInputs.Add(new MidiInputModel("None"));

            foreach (var device in InputDevice.GetAll())
            {
                MidiInputs.Add(new MidiInputModel(device.Name));
            }

            SelectedMidiInput = MidiInputs[0];

            EnableVibrato       = Properties.Settings.Default.EnableVibrato;
            TransposeNotes      = Properties.Settings.Default.TransposeNotes;
            PlayThroughSpeakers = Properties.Settings.Default.PlayThroughSpeakers;
        }
コード例 #4
0
        public MainViewModel()
        {
            MidiInputs.Add(new MidiInputModel("None"));

            foreach (var device in InputDevice.GetAll())
            {
                MidiInputs.Add(new MidiInputModel(device.Name));
            }

            SelectedMidiInput = MidiInputs[0];

            EnableVibrato       = Properties.Settings.Default.EnableVibrato;
            TransposeNotes      = Properties.Settings.Default.TransposeNotes;
            PlayThroughSpeakers = Properties.Settings.Default.PlayThroughSpeakers;
            PlaybackCurrentTimeWatcher.Instance.PollingInterval = TimeSpan.FromSeconds(1);
        }