From 32e607ca1df190f92e162c6e8c4bd7affe93a86b Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Thu, 11 Jan 2018 12:24:42 +0100 Subject: [PATCH] Preliminary code for a folder selection dialog to initiate a transfer. Refers to #2 --- ATXTray/ATXTray.csproj | 13 +++++++++++++ ATXTray/AutoTxTray.cs | 21 ++++++++++++++++++++- ATXTray/packages.config | 5 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 ATXTray/packages.config diff --git a/ATXTray/ATXTray.csproj b/ATXTray/ATXTray.csproj index 340c1b3..3fcf8f0 100644 --- a/ATXTray/ATXTray.csproj +++ b/ATXTray/ATXTray.csproj @@ -35,6 +35,18 @@ <ApplicationIcon>AutoTx.ico</ApplicationIcon> </PropertyGroup> <ItemGroup> + <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="Microsoft.WindowsAPICodePack.ShellExtensions, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> @@ -59,6 +71,7 @@ <AutoGen>True</AutoGen> <DependentUpon>Resources.resx</DependentUpon> </Compile> + <None Include="packages.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> diff --git a/ATXTray/AutoTxTray.cs b/ATXTray/AutoTxTray.cs index 95da906..c21b0c5 100644 --- a/ATXTray/AutoTxTray.cs +++ b/ATXTray/AutoTxTray.cs @@ -4,6 +4,7 @@ using System.Timers; using System.Drawing; using System.IO; using System.Windows.Forms; +using Microsoft.WindowsAPICodePack.Dialogs; using ATXSerializables; using Timer = System.Timers.Timer; @@ -35,6 +36,7 @@ namespace ATXTray private readonly ToolStripMenuItem _miSvcRunning = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miSvcSuspended = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miTxProgress = new ToolStripMenuItem(); + private readonly ToolStripMenuItem _miTxEnqueue = new ToolStripMenuItem(); public AutoTxTray() { _notifyIcon.Visible = true; @@ -70,15 +72,20 @@ namespace ATXTray _miSvcSuspended.Text = @"No limits apply, service active."; _miSvcSuspended.Click += ShowContextMenu; - _miTxProgress.Text = "No transfer running."; + _miTxProgress.Text = @"No transfer running."; _miTxProgress.Click += ShowContextMenu; + _miTxEnqueue.Text = @"+++ Add new directory for transfer. +++"; + _miTxEnqueue.Click += _miTxEnqueue_Click; + _cmStrip.Items.AddRange(new ToolStripItem[] { _miTitle, _miSvcRunning, _miSvcSuspended, _miTxProgress, new ToolStripSeparator(), + _miTxEnqueue, + new ToolStripSeparator(), _miExit }); @@ -135,6 +142,18 @@ namespace ATXTray _notifyIcon.ContextMenuStrip.Show(); } + private void _miTxEnqueue_Click(object sender, EventArgs e) { + var dirDialog = new CommonOpenFileDialog { + Title = @"Select directory to be transferred", + IsFolderPicker = true, + EnsurePathExists = true, + DefaultDirectory = _config.SourceDrive + }; + if (dirDialog.ShowDialog() == CommonFileDialogResult.Ok) { + MessageBox.Show("Directory selected: " + dirDialog.FileName); + } + } + /// <summary> /// Read (or re-read) the service status file if it has changed since last time. /// </summary> diff --git a/ATXTray/packages.config b/ATXTray/packages.config new file mode 100644 index 0000000..e06f06e --- /dev/null +++ b/ATXTray/packages.config @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.0" targetFramework="net45" /> + <package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net45" /> +</packages> \ No newline at end of file -- GitLab