Skip to content

Commit

Permalink
Change: Change DL button background color depending on exist download…
Browse files Browse the repository at this point in the history
… file

close #11
  • Loading branch information
minfia committed Feb 20, 2022
1 parent ed7f88e commit 8a80078
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions source/AviUtlAutoInstaller/Models/Files/PreRepoFileR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public bool ReadInstallItemList()
};
item.IsSelect = ((InstallFileType.Main == item.FileType) || (item.CommandName == "exedit")) ? true : false;
item.IsItemSelectEnable = (InstallFileType.Main == item.FileType || (item.CommandName == "exedit")) ? false : true;
item.IsDownloadCompleted = System.IO.File.Exists($"{SysConfig.CacheDirPath}\\{item.DownloadFileName}");

InstallItem.DependentAction = InstallItemList.DependentAction;
InstallItemList.AddInstallItem(InstallItemList.RepoType.Pre, item);
Expand Down
1 change: 1 addition & 0 deletions source/AviUtlAutoInstaller/Models/Files/UserRepoFileRW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void AddInstallItemV100(TomlTableArray array)
InstallFile = array[i].Get<string>(_rwKeyTypeDic[RWKeyType.AppendFile]),
NicoVideoID = array[i].Get<string>(_rwKeyTypeDic[RWKeyType.NicoVideoID])
};
item.IsDownloadCompleted = System.IO.File.Exists($"{SysConfig.CacheDirPath}\\{item.DownloadFileName}");

if (!InstallItemList.CheckDuplicateName(InstallItemList.RepoType.User, item.Name) ||
!InstallItemList.CheckDuplicateURL(InstallItemList.RepoType.User, item.URL) ||
Expand Down
4 changes: 4 additions & 0 deletions source/AviUtlAutoInstaller/ViewModels/InstallEditViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,10 @@ private async Task OnDownload()

string message = GetDownloadResultMessage(res);
headItem.DownloadExecute = true;
if (message == "")
{
headItem.IsDownloadCompleted = true;
}
if (message != "" && i == 0)
{
downloadFailedList.Add(headItem, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ public void SetInstallItem(InstallItem item)
Section = item.SectionType;
ItemType = string.IsNullOrEmpty(item.ScriptDirName) ? (item.SectionType.Equals("本体") ? "本体" : "プラグイン") : "スクリプト";
Dependent = item.DependentName.Equals("None") ? "なし" : item.DependentName;
DownloadURL = (string.IsNullOrEmpty(item.URL) ? item.DownloadPage : item.URL);
DLStatus = File.Exists($"{SysConfig.CacheDirPath}\\{item.DownloadFileName}") ? "ダウンロード済み" : "未ダウンロード";
DownloadURL = string.IsNullOrEmpty(item.URL) ? item.DownloadPage : item.URL;
item.IsDownloadCompleted = File.Exists($"{SysConfig.CacheDirPath}\\{item.DownloadFileName}");
DLStatus = item.IsDownloadCompleted ? "ダウンロード済み" : "未ダウンロード";
GuideURL = string.IsNullOrEmpty(item.NicoVideoID) ? item.GuideURL : $"https://www.nicovideo.jp/watch/{item.NicoVideoID}";
}

Expand Down
13 changes: 11 additions & 2 deletions source/AviUtlAutoInstaller/Views/InstallEditView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
<Style x:Key="DataGridButtonHeaderStyle" TargetType="DataGridColumnHeader" BasedOn="{StaticResource MahApps.Styles.DataGridColumnHeader}">
<Setter Property="BorderThickness" Value="0,0,1,3"/>
</Style>
<Style x:Key="DownloadButtonStyle" TargetType="Button" BasedOn="{StaticResource MahApps.Styles.Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDownloadCompleted}" Value="true">
<Setter Property="Background" Value="DeepSkyBlue"/>
</DataTrigger>
</Style.Triggers>
</Style>
<FrameworkElement x:Key="proxyElement"/>
</Window.Resources>
<DockPanel>
Expand Down Expand Up @@ -312,7 +319,8 @@
<DataTemplate>
<Button Width="36"
IsEnabled="{Binding DownloadExecute}"
Command="{Binding Source={StaticResource proxyElement}, Path=DataContext.DownloadCommand}">
Command="{Binding Source={StaticResource proxyElement}, Path=DataContext.DownloadCommand}"
Style="{StaticResource DownloadButtonStyle}">
<Button.Content>
<Path Data="M0,7.3121409 L2,7.3121409 2,11.31242 14,11.31242 14,7.3121409 16,7.3121409 16,11.31242 16,13.31256 14,13.31256 2,13.31256 0,13.31256 0,11.31242 z M6.9792457,0 L8.9792767,3.0994415E-05 8.9792929,1.0601282 8.9807262,1.0601282 8.9807959,5.5634842 10.104957,4.4393239 11.519214,5.8535812 9.3828039,7.9899912 9.3882141,7.9954014 7.974,9.4096153 4.4383569,5.8739724 5.852571,4.4597585 6.9807658,5.5879536 6.98071,2.000031 6.9792767,2.000031 z" Fill="#FFF4F4F5"/>
</Button.Content>
Expand Down Expand Up @@ -443,7 +451,8 @@
<DataTemplate>
<Button Width="36"
IsEnabled="{Binding DownloadExecute}"
Command="{Binding Source={StaticResource proxyElement}, Path=DataContext.DownloadCommand}">
Command="{Binding Source={StaticResource proxyElement}, Path=DataContext.DownloadCommand}"
Style="{StaticResource DownloadButtonStyle}">
<Button.Content>
<Path Data="M0,7.3121409 L2,7.3121409 2,11.31242 14,11.31242 14,7.3121409 16,7.3121409 16,11.31242 16,13.31256 14,13.31256 2,13.31256 0,13.31256 0,11.31242 z M6.9792457,0 L8.9792767,3.0994415E-05 8.9792929,1.0601282 8.9807262,1.0601282 8.9807959,5.5634842 10.104957,4.4393239 11.519214,5.8535812 9.3828039,7.9899912 9.3882141,7.9954014 7.974,9.4096153 4.4383569,5.8739724 5.852571,4.4597585 6.9807658,5.5879536 6.98071,2.000031 6.9792767,2.000031 z" Fill="#FFF4F4F5"/>
</Button.Content>
Expand Down

0 comments on commit 8a80078

Please # to comment.