private void ModList_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //return; _draggedMod = (ModItemInfo)TryFindRowAtPoint((UIElement)sender, e.GetPosition(ModList))?.DataContext; //DraggedMod = (ModItemInfo) ModList.SelectedItem; }
private void ModList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (!_isSortedByLoadOrder) { var targetMod = (ModItemInfo)TryFindRowAtPoint((UIElement)sender, e.GetPosition(ModList))?.DataContext; if (targetMod != null && !ReferenceEquals(_draggedMod, targetMod)) { var msg = "Drag and drop is only available when sorted by load order!"; Log.Warn(msg); MessageBox.Show(msg); } } //if (DraggedMod != null && HasOrderChanged) //Log.Info("Dragging over, saving..."); //_instanceManager.SaveConfig(); _draggedMod = null; }
private void BulkButton_OnClick(object sender, RoutedEventArgs e) { var editor = new CollectionEditor(); //let's see just how poorly we can do this var modList = ((MtObservableList <ModItemInfo>)DataContext).ToList(); var idList = modList.Select(m => m.ToString()).ToList(); var tasks = new List <Task>(); //blocking editor.Edit <string>(idList, "Mods"); modList.RemoveAll(m => { var mod = m.ToString(); return(idList.Any(mod.Equals)); }); modList.AddRange(idList.Select(id => { var info = new ModItemInfo(ModItemUtils.Create(id)); tasks.Add(Task.Run(info.UpdateModInfoAsync)); return(info); })); _instanceManager.DedicatedConfig.Mods.Clear(); foreach (var mod in modList) { _instanceManager.DedicatedConfig.Mods.Add(mod); } if (tasks.Any()) { Task.WaitAll(tasks.ToArray()); } Dispatcher.Invoke(() => { _instanceManager.DedicatedConfig.Save(); }); }
private void BulkButton_OnClick(object sender, RoutedEventArgs e) { var editor = new CollectionEditor(); //let's see just how poorly we can do this var modList = ((MtObservableList <ModItemInfo>)DataContext).ToList(); var idList = modList.Select(m => m.PublishedFileId).ToList(); var tasks = new List <Task>(); //blocking editor.Edit <ulong>(idList, "Mods"); modList.RemoveAll(m => !idList.Contains(m.PublishedFileId)); foreach (var id in idList) { if (!modList.Any(m => m.PublishedFileId == id)) { var mod = new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(id)); tasks.Add(Task.Run(mod.UpdateModInfoAsync)); modList.Add(mod); } } _instanceManager.DedicatedConfig.Mods.Clear(); foreach (var mod in modList) { _instanceManager.DedicatedConfig.Mods.Add(mod); } if (tasks.Any()) { Task.WaitAll(tasks.ToArray()); } Dispatcher.Invoke(() => { _instanceManager.DedicatedConfig.Save(); }); }
private void AddBtn_OnClick(object sender, RoutedEventArgs e) { if (TryExtractId(AddModIDTextBox.Text, out ulong id)) { var mod = new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(id)); //mod.PublishedFileId = id; _instanceManager.DedicatedConfig.Mods.Add(mod); Task.Run(mod.UpdateModInfoAsync) .ContinueWith((t) => { Dispatcher.Invoke(() => { _instanceManager.DedicatedConfig.Save(); }); }); AddModIDTextBox.Text = ""; } else { AddModIDTextBox.BorderBrush = Brushes.Red; Log.Warn("Invalid mod id!"); MessageBox.Show("Invalid mod id!"); } }
private void AddBtn_OnClick(object sender, RoutedEventArgs e) { if (TryExtractId(AddModIDTextBox.Text, out ulong id)) { var mod = new ModItemInfo(ModItemUtils.Create(id, UgcServiceTypeBox.SelectedValue?.ToString())); _instanceManager.DedicatedConfig.Mods.Add(mod); Task.Run(mod.UpdateModInfoAsync) .ContinueWith((t) => { Dispatcher.Invoke(() => { _instanceManager.DedicatedConfig.Save(); }); }); AddModIDTextBox.Text = ""; } else { AddModIDTextBox.BorderBrush = Brushes.Red; Log.Warn("Invalid mod id!"); MessageBox.Show("Invalid mod id!"); } }