private void Save(FileInfo info, ContainerFile meta) { JsonSerializerOptions options = new JsonSerializerOptions(); options.IgnoreReadOnlyProperties = true; options.WriteIndented = true; File.WriteAllText(info.FullName, JsonSerializer.Serialize(meta, options)); }
private void Lock(ListViewItem listViewItem) { ContainerFile meta = (ContainerFile)listViewItem.Tag; meta.Locked = !meta.Locked; backup.Save(meta); UpdateIcon(listViewItem); listView1.SelectedItems.Clear(); }
private void Delete(ListViewItem listViewItem) { ContainerFile meta = (ContainerFile)listViewItem.Tag; if (!meta.Locked) { Delete(meta); RefreshZipList(); } }
private void Upload(ListViewItem listViewItem) { toolStripStatusLabel1.Image = null; toolStripStatusLabel1.Text = "Set save"; Process process = null; String fol2der = null; if (quitTLDOnChangeToolStripMenuItem.Checked) { foreach (Process theprocess in Process.GetProcesses()) { if (theprocess.ProcessName == "tld") { process = theprocess; } } if (process != null) { Trace.WriteLine(String.Format("Process is started: {0} ID: {1}", process.ProcessName, process.Id)); Thread.Sleep(1000); process.Kill(); fol2der = process.MainModule.FileName; Trace.WriteLine($"fol2der: {fol2der}"); } } Trace.WriteLine($"Replace: {listViewItem}"); ContainerFile meta = (ContainerFile)listView1.SelectedItems[0].Tag; backup.Replace(meta); if (quitTLDOnChangeToolStripMenuItem.Checked) { if (process != null && fol2der != null) { Thread.Sleep(1000); try { Process.Start(fol2der); } catch (Exception ez) { Trace.WriteLine(ez.StackTrace); } } } toolStripStatusLabel1.Text = "Set save: OK"; Trace.WriteLine("Set save: OK"); toolStripStatusLabel1.Image = global::SaveManager.Properties.Resources.StatusOK_16x; System.Threading.Tasks.Task.Delay(2 * 1000).ContinueWith(ResetStatusLine); }
private void OnListLeftClick(MouseEventArgs e) { if (listView1.SelectedItems.Count != 0) { ContainerFile meta = (ContainerFile)listView1.SelectedItems[0].Tag; if (!meta.Deleted) { Upload(listView1.SelectedItems[0]); } } }
private void Edit(ListViewItem listViewItem) { ContainerFile meta = (ContainerFile)listViewItem.Tag; string result = Microsoft.VisualBasic.Interaction.InputBox("Summary?", "Edit Summary", meta.Summary); if (result.Length > 0) { meta.Summary = result; backup.Save(meta); listView1.SelectedItems.Clear(); RefreshZipList(); } }
private void UpdateIcon(ListViewItem item) { ContainerFile meta = (ContainerFile)item.Tag; if (meta.Deleted) { item.ImageKey = "delete"; } else if (meta.Locked) { item.ImageKey = "lock"; } else { item.ImageIndex = -1; } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { e.Cancel = listView1.SelectedItems.Count != 1; if (!e.Cancel) { ContainerFile meta = (ContainerFile)listView1.SelectedItems[0].Tag; deleteToolStripMenuItem.Text = meta.Deleted ? "Recover" : "Delete"; lockToolStripMenuItem.Text = meta.Locked ? "Unlock" : "Lock"; deleteToolStripMenuItem.Visible = !meta.Locked; editSummaryToolStripMenuItem.Visible = !meta.Deleted; lockToolStripMenuItem.Visible = !meta.Deleted; uploadToolStripMenuItem.Visible = !meta.Deleted; toolStripSeparator1.Visible = uploadToolStripMenuItem.Visible; } }
private void Delete(ContainerFile meta) { meta.Deleted = !meta.Deleted; backup.Save(meta); }
internal void Save(ContainerFile meta) { FileInfo info = new FileInfo(zipFolder + meta.MetadataFilename); Save(info, meta); }
internal void Replace(ContainerFile meta) { DeleteDirectory(wgsFolder); System.IO.Directory.CreateDirectory(wgsFolder); ZipFile.ExtractToDirectory(zipFolder + meta.Filename, wgsFolder); }