104 lines
2.4 KiB
C#
104 lines
2.4 KiB
C#
using ImGuiNET;
|
|
using skyscraper5.Skyscraper.Equipment;
|
|
using skyscraper5.Skyscraper.Scraper.Storage;
|
|
using skyscraper5.src.Skyscraper.FrequencyListGenerator;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Intrinsics.X86;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using skyscraper8.Skyscraper.Scraper.Storage;
|
|
|
|
namespace SDL2Demo.Forms
|
|
{
|
|
class BlindscanJobDeleter : IRenderable
|
|
{
|
|
private readonly DataStorage storage;
|
|
private List<DbBlindscanJob> blindscanJobs;
|
|
private Guid selectedGuid;
|
|
private string tableGuid;
|
|
public bool Closed { get; private set; }
|
|
|
|
public BlindscanJobDeleter(DataStorage storage)
|
|
{
|
|
this.storage = storage;
|
|
this.LoadPastBlindscans();
|
|
this.tableGuid = Guid.NewGuid().ToString();
|
|
}
|
|
|
|
private void LoadPastBlindscans()
|
|
{
|
|
blindscanJobs = storage.GetDbBlindscanJobs().ToList();
|
|
selectedGuid = Guid.Empty;
|
|
}
|
|
|
|
private void DeleteSelectedJob()
|
|
{
|
|
storage.DeleteBlindscanJob(selectedGuid);
|
|
LoadPastBlindscans();
|
|
}
|
|
|
|
|
|
public void Render()
|
|
{
|
|
bool pOpen = true;
|
|
ImGuiWindowFlags windowFlags = ImGuiWindowFlags.None;
|
|
if (ImGui.Begin("Configure Dish Types", ref pOpen, windowFlags))
|
|
{
|
|
ImGui.Text(String.Format("{0} past jobs in DB.", blindscanJobs.Count));
|
|
ImGui.Text(String.Format("Selected for deletion: {0}", selectedGuid.ToString()));
|
|
ImGui.SameLine();
|
|
|
|
bool nothingSelected = selectedGuid == Guid.Empty;
|
|
|
|
ImGui.BeginDisabled(nothingSelected);
|
|
if (ImGui.Button("Perform Deletion"))
|
|
DeleteSelectedJob();
|
|
ImGui.EndDisabled();
|
|
|
|
ImGui.Separator();
|
|
|
|
ImGui.BeginTable(tableGuid, 4);
|
|
ImGui.TableNextRow();
|
|
ImGui.TableSetColumnIndex(0);
|
|
ImGui.Text("Date");
|
|
|
|
ImGui.TableSetColumnIndex(1);
|
|
ImGui.Text("Job");
|
|
|
|
ImGui.TableSetColumnIndex(2);
|
|
ImGui.Text("State");
|
|
|
|
foreach(DbBlindscanJob blindscanJob in blindscanJobs)
|
|
{
|
|
ImGui.TableNextRow();
|
|
ImGui.TableSetColumnIndex(0);
|
|
ImGui.Text(blindscanJob.DateAdded.ToString("dd.MM.yyyy hh:mm"));
|
|
|
|
ImGui.TableSetColumnIndex(1);
|
|
ImGui.Text(blindscanJob.ToString(1));
|
|
|
|
ImGui.TableSetColumnIndex(2);
|
|
ImGui.Text(blindscanJob.ToString(2));
|
|
|
|
ImGui.TableSetColumnIndex(3);
|
|
ImGui.PushID(blindscanJob.JobGuid.ToString());
|
|
if (ImGui.Button("Delete"))
|
|
{
|
|
this.selectedGuid = blindscanJob.JobGuid;
|
|
}
|
|
ImGui.PopID();
|
|
}
|
|
|
|
ImGui.EndTable();
|
|
|
|
}
|
|
ImGui.End();
|
|
|
|
if (!pOpen)
|
|
Closed = true;
|
|
}
|
|
}
|
|
}
|