Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        private void Lock(ListViewItem listViewItem)
        {
            ContainerFile meta = (ContainerFile)listViewItem.Tag;

            meta.Locked = !meta.Locked;
            backup.Save(meta);
            UpdateIcon(listViewItem);
            listView1.SelectedItems.Clear();
        }
Ejemplo n.º 3
0
        private void Delete(ListViewItem listViewItem)
        {
            ContainerFile meta = (ContainerFile)listViewItem.Tag;

            if (!meta.Locked)
            {
                Delete(meta);
                RefreshZipList();
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 private void OnListLeftClick(MouseEventArgs e)
 {
     if (listView1.SelectedItems.Count != 0)
     {
         ContainerFile meta = (ContainerFile)listView1.SelectedItems[0].Tag;
         if (!meta.Deleted)
         {
             Upload(listView1.SelectedItems[0]);
         }
     }
 }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
0
 private void Delete(ContainerFile meta)
 {
     meta.Deleted = !meta.Deleted;
     backup.Save(meta);
 }
Ejemplo n.º 10
0
        internal void Save(ContainerFile meta)
        {
            FileInfo info = new FileInfo(zipFolder + meta.MetadataFilename);

            Save(info, meta);
        }
Ejemplo n.º 11
0
 internal void Replace(ContainerFile meta)
 {
     DeleteDirectory(wgsFolder);
     System.IO.Directory.CreateDirectory(wgsFolder);
     ZipFile.ExtractToDirectory(zipFolder + meta.Filename, wgsFolder);
 }