Skip to content

Commit

Permalink
Added icon
Browse files Browse the repository at this point in the history
  • Loading branch information
biteworks committed Dec 20, 2020
1 parent e392bfd commit 14eedad
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CopyFolderTool/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CopyFolderTool"
Startup="Application_Startup">
Startup="Application_Startup"
ShutdownMode="OnExplicitShutdown">
<Application.Resources>

</Application.Resources>
Expand Down
6 changes: 6 additions & 0 deletions CopyFolderTool/CopyFolderTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
Expand Down Expand Up @@ -101,5 +104,8 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Binary file added CopyFolderTool/Icon.ico
Binary file not shown.
15 changes: 9 additions & 6 deletions CopyFolderTool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CopyFolderTool"
mc:Ignorable="d"
Title="MainWindow" Height="360" Width="420" Background="#FFD1D1D1" ResizeMode="NoResize">
Title="CopyFolderTool" Height="410" Width="420" Background="#FFD1D1D1" ResizeMode="NoResize" Icon="Icon.ico">
<StackPanel Margin="10">
<Label FontWeight="Bold">Source</Label>
<Label FontWeight="Bold">Source Folder</Label>
<TextBox Name="fieldSource" Margin="5" Padding="3"/>

<Label FontWeight="Bold">Destination</Label>
<Label FontWeight="Bold">Destination Folder</Label>
<DockPanel HorizontalAlignment="Left" Width="400">
<TextBox Name="fieldDestination" Margin="5" Padding="3" Width="330"/>
<Button Content=". . ." Margin="5" Click="selectDestinationFolder" Padding="3" Width="38" HorizontalAlignment="Left"/>
</DockPanel>

<Label FontWeight="Bold">Options</Label>
<Label FontWeight="Bold">Copy Options</Label>
<CheckBox IsChecked="True" Name="option_E" Margin="5">Copy subfolders</CheckBox>
<CheckBox Name="option_XO" Margin="5">Copy only new or changed files</CheckBox>
<CheckBox Name="option_MOV" Margin="5">Move files (Source data will be deleted)</CheckBox>

<Button Content="Start copying" Margin="5,20,5,5" Click="copyToServer" Padding="3"/>
<Label FontWeight="Bold">More Options</Label>
<CheckBox Name="option_Shutdown" Margin="5">Shutdown the computer after copying</CheckBox>

<Button Name="btn_startCopying" Content="Start copying" Margin="5,20,5,5" Click="copyToServer" Padding="3"/>
<Label FontSize="10" IsEnabled="False" HorizontalAlignment="Center" Margin="0,8,0,0" VerticalAlignment="Bottom">Copyright by Tobias Wilhelm (Version 1.0.0)</Label>
</StackPanel>
</StackPanel>
</Window>
29 changes: 26 additions & 3 deletions CopyFolderTool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public MainWindow()
private void copyToServer(object sender, RoutedEventArgs e)
{
string command;
string sourcePath = @fieldSource.Text;
string destinationPath = @fieldDestination.Text;
string sourcePath = fieldSource.Text;
string destinationPath = fieldDestination.Text;

//Optionen
string optionE = "";
string optionXO = "";
string optionMOV = "";
string optionClose = "";
string standardOptions = " /MT:8 /FFT";

if (option_E.IsChecked == true)
Expand All @@ -46,11 +47,27 @@ private void copyToServer(object sender, RoutedEventArgs e)
optionXO = " /MOV";
}

if(option_Shutdown.IsChecked == true)
{
optionClose = "/C ";
}
else
{
optionClose = "/K ";
}

if (sourcePath.Length != 0 && destinationPath.Length != 0)
{
command = "/K ROBOCOPY \"" + @sourcePath + "\" \"" + @destinationPath + "\" " + optionE + optionXO + optionMOV + standardOptions;
btn_startCopying.IsEnabled = false;
command = optionClose + "ROBOCOPY \"" + @sourcePath + "\" \"" + @destinationPath + "\" " + optionE + optionXO + optionMOV + standardOptions;
System.Diagnostics.Process process = System.Diagnostics.Process.Start("CMD.exe", command);
process.WaitForExit();
Application.Current.Shutdown();

if (option_Shutdown.IsChecked == true)
{
_ = System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
}
}
else
{
Expand All @@ -68,5 +85,11 @@ private void selectDestinationFolder(object sender, RoutedEventArgs e)
fieldDestination.Text = dialog.FileName;
}
}

protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
Application.Current.Shutdown();
}
}
}
Binary file added _icon/Icon.ico
Binary file not shown.

0 comments on commit 14eedad

Please sign in to comment.