private async Task LoadMixes() { Mixes = await MixDataHandler.instance.GetMixes(false); OrderMixes(CurrentSortingState); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { IsLoading = false; CurrentMix = Mixes.FirstOrDefault(); NotifyPropertyChanged("NoMixes"); }); }
public PopularMixListViewModel() { _header = new HeaderInfo { Title = "Popular", IsSelectedAction = isSelected => { if (!Mixes.Any() && isSelected) { SearchForMixes(SortType); } } }; }
public void OrderMixes(int Ordering) { Settings CurrentSettings = this.CurrentSettings; if (Mixes == null || Mixes.Count() == 0) { NotifyPropertyChanged("Mixes"); return; } if (CurrentSettings.SortingIndex != Ordering) { CurrentSettings.SortingIndex = Ordering; SettingsDataHandler.instance.UpdateSettings(CurrentSettings); } switch (Ordering) { case 0: Mixes = Mixes.OrderByDescending(m => m.RealDate).ThenByDescending(m => m.StartTime).ToArray(); break; case 1: Mixes = Mixes.OrderBy(m => m.RealDate).ThenBy(m => m.StartTime).ToArray(); break; case 2: Mixes = Mixes.OrderByDescending(m => m.Rating).ThenBy(m => m.InternalID).ToArray(); break; case 3: Mixes = Mixes.OrderByDescending(m => m.TimesPlayed).ThenBy(m => m.InternalID).ToArray(); break; case 4: Mixes = Mixes.OrderByDescending(m => m.TimeDownloaded).ThenBy(m => m.InternalID).ToArray(); break; } NotifyPropertyChanged("Mixes"); MessageService.SendMessageToBackground(new UpdatePlaylistMessage(true)); }
static Mixes IdentifyMix(Stream fs) { Mixes identifiedMix = Mixes.Unidentified; var enc = Encoding.GetEncoding(437); byte[] nameBytes = new byte[6]; byte[] chunk0 = new byte[CHUNK_LENGTH]; fs.Read(chunk0, 0, CHUNK_LENGTH); Array.Copy(chunk0, nameBytes, nameBytes.Length); Util.ByteSwapInPlace16(nameBytes); string name = enc.GetString(nameBytes).Trim().ToUpperInvariant(); switch (name) { case @"GQ753": identifiedMix = Mixes.First; break; case @"GX853": identifiedMix = Mixes.Second; break; case @"GQ825": identifiedMix = Mixes.Third; break; case @"GQ847": identifiedMix = Mixes.Fourth; break; case @"GQ981": identifiedMix = Mixes.Fifth; break; case @"GCA21": identifiedMix = Mixes.Sixth; break; case @"GEB07": identifiedMix = Mixes.Seventh; break; case @"GQ993": identifiedMix = Mixes.Club; break; case @"GQ858": identifiedMix = Mixes.Complete; break; case @"GQ988": identifiedMix = Mixes.Complete2; break; case @"GQA05": identifiedMix = Mixes.Core; break; case @"GQ995": identifiedMix = Mixes.DCT; break; case @"GCC01": identifiedMix = Mixes.Final; break; } if (identifiedMix == Mixes.First || identifiedMix == Mixes.Second || (identifiedMix == Mixes.Unidentified && totalChunks <= 64)) { // 1st, 2nd Console.WriteLine("Using 1gb config"); soundOffset = 0x2000; chartOffsets = new int[] { 0x000400 }; config["BMS"].SetDefaultString("Difficulty1", "normal"); config["IIDX"].SetDefaultString("Difficulty0", "1"); } else if (identifiedMix == Mixes.Third || identifiedMix == Mixes.Complete || (identifiedMix == Mixes.Unidentified && totalChunks <= 128)) { // 3rd, complete Console.WriteLine("Using 2gb config"); soundOffset = 0x2000; chartOffsets = new int[] { 0x000400, 0xF02000, 0xF03000 }; config["BMS"].SetDefaultString("Difficulty1", "light"); config["BMS"].SetDefaultString("Difficulty2", "normal"); config["BMS"].SetDefaultString("Difficulty3", "another"); config["IIDX"].SetDefaultString("Difficulty0", "2"); config["IIDX"].SetDefaultString("Difficulty1", "1"); config["IIDX"].SetDefaultString("Difficulty2", "3"); } else if (identifiedMix == Mixes.Fourth || identifiedMix == Mixes.Fifth) { // 4th, 5th Console.WriteLine("Using 2gb alternate config"); soundOffset = 0x2000; chartOffsets = new int[] { 0x000800, 0xF02000, 0xF03000 }; config["BMS"].SetDefaultString("Difficulty1", "light"); config["BMS"].SetDefaultString("Difficulty2", "normal"); config["BMS"].SetDefaultString("Difficulty3", "another"); config["IIDX"].SetDefaultString("Difficulty0", "2"); config["IIDX"].SetDefaultString("Difficulty1", "1"); config["IIDX"].SetDefaultString("Difficulty2", "3"); } else if (totalChunks <= 260) { // club, complete2, core, dct Console.WriteLine("Using 4gb config"); soundOffset = 0x2000; chartOffsets = new int[] { 0x000800, 0xF02000, 0xF03000 }; config["BMS"].SetDefaultString("Difficulty1", "light"); config["BMS"].SetDefaultString("Difficulty2", "normal"); config["BMS"].SetDefaultString("Difficulty3", "another"); config["IIDX"].SetDefaultString("Difficulty0", "2"); config["IIDX"].SetDefaultString("Difficulty1", "1"); config["IIDX"].SetDefaultString("Difficulty2", "3"); } else if (totalChunks <= 400) { // 6th, 7th Console.WriteLine("Using 6gb config"); soundOffset = 0x2000; chartOffsets = new int[] { 0x000800, 0xF02000, 0xF03000 }; config["BMS"].SetDefaultString("Difficulty1", "light"); config["BMS"].SetDefaultString("Difficulty2", "normal"); config["BMS"].SetDefaultString("Difficulty3", "another"); config["IIDX"].SetDefaultString("Difficulty0", "2"); config["IIDX"].SetDefaultString("Difficulty1", "1"); config["IIDX"].SetDefaultString("Difficulty2", "3"); } else { // final Console.WriteLine("Using FINAL config"); soundOffset = 0x20000; chartOffsets = new int[] { 0x002000, 0x006000, 0x00A000, 0x00E000, 0x012000, 0x016000 }; sampleMapOffsets = new int[] { 0x000000, 0x001000 }; config["BMS"].SetDefaultString("Difficulty1", "light"); config["BMS"].SetDefaultString("Difficulty2", "normal"); config["BMS"].SetDefaultString("Difficulty3", "another"); config["IIDX"].SetDefaultString("Difficulty0", "2"); config["IIDX"].SetDefaultString("Difficulty1", "1"); config["IIDX"].SetDefaultString("Difficulty2", "3"); config["IIDX"].SetDefaultString("Difficulty3", "2"); config["IIDX"].SetDefaultString("Difficulty4", "1"); config["IIDX"].SetDefaultString("Difficulty5", "3"); sampleMapAssignment = new int[] { 0, 0, 0, 1, 1, 1 }; } return(identifiedMix); }
public void UpdateAsync() { SendFunction("", true, x => { try { var e = (DownloadStringCompletedEventArgs)x; if (e.Error != null) { OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = false }); return; } if (e.UserState == null) { return; } IsInitializing = true; _logger.Debug("Updating vMix state."); var _temp = Create(e.Result); if (_temp == null) { _logger.Debug("vMix is offline"); _logger.Debug("Firing \"updated\" event."); IsInitializing = false; OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = false }); } _logger.Debug("Calculating difference."); Diff(this, _temp); _logger.Debug("Updating inputs."); if (Inputs == null) { Inputs = new List <Input>(); } if (Overlays == null) { Overlays = new List <Overlay>(); } if (Audio == null) { Audio = new List <Master>(); } if (Transitions == null) { Transitions = new List <Transition>(); } Inputs.Clear(); foreach (var item in _temp.Inputs) { Inputs.Add(item); } Overlays.Clear(); foreach (var item in _temp.Overlays) { Overlays.Add(item); } Audio.Clear(); foreach (var item in _temp.Audio) { Audio.Add(item); } Transitions.Clear(); foreach (var item in _temp.Transitions) { Transitions.Add(item); } Mixes.Clear(); foreach (var item in _temp.Mixes) { Mixes.Add(item); } if (_currentStateText != _temp._currentStateText) { _currentStateText = _temp._currentStateText; } _logger.Debug("Firing \"updated\" event."); IsInitializing = false; OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = true, OldInputs = null, NewInputs = null }); return; } catch (Exception e) { IsInitializing = false; _logger.Error(e, "Exception at UpdateAsync"); } }); }
public bool Update() { try { IsInitializing = true; _logger.Debug("Updating vMix state."); var _temp = Create(); if (_temp == null) { _logger.Debug("vMix is offline"); _logger.Debug("Firing \"updated\" event."); OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = false }); IsInitializing = false; return(false); } _logger.Debug("Calculating difference."); Diff(this, _temp); _logger.Debug("Updating inputs."); Inputs.Clear(); foreach (var item in _temp.Inputs) { Inputs.Add(item); } Overlays.Clear(); foreach (var item in _temp.Overlays) { Overlays.Add(item); } Audio.Clear(); foreach (var item in _temp.Audio) { Audio.Add(item); } Transitions.Clear(); foreach (var item in _temp.Transitions) { Transitions.Add(item); } Mixes.Clear(); foreach (var item in _temp.Mixes) { Mixes.Add(item); } //UpdateChangedInputs(_currentStateText, _temp._currentStateText); if (_currentStateText != _temp._currentStateText) { _currentStateText = _temp._currentStateText; } _logger.Debug("Firing \"updated\" event."); OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = true, OldInputs = null, NewInputs = null }); IsInitializing = false; return(true); } catch (Exception e) { IsInitializing = false; _logger.Error(e, "Exception at Update"); return(false); } }