Skip to content

Commit

Permalink
Release v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gy12346123 committed Nov 30, 2016
1 parent b9715fb commit dd00e13
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 32 deletions.
11 changes: 10 additions & 1 deletion BaiduCloudSupport/API/PCS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,17 @@ public static void DownloadFileSegment(string access_token, ulong fs_id, string
MainWindow.totalData.TotalDownload = DownloadManager.Instance.Downloads.Count();
GetDownloadInfo();
};
string URL;
if (remoteFile.Contains("http://") || remoteFile.Contains("https://"))
{
URL = remoteFile;
}else
{
URL = DownloadBaseURL + "file?method=download&access_token=" + access_token + "&path=" + ConvertPath2URLFormat(remoteFile);
}

Downloader downloader = DownloadManager.Instance.Add(
ResourceLocation.FromURL(DownloadBaseURL + "file?method=download&access_token=" + access_token + "&path=" + ConvertPath2URLFormat(remoteFile)),
ResourceLocation.FromURL(URL),
new ResourceLocation[] { },
localFile,
Convert.ToInt32(Setting.DownloadSegment),
Expand Down
56 changes: 33 additions & 23 deletions BaiduCloudSupport/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ public async void DownloadFile(FileListDataItem item)
{
try
{
totalData.ProgressRing_IsActive = true;
if (item.size.Contains("G") || item.size.Contains("T"))
{
// File too big
Expand All @@ -752,35 +753,44 @@ public async void DownloadFile(FileListDataItem item)
else
{
// Download
DownloadListDataItem dataItem = new DownloadListDataItem
{
fs_id = item.fs_id,
file = item.file,
size = 0L,
received = 0L,
percentage = 0d,
rate = 0d,
startTime = DateTime.Now,
isSelected = false
};

if (totalData.DownloadListDataItems != null && totalData.DownloadListDataItems.Count() != 0)
Window.NewDownloadTaskWindow taskWindow = new Window.NewDownloadTaskWindow(await PCS.DownloadURL(Setting.Baidu_Access_Token, item.path));
taskWindow.Owner = this;
if ((bool)taskWindow.ShowDialog())
{
DownloadListAddItem(totalData.DownloadListDataItems, dataItem);
}
else
{
List<DownloadListDataItem> list = new List<DownloadListDataItem>();
list.Add(dataItem);
totalData.DownloadListDataItems = list;
DownloadListDataItem dataItem = new DownloadListDataItem
{
fs_id = item.fs_id,
file = item.file,
size = 0L,
received = 0L,
percentage = 0d,
rate = 0d,
startTime = DateTime.Now,
isSelected = false
};

if (totalData.DownloadListDataItems != null && totalData.DownloadListDataItems.Count() != 0)
{
DownloadListAddItem(totalData.DownloadListDataItems, dataItem);
}
else
{
List<DownloadListDataItem> list = new List<DownloadListDataItem>();
list.Add(dataItem);
totalData.DownloadListDataItems = list;
}

CheckDownloadFolder();
PCS.DownloadFileSegment(Setting.Baidu_Access_Token, item.fs_id, taskWindow.DownloadURL, Setting.DownloadPath + item.file);
}
CheckDownloadFolder();
//PCS.DownloadFile(Setting.Baidu_Access_Token, item.fs_id, item.path, Setting.DownloadPath + item.file);
PCS.DownloadFileSegment(Setting.Baidu_Access_Token, item.fs_id, item.path, Setting.DownloadPath + item.file);
taskWindow = null;
}
}catch (Exception ex)
{
LogHelper.WriteLog("MainWindow.DownloadFile", ex);
}finally
{
totalData.ProgressRing_IsActive = false;
}
}

Expand Down
8 changes: 4 additions & 4 deletions BaiduCloudSupport/Window/NewDownloadTaskWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
<StackPanel Grid.Row="0" Width="auto" Margin="5">
<TextBlock Text="{StaticResource NewDownloadTaskWindow_Title}" HorizontalAlignment="Center" />
<TextBlock Text="{StaticResource NewDownloadTaskWindow_DownloadURL}" Margin="0,0,0,5"/>
<RichTextBox Height="150"/>
<TextBox Name="textBox_URL" Text="{Binding DownloadURL, Mode=TwoWay}" Height="150" />
</StackPanel>
<StackPanel Grid.Row="1">
<WrapPanel HorizontalAlignment="Center" Margin="5">
<TextBox Name="textBox_LoadDownloadPath" Width="300" Height="25" Text="{Binding DownloadDefaultFolderPath}" Margin="0,0,5,0" />
<Button Name="button_LoadDownloadPath" Content="{StaticResource Flyout_Setting_Button_DownloadPath}" Width="70" Height="25" Style="{StaticResource AccentedSquareButtonStyle}" />
<TextBox Name="textBox_LoadDownloadPath" Width="300" Height="25" Text="{Binding DownloadDefaultFolderPath, Mode=TwoWay}" Margin="0,0,5,0" />
<Button Name="button_LoadDownloadPath" Content="{StaticResource Flyout_Setting_Button_DownloadPath}" Width="70" Height="25" Style="{StaticResource AccentedSquareButtonStyle}" Click="button_LoadDownloadPath_Click" />
</WrapPanel>
<WrapPanel HorizontalAlignment="Right" Margin="5,20,5,0">
<TextBlock Name="textBlock_Space" Text="{Binding Space, StringFormat='{StaticResource NewDownloadTaskWindow_TextBlock_Space_Format}'}" Width="150" Margin="0,0,120,0" VerticalAlignment="Center" />
<Button Name="button_Download" Content="{StaticResource NewDownloadTaskWindow_Button_Download}" Width="70" Height="25" Margin="0,0,20,0" Style="{StaticResource AccentedSquareButtonStyle}" />
<Button Name="button_Download" Content="{StaticResource NewDownloadTaskWindow_Button_Download}" Width="70" Height="25" Margin="0,0,20,0" Style="{StaticResource AccentedSquareButtonStyle}" Click="button_Download_Click" />
</WrapPanel>

</StackPanel>
Expand Down
53 changes: 49 additions & 4 deletions BaiduCloudSupport/Window/NewDownloadTaskWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,63 @@ public long Space
}
}

public NewDownloadTaskWindow()
private string _DownloadURL;

public string DownloadURL
{
get { return _DownloadURL; }
set
{
if (_DownloadURL != value)
{
_DownloadURL = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("DownloadURL"));
}
}
}
}



public NewDownloadTaskWindow(string url)
{
InitializeComponent();
DownloadURL = url;
}

private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
textBox_LoadDownloadPath.DataContext = MainWindow.totalData;
textBlock_Space.DataContext = this;
MainWindow.totalData.DownloadDefaultFolderPath = Setting.DownloadPath;
DirectoryInfo info = new DirectoryInfo(Setting.DownloadPath);
Space = Other.Tools.GetHardDiskFreeSpace(info.Root.FullName);
textBox_URL.DataContext = this;
if (Setting.DownloadPath != null && !Setting.DownloadPath.Equals(""))
{
MainWindow.totalData.DownloadDefaultFolderPath = Setting.DownloadPath;
DirectoryInfo info = new DirectoryInfo(Setting.DownloadPath);
Space = Other.Tools.GetHardDiskFreeSpace(info.Root.FullName);
}

}

private void button_LoadDownloadPath_Click(object sender, RoutedEventArgs e)
{
string path = Other.Tools.GetFolder(GlobalLanguage.FindText("MainWindow_LoadDownloadPath_Title"), true);
if (path != string.Empty)
{
MainWindow.totalData.DownloadDefaultFolderPath = path;
}
}

private void button_Download_Click(object sender, RoutedEventArgs e)
{
if (textBox_LoadDownloadPath.Text == null || textBox_LoadDownloadPath.Text.Equals(""))
{
textBox_LoadDownloadPath.Background = Brushes.Red;
return;
}
DialogResult = true;
}
}
}

0 comments on commit dd00e13

Please sign in to comment.