123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using QVCopier.Models;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using QVCopier.Utility;
- namespace QVCopier
- {
- public partial class QvcMainForm : Form
- {
- private readonly List<LogEntry> _logs = new();
- private readonly List<WorkItem> _items = new();
- public QvcMainForm()
- {
- InitializeComponent();
- }
- private void QvcMainForm_Load(object sender, EventArgs e)
- {
- MainListView.Items.Clear();
- LogListView.Items.Clear();
- InitLogger();
- }
- private void QvcMainForm_Shown(object sender, EventArgs e)
- {
- }
- private void DestFolderTextBox_DragEnter(object sender, DragEventArgs e)
- {
- string[] data;
- e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop)
- && (data = (string[])e.Data.GetData(DataFormats.FileDrop)).Length == 1
- && Directory.Exists(data[0])
- ? DragDropEffects.Link
- : DragDropEffects.None;
- }
- private void DestFolderTextBox_DragDrop(object sender, DragEventArgs e)
- {
- DestFolderTextBox.Text = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
- }
- private void ChooseDestButton_Click(object sender, EventArgs e)
- {
- var cm = new ContextMenuStrip();
- var msgItem = cm.Items.Add("Looking up...");
- msgItem.Enabled = false;
- cm.Items.Add("-").Enabled = false;
- Task.Run(() =>
- {
- var paths = ExplorerAccessor.GetOpenedWindowPath();
- if (paths.Length == 0)
- {
- cm.Invoke(new Action(() => msgItem.Text = "No explorer window found"));
- }
- else
- {
- cm.Invoke(new Action(() => msgItem.Text = $"{paths.Length} found"));
- foreach (var path in paths)
- {
- cm.Invoke(new Action(() =>
- {
- var item = new ToolStripMenuItem(path);
- item.Click += delegate { DestFolderTextBox.Text = path; };
- cm.Items.Add(item);
- }));
- }
- }
- });
- cm.Show(ChooseDestButton, new Point(0, ChooseDestButton.Height));
- }
- }
- }
|