예제 #1
0
        private void BtnOperate_Click(object sender, EventArgs e)
        {
            paths.TryGetValue("source", out string sourcePath);
            paths.TryGetValue("dest", out string destPath);
            paths.TryGetValue("backup", out string backupPath);
            if (ContainsNullOrWhitespace(sourcePath, destPath, backupPath))
            {
                BtnOperate.Enabled = false;
                return;
            }

            BtnBrowseSource.Enabled = false;
            BtnBrowseDest.Enabled   = false;
            BtnBrowseBackup.Enabled = false;
            BtnOperate.Enabled      = false;

            Thread t = new Thread(() =>
            {
                DirUtils.DoOperation(sourcePath, destPath, backupPath, Log);
                Invoke((MethodInvoker) delegate
                {
                    Log("Done!");
                    BtnBrowseSource.Enabled = true;
                    BtnBrowseDest.Enabled   = true;
                    BtnBrowseBackup.Enabled = true;
                    BtnOperate.Enabled      = true;
                });
            });

            t.Start();
        }
예제 #2
0
        private void BackupPreview()
        {
            paths.TryGetValue("source", out string sourcePath);
            paths.TryGetValue("dest", out string destPath);
            if (ContainsNullOrWhitespace(sourcePath, destPath))
            {
                return;
            }

            Thread t = new Thread(() =>
            {
                string[] files = DirUtils.GetOverwriteItems(sourcePath, destPath);
                Invoke((MethodInvoker) delegate
                {
                    ListBackup.Items.Clear();
                    Log("Populating backup items...");
                });

                foreach (string s in files)
                {
                    Invoke((MethodInvoker) delegate
                    {
                        ListBackup.Items.Add(s);
                    });
                }
            });

            t.Start();
        }
예제 #3
0
        private void BrowseOperation(ListBox preview, Label labelPath, string pathKey)
        {
            paths.TryGetValue(pathKey, out string initial);
            string path = DirUtils.SelectDirectory(initial);

            if (path == null)
            {
                return;
            }

            Invoke((MethodInvoker) delegate {
                labelPath.Text = path;
                paths[pathKey] = path;
                if (preview != null)
                {
                    preview.Items.Clear();
                }
            });

            if (preview != null)
            {
                string[] files = DirUtils.GetSubItems(path, true);

                foreach (string s in files)
                {
                    //string reducedName = s.Replace(path, "");
                    Invoke((MethodInvoker) delegate {
                        preview.Items.Add(s);
                    });
                }
            }
        }