1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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));
- }
- }
- }
|