public virtual void DeleteFiles(HttpContext context) { YZRequest request = new YZRequest(context); JArray post = request.GetPostData <JArray>(); List <int> fileids = post.ToObject <List <int> >(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { foreach (int fileid in fileids) { DirectoryManager.DeleteFile(provider, cn, fileid); } } } }
private static UiElement SpawnFolderItem(UiWindow window, UiWindow parent, UiSpacer spacer, Action <Color> setColor, string folder, Func <string, bool> onClick, Action <UiWindow, UiSpacer, Action <Color> > renew) { var itemRow = new UiRow(); var itemButton = new UiButton(); itemRow.AddChild(itemButton); var itemText = new UiTextBlock(); itemText.SetString(folder); itemButton.AddChild(itemText); itemRow.AddChild(spacer); itemButton.OnClick += () => { if (onClick(folder)) { parent.Dispose(); } }; var deleteButton = new UiButton(); itemRow.AddChild(deleteButton); var deleteIcon = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.delete.text"); deleteButton.AddChild(deleteIcon); deleteButton.OnClick += () => { var confirmWindow = new UiWindow(); confirmWindow.Container.SetBackground(Constants.Backgrounds.Dark); parent.AddChildWindow(confirmWindow); var confirmTitle = new UiTextBlock(); confirmWindow.AddChild(confirmTitle); confirmTitle.SetFont(Constants.Fonts.MyFirstCrush36); confirmTitle.SetColor(Color.Orange); confirmTitle.SetString(string.Format(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.deleteTitle"), folder)); confirmWindow.AddChild(spacer); var confirmMessage = new UiTextBlock(); confirmWindow.AddChild(confirmMessage); confirmMessage.SetString(string.Format(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.deleteMessage"), folder)); confirmWindow.AddChild(spacer); var buttonRow = new UiRow(); confirmWindow.AddChild(buttonRow); var confirmButton = new UiButton(); buttonRow.AddChild(confirmButton); var confirmButtonText = new UiTextBlock(); confirmButton.AddChild(confirmButtonText); confirmButtonText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.delete")); buttonRow.AddChild(spacer); confirmButton.OnClick += () => { if (_favDir.FileExists(folder)) { _favDir.DeleteFile(folder); } parent.Dispose(); renew(window, spacer, setColor); }; confirmWindow.OnClose += () => { parent.ListenForEscape(true); parent.Show(); parent.StartUpdateCalls(); }; var cancelButton = new UiButton(); buttonRow.AddChild(cancelButton); var cancelText = new UiTextBlock(); cancelButton.AddChild(cancelText); cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel")); cancelButton.OnClick += () => { confirmWindow.Dispose(); }; parent.Hide(); parent.ListenForEscape(false); parent.StopUpdateCalls(); confirmWindow.Show(); }; return(itemRow); }